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

problem with spell triggering

Status
Not open for further replies.
Level 4
Joined
Apr 14, 2012
Messages
72
Hey guys I wanna ask why is this spell not working...?

  • QuickFan
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Quick Fan
    • Actions
      • Set SpellCastingUnit = (Triggering unit)
      • Set DamageOfCaster = ((Agility of SpellCastingUnit (Include bonuses)) x 2)
      • Set DamageOfCaster2 = (Real(DamageOfCaster))
      • Unit Group - Pick every unit in (Units within 250.00 of (Position of DamageTakingUnit) matching ((DamageTakingUnit belongs to an enemy of (Matching player)) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit - Cause SpellCastingUnit to damage (Picked unit), dealing DamageOfCaster2 damage of attack type Spells and damage type Normal
          • Special Effect - Create a special effect attached to the overhead of DamageTakingUnit using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
          • Special Effect - Destroy (Last created special effect)
          • Unit Group - Add DamageTakingUnit to DamageTakingUnitGroup
      • Trigger - Turn on QuickFanLoop <gen>
  • QuickFanLoop
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
      • (DamageTakingUnit is in DamageTakingUnitGroup) Equal to True
    • Actions
      • Unit Group - Pick every unit in DamageTakingUnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Cause SpellCastingUnit to damage (Picked unit), dealing ((Real((Agility of SpellCastingUnit (Include bonuses)))) x 2.00) damage of attack type Spells and damage type Normal
          • Special Effect - Create a special effect attached to the head of (Picked unit) using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
          • Special Effect - Destroy (Last created special effect)
          • Unit Group - Remove (Picked unit) from DamageTakingUnitGroup
          • Custom script: call DestroyGroup (udg_DamageTakingUnitGroup)
          • Set Numbers_Triggered = (Numbers_Triggered + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Numbers_Triggered Greater than or equal to 4
        • Then - Actions
          • Set Numbers_Triggered = 0
          • Trigger - Turn off (This trigger)
        • Else - Actions
Any ideas? Im new in triggering.. ;D
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
  • ((DamageTakingUnit belongs to an enemy of (Matching player)) Equal to True)
"DamageTakingUnit" returns null.

Use "(Matching Unit) belongs to an enemy of (Owner of (Triggering Unit))"

  • (Position of DamageTakingUnit)
Also leaks.

  • Set SpellCastingUnit = (Triggering unit)
(Triggering Unit) is a local variable, it does not need to be saved into a separate variable.

  • Set DamageOfCaster2 = (Real(DamageOfCaster))
Can be removed, just use "DamageOfCaster" instead.
 
Level 4
Joined
Apr 14, 2012
Messages
72
  • Set DamageOfCaster2 = (Real(DamageOfCaster))
Can be removed, just use "DamageOfCaster" instead.[/QUOTE]

It can't be removed because I have DamageOfCaster on integer type, which cannot be used for damage, and that's why I give DamageOfCaster2(type real) the value of DamageOfCaster. And use the second one.
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
  • Custom script: call DestroyGroup (udg_DamageTakingUnitGroup)
Should be put last (after all ITE calls), as it will destroy the group after first unit is picked.

And why do you save the real variable then when you are not using it at all?
Actually, both variables are not even being used.

If you elaborate more about what the triggger should do, I might be able to provide better solutions to your problem as you've not said whats wrong with it.
 
Level 25
Joined
Sep 26, 2009
Messages
2,377
- First thing, the spell isn't MUI (if more than one unit casts it at the same/similar time, it will cause unintentional behavior)
- you don't need "DamageTakingUnit" as everytime you will be using Picked Unit instead

- What MortAr probably meant is that you don't need DamageOfCaster and DamageOfCaster2, but only one of them. Just look at the loop trigger - you already made the calculations for damage there without having to store the calculated damage into 2 different variables. It will be better however to calculate and then store the value into real variable like this
  • Set DamageAmount = (Real(((Agility of SpellCastingUnit (Include bonuses)) x 2)))
Do this before you even start picking units in range/in group. That way the trigger won't calculate the DamageAmount for each picked unit over and over.

- Before you start picking any units within 250 range, you first need to set the point. Your point is also set badly, as the point is centered around "DamageTakingUnit" while you did not specify what unit is that. You probably wanted "SpellCastingUnit" there. Anyway set point like this first:
  • Set TempPoint = (Position of SpellCastingUnit)
- In the pick every unit action you don't match any player and you still don't have DamageTakingUnit set. You will need this:
  • Unit Group - Pick every unit in (Units within 250.00 of TempPoint matching (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)) and do (Actions)
    • Loop - Actions
You may also want to add more things the unit should match, like that the unit has to be alive, it shouldn't be building, etc.

- What you also need are additional 3 commands:
  • Custom script: set bj_wantDestroyGroup = true
which you put before the group loop in your first trigger
and
  • Custom script: call RemoveLocation(udg_TempPoint)
  • Custom script: set udg_TempPoint = null
these you put after the group loop in your first trigger.

- In the second trigger, you don't need that
  • (DamageTakingUnit is in DamageTakingUnitGroup) Equal to True
condition, also you still didn't set which unit DamageTakingUnit even is.

- I don't know what your ability does however what you do in your second trigger at the end of the loop is that after you damage the first picked unit of that group, you destroy that group (thus no other unit will ever take damage).

- Now that I take a look at the
  • Set Numbers_Triggered = (Numbers_Triggered + 1)
in the loop, I am not sure what you want. Do you want to damage 4 units after 2 seconds since the cast? Or do you want to damage all units who were affected by the spell (= were in the 250 radius) 4 times?

The loop trigger is a mess to me - because I don't understand what you want your ability to do, I can't really say if what you have in your Group Loop in the second trigger is good or bad.
 
Level 4
Joined
Apr 14, 2012
Messages
72
What about now?

  • QuickFan
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Quick Fan
    • Actions
      • Set SpellCastingUnit = (Casting unit)
      • Set DamageTakingUnit = (Target unit of ability being cast)
      • Unit Group - Pick every unit in (Units within 250.00 of (Position of DamageTakingUnit) matching ((DamageTakingUnit belongs to an enemy of (Triggering player)) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit - Cause SpellCastingUnit to damage (Picked unit), dealing ((Real((Agility of SpellCastingUnit (Include bonuses)))) x 3.00) damage of attack type Spells and damage type Normal
          • Special Effect - Create a special effect attached to the overhead of DamageTakingUnit using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
          • Special Effect - Destroy (Last created special effect)
          • Unit Group - Add (Picked unit) to DamageTakingUnitGroup
      • Trigger - Turn on QuickFanLoop <gen>
And the Loop should do 1.5x agi damage to the targets around target of ability being cast every 1.50 seconds up to 4 times.

  • QuickFanLoop
    • Events
      • Time - Every 1.50 seconds of game time
    • Conditions
      • (DamageTakingUnit is in DamageTakingUnitGroup) Equal to True
    • Actions
      • Unit Group - Pick every unit in DamageTakingUnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Cause SpellCastingUnit to damage (Picked unit), dealing ((Real((Agility of SpellCastingUnit (Include bonuses)))) x 1.50) damage of attack type Spells and damage type Normal
          • Special Effect - Create a special effect attached to the head of (Picked unit) using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
          • Special Effect - Destroy (Last created special effect)
          • Set Numbers_Triggered = (Numbers_Triggered + 1)
      • Custom script: call DestroyGroup (udg_DamageTakingUnitGroup)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Numbers_Triggered Greater than or equal to 4
        • Then - Actions
          • Set Numbers_Triggered = 0
          • Trigger - Turn off (This trigger)
        • Else - Actions
...
 
Level 25
Joined
Sep 26, 2009
Messages
2,377
It's way better than before, imo, but you still have some errors there.

First, get rid of "DamageTakingUnit". Since in the QuickFan trigger you have no "wait" actions, there is no need to save the target of ability into variable.
So currently replace DamageTakingUnit with the default "Target unit of ability being cast"

You also leak a location.
Right before you pick units around the target, use this line:
  • Actions
    • Set Point_var = (Position of (Target unit of ability being cast))
And then, when you are picking units, you use "Point_var" as the location (instead of "Position of DamageTakingUnit").
Point_var is a Point-type variable.

Also you have incorrect condition for your unit group in QuickFan trigger. It's this condition
  • ((DamageTakingUnit belongs to an enemy of (Triggering player)) Equal to True))
First, you have no triggering player, but triggering unit! So the correct way is
  • (Owner of (Triggering unit))
You also check if the DamageTakingUnit is an enemy of the caster. You don't need that really. If you want your spell to be castable on enemies only, then find your spell in Object Editor and check "Enemy" in "Stats - Targets Allowed".

I assume you want to pick up allies of the target / enemies of the caster. The correct way to find that group would be
  • Unit Group - Pick every unit in (Units within 250.00 of Point_var matching (((Matching unit) belongs to an ally of (Owner of (Target unit of ability being cast))) Equal to True)) and do (Actions)
    • Loop - Actions
Note, this way no neutral unit will be picked. Only allied units of the target. If you want neutral units included, use "(((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True))" instead.
Last, put both "custom script" lines at the end of QuickFan trigger.
  • Custom script: call RemoveLocation(udg_Point_var)
  • Custom script: set udg_Point_var = null
These custom scripts remove the Point_var location, preventing leak in your map.

----------------------------
In your second trigger, you don't need that "(DamageTakingUnit is in DamageTakingUnitGroup) Equal to True" condition as the target will always be in damaging group.

Next thing, I still don't understand what you want. If you want to damage all units in DamageTakingGroup 4 times, then place this line
  • Set Numbers_Triggered = (Numbers_Triggered + 1)
out of the Group loop, else it will increase its value by 1 for each unit in DamageTakingGroup.

The last thing is
  • Custom script: call DestroyGroup (udg_DamageTakingUnitGroup)
use that in the If/then/else action's "Then - Actions" (i.e. when the trigger is being turned off).
What you currently do is after 1,5 second you pick all units in DamageTakingGroup, do damage to them and then you destroy the group, thus preventing any unit from being damaged again.
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
  • Set SpellCastingUnit = (Casting unit)
  • Set DamageTakingUnit = (Target unit of ability being cast)
  • Unit Group - Pick every unit in (Units within 250.00 of (Position of DamageTakingUnit) matching ((DamageTakingUnit belongs to an enemy of (Triggering player)) Equal to True)) and do (Actions)
-->>

  • Set SpellCastingUnit = (Triggering unit)
  • Set DamageTakingUnit = (Target unit of ability being cast)
  • Set loc = (Position of DamageTakingUnit)
  • Set group = (Units within 250.00 of loc matching (((Matching unit) belongs to an enemy of (Triggering player)) Equal to True))
  • Unit Group - Pick every unit in group and do (Actions)
At the end of trigger QuickFan:
  • Custom script: DestroyGroup(udg_group)
  • Custom script: call RemoveLocation(udg_loc)
Line:
  • Set Numbers_Triggered = (Numbers_Triggered + 1)
shouldnt be inside Unit Group action statement - you perform increment operation once per unit picked, instead of once per 1,5 period.
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,377
  • Set group = (Units within 250.00 of loc matching ((DamageTakingUnit belongs to an enemy of (Triggering player)) Equal to True))
You don't need to see if DamageTakingUnit belongs to an enemy, you can set that in Stats - Targets allowed
It doesn't even make sense because in the group there will be also allies of the caster, neutral units and of course enemies, as long as the spell has been cast on an enemy.
 
Level 4
Joined
Apr 14, 2012
Messages
72
Okay now Im pretty sure it's fine but I still don't get the custom scripts and Im not sure if they are made right now, can I get a little more describing explanation on them please, thanks! :goblin_good_job:

  • QuickFan
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Quick Fan
    • Actions
      • Set SpellCastingUnit = (Casting unit)
      • Set Point = (Position of (Target unit of ability being cast))
      • Unit Group - Pick every unit in (Units within 250.00 of Point matching (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit - Cause SpellCastingUnit to damage (Picked unit), dealing ((Real((Agility of SpellCastingUnit (Include bonuses)))) x 3.00) damage of attack type Spells and damage type Normal
          • Special Effect - Create a special effect attached to the overhead of DamageTakingUnit using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
          • Special Effect - Destroy (Last created special effect)
          • Unit Group - Add (Picked unit) to DamageTakingUnitGroup
      • Custom script: call DestroyGroup(udg_group)
      • Custom script: call RemoveLocation(udg_Point)
      • Trigger - Turn on QuickFanLoop <gen>
  • QuickFanLoop
    • Events
      • Time - Every 1.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in DamageTakingUnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Cause SpellCastingUnit to damage (Picked unit), dealing ((Real((Agility of SpellCastingUnit (Include bonuses)))) x 1.50) damage of attack type Spells and damage type Normal
          • Special Effect - Create a special effect attached to the head of (Picked unit) using Abilities\Spells\Other\Stampede\StampedeMissileDeath.mdl
          • Special Effect - Destroy (Last created special effect)
      • Set Numbers_Triggered = (Numbers_Triggered + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Numbers_Triggered Greater than or equal to 4
        • Then - Actions
          • Set Numbers_Triggered = 0
          • Custom script: call DestroyGroup (udg_DamageTakingUnitGroup)
          • Trigger - Turn off (This trigger)
        • Else - Actions
 
Level 25
Joined
Sep 26, 2009
Messages
2,377
Fiend_68, you can't use
  • Custom script: call DestroyGroup(udg_group)
in your first trigger. The default way this custom script looks is like this:
  • Custom script: call DestroyGroup(udg_NameOfGroup)
See? The NameOfGroup is (obviously) the name of a group you want to delete. But when you look at your trigger again, you create a group and you don't give it a name - so it only makes sense that you can't use this custom script to delete it, because it simply doesn't have a name.

If you look at what Spinnaker posted, it was
  • Set group = (Units within 250.00 of loc matching (((Matching unit) belongs to an enemy of (Triggering player)) Equal to True))
In this case, the default line is
"Set NameOfGroup = (units in X range matching *Conditions*)"
As you can see, in his case he simply named the group as "group", so it is "Set group = ..." and it is because the group is called "group" that he can remove it through the custom script.

To elaborate, if he called the group as "Spiny" instead, the line would be like this:
  • Set Spiny = (Units within 250.00 of loc matching *Conditions*)
  • ....
  • actions of the trigger
  • ....
  • Custom Script: call DestroyGroup(udg_Spiny)
 
Status
Not open for further replies.
Top