HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Item Drops

06-28-2005, 02:55 AM#1
Setreal
Sorry about yet another question but this is for the betterment of my map ( and I appreciate the help everyone has given so far ). For item drops is there any way to do any of the following...

- Raise max item lvl beyond 9

- Create multiple item pools (WEU add-on)

- Some alternative method of item drops where I could have various drop sets (Eg. Lvl 1 drop sets for low lvl creeps, but would need many different drop sets for variety ( as in more then 9 ) ).

Thanks in advance.
06-28-2005, 03:08 AM#2
Ceo
This is a part of a drop system I made.

You create a drop table for a mob with the DropTableFunction

And you add drops to its drop table with the AddDrop function. Percent is the chance you want for it to drop out of a given amount (if you want the max to be 1000, putting 100 in the percent would give it a 10% chance to drop)

In the PickDrops function, change the GetRandomInt(1, 1000) to whatever numbers you want for the chance to be out of


Code:
function Ce_DropTable takes integer monster returns nothing
call StoreInteger(udg_gamecache, "DropMax", I2S(monster), 0)
endfunction

function Ce_AddDrop takes integer monster, integer drop, integer percent returns nothing
call StoreInteger(udg_gamecache, "DropItem", I2S(monster)+I2S(GetStoredInteger(udg_gamecache, "DropMax", I2S(monster))), drop)
call StoreInteger(udg_gamecache, "DropPercent", I2S(monster)+I2S(GetStoredInteger(udg_gamecache, "DropMax", I2S(monster))), percent)
call StoreInteger(udg_gamecache, "DropMax", I2S(monster), GetStoredInteger(udg_gamecache, "DropMax", I2S(monster))+1)
endfunction

function Ce_PickDrops takes nothing returns nothing
local integer x = 0
local integer rand
local string monster = I2S(GetUnitTypeId(GetDyingUnit()))
loop
 exitwhen x == GetStoredInteger(udg_gamecache, "DropMax", I2S(GetUnitTypeId(GetDyingUnit())))
 set rand = GetRandomInt(1, 1000)
 if GetStoredInteger(udg_gamecache, "DropPercent", monster+I2S(x)) >= rand then
  call CreateItem(GetStoredInteger(udg_gamecache, "DropItem", monster+I2S(x)), GetUnitX(GetDyingUnit()), GetUnitY(GetDyingUnit()))
 endif
 set x = x + 1
endloop
endfunction

function InitTrig_Drop_Functions takes nothing returns nothing
    set gg_trg_Drop_Functions = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Drop_Functions, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction(gg_trg_Drop_Functions, function Ce_PickDrops)
endfunction
06-28-2005, 03:49 AM#3
Setreal
I use the GUI so I'm not quite sure what's going on in your code there. Could you perhaps explain it more indepthly or give a breif GUI example.
06-28-2005, 04:01 AM#4
Ceo
Make a trigger called Drop Functions, change it to custom text, and delete everything in it. Then paste all that code. Change the GetRandomInt() function to correspond to the scale you want your percentages to be on.

Now make another trigger with event map initialization and fill it up with all the item pools you want like so:


Code:
function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
call Ce_DropTable('earc')
call Ce_AddDrop('earc', 'ratf', 500)
call Ce_AddDrop('earc', 'olig', 250)
call Ce_AddDrop('earc', 'clfm', 1000)
call Ce_DropTable('edry')
call Ce_AddDrop('edry', 'oven', 750)
call Ce_AddDrop('edry', 'lnrn', 333)
endfunction

//===========================================================================
function InitTrig_Test_Drop_Functions takes nothing returns nothing
    set gg_trg_Test_Drop_Functions = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Test_Drop_Functions, function Trig_Untitled_Trigger_002_Actions )
endfunction

