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

[Trigger] Same triggers for 2 base spells

Status
Not open for further replies.
Level 10
Joined
Dec 16, 2017
Messages
376
Hello guys, i am trying to ease things when making spells in my map, as 1 hero has 4 jobs, each job 1 and 2 have 4 spells, job 3 and job 4 have 3 spells, after each job completed, the next one has the last jobs spells in a spellbook, so for each spell of jobs 1-2-3, i use 2 spells(as i found a little trick to ease things, instead of making 4 spells for 1 type of spell for each job, i just do 2,and level them accordingly), one is hero ability and one is unit ability(that i level to match the job), so a job 4 fully leveled has 1 spellbook of 11 spells and 3 units abilities.
Now, for more triggered spells, i would like to do something, that i tried but didn't seemed to work.. i want to create 2 abilities for one trigger, but what condition shall i use? For this, each caster is different, because the 2 abilities are, one the hero ability, and the other one the unit ability...i want to change dmg and duration of this spell, how shall i do it properly, as what condition to trigger it? it can be trigger by 2 different units, like job 3 and job 4 of magician, each player can have just one type of those units, but more players can have the same unit.

  • Sleet Storm Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Sleet Storm Magician Job 4
    • Actions
      • Set SleetStorm_Index = (SleetStorm_Index + 1)
      • Set SleetStorm_Caster[SleetStorm_Index] = (Triggering unit)
      • Set SleetStorm_Position[SleetStorm_Index] = (Target point of ability being cast)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Sleet Storm Magician Job 4
        • Then - Actions
          • Set SleetStorm_Damage[SleetStorm_Index] = ((0.75 x (Real((Level of (Ability being cast) for SleetStorm_Caster[SleetStorm_Index])))) x (Real((Intelligence of SleetStorm_Caster[SleetStorm_Index] (Include bonuses)))))
          • Set SleetStorm_Duration[SleetStorm_Index] = (8 + (4 x (Level of (Ability being cast) for SleetStorm_Caster[SleetStorm_Index])))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Sleet Storm Magician Job 3
        • Then - Actions
          • Set SleetStorm_Damage[SleetStorm_Index] = ((2.00 x (Real((Level of (Ability being cast) for SleetStorm_Caster[SleetStorm_Index])))) x (Real((Intelligence of SleetStorm_Caster[SleetStorm_Index] (Include bonuses)))))
          • Set SleetStorm_Duration[SleetStorm_Index] = (12 + (4 x (Level of (Ability being cast) for SleetStorm_Caster[SleetStorm_Index])))
        • Else - Actions
      • Unit - Create 1 Dummy Empty for (Owner of SleetStorm_Caster[SleetStorm_Index]) at SleetStorm_Position[SleetStorm_Index] facing Default building facing degrees
      • Set SleetStorm_Dummy[SleetStorm_Index] = (Last created unit)
      • Special Effect - Create a special effect attached to the origin of SleetStorm_Dummy[SleetStorm_Index] using Sleet Storm.mdx
      • Set SleetStorm_SFX[SleetStorm_Index] = (Last created special effect)
      • Animation - Change SleetStorm_Dummy[SleetStorm_Index]'s size to (300.00%, 300.00%, 300.00%) of its original size
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SleetStorm_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on Sleet Storm Loop <gen>
        • Else - Actions
  • Sleet Storm Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SleetStorm_Loop) from 1 to SleetStorm_Index, do (Actions)
        • Loop - Actions
          • Set SleetStorm_Duration[SleetStorm_Loop] = (SleetStorm_Duration[SleetStorm_Loop] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SleetStorm_Duration[SleetStorm_Loop] Greater than or equal to 0
              • (SleetStorm_Caster[SleetStorm_Loop] is alive) Equal to True
            • Then - Actions
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 500.00 of SleetStorm_Position[SleetStorm_Loop]) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is alive) Equal to True
                      • ((Picked unit) belongs to an enemy of (Owner of SleetStorm_Caster[SleetStorm_Loop])) Equal to True
                    • Then - Actions
                      • Unit - Cause SleetStorm_Caster[SleetStorm_Loop] to damage (Picked unit), dealing SleetStorm_Damage[SleetStorm_Loop] damage of attack type Spells and damage type Normal
                      • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Weapons\LichMissile\LichMissile.mdl
                      • Special Effect - Destroy (Last created special effect)
                    • Else - Actions
            • Else - Actions
              • Special Effect - Destroy SleetStorm_SFX[SleetStorm_Loop]
              • Custom script: call RemoveLocation(udg_SleetStorm_Position[udg_SleetStorm_Loop])
              • Unit - Add a 0.10 second Generic expiration timer to SleetStorm_Dummy[SleetStorm_Loop]
              • Set SleetStorm_Position[SleetStorm_Loop] = SleetStorm_Position[SleetStorm_Index]
              • Set SleetStorm_Caster[SleetStorm_Loop] = SleetStorm_Caster[SleetStorm_Index]
              • Set SleetStorm_Damage[SleetStorm_Loop] = SleetStorm_Damage[SleetStorm_Index]
              • Set SleetStorm_Dummy[SleetStorm_Loop] = SleetStorm_Dummy[SleetStorm_Index]
              • Set SleetStorm_Duration[SleetStorm_Loop] = SleetStorm_Duration[SleetStorm_Index]
              • Set SleetStorm_SFX[SleetStorm_Loop] = SleetStorm_SFX[SleetStorm_Index]
              • Set SleetStorm_Index = (SleetStorm_Index - 1)
              • Set SleetStorm_Loop = (SleetStorm_Loop - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SleetStorm_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
Later Edit:
The Mammonite job 1 spell is the hero ability that is leveled up to 5 levels (but in the case of this spell, i just use it to take gold from triggers, because the damage is done via object editor) and the Mammonite Job 2 spell is the unit ability that has 3 levels, level 1 = job 2, level 2 = job 3, level 3 = job 4, and i level up the spell accordingly of what type of unit has it with triggers like:
  • Warlord Spellbook Increase
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Entering unit)) Equal to |c00E56717[Warlord] - |c00DB7093[Job 3]|r
        • Then - Actions
          • Unit - Set level of Sword Strike Warlord Job 234 for (Entering unit) to 2
          • Unit - Set level of Taunt Warlord Job 234 for (Entering unit) to 2
          • Unit - Set level of Anciestry Awaken Warlord Job 234 for (Entering unit) to 2
          • Unit - Set level of Armor of Steel Warlord Job 234 for (Entering unit) to 2
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Entering unit)) Equal to |c00E56717[Warlord] - |c00FF00FF[Job 4]|r
        • Then - Actions
          • Unit - Set level of Sword Strike Warlord Job 234 for (Entering unit) to 3
          • Unit - Set level of Taunt Warlord Job 234 for (Entering unit) to 3
          • Unit - Set level of Anciestry Awaken Warlord Job 234 for (Entering unit) to 3
          • Unit - Set level of Armor of Steel Warlord Job 234 for (Entering unit) to 3
          • Unit - Set level of Linked Blood Warlord Job 34 for (Entering unit) to 2
          • Unit - Set level of War Frenzy Warlord Job 34 for (Entering unit) to 2
          • Unit - Set level of Shockwave Warlord Job 34 for (Entering unit) to 2
          • Unit - Set level of Ancient Fear Warlord Job 34 for (Entering unit) to 2
        • Else - Actions
