Weird random number issue.

Grags_1977

Ultra Cool Member
Reaction score
32
Searchers. If you're having random number problems. 2 possible solutions.

A, File/Preferences/Test Map: Uncheck Fixed Random Seed.

B, Obviously a bug in the wc3 engine. Try Converting a random real to an integer.

Example: Set RandomNumber = (Integer((Random real number between 1.00 and 4.00)))




Original Message
This just stopped working out of nowhere and I have no idea why.


This part runs at Initialization.
Code:
        Set Region_HostileToDie[1] = HostileToDie01 <gen>
        Set Camera_HostileToDie[1] = HostileToDie01 <gen>
        Set Region_HostileToDie[2] = HostileToDie02 <gen>
        Set Camera_HostileToDie[2] = HostileToDie02 <gen>
        Set Region_HostileToDie[3] = HostileToDie03 <gen>
        Set Camera_HostileToDie[3] = HostileToDie03 <gen>
        Set Region_HostileToDie[4] = HostileToDie04 <gen>
        Set Camera_HostileToDie[4] = HostileToDie04 <gen>
        Set Unit_HostileToDies[1] = Bounty (Level 1)
        Set Unit_HostileToDies[2] = Bounty (Level 2)
        Set Unit_HostileToDies[3] = Bounty (Level 3)
        Set Unit_HostileToDies[4] = Bounty (Level 4)
        Set Unit_HostileToDies[5] = Bounty (Level 5)
        Set Unit_HostileToDies[6] = Bounty (Level 6)
        Set Unit_HostileToDies[7] = Bounty (Level 7)
        Set Unit_HostileToDies[8] = Bounty (Level 8)
        Set Unit_HostileToDies[9] = Bounty (Level 9)
        Set Unit_HostileToDies[10] = Bounty (Level 10)
        Set Unit_HostileToDie = No unit

This part runs when talking to a quest giver.
Code:
        Set Integer_RandomNumber = (Random integer number between 1 and 4)
        Set TempPoint[20] = (Center of Region_HostileToDie[Integer_RandomNumber])
        Unit - Create 1 Bounty (Level 1) for Neutral Hostile at TempPoint[20] facing Default building facing degrees
        Custom script:   call RemoveLocation( udg_TempPoint[20] )
        Set Unit_HostileToDie = (Last created unit)
        Camera - Apply Camera_HostileToDie[Integer_RandomNumber] for Player 1 (Red) over 5.00 seconds
        Wait 3.00 seconds
        Special Effect - Create a special effect attached to the overhead of Unit_HostileToDie using Abilities\Spells\Other\Aneu\AneuCaster.mdl
        Set SpecialEffect_HostileToDie = (Last created special effect)


For some reason the hostile unit is ALLWAYS placed at HostileToDie03. What am I missing?!?!


These are the full triggers

Trigger:
  • Variables
    • Events
    • Conditions
    • Actions
      • Set Real_InfernoAOE = 400.00
      • Set Real_FireBoltDamage = 6.00
      • Set Integer_SpinAttackMax = 2
      • Set Region_HostileToDie[1] = HostileToDie01 &lt;gen&gt;
      • Set Camera_HostileToDie[1] = HostileToDie01 &lt;gen&gt;
      • Set Region_HostileToDie[2] = HostileToDie02 &lt;gen&gt;
      • Set Camera_HostileToDie[2] = HostileToDie02 &lt;gen&gt;
      • Set Region_HostileToDie[3] = HostileToDie03 &lt;gen&gt;
      • Set Camera_HostileToDie[3] = HostileToDie03 &lt;gen&gt;
      • Set Region_HostileToDie[4] = HostileToDie04 &lt;gen&gt;
      • Set Camera_HostileToDie[4] = HostileToDie04 &lt;gen&gt;
      • Set Unit_HostileToDies[1] = Bounty (Level 1)
      • Set Unit_HostileToDies[2] = Bounty (Level 2)
      • Set Unit_HostileToDies[3] = Bounty (Level 3)
      • Set Unit_HostileToDies[4] = Bounty (Level 4)
      • Set Unit_HostileToDies[5] = Bounty (Level 5)
      • Set Unit_HostileToDies[6] = Bounty (Level 6)
      • Set Unit_HostileToDies[7] = Bounty (Level 7)
      • Set Unit_HostileToDies[8] = Bounty (Level 8)
      • Set Unit_HostileToDies[9] = Bounty (Level 9)
      • Set Unit_HostileToDies[10] = Bounty (Level 10)
      • Set Unit_HostileToDie = No unit
      • Set TempUnitGroup[1] = (Units of type Bob)
      • Set Unit_Hero = (Random unit from TempUnitGroup[1])
      • Custom script: call DestroyGroup ( udg_TempUnitGroup[1] )
      • Trigger - Add to Death Bring Reset Cam and Movement &lt;gen&gt; the event (Unit - Unit_Hero Takes damage)
      • Trigger - Add to In range &lt;gen&gt; the event (Unit - A unit comes within 1800.00 of Unit_Hero)
      • Hero - Modify unspent skill points of Unit_Hero: Subtract 1 points
      • Set Sound_SpinAttack[1] = SpinAttackHit1 &lt;gen&gt;
      • Set Sound_SpinAttack[2] = SpinAttackHit2 &lt;gen&gt;
      • Set Sound_SpinAttack[3] = SpinAttackHit3 &lt;gen&gt;
      • Set Integer_GoldRewardCaptain = 200
      • Set Sound_Music = Music_Human &lt;gen&gt;

