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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top