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

Votation by clicking on item

Status
Not open for further replies.
Level 6
Joined
Sep 24, 2015
Messages
174
Hi people,


I try to set up a votation system to train a special unit for 2 players, this is initiated whenever a player clicks on an item, let me explain it (try) :


1. After 65 seconds an item is added in builder's inventory for each Human players in the game.


2. If any player of the Humans group clicks on the item then it initiates the Slayer election, the item is destroyed for all players. A timer is started for player group of owner of triggering unit.


3. Timer expires : if there are more than 2 players who want to train the special unit, then a Dialog is created and dialog button is shown to players in Human group with the name of all the players who have clicked on the new item created after timer expired, then players in Human group have to chose 2 players from the list, a new timer is started. Timer expires : the 2 players who have the most votes are now set to protector1 and protector2.

If there are 2 players who want to train the special unit, then set voted player 1 to protector 1 and voted player 2 to protector2.

If there is 1 player who wants to train the special unit, then don't remove the item from builders and set player who clicked on the item to protector1,

If a new player clicks on the item during the game, then set that new player to protector2.



Part 3 is really tricky for me and something is wrong there i believe.



Here are all the triggers :


  • Slayer election item after spawn
    • Events
      • Time - Elapsed game time is 65.00 seconds
    • Conditions
    • Actions
      • Set VariableSet tempUnitGroup = (Units of type Builder)
      • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Add Inventory (Builder) to (Picked unit)
          • Hero - Create |cffff0000Slayer election item|r and give it to (Picked unit)
      • Custom script: call DestroyGroup ( udg_tempUnitGroup )
      • Set VariableSet tempUnitGroup = (Units of type aitz-)
      • Unit Group - Pick every unit in (Units of type aitz-) and do (Actions)
        • Loop - Actions
          • Unit - Add Inventory (Builder) to (Picked unit)
          • Hero - Create |cffff0000Slayer election item|r and give it to (Picked unit)
      • Custom script: call DestroyGroup ( udg_tempUnitGroup )
      • Game - Display to HumanGroup the text: |cffffff00Zero :|r ...

  • Item is used to initiate election
    • Events
      • Unit - A unit Uses an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to |cffff0000Slayer election item|r
        • Then - Actions
          • Countdown Timer - Start SlayerElectionTimer as a One-shot timer that will expire in 30.00 seconds
          • Countdown Timer - Create a timer window for (Last started timer) with title New item for electi...
          • Player Group - Pick every player in HumanGroup and do (Actions)
            • Loop - Actions
              • Game - Display to (Player group((Picked player))) the text: |cffffff00Zero :|r ...
          • Set VariableSet tempUnitGroup = (Units of type Builder)
          • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
            • Loop - Actions
              • Item - Remove (Item carried by (Picked unit) of type |cffff0000Slayer election item|r)
              • Unit - Remove Inventory (Builder) from (Picked unit)
          • Custom script: call DestroyGroup ( udg_tempUnitGroup )
          • Set VariableSet tempUnitGroup = (Units of type aitz-)
          • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
            • Loop - Actions
              • Item - Remove (Item carried by (Picked unit) of type |cffff0000Slayer election item|r)
              • Unit - Remove Inventory (Builder) from (Picked unit)
          • Custom script: call DestroyGroup ( udg_tempUnitGroup )
        • Else - Actions

  • item 1 Timer expires
    • Events
      • Time - SlayerElectionTimer expires
    • Conditions
    • Actions
      • Countdown Timer - Destroy (Last created timer window)
      • Set VariableSet tempUnitGroup = (Units of type Builder)
      • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Add Inventory (Builder) to (Picked unit)
          • Hero - Create |cff00ffffI'm guardian of humanity|r and give it to (Picked unit)
      • Custom script: call DestroyGroup ( udg_tempUnitGroup )
      • Set VariableSet tempUnitGroup = (Units of type aitz-)
      • Unit Group - Pick every unit in (Units of type aitz-) and do (Actions)
        • Loop - Actions
          • Unit - Add Inventory (Builder) to (Picked unit)
          • Hero - Create |cff00ffffI'm guardian of humanity|r and give it to (Picked unit)
      • Custom script: call DestroyGroup ( udg_tempUnitGroup )

  • Item is used for election and results
    • Events
      • Unit - A unit Uses an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to |cff00ffffI'm guardian of humanity|r
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Owner of (Triggering unit)) is in HumanGroup.) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Owner of (Triggering unit)) is in ProtectorOfHUmanity.) Equal to False
                • Then - Actions
                  • Player Group - Add (Owner of (Triggering unit)) to ProtectorOfHUmanity
                  • Hero - Drop (Item being manipulated) from (Triggering unit).
                  • Item - Remove (Last dropped item)
                  • Player Group - Pick every player in (Player group((Owner of (Triggering unit)))) and do (Actions)
                    • Loop - Actions
                      • Game - Display to HumanGroup for 15.00 seconds the text: ((Name of (Owner of (Triggering unit))) + was nominated for the Vampire Slayer election.)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • VampSlayerStatus Equal to 0
                    • Then - Actions
                      • Game - Display to (Player group((Picked player))) the text: |cffffff00Zero :|r ...
                      • Countdown Timer - Start ChosenPlayers as a One-shot timer that will expire in 15.00 seconds
                      • Countdown Timer - Create a timer window for (Last started timer) with title Results in...
                      • Player Group - Pick every player in HumanGroup and do (Actions)
                        • Loop - Actions
                          • Countdown Timer - Show ResultTimerNewElection for (Picked player)
                    • Else - Actions
                  • Set VariableSet VampSlayerStatus = 1
                • Else - Actions
            • Else - Actions
        • Else - Actions

  • item 2 Timer expires
    • Events
      • Time - ChosenPlayers expires
    • Conditions
    • Actions
      • Set VariableSet ResultTimerNewElection = (Last created timer window)
      • Countdown Timer - Destroy ResultTimerNewElection
      • Player Group - Pick every player in ProtectorOfHUmanity and do (Actions)
        • Loop - Actions
          • Game - Display to (Player group((Picked player))) the text: |cffffff00Zero :|r ...
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of players in ProtectorOfHUmanity) Greater than 2
            • Then - Actions
              • Game - Display to HumanGroup the text: (|cffffff00Zero :|r More than 2 players want to train special slayers. + , a new votation is made to chose wich players will be the chosen ones.)
              • Set VariableSet tempUnitGroup = (Units of type Builder)
              • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
                • Loop - Actions
                  • Item - Remove (Item carried by (Picked unit) of type |cff00ffffI'm guardian of humanity|r)
                  • Unit - Remove Inventory (Builder) from (Picked unit)
              • Custom script: call DestroyGroup ( udg_tempUnitGroup )
              • Set VariableSet tempUnitGroup = (Units of type aitz-)
              • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
                • Loop - Actions
                  • Item - Remove (Item carried by (Picked unit) of type |cff00ffffI'm guardian of humanity|r)
                  • Unit - Remove Inventory (Builder) from (Picked unit)
              • Custom script: call DestroyGroup ( udg_tempUnitGroup )
              • Dialog - Clear SlayerElection
              • Dialog - Change the title of SlayerElection to Chose 2 players...
              • For each (Integer A) from 1 to 24, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Player((Integer A))) is in ProtectorOfHUmanity.) Equal to True
                    • Then - Actions
                      • Set VariableSet VampSlayerVotesCount[(Integer A)] = 0
                      • Dialog - Create a dialog button for VampSlayerDialog labelled (Name of (Player((Integer A))))
                      • Set VariableSet VampSlayerDialogBTN[(Integer A)] = (Last created dialog Button)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Player((Integer A))) is in HumanGroup.) Equal to True
                        • Then - Actions
                          • Dialog - Show SlayerElection for (Player((Integer A)))
                        • Else - Actions
                    • Else - Actions
              • Countdown Timer - Start SlayerElectionFinalTimer as a One-shot timer that will expire in 20.00 seconds
              • Countdown Timer - Create a timer window for (Last started timer) with title Final result in...
              • Player Group - Pick every player in HumanGroup and do (Actions)
                • Loop - Actions
                  • Countdown Timer - Show FinalResultTimerWindow for (Picked player)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of players in ProtectorOfHUmanity) Equal to 2
            • Then - Actions
              • Set VariableSet tempUnitGroup = (Units of type Builder)
              • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
                • Loop - Actions
                  • Item - Remove (Item carried by (Picked unit) of type |cff00ffffI'm guardian of humanity|r)
                  • Unit - Remove Inventory (Builder) from (Picked unit)
              • Custom script: call DestroyGroup ( udg_tempUnitGroup )
              • Set VariableSet tempUnitGroup = (Units of type aitz-)
              • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
                • Loop - Actions
                  • Item - Remove (Item carried by (Picked unit) of type |cff00ffffI'm guardian of humanity|r)
                  • Unit - Remove Inventory (Builder) from (Picked unit)
              • Custom script: call DestroyGroup ( udg_tempUnitGroup )
              • Player Group - Pick every player in ProtectorOfHUmanity and do (Actions)
                • Loop - Actions
                  • Player Group - Add (Picked player) to ChosenOnes
                  • Player Group - Remove (Picked player) from ProtectorOfHUmanity.
              • Player Group - Pick every player in ChosenOnes and do (Actions)
                • Loop - Actions
                  • Set VariableSet Protector1 = (Random player from ChosenOnes)
                  • Set VariableSet Protector2 = (Random player from ChosenOnes)
                  • Player - Limit training of Slayer to 0 for (Picked player)
                  • Player - Limit training of Berserk to 2 for (Picked player)
                  • Player - Limit training of Heroes to 2 for (Picked player)
                  • Game - Display to HumanGroup the text: (|cffffff00Zero :|r Protectors are : + (Name of (Picked player)))
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of players in ProtectorOfHUmanity) Equal to 1
            • Then - Actions
              • Game - Display to HumanGroup the text: |cffffff00Zero :|r ...
              • Game - Display to HumanGroup the text: |cffffff00Zero :|r ...
              • Set VariableSet tempUnitGroup = (Units of type Builder)
              • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
                • Loop - Actions
                  • Item - Remove (Item carried by (Picked unit) of type |cff00ffffI'm guardian of humanity|r)
                  • Unit - Remove Inventory (Builder) from (Picked unit)
              • Custom script: call DestroyGroup ( udg_tempUnitGroup )
              • Set VariableSet tempUnitGroup = (Units of type aitz-)
              • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
                • Loop - Actions
                  • Item - Remove (Item carried by (Picked unit) of type |cff00ffffI'm guardian of humanity|r)
                  • Unit - Remove Inventory (Builder) from (Picked unit)
              • Custom script: call DestroyGroup ( udg_tempUnitGroup )
              • Player Group - Pick every player in ProtectorOfHUmanity and do (Actions)
                • Loop - Actions
                  • Player Group - Add (Picked player) to ChosenOnes
                  • Player Group - Remove (Picked player) from ProtectorOfHUmanity.
              • Player Group - Pick every player in ChosenOnes and do (Actions)
                • Loop - Actions
                  • Set VariableSet Protector1 = (Picked player)
                  • Player - Limit training of Slayer to 0 for (Picked player)
                  • Player - Limit training of Berserk to 2 for (Picked player)
                  • Player - Limit training of Heroes to 2 for (Picked player)
                  • Game - Display to HumanGroup the text: (Protector/s : + (Name of (Picked player)))
            • Else - Actions

  • VampSlayer Voting
    • Events
      • Dialog - A dialog button is clicked for SlayerElection
    • Conditions
      • VampSlayerStatus Equal to 1
    • Actions
      • For each (Integer A) from 1 to 24, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to VampSlayerDialogBTN[(Integer A)]
              • ((Player((Integer A))) is in VampSlayerNominated.) Equal to True
            • Then - Actions
              • Game - Display to HumanGroup for 7.00 seconds the text: ((Name of (Triggering player)) + ( has voted for + (Name of (Player((Integer A))))))
              • Set VariableSet VampSlayerVotesCount[(Integer A)] = (VampSlayerVotesCount[(Integer A)] + 1)
            • Else - Actions

  • Final timer expires
    • Events
      • Time - SlayerElectionFinalTimer expires
    • Conditions
    • Actions
      • Set VariableSet FinalResultTimerWindow = (Last created timer window)
      • Countdown Timer - Destroy FinalResultTimerWindow
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • VampSlayerVotesCount[(Integer A)] Greater than VampSlayerVotesCount[(Player number of Protector1)]
              • ((Player((Integer A))) is in ProtectorOfHUmanity.) Equal to True
            • Then - Actions
              • Set VariableSet Protector1 = (Player((Integer A)))
              • Player Group - Remove (Player((Integer A))) from ProtectorOfHUmanity.
              • Player Group - Add (Player((Integer A))) to ChosenOnes
            • Else - Actions
      • For each (Integer B) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • VampSlayerVotesCount[(Integer B)] Greater than VampSlayerVotesCount[(Player number of Protector2)]
              • ((Player((Integer A))) is in ProtectorOfHUmanity.) Equal to True
            • Then - Actions
              • Set VariableSet Protector2 = (Player((Integer B)))
              • Player Group - Remove (Player((Integer B))) from ProtectorOfHUmanity.
              • Player Group - Add (Player((Integer B))) to ChosenOnes
            • Else - Actions
      • Player Group - Pick every player in ChosenOnes and do (Actions)
        • Loop - Actions
          • Player - Limit training of Slayer to 0 for (Picked player)
          • Player - Limit training of Berserk to 2 for (Picked player)
          • Player - Limit training of Heroes to 2 for (Picked player)
          • Game - Display to HumanGroup the text: (Protectors are : + (Name of (Picked player)))
          • Game - Display to HumanGroup the text: |cffffff00Zero :|...

It is actually not working, i'm doing something wrong with the votescount and the ChosenOnes players.


If someone could tell me what's wrong please...


2 months that i'm trying to set that up alone with basic knowledge of GUI and some examples from other coders.
 

zam

zam

Level 3
Joined
Jan 1, 2021
Messages
31
  • Unit - Uses an Item
This is not "Click on Unit" this is when someone Uses an Ability of an Item/Click on it Unless that's what you meant.
As for the problem i think it's in here.

Screenshot1

You're using Integer A for the Conditions instead of Integer B so it isn't looping through the things you want it loop.
 
Status
Not open for further replies.
Top