For simple edits/effects like this spell has, i can do this, but for more triggered spells like above (Sleet Storm), how should it be done properly?

  • Mammonite Job 1234
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Mammonite Merchant Job 1
          • (Ability being cast) Equal to Mammonite Merchant Job 2
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Mammonite Merchant Job 1
          • ((Owner of (Triggering unit)) Current gold) Less than 300
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop
        • Else - Actions
          • Player - Add -300 to (Owner of (Triggering unit)) Current gold
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Mammonite Merchant Job 2
          • (Level of Mammonite Merchant Job 2 for (Triggering unit)) Equal to 1
          • ((Owner of (Triggering unit)) Current gold) Less than 500
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop
        • Else - Actions
          • Player - Add -500 to (Owner of (Triggering unit)) Current gold
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Mammonite Merchant Job 2
          • (Level of Mammonite Merchant Job 2 for (Triggering unit)) Equal to 2
          • ((Owner of (Triggering unit)) Current gold) Less than 700
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop
        • Else - Actions
          • Player - Add -700 to (Owner of (Triggering unit)) Current gold
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Mammonite Merchant Job 2
          • (Level of Mammonite Merchant Job 2 for (Triggering unit)) Equal to 3
          • ((Owner of (Triggering unit)) Current gold) Less than 900
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop
        • Else - Actions
          • Player - Add -900 to (Owner of (Triggering unit)) Current gold
 
