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

Simple trigger to check who is target and then do some actions

Status
Not open for further replies.
Level 11
Joined
Jul 17, 2013
Messages
544
Hi guys i made a trigger to check which hero received a buff. but it doesnt work propley

  • catch heroes
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to dla arma
    • Actions
      • Wait 0.10 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Gimli 0005 <gen> has buff Catched (Pause)) Equal to True
        • Then - Actions
          • Unit - Pause Gimli 0005 <gen>
          • Unit - Set Max HP of (Casting unit) to ((Max HP of (Casting unit)) + 7)
          • Unit - Hide Gimli 0005 <gen>
          • Unit - Set level of (Ability being cast) for (Casting unit) to 2
          • Unit - Set (Casting unit) movement speed to 35.00
          • Special Effect - Create a special effect attached to the chest of (Casting unit) using Gimli_LOTR_ByJhotam.MDX
          • Special Effect - Set Scale of (Last created special effect) to 0.50
          • Special Effect - Set Color of (Last created special effect) to color of Neutral Hostile
          • Set VariableSet watcherarmy[7] = (Last created special effect)
          • Set VariableSet watcherinteger[7] = 1
          • Unit - Remove dla arma from (Casting unit)
          • Unit - Remove Catched (Pause) buff from Gimli 0005 <gen>
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Merry 0008 <gen> has buff Catched (Pause)) Equal to True
        • Then - Actions
          • Unit - Pause Merry 0008 <gen>
          • Unit - Set Max HP of (Casting unit) to ((Max HP of (Casting unit)) + 8)
          • Unit - Hide Merry 0008 <gen>
          • Unit - Set level of (Ability being cast) for (Casting unit) to 2
          • Unit - Set (Casting unit) movement speed to 35.00
          • Special Effect - Create a special effect attached to the chest of (Casting unit) using merry.mdx
          • Special Effect - Set Scale of (Last created special effect) to 0.40
          • Special Effect - Set Color of (Last created special effect) to color of Neutral Hostile
          • Set VariableSet watcherarmy[8] = (Last created special effect)
          • Set VariableSet watcherinteger[8] = 1
          • Unit - Remove Catched (Pause) buff from Merry 0008 <gen>
          • Unit - Remove dla arma from (Casting unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Pippin 0009 <gen> has buff Catched (Pause)) Equal to True
        • Then - Actions
          • Unit - Pause Pippin 0009 <gen>
          • Unit - Set Max HP of (Casting unit) to ((Max HP of (Casting unit)) + 9)
          • Unit - Hide Pippin 0009 <gen>
          • Unit - Set level of (Ability being cast) for (Casting unit) to 2
          • Unit - Set (Casting unit) movement speed to 35.00
          • Special Effect - Create a special effect attached to the chest of (Casting unit) using pippin.mdx
          • Special Effect - Set Scale of (Last created special effect) to 0.40
          • Special Effect - Set Color of (Last created special effect) to color of Neutral Hostile
          • Set VariableSet watcherarmy[9] = (Last created special effect)
          • Set VariableSet watcherinteger[9] = 1
          • Unit - Remove Catched (Pause) buff from Pippin 0009 <gen>
          • Unit - Remove dla arma from (Casting unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Frodo 0007 <gen> has buff Catched (Pause)) Equal to True
        • Then - Actions
          • Unit - Pause Frodo 0007 <gen>
          • Unit - Set Max HP of (Casting unit) to ((Max HP of (Casting unit)) + 4)
          • Unit - Hide Frodo 0007 <gen>
          • Unit - Set level of (Ability being cast) for (Casting unit) to 2
          • Unit - Set (Casting unit) movement speed to 35.00
          • Special Effect - Create a special effect attached to the chest of (Casting unit) using frodo.mdx
          • Special Effect - Set Scale of (Last created special effect) to 0.40
          • Special Effect - Set Color of (Last created special effect) to color of Neutral Hostile
          • Set VariableSet watcherarmy[4] = (Last created special effect)
          • Set VariableSet watcherinteger[4] = 1
          • Unit - Remove Catched (Pause) buff from Frodo 0007 <gen>
          • Unit - Remove dla arma from (Casting unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Sam 0006 <gen> has buff Catched (Pause)) Equal to True
        • Then - Actions
          • Unit - Pause Sam 0006 <gen>
          • Unit - Set Max HP of (Casting unit) to ((Max HP of (Casting unit)) + 5)
          • Unit - Hide Sam 0006 <gen>
          • Unit - Set level of (Ability being cast) for (Casting unit) to 2
          • Unit - Set (Casting unit) movement speed to 35.00
          • Special Effect - Create a special effect attached to the chest of (Casting unit) using sam.mdx
          • Special Effect - Set Scale of (Last created special effect) to 0.40
          • Special Effect - Set Color of (Last created special effect) to color of Neutral Hostile
          • Set VariableSet watcherarmy[5] = (Last created special effect)
          • Set VariableSet watcherinteger[5] = 1
          • Unit - Remove Catched (Pause) buff from Sam 0006 <gen>
          • Unit - Remove dla arma from (Casting unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Legolas 0004 <gen> has buff Catched (Pause)) Equal to True
        • Then - Actions
          • Unit - Remove dla arma from (Casting unit)
          • Unit - Pause Legolas 0004 <gen>
          • Unit - Set Max HP of (Casting unit) to ((Max HP of (Casting unit)) + 6)
          • Unit - Hide Legolas 0004 <gen>
          • Unit - Set (Casting unit) movement speed to 35.00
          • Special Effect - Create a special effect attached to the chest of (Casting unit) using Legolas.mdx
          • Special Effect - Set Scale of (Last created special effect) to 0.60
          • Special Effect - Set Color of (Last created special effect) to color of Neutral Hostile
          • Set VariableSet watcherarmy[6] = (Last created special effect)
          • Set VariableSet watcherinteger[6] = 1
          • Unit - Remove Catched (Pause) buff from Legolas 0004 <gen>
          • Unit - Remove dla arma from (Casting unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Aragorn 0001 <gen> has buff Catched (Pause)) Equal to True
        • Then - Actions
          • Unit - Pause Aragorn 0001 <gen>
          • Unit - Set Max HP of (Casting unit) to ((Max HP of (Casting unit)) + 1)
          • Unit - Hide Aragorn 0001 <gen>
          • Unit - Set level of (Ability being cast) for (Casting unit) to 2
          • Unit - Set (Casting unit) movement speed to 35.00
          • Special Effect - Create a special effect attached to the chest of (Casting unit) using Aragorn_v1.mdx
          • Special Effect - Set Color of (Last created special effect) to color of Neutral Hostile
          • Special Effect - Set Scale of (Last created special effect) to 0.65
          • Set VariableSet watcherarmy[1] = (Last created special effect)
          • Set VariableSet watcherinteger[1] = 1
          • Unit - Remove Catched (Pause) buff from Aragorn 0001 <gen>
          • Unit - Remove dla arma from (Casting unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Boromir 0003 <gen> has buff Catched (Pause)) Equal to True
        • Then - Actions
          • Unit - Pause Boromir 0003 <gen>
          • Unit - Set Max HP of (Casting unit) to ((Max HP of (Casting unit)) + 2)
          • Unit - Hide Boromir 0003 <gen>
          • Unit - Set level of (Ability being cast) for (Casting unit) to 2
          • Unit - Set (Casting unit) movement speed to 35.00
          • Special Effect - Create a special effect attached to the chest of (Casting unit) using Boromir_war3Style.mdx
          • Special Effect - Set Scale of (Last created special effect) to 0.60
          • Special Effect - Set Color of (Last created special effect) to color of Neutral Hostile
          • Set VariableSet watcherarmy[2] = (Last created special effect)
          • Set VariableSet watcherinteger[2] = 1
          • Unit - Remove Catched (Pause) buff from Boromir 0003 <gen>
          • Unit - Remove dla arma from (Casting unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Gandalf the Grey 0002 <gen> has buff Catched (Pause)) Equal to True
        • Then - Actions
          • Unit - Pause Gandalf the Grey 0002 <gen>
          • Unit - Set Max HP of (Casting unit) to ((Max HP of (Casting unit)) + 3)
          • Unit - Hide Gandalf the Grey 0002 <gen>
          • Unit - Set level of (Ability being cast) for (Casting unit) to 2
          • Unit - Set (Casting unit) movement speed to 35.00
          • Special Effect - Create a special effect attached to the chest of (Casting unit) using war3mapImported\Gandalf.mdx
          • Special Effect - Set Scale of (Last created special effect) to 0.50
          • Special Effect - Set Color of (Last created special effect) to color of Player 9 (Gray)
          • Set VariableSet watcherarmy[3] = (Last created special effect)
          • Set VariableSet watcherinteger[3] = 1
          • Unit - Remove Catched (Pause) buff from Gandalf the Grey 0002 <gen>
          • Unit - Remove dla arma from (Casting unit)
        • Else - Actions





