• 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!

% chance to double gold or lose it

Status
Not open for further replies.
Level 2
Joined
Dec 9, 2022
Messages
6
Hey guys, was just wondering how to make a gambling system on my TD map where it gives the player a chance to double their gold or to lose it
So they walk up to the building, go to train a unit and then once it's trained, it either doubles their gold or loses it, a 50/50 chance on both.
50/50 to 2x their gold or to lose it all
Thanks x
 
Hello, here's a simple trigger to get the job done:
  • Gamble Example
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Trained unit-type) Equal to Gamble
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 0 and 1) Equal to 0
        • Then - Actions
          • Player - Set (Owner of (Trained unit)) Current gold to 0
        • Else - Actions
          • Player - Set (Owner of (Trained unit)) Current gold to (((Owner of (Trained unit)) Current gold) x 2)
The Event detects whenever any unit is trained. The Condition is a Unit-type comparison which uses the Trained Unit Type function to get the type of the trained unit. The Actions use an If Then Else statement to roll a random number between 0 and 1, if it lands on 0 then we Set the players gold to 0, if it lands on 1 then we multiply their gold by 2.
 
Last edited:
Uncle's solution doubles/zeroes your gold at the time of training completion. Is that what you intended? Or that once you start training the unit the amount is locked in so later it will only double/zero the gold you had when you started training, but any gold earned between training start and finish is unaffected?

If that sounds complicated, just ignore my question and use Uncle's solution.
 
Uncle's solution doubles/zeroes your gold at the time of training completion. Is that what you intended? Or that once you start training the unit the amount is locked in so later it will only double/zero the gold you had when you started training, but any gold earned between training start and finish is unaffected?

If that sounds complicated, just ignore my question and use Uncle's solution.
Uncles solution works perfectly for what I wanted. Once the training has finished, that's when it either doubles or sets the gold to 0
 
Status
Not open for further replies.
Back
Top