Last edited:
Level 7
Joined
Oct 20, 2010
Messages
184
I notice in your first trigger you have this line of code in the initial conditions:
  • Conditions
    • (Ability being cast) Equal to Sleet Storm Magician Job 4
This trigger will not execute its code when a different spell is cast, meaning the if statement, where you have the following, will never execute.
  • (Ability being cast) Equal to Sleet Storm Magician Job 3
I'm not sure what else the question is
 
Level 24
Joined
Jun 26, 2020
Messages
1,855
In your last trigger you should be care in with the conditions, for example here:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Ability being cast) Equal to Mammonite Merchant Job 1
      • ((Owner of (Triggering unit)) Current gold) Less than 300
    • Then - Actions
      • Unit - Order (Triggering unit) to Stop
    • Else - Actions
      • Player - Add -300 to (Owner of (Triggering unit)) Current gold
The condition is true if all the conditions are true and is false if at least one is false, so in that case the else part will run, so in the case of the "Ability being cast" being the "Mammonite Merchant Job 2" will run the else part yes or yes because the condition is false when it should do nothing in that part (I think that's your desire).
To avoid that you should only do the comparision of the gold only when the condition "(Ability being cast) Equal to Mammonite Merchant Job 1" is true, like this:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Ability being cast) Equal to Mammonite Merchant Job 1
    • Then - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Triggering unit)) Current gold) Less than 300
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop
        • Else - Actions
          • Player - Add -300 to (Owner of (Triggering unit)) Current gold
    • Else - Actions
 
Level 2
Joined
Apr 4, 2022
Messages
13
So, as Bain pointed out, the reason your first trigger doesn't work with both you spells is the main condition :

  • (Ability being cast) Equal to Sleet Storm Magician Job 4
What you need to do here is add a "or - multiple condition" and under it, you can test for each spell your want to trigger. Here is an example :

  • Or - Any (Conditions) are true
    • Conditions
      • (Ability being cast) Equal to Sleet Storm Magician Job 4
      • (Ability being cast) Equal to Sleet Storm Magician Job 3
      • (Ability being cast) Equal to Sleet Storm Magician Job 2
Then, in the action part you can add your if/then/else to set up variables for different spells

Also, in that first trigger the second if/then/else should be in the else part of the first one, because if Sleet Storm Magician Job 4 is casted, then Sleet Storm Magician Job 3 isn't so it's useless to test the second if first is right.

In the second trigger, you decrease the value of SleetStorm_Index, which is used as limit of the for loop. In general in programming it is considered a very bad practice to temper with the limit of a for loop inside it, it can cause multiple problems, including making you code obscure for peer reviewing.

This part :

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • SleetStorm_Index Equal to 0
    • Then - Actions
      • Trigger - Turn off (This trigger)
    • Else - Actions
is useless because the loop condition is for integer A from 1 to x. So as A>1, if x = 0, A>x so exit loop, if it doesn't exit, you have a problem in the loop itself (that may be caused because of the tempering of the limit of the loop).
 
Last edited:
Status
Not open for further replies.
Top