what happens is that too many heroes are hidden sometimes. the caster should be able to hide only 1 hero since ability is removed from him. the ability is based on storm bolt. anyway how to remake trigger to make it working propley? caster should hide 1 unit and no more.
 
This trigger is not MUI. After the "Wait 0.10 seconds" at the start, sometimes all your variables will be wrong because they are global and anything that happened during those 0.10 may have modified them. This is the reason why sometimes it works sometimes it doesn't.

You will have to either :
- Remove this wait if it's possible
- use "local globals". This way your variables will survive to the Wait. More informations about this trick here.
 
Level 11
Joined
Jul 17, 2013
Messages
544
This trigger is not MUI. After the "Wait 0.10 seconds" at the start, sometimes all your variables will be wrong because they are global and anything that happened during those 0.10 may have modified them. This is the reason why sometimes it works sometimes it doesn't.

You will have to either :
- Remove this wait if it's possible
- use "local globals". This way your variables will survive to the Wait. More informations about this trick here.


I am bit noob in gui, if u dont mind can you give me more explainations?? So i need to set caster of spell to be local? Or also the integers??
 
In you keep the wait, the following variables have to be local in your example:
- Event - casting unit
- Event - ability being cast

So for example you need to create 2 global variables:
- name: Caster, type: unit
- name: Spell, type: abilityid
(example of name, choose what fits you)

At the beginning of your trigger, add 4 lines as below, at the end at one line:
  • custom script: local unit udg_Caster
  • custom script: local abilityid udg_Spell
  • set variableSet Caster = (Casting unit)
  • set variableSet Spell = (Ability being cast)
  • ...
  • <all you code here, use Caster & Spell instead of Casting Unit & Ability being cast of course>
  • ...
  • custom script: set udg_Caster = null // This line is just to avoid memory leak.
 
Status
Not open for further replies.
Top