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

[Trigger] I'm trying to create a spell

Status
Not open for further replies.
Here I'm trying to create a spell - it saves nearby X units that respond to your conditions, and when cast again to move them back. I'm making this with Bribe's Indexer. However, it's not working - the indexing. It's like somehow it bugs the map. I tried to use init to show the custom value of a unit, with message, but nothing shows. In another empty map I did it only with putting message and it worked. Can you look at it and tell me what's the problem?

LINK



But better open the map
  • AR Config
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- SET VARIABLES DEPENDING ON YOUR PREFERENCES --------
      • -------- -------------------------------------------------------------------------- --------
      • -------- TRUE variables will include such units in the spell --------
      • Set AR_Target_Owned_Units = True
      • Set AR_Target_Heroes = True
      • Set AR_Target_Flying = True
      • Set AR_Target_Ground = True
      • Set AR_Target_Mechanical = True
      • Set AR_Target_Ally_Units = False
      • Set AR_Target_Enemy_Units = False
      • Set AR_Target_Buildings = False
      • Set AR_Target_Passive_Units = False
      • Set AR_Target_Magic_Immuned = False
      • -------- The range in which the spell pick units --------
      • Set AR_Range = 600.00
      • -------- The number of Units Picked for each level of the spell --------
      • Set AR_Units_Picked[1] = 3
      • Set AR_Units_Picked[2] = 4
      • Set AR_Units_Picked[3] = 5
      • -------- -------------------------------------------------------------------------- --------
      • -------- END OF CONFIGURATION --------
  • AR cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Arcane Recall
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AR_Casted[(Custom value of (Triggering unit))] Equal to False
        • Then - Actions
          • Set AR_Position = (Position of (Triggering unit))
          • Set AR_Pick[(Custom value of (Triggering unit))] = (Units within AR_Range of AR_Position)
          • Custom script: call RemoveLocation(udg_AR_Position)
          • Unit Group - Remove (Triggering unit) from AR_Pick[(Custom value of (Triggering unit))]
          • Unit Group - Pick every unit in AR_Pick[(Custom value of (Triggering unit))] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AR_Target_Ally_Units Equal to False
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Owner of (Triggering unit)) is an ally of (Owner of (Picked unit))) Equal to True
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from AR_Pick[(Custom value of (Triggering unit))]
                    • Else - Actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AR_Target_Buildings Equal to False
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is A structure) Equal to True
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from AR_Pick[(Custom value of (Triggering unit))]
                    • Else - Actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AR_Target_Flying Equal to False
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is A flying unit) Equal to True
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from AR_Pick[(Custom value of (Triggering unit))]
                    • Else - Actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AR_Target_Magic_Immuned Equal to False
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is Magic Immune) Equal to True
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from AR_Pick[(Custom value of (Triggering unit))]
                    • Else - Actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AR_Target_Mechanical Equal to False
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is Mechanical) Equal to True
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from AR_Pick[(Custom value of (Triggering unit))]
                    • Else - Actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AR_Target_Ground Equal to False
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is A ground unit) Equal to True
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from AR_Pick[(Custom value of (Triggering unit))]
                    • Else - Actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AR_Target_Enemy_Units Equal to False
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Owner of (Triggering unit)) is an enemy of (Owner of (Picked unit))) Equal to True
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from AR_Pick[(Custom value of (Triggering unit))]
                    • Else - Actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AR_Target_Heroes Equal to False
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is A Hero) Equal to True
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from AR_Pick[(Custom value of (Triggering unit))]
                    • Else - Actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AR_Target_Passive_Units Equal to False
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Owner of (Picked unit)) Equal to Neutral Passive
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from AR_Pick[(Custom value of (Triggering unit))]
                    • Else - Actions
                • Else - Actions
          • For each (Integer A) from 1 to 100, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in AR_Pick[(Custom value of (Triggering unit))]) Greater than AR_Units_Picked[(Level of Arcane Recall for (Triggering unit))]
                • Then - Actions
                  • Unit Group - Remove (Random unit from AR_Pick[(Custom value of (Triggering unit))]) from AR_Pick[(Custom value of (Triggering unit))]
                • Else - Actions
                  • Unit Group - Pick every unit in AR_Pick[(Custom value of (Triggering unit))] and do (Actions)
                    • Loop - Actions
                      • Set AR_Position = (Position of (Picked unit))
                      • Set AR_OldPos[(Custom value of (Picked unit))] = (Position of (Picked unit))
                      • Special Effect - Create a special effect at AR_Position using Abilities\Spells\Human\MassTeleport\MassTeleportTo.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • Custom script: call RemoveLocation(udg_AR_Position)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in AR_Pick[(Custom value of (Triggering unit))]) Greater than 0
            • Then - Actions
              • Set AR_Casted[(Custom value of (Triggering unit))] = True
            • Else - Actions
        • Else - Actions
          • Unit Group - Pick every unit in AR_Pick[(Custom value of (Triggering unit))] and do (Actions)
            • Loop - Actions
              • Set AR_Position = (Position of (Picked unit))
              • Special Effect - Create a special effect at AR_Position using Abilities\Spells\Human\MassTeleport\MassTeleportTo.mdl
              • Special Effect - Destroy (Last created special effect)
              • Set AR_OldPos[(Custom value of (Picked unit))] = (Position of (Picked unit))
              • Special Effect - Create a special effect at AR_OldPos[(Custom value of (Picked unit))] using Abilities\Spells\Human\MassTeleport\MassTeleportTo.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Move (Picked unit) instantly to AR_OldPos[(Custom value of (Picked unit))]
              • Custom script: call RemoveLocation(udg_AR_OldPos[GetUnitUserData(GetEnumUnit())])
          • Set AR_Casted[(Custom value of (Triggering unit))] = False
 
