Thursday, April 19, 2012

Making a Trigger spawned unit drop random loot?

Ok so, i have a boss in my map, several actually, that i want to drop loot. As they are spawned by triggers, i cannot assign them a loot table. I was going to give them the items upon spawn and set them to drop them upon death, but that would mess with the bosses combat stats/abilities and deny the random chance of an item dropping.

I had no luck try to solve it and so did the best i could think of, which is this:


Code:
First Kill Loot
Events
Unit - A unit Dies
Conditions
(Unit-type of (Triggering unit)) Equal to Sarth NORMAL MODE
Actions
Item - Create Ring of Magic Warding at (Center of Sarth Spawn <gen>)
Wait 0.01 seconds
Item - Create Ring of Brutality at (Center of Sarth Spawn <gen>)
Wait 0.01 seconds
Item - Create Ring of Brutality at (Center of Sarth Spawn <gen>)
Wait 0.01 seconds
Item - Create Ring of Tranquility at (Center of Sarth Spawn <gen>)
Wait 0.01 seconds
Item - Create Ring of Tranquility at (Center of Sarth Spawn <gen>)
Wait 0.01 seconds
Item - Create Tome of Fortitude at (Center of Sarth Spawn <gen>)
Wait 0.01 seconds
Item - Create Tome of Fortitude at (Center of Sarth Spawn <gen>)
Wait 0.01 seconds
Item - Create Tome of Fortitude at (Center of Sarth Spawn <gen>)
Trigger - Turn on Subsequent Kills Loot <gen>
Trigger - Turn off (This trigger)

This is the loot the party gets for killing the boss the first time, as you can see, it's not a random drop chance and i just create the items at the bosses spawn point when he dies. Now, to prevent the stacking of potentially powerful items onto a single hero, i put in a subsequent kills loot trigger. The rest of the kills provide only charged items instead of gear drops. As shown:


Code:
Subsequent Kills Loot
Events
Unit - A unit Dies
Conditions
(Unit-type of (Triggering unit)) Equal to Sarth NORMAL MODE
Actions
Item - Create Scroll of Power at (Center of Sarth Spawn <gen>)
Wait 0.01 seconds
Item - Create Tome of Fortitude at (Center of Sarth Spawn <gen>)



Ok, now comes my request for aid. What i really want is a way to make the trigger spawned boss drop loot randomly, just like if i had assigned it a loot table. I did a quick google and saw something relating to "ItemPools"? I think that was JASS though and i'm completely newb at JASS.

Is there anyway to do this without JASS? If not could someone give me a JASS solution and explain in VERY simple terms how i can use it?

Sorry for being so troublesome, but thanks in advance. |||To randomly drop items with triggers, you can use an if/then. If (random number between (1) and (10)) is equal to (1), then create item. That would create a %10 chance of dropping an item.

To drop a random item type, you can use a random number with an array of items, such as "create Item_Type[random number between 1 and 10]". If you had already set an array of 10 item types, that would select one of them randomly.|||Thanks for the help. Could you give me an example of the array so i know how to set it up?

If it's not too much trouble. |||Basic array usage is discussed here:

http://war3.incgamers.com/forums/showthread.php?t=40957

When you set each element of the array, it is done with a trigger, typically at the start of the map.

If you read through the rest of the tutorials, you should get a decent grasp of how to develop working logic structures.

No comments:

Post a Comment