• 🏆 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] Problem with the units group

Status
Not open for further replies.
Level 20
Joined
Feb 23, 2015
Messages
243
Hi
I've made a spell that drains mana from every enemy unit in the area and transfers it to the caster. Problem is, that the actions in 'unit group' part doesn't happen - spell creates special effect in the point and after the time lightning appear between targeted location and caster, but there is no effect on enemy units. Here are triggers:
  • WCast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equals to W_Ability
    • Actions
      • Set W_LightningIndex = 0
      • Set W_Caster = (Triggering unit)
      • Set W_Point = (Target point of ability being cast)
      • Set W_Level = (Level of W_Ability for W_Caster)
      • Special Effect - Create a special effect at W_Point using Abilities\Weapons\SpiritOfVengeanceMissile\SpiritOfVengeanceMissile.mdl
      • Set W_Effect = (Last created special effect)
      • Unit Group - Add all units of (Units within W_Range of W_Point matching ((Owner of (Matching unit)) Equals to (Random player from (All enemies of (Owner of W_Caster))))) to W_Group
      • Unit Group - Pick every unit in W_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Greater than 0.00
            • To - Actions
              • Lightning - Create a Chain Lightning - Secondary Bolt lightning effect from source (Position of (Picked unit)) to target W_Point
              • Set W_Lightning[W_LightningIndex] = (Last created lightning effect)
              • Set W_LightningIndex = (W_LightningIndex + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Mana of (Picked unit)) Greater or equal to W_ManaAmount[(W_Level - 1)]
                • To - Actions
                  • Set W_StolenMana = (W_StolenMana + W_ManaAmount[(W_Level - 1)])
                  • Unit - Cause W_Caster to damage (Picked unit), dealing (W_DamageMultiplier[(W_Level - 1)] x W_ManaAmount[(W_Level - 1)]) damage of attack type Spells and damage type Magic
                  • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - W_ManaAmount[(W_Level - 1)])
                • Else - Actions
                  • Set W_StolenMana = (W_StolenMana + (Mana of (Picked unit)))
                  • Unit - Cause W_Caster to damage (Picked unit), dealing (W_DamageMultiplier[(W_Level - 1)] x (Mana of (Picked unit))) damage of attack type Spells and damage type Magic
                  • Unit - Set mana of (Picked unit) to 0.00
            • Else - Actions
      • Wait 0.50 seconds
      • For each (Integer A) from W_LightningIndex to 0, do (Actions)
        • Loop - Actions
          • Lightning - Destroy W_Lightning[W_LightningIndex]
          • Set W_LightningIndex = (W_LightningIndex - 1)
      • Lightning - Create a Chain Lightning - Primary Bolt lightning effect from source W_Point to target (Position of W_Caster)
      • Wait 0.10 seconds
      • Lightning - Destroy (Last created lightning effect)
      • Unit - Set mana of W_Caster to ((Mana of W_Caster) + W_StolenMana)
      • Set W_StolenMana = 0.00
      • Set W_Group = (Random 0 units from W_Group)
      • Special Effect - Destroy W_Effect
      • Custom script: call RemoveLocation(udg_W_Point)
I used waits 'cause the spell doesn't need to be MUI - there is only one hero that use it, and it has 4 seconds cooldown.
 