Now, what is going on here? First, I made a trigger and converted it to custom text. Then, I called the DropTable function to create a drop table for the monster 'edry', which stands for Dryad. How are you supposed to know this? An easy way to find the integer code for a creep is to make a Create Unit trigger with the unit you want and change it to custom text.

I then call AddDrop multiple times for each table. You do the same thing with the integer code for items, make a create item trigger and change it to custom text. The number at the end of each function is its chance to drop out of whatever you set GetRandomInt(1, x) to. The first one is 500. If you set x to 1000, the first item would have a 50% chance to drop every time 'edry' unit is killed.

if you need more help ask.
06-28-2005, 04:24 AM#5
Setreal
Ah great explanation but the second trigger(which I named Init since you only specified a name for the first one) is erroring for me. ''The trigger Init must have an initialization function called 'Init_Trig_Init' ''

Edit : Also I noticed the use of game_cache in the first trigger. Would this make it inviable for multiplayer or is that only for trying to use the cache to save data across maps.
06-28-2005, 04:37 AM#6
Ceo
Quote:
Originally Posted by Setreal
Ah great explanation but the second trigger(which I named Init since you only specified a name for the first one) is erroring for me. ''The trigger Init must have an initialization function called 'Init_Trig_Init' ''

Edit : Also I noticed the use of game_cache in the first trigger. Would this make it inviable for multiplayer or is that only for trying to use the cache to save data across maps.

Sorry for the mixup. The second trigger in my example is named Untitled Trigger 002. Change everything in the second trigger that says Untitled_Trigger_002 to Init and you should be alright.


Game Cache is not only for saving across maps. You can also save data in the game cache and retrieve it from the same game. Basically I am using it as a 2D array.
06-28-2005, 06:09 AM#7
weaaddar
Um you do realize there is a perfectly good Itempool native system which is great for item drops? Look at my map Reviver 2.0 for a simple drop table made with an item pool.
06-28-2005, 06:09 AM#8
weaaddar
Um you do realize there is a perfectly good Itempool native system which is great for item drops? Look at my map Reviver 2.0 for a simple drop table made with an item pool.
06-28-2005, 06:26 AM#9
Ceo
Quote:
Originally Posted by weaaddar
Um you do realize there is a perfectly good Itempool native system which is great for item drops? Look at my map Reviver 2.0 for a simple drop table made with an item pool.

No, the native itempool system is crap. Who in god's name would want the same item pool for every creep on the map?
06-28-2005, 11:29 AM#10
Setreal
Still getting the ''The trigger Init must have an initialization function called 'Init_Trig_Init' '' error when I try to checkmark enable for the Init trigger. Maybe something else needs to be changed too?

Here's my two triggers...

Trigger Init - Runs on Map Initialization / Not Enabled ( Get above error )

Quote:
function Trig_Init_Actions takes nothing returns nothing
call Ce_DropTable('earc')
call Ce_AddDrop('earc', 'ratf', 500)
call Ce_AddDrop('earc', 'olig', 250)
call Ce_AddDrop('earc', 'clfm', 1000)
call Ce_DropTable('edry')
call Ce_AddDrop('edry', 'oven', 750)
call Ce_AddDrop('edry', 'lnrn', 333)
endfunction

//===========================================================================
function InitTrig_Test_Drop_Functions takes nothing returns nothing
set gg_trg_Test_Drop_Functions = CreateTrigger( )
call TriggerAddAction( gg_trg_Test_Drop_Functions, function Trig_Init_Actions )
endfunction

Drop Functions - Not Run at Map Initialization ( is it supposed to? ) / Enabled

Quote:
function Ce_DropTable takes integer monster returns nothing
call StoreInteger(udg_gamecache, "DropMax", I2S(monster), 0)
endfunction

