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

[Spell] Unit not added to group

Status
Not open for further replies.
Level 12
Joined
May 16, 2020
Messages
660
Hi guys,

I have a quite simple trigger, but it's not working anymore (it worked 2 months ago >_>)

The problem is that the unit is not added to the group. Essentially this part of the trigger:
  • Unit Group - Add Enchant_Target to Enchant_Group[Enchant_CV]

I usually solve this by adding this line, but here I don't want to create a new group everytime the spell is cast.
  • Custom script: set udg_Group[X] = CreateGroup()

FYI: The array of the group is [1] - I think this is OK here though... (but never really understood this)

Does anyone know how to fix this?

  • Enchant
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Enchant
    • Actions
      • Set VariableSet Enchant_Caster = (Triggering unit)
      • Set VariableSet Enchant_CV = (Custom value of Enchant_Caster)
      • Game - Display to (All players) the text: (String(Enchant_CV))
      • Set VariableSet Enchant_Target = (Target unit of ability being cast)
      • Set VariableSet Enchant_Stats[1] = (100 + (100 x (Level of Enchant for Enchant_Caster)))
      • Set VariableSet Enchant_Stats[2] = (-10 + (20 x (Level of Enchant for Enchant_Caster)))
      • Set VariableSet Enchant_Stats[3] = (2 x (Level of Enchant for Enchant_Caster))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Enchant_Target is A Hero) Equal to False
          • (Enchant_Target is An Ancient) Equal to False
          • (Enchant_Target is an illusion) Equal to False
          • (Owner of Enchant_Target) Not equal to Player 13 (Maroon)
        • Then - Actions
          • Game - Display to (All players) the text: (String((Number of units in Enchant_Group[Enchant_CV])))
          • Unit Group - Pick every unit in Enchant_Group[Enchant_CV] and do (Actions)
            • Loop - Actions
              • Unit - Kill (Picked unit)
              • Unit Group - Remove (Picked unit) from Enchant_Group[Enchant_CV].
          • Unit Group - Add Enchant_Target to Enchant_Group[Enchant_CV]
          • Unit - Remove All buffs from Enchant_Target
          • Unit - Change ownership of Enchant_Target to (Owner of Enchant_Caster) and Change color
          • Special Effect - Create a special effect attached to the origin of Enchant_Target using war3mapImported\Enchant.mdx
          • Special Effect - Destroy (Last created special effect)
          • Unit - Add a (30.00 x (Real((Level of Enchant for Enchant_Caster)))) second Generic expiration timer to Enchant_Target
          • Custom script: call AddUnitBonus(udg_Enchant_Target, BONUS_HEALTH, udg_Enchant_Stats[1])
          • Custom script: call AddUnitBonus(udg_Enchant_Target, BONUS_DAMAGE, udg_Enchant_Stats[2])
          • Custom script: call AddUnitBonus(udg_Enchant_Target, BONUS_ARMOR, udg_Enchant_Stats[3])
          • Unit - Set Unit: Enchant_Target's Real Field: Hit Points ('uhpc') to Value: (Max life of Enchant_Target)
        • Else - Actions
 
Last edited:
Level 5
Joined
Oct 16, 2007
Messages
67
Enchant_Group is an array. Is the Index big enougth? Warcraft 3 only creates groups for you until this index. So it is possible that you have no group.
You could also use jass with a few lines of custom script:

if udg_Group[X] == null then
set udg_Group[X] = CreateGroup()
endif

You probably should clear the group after that to make sure no old units are in it.

edit: I haven't checked if there is a GUI way.
 
Level 12
Joined
May 16, 2020
Messages
660
How can I figure out if "the index is big enough"?

The group should only every consist of max 1 unit. The spell essentially works like a timed charm; you cast it on an enemy, and possess this unit for X seconds. If you cast the spell on a new unit, while already possessing one, the old one dies.

For now I didn't clear the group, as I'm only adding/removing units to/fromt he group (and this shouldn't leak).
 
Level 13
Joined
Feb 5, 2018
Messages
567
Enchant_Group is an array. Is the Index big enougth? Warcraft 3 only creates groups for you until this index. So it is possible that you have no group.
You could also use jass with a few lines of custom script:

Does not matter here. The UnitIndexer cycles the indexes so it can never exceed the limit. In this trigger he uses unit index as and arry for the group.

I would first remove the kill unit part and after I would remove the condition checks just to see where the bug is within.

You could also try to debug the trigger with game messages and see what parts of the trigger are fired.
 
Level 5
Joined
Oct 16, 2007
Messages
67
Lets test it.
@Ugabunda you are printing the value of Enchant_CV. What is the Value? Because that is the index you are trying to use. Since your Group Array Size is 1 only the value 0 and 1 for Enchant_CV will work.
 
Level 12
Joined
May 16, 2020
Messages
660
Sure! The Custom Value of the Hero that casts the ability is always 115. So does that mean it won't work?

And if so, why does CreateGroup fix the issue?

Edit: What I just find really weird, is that this spell worked as of 30 January 2021 (at least if my memory serves right...). I took a break from mapping, came back and noticed that this spell is no longer working
 
Last edited:
Level 5
Joined
Oct 16, 2007
Messages
67
Until you get it working again we can't say if it will work. Maybe I'm wrong. If you, for the test, set the variable Enchant_CV to 0 in that trigger and it works we know it's the array size.

If you make a Unit Group Array in warcraft 3 it will add some background code.
On Map start it will loop from 0 to your size doing:
set udg_Group[index] = CreateGroup()

So, if you try to acces 115 but only got a size of 1 there is no unit group created. And you can't add a unit into no group.
However, this dosen't count for all variable types, with integer for example it will work.
Edit: Start Value for integer will be set until the index. Afterwards it's 0.
 
Last edited:
Level 12
Joined
May 16, 2020
Messages
660
Your previous post fixed the issue - thank you! I added:

  • Custom script: if udg_Enchant_Group[udg_Enchant_CV] == null then
  • Custom script: set udg_Enchant_Group[udg_Enchant_CV] = CreateGroup()
  • Custom script: endif
I kinda don't want to set the Enchant_CV = 0, because this ties the group to the caster. If I set it to 0, then the spell would no longer be MUI. Or did you mean something else?
 
Level 5
Joined
Oct 16, 2007
Messages
67
Your previous post fixed the issue - thank you! I added:

  • Custom script: if udg_Enchant_Group[udg_Enchant_CV] == null then
  • Custom script: set udg_Enchant_Group[udg_Enchant_CV] = CreateGroup()
  • Custom script: endif
I kinda don't want to set the Enchant_CV = 0, because this ties the group to the caster. If I set it to 0, then the spell would no longer be MUI. Or did you mean something else?
I just meant to test if it runs without MUI to be sure it's the index. However, if it works with the code you just inserted it's already what I guessed.
I'm glad it works now.
 
Status
Not open for further replies.
Top