• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Betting system

Status
Not open for further replies.
Level 2
Joined
Feb 21, 2010
Messages
12
Hello,

I am making an RPG map with a hippodrome, where people will be able to bet for the unit that will make it to the finish line first.

So, I have made a little arena with 4 lanes, in which 4 units (for example, a peasant, a peon, an acolyte and a wisp) will appear in one each.

Then, one dialog appears, with the title "Which lane will you bet on?" with 4dialog buttions:

-Lane 1
-Lane 2
-Lane 3
-Lane 4

Then, as the player chooses which lane he wants to vote on, another dialog appears with this time the title "How much gold will you bet?" with 4 dialog buttons:

-1 000
-2 000
-5 000
-10 000

Now, lets say the unit in lane 4 will win. I wish to create triggers to be able to adapt themseles to every type of situation. Like, the guy bets on lane 1, he loses 10 000 if he clicked on the 10 000 dialog button. The guy bets on lane 2, and he loses 1 000 if he clicked on the 1 000 dialog button. The guy that bets on Lane 4 gets the double of what he betted on.

I tried doing this with making player groups, but I didn't manage.

Thank for vert much for responding.
 
You can use hashtables for that. Example:
  • Trigger1
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Hashtable - Create a hashtable
    • Set Hashtable = (Last created hashtable)
The following trigger will be the one that checks what value is clicked. Whatever the value is, it will be stored on the respective player. Let's say that your dialog is called "BetDialog" and the Buttons of it are Button[1]/[2]/[3]/[4] with the values 1.000/2.000/5.000/10.000. Now:
  • Trigger2
    • Events
      • Dialog - A dialog button is clicked for BetDialog
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to Button[1]
        • Then - Actions
          • Hashtable - Save 1000 as (Key betamount) of (Key (Triggering player)) in Hashtable
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Button[2]
            • Then - Actions
              • Hashtable - Save 2000 as (Key betamount) of (Key (Triggering player)) in Hashtable
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to Button[3]
                • Then - Actions
                  • Hashtable - Save 5000 as (Key betamount) of (Key (Triggering player)) in Hashtable
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Clicked dialog button) Equal to Button[4]
                    • Then - Actions
                      • Hashtable - Save 10000 as (Key betamount) of (Key (Triggering player)) in Hashtable
                    • Else - Actions
I don't know how units for each "LANE" are defined, so use the condition you want in the following trigger.

  • Trigger3
  • Events
    • Unit - A unit dies
  • Conditions
  • Actions
    • Player Group - Pick every player in (All players) and do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • [The condition that will define what lane the unit was on (Maybe with custom values?)]
          • Then - Actions
            • Player - Add (-1*(Load (Key(betamount)) of (Key(Picked player))) to (Picked player) Current gold
          • Else - Actions
            • Player - Add (2*(Load (Key(betamount)) of (Key(Picked player))) to (Picked player) Current gold
        • Hashtable - Clear all child hashtables of (Key(Picked player)) in Hashtable
 
Level 2
Joined
Feb 21, 2010
Messages
12
Ok, I've managed to do the first trigger. Thanks for helping but, what do you mean by custom values?
 
Status
Not open for further replies.
Top