function Ce_AddDrop takes integer monster, integer drop, integer percent returns nothing
call StoreInteger(udg_gamecache, "DropItem", I2S(monster)+I2S(GetStoredInteger(udg_gamecache, "DropMax", I2S(monster))), drop)
call StoreInteger(udg_gamecache, "DropPercent", I2S(monster)+I2S(GetStoredInteger(udg_gamecache, "DropMax", I2S(monster))), percent)
call StoreInteger(udg_gamecache, "DropMax", I2S(monster), GetStoredInteger(udg_gamecache, "DropMax", I2S(monster))+1)
endfunction

function Ce_PickDrops takes nothing returns nothing
local integer x = 0
local integer rand
local string monster = I2S(GetUnitTypeId(GetDyingUnit()))
loop
exitwhen x == GetStoredInteger(udg_gamecache, "DropMax", I2S(GetUnitTypeId(GetDyingUnit())))
set rand = GetRandomInt(1, 1000)
if GetStoredInteger(udg_gamecache, "DropPercent", monster+I2S(x)) >= rand then
call CreateItem(GetStoredInteger(udg_gamecache, "DropItem", monster+I2S(x)), GetUnitX(GetDyingUnit()), GetUnitY(GetDyingUnit()))
endif
set x = x + 1
endloop
endfunction

function InitTrig_Drop_Functions takes nothing returns nothing
set gg_trg_Drop_Functions = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(gg_trg_Drop_Functions, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction(gg_trg_Drop_Functions, function Ce_PickDrops)
endfunction
06-28-2005, 01:36 PM#11
weaaddar
you can use multiple itempools. My stupid demo map only used one but you can use an itempool for any and all units. Trust me Itempools are grand.
06-28-2005, 01:40 PM#12
Setreal
As I said earlier i'm not exaclty JASS savvy, could you possibly explain how to make multiple pools from your example? ( weaddar )
06-28-2005, 01:49 PM#13
Ceo
here:

Code:
 function Trig_Init_Actions takes nothing returns nothing
call Ce_DropTable('earc')
call Ce_AddDrop('earc', 'ratf', 500)
call Ce_AddDrop('earc', 'olig', 250)
call Ce_AddDrop('earc', 'clfm', 1000)
call Ce_DropTable('edry')
call Ce_AddDrop('edry', 'oven', 750)
call Ce_AddDrop('edry', 'lnrn', 333)
endfunction

//================================================== =========================
function InitTrig_Init takes nothing returns nothing
set gg_trg_Init = CreateTrigger( )
call TriggerAddAction( gg_trg_Init, function Trig_Init_Actions )
endfunction
06-28-2005, 06:24 PM#14
Setreal
I was able to enable it now but when I try to save I get multiple errors.

Seperate ''Expected a function name error'' for lines 12331-12337
Quote:
call Ce_DropTable('earc')
to
Quote:
call Ce_AddDrop('edry', 'lnrn', 333)


Seperate ''Expected a name'' for lines 12348, 12352-4 , 12362 , 12364-5
Quote:
call StoreInteger(udg_gamecache, "DropMax", I2S(monster), 0)
and
Quote:
call StoreInteger(udg_gamecache, "DropItem", I2S(monster)+I2S(GetStoredInteger(udg_gamecache, "DropMax", I2S(monster))), drop)
to
Quote:
call StoreInteger(udg_gamecache, "DropMax", I2S(monster), GetStoredInteger(udg_gamecache, "DropMax", I2S(monster))+1)
and
Quote:
exitwhen x == GetStoredInteger(udg_gamecache, "DropMax", I2S(GetUnitTypeId(GetDyingUnit())))
and
Quote:
if GetStoredInteger(udg_gamecache, "DropPercent", monster+I2S(x)) >= rand then
to
Quote:
call CreateItem(GetStoredInteger(udg_gamecache, "DropItem", monster+I2S(x)), GetUnitX(GetDyingUnit()), GetUnitY(GetDyingUnit()))
)

''Expected 'end loop' error for line 12366
Quote:
endif
06-28-2005, 06:30 PM#15
Zoxc
I can help you with your jass problems :P

Get on msn cound you?