• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Spell trigger help

Status
Not open for further replies.
Level 4
Joined
Aug 14, 2007
Messages
66
Im having troubles with 2 of my spells and I could use some help.

My gust spell is intended to work like cyclone but cause the target unit to be pushed back and damaged as well.

This is the trigger for the initial casting of the spell
  • Gust Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Gust
    • Actions
      • Set gustunit_caster[(Custom value of (Casting unit))] = (Casting unit)
      • Set gustunit_target[(Custom value of (Casting unit))] = (Target unit of ability being cast)
      • Set gustcastertemppoint = (Position of (Casting unit))
      • Set gustcasttemppoint = (Position of (Target unit of ability being cast))
      • Set gustangle[(Custom value of (Casting unit))] = (Angle from gustcastertemppoint to gustcasttemppoint)
      • Game - Display to (All players) the text: (String(gustangle[(Custom value of (Casting unit))]))
      • Custom script: call RemoveLocation(udg_gustcasttemppoint)
      • Custom script: call RemoveLocation(udg_gustcastertemppoint)
      • Wait (1.00 + (Real((Level of (Ability being cast) for (Casting unit))))) seconds
      • Set gustunit_target[(Custom value of (Casting unit))] = No unit
      • Set gustunit_caster[(Custom value of (Casting unit))] = No unit
and this is the trigger that causes the effect.

  • Gust Movement
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer gustinteger) from (Player number of Player 1 (Red)) to (Player number of Player 10 (Light Blue)), do (Actions)
        • Loop - Actions
          • Set gusttemppoint[gustinteger] = (Position of gustunit_target[gustinteger])
          • Set gusttemppoint_2 = (gusttemppoint[gustinteger] offset by 10.00 towards gustangle[gustinteger] degrees)
          • Unit - Move gustunit_target[gustinteger] instantly to gusttemppoint_2
          • Unit - Cause gustunit_caster[gustinteger] to damage gustunit_target[gustinteger], dealing 25.00 damage of attack type Spells and damage type Force
          • Custom script: call RemoveLocation(udg_gusttemppoint_2)
          • Custom script: call RemoveLocation(udg_gusttemppoint[udg_gustinteger])

My second spell causes vines to sprout randomly in a target area, which works fine, but then the vines are suppose to repeatedly cast a custom version of entangling roots on enemies that get too close to these vines, which only semi works (sometimes enemies will walk right by the vines unaffected).

  • Latch
    • Events
      • Time - Every 1.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in latchtempugroup and do (Actions)
        • Loop - Actions
          • Set latchtemppoint = (Position of (Picked unit))
          • Set latchtempugroup_2 = (Units within 150.00 of latchtemppoint)
          • Unit - Order (Picked unit) to Night Elf Keeper Of The Grove - Entangling Roots (Random unit from latchtempugroup_2)
          • Custom script: call RemoveLocation(udg_latchtemppoint)
          • Custom script: call DestroyGroup(udg_latchtempugroup_2)
All vines that are spawned by the spell are given a 10 second generic timed life and are added to the unit group latchtempugroup, as well as ordered to play their "birth" animation.

Any help is greatly appreciated
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
I think, in the first one... Change casting unit to Triggering unit... Casting unit will not be tracked after waits, while triggering unit does, and yet, they refer to the same unit...
(Change ALL casting unit to triggering unit... it is more safe.)

Im alittle confused... are you sure the custom values in the first trigger is being equalent to the player number of the loopinteger in the second trigger?

Third trigger. You must add matching conditions when you create the inner unit group where you check that the matching unit is not one of your allies and that it is not dead. otherwise the hero will fail most of the times casting the spell
 
Level 4
Joined
Aug 14, 2007
Messages
66
I think, in the first one... Change casting unit to Triggering unit... Casting unit will not be tracked after waits, while triggering unit does, and yet, they refer to the same unit...
(Change ALL casting unit to triggering unit... it is more safe.)

I tried that and it still didnt work

  • Gust Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Gust
    • Actions
      • Set gustunit_caster[(Custom value of (Triggering unit))] = (Triggering unit)
      • Set gustunit_target[(Custom value of (Triggering unit))] = (Target unit of ability being cast)
      • Set gustcastertemppoint = (Position of (Triggering unit))
      • Set gustcasttemppoint = (Position of (Target unit of ability being cast))
      • Set gustangle[(Custom value of (Triggering unit))] = (Angle from gustcastertemppoint to gustcasttemppoint)
      • Game - Display to (All players) the text: (String(gustangle[(Custom value of (Triggering unit))]))
      • Custom script: call RemoveLocation(udg_gustcasttemppoint)
      • Custom script: call RemoveLocation(udg_gustcastertemppoint)
      • Wait (1.00 + (Real((Level of (Ability being cast) for (Triggering unit))))) seconds
      • Set gustunit_target[(Custom value of (Triggering unit))] = No unit
      • Set gustunit_caster[(Custom value of (Triggering unit))] = No unit
