• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Drop chance

Status
Not open for further replies.
Level 3
Joined
Jul 26, 2011
Messages
38
Hi Guys!

can u help me with this.

if a unit kill
there are 50% chance to drop a item!
if 50% chance fail then kill (killing unit)


anyone?


:thumbs_up:
 
  • Here you go
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 2) Equal to 1
        • Then - Actions
          • Unit - Kill (Killing unit)
        • Else - Actions
          • Item - Create Tome of Experience at (Position of (Triggering unit))
Edit values, clean leaks.
 
Level 25
Joined
Jun 5, 2008
Messages
2,572
Just wanted to point that using integers for % chance is better than reals, however odd that might sound.

This is speaking for personal experience because if you use reals you can get:

23.124
23.121
13.166
13.133

And the chances seem actually less than using integers due to the amount of numbers and randomness.
Just a thing you guys could think about.
 
Level 17
Joined
Jul 17, 2011
Messages
1,864
Just wanted to point that using integers for % chance is better than reals, however odd that might sound.

This is speaking for personal experience because if you use reals you can get:

23.124
23.121
13.166
13.133

And the chances seem actually less than using integers due to the amount of numbers and randomness.
Just a thing you guys could think about.

no that is incorrect you can have a random real between 0.000 and 1.000 or a random real between 1.000 and 100.000 , 100.000 and 1000.000 or even 1,000,000 and 100,000,000.. anything will do as long as you keep the ratio equal, you can get a 0%-100% chance this is the advantage of reals over integers but in theory of course random number generation is not the best in wc3

in any case say you want a 50.555% chance to trigger critical strike
all you have to do is:
if random real number between 1.000 and 100.000 LESS THAN OR EQUAL TO
50.555
then...
and the two values above can be anything else of the mentioned, however the only advantage of reals is that they provide you with a slight accuracy advantage over integers, an accuracy which is not needed in wc3.
 
Level 17
Joined
Jul 17, 2011
Messages
1,864
well i tested too and here is what results i got with this trigger:
[trigger=trig]Untitled Trigger 021
Events
Time - Elapsed game time is 3.00 seconds
Conditions
Actions
For each (Integer A) from 1 to 100, do (Actions)
Loop - Actions
Set AAAAAAAAAAAAAAAAAAAAAAA = (Random integer number between 1 and 100)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
AAAAAAAAAAAAAAAAAAAAAAA Less than or equal to 50
Then - Actions
Game - Display to (All players) the text: IT WORKS
Set counter = (counter + 1)
Else - Actions
Wait 2.00 seconds
Game - Display to (All players) the text: (String(counter))
Wait 4.00 seconds
Set counter = 0
For each (Integer A) from 1 to 100, do (Actions)
Loop - Actions
Set AAAAAAAAAAAAAAAAAAAAAAA = (Integer((Random real number between 1.00 and 100.00)))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
AAAAAAAAAAAAAAAAAAAAAAA Less than or equal to (Integer(50.00))
Then - Actions
Game - Display to (All players) the text: IT WORKS
Set counter = (counter + 1)
Else - Actions
Wait 2.00 seconds
Game - Display to (All players) the text: (String(counter))
[/trigger]


as u can see numbers range from 1 to 100 i tested 7 individual times with this trigger and here are the results:

int values / real values
1- 54 / 56
2- 58 / 60
3- 57 / 58
4- 50 / 56
5- 52 / 52
6- 60 / 50
7- 56 / 63

not much of a difference i suppose but the reals did trigger a few more times than the integers try it out for yourself if you dont believe this
:ogre_hurrhurr:
 
Level 17
Joined
Jul 17, 2011
Messages
1,864
if you have a .3333 that goes to infinity it will eventually be rounded else the computer will run out of memory trying to store it, integers only exist so that the program will use less memory when storing numbers and they are used so store less important values, reals on the other hand are used to store very accurate information it is not possible to say that an integer is more accurate than a real in terms of accuracy
 
Status
Not open for further replies.
Top