• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

How to make percentage chance to get item?

Status
Not open for further replies.

Jaszczur_Sacrif

J

Jaszczur_Sacrif

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.
 
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.
 
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
 
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
 
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.
Back
Top