• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How to make percentage chance to get item?

Status
Not open for further replies.
Level 2
Joined
Aug 4, 2008
Messages
7
I have been thinking a long time but i still haven't invented myself how to make that when i kill an unit i have e.g. 15% chance of getting an item and 3% chance of getting another.

Could anyone help me? I really need this trigger :con:

I need other trigger too:
How to make than when I cast a spell/create unit/other action, a random unit/building is created (like this in gemstone td)

thanks.
 
Level 2
Joined
Sep 14, 2007
Messages
17
You could mess with "Item Tables..." under "advanced" in the world editor.

Also, do you want that same 3% drop rate to apply to all the monsters/creeps in your map, or do you want the more powerful (higher level) things you kill to have a higher chance of dropping than the lesser monsters? because this changes what drop system you would use...

Also, Check out the "RPG system pack" in the spells section of the hive...it has an item drop system that you can work off of.
 
Level 2
Joined
Aug 4, 2008
Messages
7
item drop is less needed, (but thanks for help ;) ) i really need a trigger:
when I build a unit
Unit name/type is "dig site"
*create stone1 or create stone2 or create stone3 or create stone4* (the same chance of getting)

this is really big problem for me, i tried something like that:
Event: a unit enters playable map area
Condition: unit type is "dig site"
Actions:
if yes then else
if number beetwen 1 and 4 is 1 create stone1
else do nothing
if number beetwen 1 and 4 is 2 create stone2
else do nothing
if number beetwen 1 and 4 is 3 create stone3
else do nothing
if number beetwen 1 and 4 is 4 create stone4
else do nothing

but sometimes it created 2, 3 or 4 different stones, not what i wanted... I just wanted one of them randomly selected to be created
 
Level 9
Joined
Feb 19, 2006
Messages
115
You're getting multiple stones because you're not using the same random number. Since you generate a new number each time, you might get something like, 3, 2, 3, 1, which means you'd get 2 and 3 at the same time. To fix that, just use an integer variable:
Event: a unit enters playable map area
Condition: unit type is "dig site"
Actions:
Set - X = random number between 1 and 4
if yes then else
if X is 1 create stone1
else do nothing
if X is 2 create stone2
else do nothing
if X is 3 create stone3
else do nothing
if X is 4 create stone4
else do nothing
 
Level 2
Joined
Aug 4, 2008
Messages
7
You are really helpfull, it works perfectly! It creates one random stone from choosen by me everytime dig site is built. I think you made me understand variables a bit ;) I set the trigger as you told me and voila, perfect.

So... how to make this problem be marked as solved? ;)
KingBob thanks once again.
 
Status
Not open for further replies.
Top