Im alittle confused... are you sure the custom values in the first trigger is being equalent to the player number of the loopinteger in the second trigger?

In my map players 1-10 are playable and you only can select one hero. As soon as you pick your hero its custom value is set to your player number:

  • Select Druid
    • Events
      • Unit - A unit enters Select Druid <gen>
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Owner of (Entering unit)) Not equal to Player 11 (Dark Green)
          • (Owner of (Entering unit)) Not equal to Player 12 (Brown)
          • (Owner of (Entering unit)) Not equal to Neutral Hostile
          • (Owner of (Entering unit)) Not equal to Neutral Passive
          • (Unit-type of (Entering unit)) Not equal to Portal (Summonable)
          • (Unit-type of (Entering unit)) Not equal to Magically Grown Vine (Level 1)
          • (Unit-type of (Entering unit)) Not equal to Magically Grown Vine (Level 2)
          • (Unit-type of (Entering unit)) Not equal to Magically Grown Vine (Level 3)
          • (Unit-type of (Entering unit)) Not equal to Temporary Vision Master
          • (Unit-type of (Entering unit)) Not equal to Phoenix (Level 1)
          • (Unit-type of (Entering unit)) Not equal to Phoenix (Level 2)
          • (Unit-type of (Entering unit)) Not equal to Phoenix (Level 3)
    • Actions
      • Set heroselecttempugroup = (Units owned by (Owner of (Entering unit)))
      • Set heroselecttemppoint = (Center of Center Room <gen>)
      • Unit Group - Pick every unit in heroselecttempugroup and do (Actions)
        • Loop - Actions
          • Unit Group - Remove (Picked unit) from PlayerUnits
          • Unit - Remove (Picked unit) from the game
      • Unit - Create 1 Druid for (Owner of (Entering unit)) at heroselecttemppoint facing Default building facing degrees
      • Unit - Order Castamatizer 3000 0030 <gen> to Neutral Fire Lord - Soul Burn (Last created unit)
      • Unit Group - Add (Last created unit) to PlayerUnits
      • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Entering unit)))
      • Custom script: call RemoveLocation(udg_heroselecttemppoint)
      • Custom script: call DestroyGroup(udg_heroselecttempugroup)
Third trigger. You must add matching conditions when you create the inner unit group where you check that the matching unit is not one of your allies and that it is not dead. otherwise the hero will fail most of the times casting the spell

Thanks that got it to work fine

  • Latch
    • Events
      • Time - Every 1.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in latchtempugroup and do (Actions)
        • Loop - Actions
          • Set latchtemppoint = (Position of (Picked unit))
          • Set latchtempugroup_2 = (Units within 150.00 of latchtemppoint matching ((((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True) and (((Matching unit) is dead) Equal to False)))
          • Unit - Order (Picked unit) to Night Elf Keeper Of The Grove - Entangling Roots (Random unit from latchtempugroup_2)
          • Custom script: call RemoveLocation(udg_latchtemppoint)
          • Custom script: call DestroyGroup(udg_latchtempugroup_2)
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Well... I would say that is not needed at all. If now only one hero can be selected only one time by only one player...

Why not simply do a variable called "Playing_Heroes" with an array, and when unit selects a hero
  • Set Playing_Heroes[(player number of owner of triggering unit)] = (Last created unit)
(in your second trigger)

the next, in your first trigger... change everything which is regarding custom value, to "player number".
  • Set gustunit_caster[(Player number of owner of (Triggering unit))] = (Triggering unit) // while this wont be needed really...
  • Set gustunit_target[(Player number of owner of (Triggering unit))] = (Target unit of ability being cast)
  • Set gustangle[(Player number of owner of (Triggering unit))] = (Angle from gustcastertemppoint to gustcasttemppoint)
  • --- And at the end ---
  • Set gustunit_target[(Player number of owner of (Triggering unit))] = No unit
when we then comes to the second trigger (in your first post) why do a such a long way through functions blizzard has made? I mean, "from player number of player 1 to player number of 10")
Simply:
  • For each (Integer gustinteger) from 1 to 10, do (Actions)
    • Loop - Actions
      • //we just need to add one thing: a condition checking if gustunit_target[gustinteger] = No unit
      • if (gustunit_target[gustinteger] = No unit)
      • then - actions //(which is no actions)
      • else - actions
        • Set gusttemppoint[gustinteger] = (Position of gustunit_target[gustinteger])
        • Set gusttemppoint_2 = (gusttemppoint[gustinteger] offset by 10.00 towards gustangle[gustinteger] degrees)
        • Unit - Move gustunit_target[gustinteger] instantly to gusttemppoint_2
        • Unit - Cause gustunit_caster[gustinteger] to damage gustunit_target[gustinteger], dealing 25.00 damage of attack type Spells and damage type Force
        • Custom script: call RemoveLocation(udg_gusttemppoint_2)
        • Custom script: call RemoveLocation(udg_gusttemppoint[udg_gustinteger])
And well, im sorry that I hadn't world editor to help you precisely. But I think this should work.
/regards
 
Level 4
Joined
Aug 14, 2007
Messages
66
Oh no every hero can be selected by anyone at any time. There can be multiple instances of each hero but each player can only have 1 hero at any time.

and I went through all my triggers and changed anything related to custom value to straight player number, i didnt realize that before :p

  • Gust Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Gust
    • Actions
      • Set gustunit_caster[(Player number of (Owner of (Casting unit)))] = (Triggering unit)
      • Set gustunit_target[(Player number of (Owner of (Casting unit)))] = (Target unit of ability being cast)
      • Set gustcastertemppoint = (Position of (Triggering unit))
      • Set gustcasttemppoint = (Position of (Target unit of ability being cast))
      • Set gustangle[(Player number of (Owner of (Casting unit)))] = (Angle from gustcastertemppoint to gustcasttemppoint)
      • Custom script: call RemoveLocation(udg_gustcasttemppoint)
      • Custom script: call RemoveLocation(udg_gustcastertemppoint)
      • Wait (1.00 + (Real((Level of (Ability being cast) for (Triggering unit))))) seconds
      • Set gustunit_target[(Player number of (Owner of (Casting unit)))] = No unit
      • Set gustunit_caster[(Player number of (Owner of (Casting unit)))] = No unit
  • Gust Movement
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer gustinteger) from (Player number of Player 1 (Red)) to (Player number of Player 10 (Light Blue)), do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • gustunit_target[gustinteger] Not equal to No unit
            • Then - Actions
              • Set gusttemppoint[gustinteger] = (Position of gustunit_target[gustinteger])
              • Set gusttemppoint_2 = (gusttemppoint[gustinteger] offset by 10.00 towards gustangle[gustinteger] degrees)
              • Unit - Move gustunit_target[gustinteger] instantly to gusttemppoint_2
              • Unit - Cause gustunit_caster[gustinteger] to damage gustunit_target[gustinteger], dealing 25.00 damage of attack type Spells and damage type Force
              • Custom script: call RemoveLocation(udg_gusttemppoint_2)
              • Custom script: call RemoveLocation(udg_gusttemppoint[udg_gustinteger])
            • Else - Actions
              • Do nothing
 