Last edited:
Level 37
Joined
Jul 22, 2015
Messages
3,485
You need to manually initialize group arrays if you did not specify a big enough size. For example: if you set the size to 1, only arrays 0 and 1 will be initialized. However, instead of just specifying a size, you can do this:

On index:
  • Custom script: if udg_SomeUnitGroup[Index] == null then
  • Custom script set udg_SomeUnitGroup[Index] = CreateGroup()
  • Custom script endif

On deindex:
  • Custom script: set udg_SomeUnitGroup[Index] = null

In the future, store the Custom value of the unit into a variable. You're also supposed to create a dummy unit and use that unit's custom value, not the triggering unit. If you use the triggering unit's custom value, you will not be able to have more than one instance per unit.

A more important thing to note is that you don't even need to index this spell. Everything is ran instantly, so you don't need to worry about overwriting variables.
 
Ok, I will store them in variables, but what about the indexing? You see it's not displaying.

A more important thing to note is that you don't even need to index this spell. Everything is ran instantly, so you don't need to worry about overwriting variables.
I have to
1. Pick every unit around the caster
2. Filter the units that does not respond to the specified conditions
3. Reduce the number fo the picked units to 3,4, or 5, depending on the level of the spell
4. Store the units' old location
5. Create effect on the units' location

On second cast:
1. Move the stored units back to the stored old position
.2 create effect on their current position
3. create effect on their old position
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
On second cast:
1. Move the stored units back to the stored old position
.2 create effect on their current position
3. create effect on their old position

But the units and their locations must be stored for later use... I don't understand.
Oh I didn't look at the Else - Actions. Then yeah I guess you need to index them, my mistake. Do keep in mind though that if they were to be affected by the same spell by another instance, they will overwrite, causing potential leaks and undesirable effects.


So... I just can set the custom value of unit to + 1 and set it on the unit?
You should not be modifying the custom value of a unit at all. Leave that to unit indexers. If you are using Bribe's template, just create a dummy unit on cast and use the custom value of the dummy unit as the index of the variables.

EDIT: Just opened up your map. Why in heavens name are you giving the variables a defined size of 8192? Not only is that pointless, but you're breaking your map. The 8192th index is buggy as hell. Also, you aren't dynamically storing the position of the units within range of the caster. This means that you will leak, and the only position saved will be the most recent unit picked in the loop.
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,378
On deindex:
  • Custom script: set udg_SomeUnitGroup[Index] = null
Do note that this does not destroy the group, it only nulls the pointer, thus creating a memory leak.
You need to use the following action to destroy group:
  • Custom script: call DestroyGroup(udg_group)
If you null the pointer after that or not has no real impact on your game (at least when talking about global variables)
 
Status
Not open for further replies.
Top