Level 5
Joined
Jan 17, 2014
Messages
131
Hi
I've made a spell that drains mana from every enemy unit in the area and transfers it to the caster. Problem is, that the actions in 'unit group' part doesn't happen - spell creates special effect in the point and after the time lightning appear between targeted location and caster, but there is no effect on enemy units. Here are triggers:
  • WCast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equals to W_Ability
    • Actions
      • Set W_LightningIndex = 0
      • Set W_Caster = (Triggering unit)
      • Set W_Point = (Target point of ability being cast)
      • Set W_Level = (Level of W_Ability for W_Caster)
      • Special Effect - Create a special effect at W_Point using Abilities\Weapons\SpiritOfVengeanceMissile\SpiritOfVengeanceMissile.mdl
      • Set W_Effect = (Last created special effect)
      • Unit Group - Add all units of (Units within W_Range of W_Point matching ((Owner of (Matching unit)) Equals to (Random player from (All enemies of (Owner of W_Caster))))) to W_Group
      • Unit Group - Pick every unit in W_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Greater than 0.00
            • To - Actions
              • Lightning - Create a Chain Lightning - Secondary Bolt lightning effect from source (Position of (Picked unit)) to target W_Point
              • Set W_Lightning[W_LightningIndex] = (Last created lightning effect)
              • Set W_LightningIndex = (W_LightningIndex + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Mana of (Picked unit)) Greater or equal to W_ManaAmount[(W_Level - 1)]
                • To - Actions
                  • Set W_StolenMana = (W_StolenMana + W_ManaAmount[(W_Level - 1)])
                  • Unit - Cause W_Caster to damage (Picked unit), dealing (W_DamageMultiplier[(W_Level - 1)] x W_ManaAmount[(W_Level - 1)]) damage of attack type Spells and damage type Magic
                  • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - W_ManaAmount[(W_Level - 1)])
                • Else - Actions
                  • Set W_StolenMana = (W_StolenMana + (Mana of (Picked unit)))
                  • Unit - Cause W_Caster to damage (Picked unit), dealing (W_DamageMultiplier[(W_Level - 1)] x (Mana of (Picked unit))) damage of attack type Spells and damage type Magic
                  • Unit - Set mana of (Picked unit) to 0.00
            • Else - Actions
      • Wait 0.50 seconds
      • For each (Integer A) from W_LightningIndex to 0, do (Actions)
        • Loop - Actions
          • Lightning - Destroy W_Lightning[W_LightningIndex]
          • Set W_LightningIndex = (W_LightningIndex - 1)
      • Lightning - Create a Chain Lightning - Primary Bolt lightning effect from source W_Point to target (Position of W_Caster)
      • Wait 0.10 seconds
      • Lightning - Destroy (Last created lightning effect)
      • Unit - Set mana of W_Caster to ((Mana of W_Caster) + W_StolenMana)
      • Set W_StolenMana = 0.00
      • Set W_Group = (Random 0 units from W_Group)
      • Special Effect - Destroy W_Effect
      • Custom script: call RemoveLocation(udg_W_Point)
I used waits 'cause the spell doesn't need to be MUI - there is only one hero that use it, and it has 4 seconds cooldown.

Try indexing instead of unit group.
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
Hi
I've made a spell that drains mana from every enemy unit in the area and transfers it to the caster. Problem is, that the actions in 'unit group' part doesn't happen - spell creates special effect in the point and after the time lightning appear between targeted location and caster, but there is no effect on enemy units.
The trigger may not work because there is probably no unit group to begin with - you add units to a unit group, but for that to work the unit group has to be created. If there is no unit group assigned to the variable, you're adding units to no unit group and iterating over nothing. Also, the condition for unit group may not work as you want.
For example Player2 and Player3 are enemies of Player1. Caster is from Player1, units that may be add to unit group are from Player3. Now the condition can actually choose Player2 (because you select random player), and Player2 is not the owner of the units (they are owner by player3), so no units may be picked. Also, afaik the condition leaks Player group. To fix this, simply use a boolean condition "Unit - unit belongs to an enemy/ally of Player", like this:
  • Set group = (Units within *Range* of *Location* matching (((Matching unit) belongs to an enemy of *Player*) Equal to True))

I used waits 'cause the spell doesn't need to be MUI - there is only one hero that use it, and it has 4 seconds cooldown.
Waits do not determine if spell is MUI or not - it is actually possible to make MUI spells using waits. The reason why they should be avoided is simply because they are inaccurate, inefficient and do not behave well in multiplayer maps.
 
Level 20
Joined
Feb 23, 2015
Messages
243
Thank you both, I improved groups and changed the part that adds units to them. I also found out that configuration trigger was disabled (although it had to happen after I starded thread on hive). It's workin' correctly now, and I think I'm gonna make it MUI.

EDIT: I tried to make it MUI and there is huge problem. Nothing happens, cast spell doesn't run. I had sth like that but I didn't managed to fix it, so I add map:View attachment dargontest.w3x
 
Last edited:
Status
Not open for further replies.
Top