Trigger:
  • Captain Back
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Talk
      • (Unit-type of (Selling unit)) Equal to Desert Guard Captain
      • ((Selling unit) belongs to an enemy of Player 1 (Red)) Equal to False
      • Unit_HostileToDie Equal to No unit
      • (Unit_Hero has an item of type Murlocs Head) Equal to False
    • Actions
      • Set Integer_HostileToDie = (Integer_HostileToDie + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Integer_HostileToDie Greater than 10
        • Then - Actions
          • Set Integer_HostileToDie = 10
        • Else - Actions
      • Special Effect - Destroy SpecialEffect_QuestCaptain
      • Trigger - Turn off (This trigger)
      • Trigger - Run Cinematic Mode On &lt;gen&gt; (ignoring conditions)
      • Camera - Apply Captain 01 &lt;gen&gt; for Player 1 (Red) over 0.00 seconds
      • Camera - Apply Captain 02 &lt;gen&gt; for Player 1 (Red) over 3.00 seconds
      • Cinematic - Send transmission to (All players) from Unit_Talk named (Name of Unit_Talk): Play Voice_Captain_Back_01 &lt;gen&gt; and display Welcome back!. Modify duration: Add 0.00 seconds and Wait
      • Set Integer_RandomNumber = (Random integer number between 1 and 4)
      • Set TempPoint[20] = (Center of Region_HostileToDie[Integer_RandomNumber])
      • Unit - Create 1 Unit_HostileToDies[Integer_HostileToDie] for Neutral Hostile at TempPoint[20] facing Default building facing degrees
      • Custom script: call RemoveLocation( udg_TempPoint[20] )
      • Set Unit_HostileToDie = (Last created unit)
      • Camera - Apply Camera_HostileToDie[Integer_RandomNumber] for Player 1 (Red) over 5.00 seconds
      • Wait 3.00 seconds
      • Special Effect - Create a special effect attached to the overhead of Unit_HostileToDie using Abilities\Spells\Other\Aneu\AneuCaster.mdl
      • Set SpecialEffect_HostileToDie = (Last created special effect)
      • Camera - Set Player 1 (Red)&#039;s camera Distance to target to 950.00 over 3.00 seconds
      • Cinematic - Send transmission to (All players) from Unit_Talk named (Name of Unit_Talk): Play Voice_Captain_Back_02 &lt;gen&gt; and display This guy is your ne.... Modify duration: Add 0.00 seconds and Wait
      • Cinematic - Send transmission to (All players) from Unit_Talk named (Name of Unit_Talk): Play Voice_Captain_Back_03 &lt;gen&gt; and display Bring me his head, .... Modify duration: Add 0.00 seconds and Wait
      • Neutral Building - Add Give Head to (Selling unit) with 1 in stock and a max stock of 1
      • Set TempPoint[21] = (Position of Unit_Hero)
      • Camera - Pan camera for Player 1 (Red) to TempPoint[21] over 0.00 seconds
      • Custom script: call RemoveLocation( udg_TempPoint[21] )
      • Trigger - Run Cinematic Mode Off &lt;gen&gt; (ignoring conditions)
      • Trigger - Turn on Captain Return Hostile Dead 02 &lt;gen&gt;
      • Trigger - Turn on Captain Return Hostile Alive &lt;gen&gt;
      • Special Effect - Create a special effect attached to the overhead of (Selling unit) using Objects\RandomObject\RandomObject.mdl
      • Set SpecialEffect_QuestCaptain = (Last created special effect)



EDIT: Hmmm why aint my spoiler tags working? It is [spoiler.][/spoiler.] right? (without the . of course)

EDIT2: Fixed random seed is unchecked btw.


EDIT3: So I went ahead and added this line.

Game - Display to (All players) the text: (String(Integer_RandomNumber))

And every time it displays 3wtf is going on?!?!

EDIT4: Going to uninstall and reinstall. I think my warcraft is bugged.

EDIT5: I like editing.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
sometimes individual actions on wc3 can be bugged, iv run into this before, i think the solution was to create a random real and convert it to an integer, but dont quote me on it : /
 

Grags_1977

Ultra Cool Member
Reaction score
32
I'm in the middle of reinstalling now. See if that helps.

EDIT: Reinstalling didn't work.

But
Set Integer_RandomNumber = (Integer((Random real number between 1.00 and 4.00)))

Worked. How !@?% stupid.

Gah, owe you a rep GFreak.
 
Reaction score
456
Well, first thing to do is not to reinstall.

I don't remember this quote by AceHart word to word, but it goes somewhat like this:
"When random fails to meet your expectations, it is random indeed."

If the Fixed Random Seed is truly unchecked, you could've tried to restart computer. Or maybe run the trigger it many times on same run, and see if it's always 3.

EDIT: It does not matter whether you use random integer/random real. Both work.
 

Grags_1977

Ultra Cool Member
Reaction score
32
Well, first thing to do is not to reinstall.

I don't remember this quote by AceHart word to word, but it goes somewhat like this:
"When random fails to meet your expectations, it is random indeed."

If the Fixed Random Seed is truly unchecked, you could've tried to restart computer. Or maybe run the trigger it many times on same run, and see if it's always 3.


Trust me. It was allways 3. I did a full test of my map and in my LONG list of things to fix, that was one of them. As the player needs to visit this guy 10 times to recieve one of the end game hidden power ups. And it was ALLWAYS the same spot. Thats 10 times in a row a 1 in 4 chance resulted in 3.

Furthermore. Once I tried to fix the problem. It was still 3 everytime. Perhaps a good 30 trys before I posted. And then I tried with the string conversion message a good 10 times before I edited it.

Once I converted it from a random real to an integer it worked. It's obviously a bug in the wc3 engine.


EDIT: Thanks for the reply nonetheless +rep. And with that +rep I managed to get 1 of the 90 gazillion reps I owe you GFreak.

EDIT2: I would like to add, that I have random integers all over the place that are working as they should. It's just this occasion it refused to. There is definately a rare bug somewhere in the wc3 engine that disallowed this to be random. As once I changed it from...

Set Integer_RandomNumber = (Random integer number between 1 and 4)

To

Set Integer_RandomNumber = (Integer((Random real number between 1.00 and 4.00)))

It worked fine. Law of averages argues a 1 in 4 chance can't be 3 everytime around 50 times. More chance of taking a dump in the queens handbag :p
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
thats more of a 1 in 10 :D where as 1 in 4 50 times in a row is 1 in 4^50, not even gonna do the math on that
 

Grags_1977

Ultra Cool Member
Reaction score
32
FFS! Now it's 2 everytime...

Balls to it, i'm just going to rotate the regions from 1 to 4. Instead of make it random. I cba with this bull...

EDIT:

Trigger:
  • Set Integer_RegionHostile = (Integer_RegionHostile + 1)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Integer_RegionHostile Greater than 4
      • Then - Actions
        • Set Integer_RegionHostile = 1
      • Else - Actions


If this doesn't work, i'm throwing my pc at the wall.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
damn lol -.-

you could just try running another trigger and that trigger could have the action in it, and just use that to set your random numbers
 

Grags_1977

Ultra Cool Member
Reaction score
32
Rotating works. I'm just going to stick with that. It's not worth the stress lol

Meanwhile, if someone could shed some light on wtf is going on here, i'd be very happy to find out.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top