Last edited:
Level 4
Joined
Aug 14, 2007
Messages
66
alright i figured out the problem, its the fact that cyclone adds locust to the target unit or something which messes with the triggers. I just based the ability off channel and now it works fine.

  • Gust Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Gust
    • Actions
      • Set gustunit_caster[(Player number of (Owner of (Casting unit)))] = (Triggering unit)
      • Set gustunit_target[(Player number of (Owner of (Casting unit)))] = (Target unit of ability being cast)
      • Special Effect - Create a special effect attached to the origin of gustunit_target[(Player number of (Owner of (Casting unit)))] using Abilities\Spells\NightElf\Cyclone\CycloneTarget.mdl
      • Unit - Pause gustunit_target[(Player number of (Owner of (Casting unit)))]
      • Set gustsfx[(Player number of (Owner of (Casting unit)))] = (Last created special effect)
      • Set gustcastertemppoint = (Position of (Triggering unit))
      • Set gustcasttemppoint = (Position of (Target unit of ability being cast))
      • Set gustangle[(Player number of (Owner of (Casting unit)))] = (Angle from gustcastertemppoint to gustcasttemppoint)
      • Custom script: call RemoveLocation(udg_gustcasttemppoint)
      • Custom script: call RemoveLocation(udg_gustcastertemppoint)
      • Wait (1.00 + (Real((Level of (Ability being cast) for (Triggering unit))))) seconds
      • Unit - Unpause gustunit_target[(Player number of (Owner of (Casting unit)))]
      • Special Effect - Destroy gustsfx[(Player number of (Owner of (Casting unit)))]
      • Set gustunit_target[(Player number of (Owner of (Casting unit)))] = No unit
      • Set gustunit_caster[(Player number of (Owner of (Casting unit)))] = No unit
  • Gust Movement
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • For each (Integer gustinteger) from (Player number of Player 1 (Red)) to (Player number of Player 10 (Light Blue)), do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • gustunit_target[gustinteger] Not equal to No unit
            • Then - Actions
              • Set gusttemppoint[gustinteger] = (Position of gustunit_target[gustinteger])
              • Set gusttemppoint_2 = (gusttemppoint[gustinteger] offset by 10.00 towards gustangle[gustinteger] degrees)
              • Unit - Move gustunit_target[gustinteger] instantly to gusttemppoint_2
              • Unit - Cause gustunit_caster[gustinteger] to damage gustunit_target[gustinteger], dealing 2.50 damage of attack type Spells and damage type Force
              • Custom script: call RemoveLocation(udg_gusttemppoint_2)
              • Custom script: call RemoveLocation(udg_gusttemppoint[udg_gustinteger])
            • Else - Actions
              • Do nothing
Thanks for all the help
 
Status
Not open for further replies.
Top