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

[Solved] spell isn't working

Status
Not open for further replies.
Level 21
Joined
Mar 29, 2020
Messages
1,237
hey there,

here is a spell I made which is supposed to create a ward that saps gold from owners of nearby buildings. It's not working. (using bribe's unit indexer).

  • bank tunnel
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Banking Tunnel (Level 1)
    • Actions
      • Unit Group - Add (Triggering unit) to BankGroup
      • Game - Display to (All players) for 5.00 seconds the text: unit added
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (bank loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on bank loop <gen>
        • Else - Actions
  • bank loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in BankGroup and do (Actions)
        • Loop - Actions
          • Set CV = (Custom value of (Picked unit))
          • Set BankTunnel[CV] = (Picked unit)
          • Set TempPoint = (Position of BankTunnel[CV])
          • Game - Display to (All players) for 5.00 seconds the text: unit and point set
          • Unit Group - Pick every unit in (Units within 200.00 of TempPoint matching (((Matching unit) is A structure) Equal to True)) and do (Actions)
            • Loop - Actions
              • Game - Display to (All players) for 5.00 seconds the text: picked buildings
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Owner of (Picked unit)) is in BankForce[CV]) Equal to False
                • Then - Actions
                  • Player Group - Add (Owner of (Picked unit)) to BankForce[CV]
                  • Game - Display to (All players) for 5.00 seconds the text: player added
                • Else - Actions
              • Player Group - Pick every player in BankForce[CV] and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked player) Current gold) Greater than 0
                    • Then - Actions
                      • Game - Display to (All players) for 5.00 seconds the text: enough gold
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Unit-type of BankTunnel[CV]) Equal to Banking Tunnel (Level 1)
                        • Then - Actions
                          • Player - Add -1 to (Picked player) Current gold
                          • Player - Add 1 to (Owner of BankTunnel[CV]) Current gold
                          • Game - Display to (All players) for 5.00 seconds the text: stolen!
                        • Else - Actions
                          • Player - Add -3 to (Picked player) Current gold
                          • Player - Add 3 to (Owner of BankTunnel[CV]) Current gold
                    • Else - Actions
          • Custom script: call RemoveLocation (udg_TempPoint)
      • If ((BankGroup is empty) Equal to True) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
  • kill bank
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Banking Tunnel (Level 1)
    • Actions
      • Set CV = (Custom value of (Triggering unit))
      • Player Group - Remove all players from BankForce[CV]
      • Game - Display to (All players) for 5.00 seconds the text: group emptied
when I tested it with texts - It works until the part in the loop trigger :
Player Group - Pick every player in BankForce[CV] and do (Actions)...

what did I do wrong?

(I made it this way bc I want to be able to have multiple wards on one enemy building, but I don't want one ward to take gold twice from the same player if next to two buildings...)
(also the unit called "banking tunnel" is summoned via a serpent ward based ability)
thanks!
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,542
The fix:
1) You don't need a Unit Indexer for this type of spell. You can remove the Arrays from BankForce and BankTunnel.

2) You want to move Player Group - Pick every player in BankForce to outside and beneath the Pick every unit function. Otherwise this will pick every player X times, X being equal to the number of picked units.

3) You can get rid of the kill bank trigger. Just check if your picked unit is Alive in your Loop, and if it isn't then remove it from BankGroup.

4) After picking every player in BankForce and adding/subtracting gold, clear the Player Group (removing all players from it).

  • Bank Summon
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Serpent Ward (Level 1)
          • (Unit-type of (Triggering unit)) Equal to Serpent Ward (Level 2)
          • (Unit-type of (Triggering unit)) Equal to Serpent Ward (Level 3)
    • Actions
      • Unit Group - Add (Triggering unit) to BankGroup
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Bank Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Bank Loop <gen>
        • Else - Actions
  • Bank Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in BankGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • Set VariableSet BankUnit = (Picked unit)
              • Set VariableSet TempPoint = (Position of BankUnit)
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 200.00 of TempPoint.) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is A structure) Equal to True
                      • ((Owner of (Picked unit)) is in BankForce.) Equal to False
                    • Then - Actions
                      • Player Group - Add (Owner of (Picked unit)) to BankForce
                    • Else - Actions
              • Custom script: call RemoveLocation (udg_TempPoint)
              • Player Group - Pick every player in BankForce and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of BankUnit) Equal to Serpent Ward (Level 1)
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked player) Current gold) Greater than or equal to 1
                        • Then - Actions
                          • Player - Add 1 to (Owner of BankUnit).Current gold
                        • Else - Actions
                      • Player - Add -1 to (Picked player).Current gold
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Unit-type of BankUnit) Equal to Serpent Ward (Level 2)
                        • Then - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • ((Picked player) Current gold) Greater than or equal to 2
                            • Then - Actions
                              • Player - Add 2 to (Owner of BankUnit).Current gold
                            • Else - Actions
                              • Player - Add ((Picked player) Current gold) to (Owner of BankUnit).Current gold
                          • Player - Add -2 to (Picked player).Current gold
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Unit-type of BankUnit) Equal to Serpent Ward (Level 3)
                            • Then - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • ((Picked player) Current gold) Greater than or equal to 3
                                • Then - Actions
                                  • Player - Add 3 to (Owner of BankUnit).Current gold
                                • Else - Actions
                                  • Player - Add ((Picked player) Current gold) to (Owner of BankUnit).Current gold
                              • Player - Add -3 to (Picked player).Current gold
                            • Else - Actions
              • Player Group - Remove all players from BankForce.
            • Else - Actions
              • Unit Group - Remove (Picked unit) from BankGroup.
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in BankGroup) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
Bugs aside, I believe you would've needed to set the Size of the Arrays for the Player Group and Unit Group as well.

Another small note, and this may be intentional, but currently this saps gold from the player's own buildings and allies buildings as well.
 
Last edited:
Status
Not open for further replies.
Top