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

Help Needed, can't find problem in malfunctioning trigger

Status
Not open for further replies.
Level 6
Joined
May 15, 2009
Messages
191
Hey everyone, this is probaly the fourth time in a week I ask for help on this forum. I am making a spell called Storm Supremacy(Will be referred to as "SP" from now on). The spell is supposed to pick 1 nearby enemy and damage them through a trigger. Now, for each level of the ability, the damage should change and pick 1 more target. But for now, lets focus on the basic.
  • Storms Supremacy
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Storm Supremacy
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Storm Supremacy for (Triggering unit)) Equal to 1
        • Then - Actions
          • Set SP_Target = No unit
          • Set SP_Loc1 = (Position of (Triggering unit))
          • Unit Group - Pick every unit in (Units within 500.00 of (Position of (Triggering unit)) matching (((Picked unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)) and do (Actions)
            • Loop - Actions
              • Unit Group - Add (Picked unit) to SP_Group
              • Set SP_Target = (Random unit from SP_Group)
              • Unit - Cause (Triggering unit) to damage SP_Target, dealing ((Real((Intelligence of (Triggering unit) (Include bonuses)))) + 125.00) damage of attack type Spells and damage type Universal
              • Special Effect - Create a special effect at (Position of SP_Target) using Abilities\Spells\Other\Monsoon\MonsoonBoltTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Set SP_Loc2 = (Position of SP_Target)
              • Custom script: call DestroyGroup(udg_SP_Group)
              • Custom script: call RemoveLocation(udg_SP_Loc1)
              • Custom script: call RemoveLocation(udg_SP_Loc2)
        • Else - Actions Do - do nothing
Problem is, at level 1 the trigger selects the caster, and damages that on the first cast. If you continue to cast the spell, it simply stops working after 1 try. And honestly, it did not work as it should the first time.

Advice on fixing is much appreciated.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Well, the condition is "Level of SP Equal to 1". Did you expect it to work at any other level?
The condition is useless though, if the caster casts the ability, then it's only normal that the ability is higher than level 1 (and there's no need to create multiple ITE's for each level).
My suggestion: remove the ITE completely.

Also, add
  • Custom script: set bj_wantDestroyGroup = true
right before the unit group.
And move "Custom script: call RemoveLocation(udg_SP_Loc1)" to right behind the unit group.
And "Pick every unit in (Units within 500.00 of (Position of (Triggering unit))" should be " Pick every unit in (Units within 500.00 of SP_Loc1"
And "Create a special effect at (Position of SP_Target) using [...]" should be "Create a special effect at SP_Loc2 using [...]", where SP_Loc2 should be set before that action.
And "Set SP_Target = No Unit" is pretty useless as well. Remove that line.

You seem to have some problems with leaks (as I have already indicated above).
 
Level 6
Joined
May 15, 2009
Messages
191
I added in the Level of Ability Equal to 1, because it is an If/Then/Else function. As I mentioned, the spell will hit more and more targets for higher damage as it levels up. So, if the level of the ability is not 1, then it goes on to check if it is 2, if not then checks 3 and so on.

And also, I made as many of the changes as I could. But "set bj_wantDestroyGroup = True" made the trigger bug and said that it "expected a name" And also, the spell still just targets(and damages) the casting unit. Does nothing to enemies around.

  • Storms Supremacy
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Storm Supremacy
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Storm Supremacy for (Triggering unit)) Equal to 1
        • Then - Actions
          • Set SP_Loc1 = (Position of (Triggering unit))
          • Unit Group - Pick every unit in (Units within 500.00 of SP_Loc1 matching (((Picked unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)) and do (Actions)
            • Loop - Actions
              • Custom script: call RemoveLocation(udg_SP_Loc1)
              • Unit Group - Add (Picked unit) to SP_Group
              • Set SP_Target = (Random unit from SP_Group)
              • Unit - Cause (Triggering unit) to damage SP_Target, dealing ((Real((Intelligence of (Triggering unit) (Include bonuses)))) + 125.00) damage of attack type Spells and damage type Universal
              • Special Effect - Create a special effect at SP_Loc2 using Abilities\Spells\Other\Monsoon\MonsoonBoltTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Set SP_Loc2 = (Position of SP_Target)
              • Custom script: call DestroyGroup(udg_SP_Group)
              • Custom script: call RemoveLocation(udg_SP_Loc2)
        • Else - Actions
          • Do nothing
Still malfunctioning
 
You don't need to loop through the group to get a random unit (you can do that of course, but GUI already offers the Random unit):
  • Set PS_Loc1 = (Position of (Triggering unit))
  • Set SP_Group = (Units within 500.00 of SP_Loc1 matching ((Matching unit) belongs to an enemy of (Triggering player)) Equal to True)
  • Set SP_Target = (Random unit from SP_Group)
  • Unit - Cause (Triggering unit) to damage SP_Target, dealing ((Real((Intelligence of (Triggering unit) (Include bonuses)))) + 125.00) damage of attack type Spells and damage type Universal
  • Custom script: call DestroyGroup (udg_SP_Group)
  • Custom script: call RemoveLocation (udg_SP_Loc1)
 
Level 6
Joined
May 15, 2009
Messages
191
Thx for the help Pharoh IT NOW WORKS, however im pretty sure that I need the SP target no matter what, since I will need to create a lightning effect at it.
Thx for the help +rep for you.

Level 4 and 5 will only hit 3 and 4 targets respectivly, which makes no sense, since the trigger part below appears 4 times on level 4, and 5 times on level 5. Still, the spell will hit one less target than it should.
  • Set SP_Target = Random Unit from SP_Group
  • Cause (triggering unit) to damage (SP_Target) dealing (Blablabla) damage
  • Create Special Effect attached to the origin of (SP_Target) useing (Effect)
  • Destroy last created Special Effect
 
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
I added in the Level of Ability Equal to 1, because it is an If/Then/Else function. As I mentioned, the spell will hit more and more targets for higher damage as it levels up. So, if the level of the ability is not 1, then it goes on to check if it is 2, if not then checks 3 and so on.
[...] and there's no need to create multiple ITE's for each level [...]
"ITE" means "If/Then/Else" by the way.

So yeah, you can just loop the same thing until the number of targets has been reached, or until there are no more nearby valid targets.
Don'r forget to remove SP_Target from the group each time.
 
Two ways to do that:
1) Create a new unit group variable:
  • Actions
    • Set PS_Loc1 = (Position of (Triggering unit))
    • Set SP_Group = (Units within 500.00 of SP_Loc1 matching ((Matching unit) belongs to an enemy of (Triggering player)) Equal to True)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Level of (Ability being cast) for (Triggering unit)) Equal to 1
      • Then - Actions
        • Set SP_Target = (Random unit from SP_Group)
        • Unit - Cause (Triggering unit) to damage SP_Target, dealing ((Real((Intelligence of (Triggering unit) (Include bonuses)))) + 125.00) damage of attack type Spells and damage type Universal
      • Else - Actions
        • Set NewGroup = (Random (Level of (Ability being cast) for (Triggering unit)) units from SP_Group)
        • Unit Group - Pick every unit in NewGroup and do (Actions)
          • Loop - Actions
            • Unit - Cause (Triggering unit) to damage (Picked unit), dealing ((Real((Intelligence of (Triggering unit) (Include bonuses)))) + 125.00) damage of attack type Spells and damage type Universal
        • Custom script: call DestroyGroup (udg_NewGroup)
    • Custom script: call DestroyGroup (udg_SP_Group)
    • Custom script: call RemoveLocation (udg_SP_Loc1)
2) Loop through the SP_Group itself:
  • Actions
    • Custom script: local integer i = 0
    • Set PS_Loc1 = (Position of (Triggering unit))
    • Set SP_Group = (Units within 500.00 of SP_Loc1 matching ((Matching unit) belongs to an enemy of (Triggering player)) Equal to True)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Level of (Ability being cast) for (Triggering unit)) Equal to 1
      • Then - Actions
        • Set SP_Target = (Random unit from SP_Group)
        • Unit - Cause (Triggering unit) to damage SP_Target, dealing ((Real((Intelligence of (Triggering unit) (Include bonuses)))) + 125.00) damage of attack type Spells and damage type Universal
      • Else - Actions
        • Set Level = (Level of (Ability being cast) for (Triggering unit))
        • Custom script: loop
        • Custom script: set udg_SP_Target = FirstOfGroup (udg_SP_Group)
        • Custom script: exitwhen i > udg_Level or udg_SP_Target == null
        • Custom script: call UnitDamageTarget(GetTriggerUnit(),udg_SP_Target, 200,true,false, ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
        • Custom script: set i = i + 1
        • Custom script: endloop
    • Custom script: call DestroyGroup (udg_SP_Group)
    • Custom script: call RemoveLocation (udg_SP_Loc1)
 
Status
Not open for further replies.
Top