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

[Trigger] Being attacked / Attacking.. Help?

Status
Not open for further replies.
Level 3
Joined
Jul 27, 2011
Messages
27
I want it so when test_caster attacks or is attacked the variable increases by 1. That's it :p

Somebody knows why this isn't working?

Thanks.

  • addStacks
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Attacked unit) Equal to test_caster
      • Or - Any (Conditions) are true
        • Conditions
          • (Attacking unit) Equal to test_caster
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • test_var Less than 10
        • Then - Actions
          • Set test_var = (test_var + 1)
        • Else - Actions
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
First off this isn't nessecary:
  • Or - Any (Conditions) are true
  • Conditions
  • (Attacking unit) Equal to test_caster
Second, are you sure that test_caster is set properly.
I don't see why this shouldn't work.
 
Level 3
Joined
Jul 27, 2011
Messages
27
First off this isn't nessecary:
  • Or - Any (Conditions) are true
  • Conditions
  • (Attacking unit) Equal to test_caster
Second, are you sure that test_caster is set properly.
I don't see why this shouldn't work.

Then it only triggers on being attacked? :s

I set the test_caster by doing this:

  • Bs activateTriggers
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Bloodscent
    • Actions
      • Set test_caster = (Learning Hero)
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Could you change this: (Learning Hero) to triggering unit?
Also, what is the initial value of test_var?

Then it only triggers on being attacked? :s

Ow yeah sorry, I overlooked that, but I meant you don't have to use the OR, you can simply add another condition in there if nessecary.
Unnessecary code should be avoided.
 
Level 3
Joined
Jul 27, 2011
Messages
27
Could you change this: (Learning Hero) to triggering unit?
Also, what is the initial value of test_var?

Yeah I could try that, and the inital value is "No Unit".

Ow yeah sorry, I overlooked that, but I meant you don't have to use the OR, you can simply add another condition in there if nessecary.

Ah okey, I'll try that too! ^^
But this will have to wait until tomorrow, getting pretty late here..

Thanks alot for your help, I'll come back tomorrow and let you know how it goes! :)
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
  • addStacks
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Attacking unit) Equal to test_caster
          • (Attacked unit) Equal to test_caster
Your trigger was requesting both the attacked and attacked unit be the test caster.

Wow, how did I miss that xD
 
Level 3
Joined
Jul 27, 2011
Messages
27
  • addStacks
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Attacking unit) Equal to test_caster
          • (Attacked unit) Equal to test_caster
Your trigger was requesting both the attacked and attacked unit be the test caster.

But it's "or".. Doesn't that mean it only needs one of the conditions to be true? :O

EDIT: I put the conditions in as it showed in your trigger and it works perfectly now, thanks! :)
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
But it's "or".. Doesn't that mean it only needs one of the conditions to be true? :O

EDIT: I put the conditions in as it showed in your trigger and it works perfectly now, thanks! :)

Both should be in the OR block because else it would not compare the 2 conditions with each other. Yes, or means if one of the conditions are true then it should execute the trigger.

In your example:

  • (Attacked unit) Equal to test_caster
  • Or - Any (Conditions) are true
  • Conditions
  • (Attacking unit) Equal to test_caster
You are basically saying that the trigger should only be executed when Attacked unit equals test_caster.
If this is false the trigger will not be executed.
The OR block will be ignored unless you put the Attacked unit condition within the OR block, meaning the trigger will now be executed if one of the 2 conditions are true.
 
Level 3
Joined
Jul 27, 2011
Messages
27
Both should be in the OR block because else it would not compare the 2 conditions with each other. Yes, or means if one of the conditions are true then it should execute the trigger.

In your example:

  • (Attacked unit) Equal to test_caster
  • Or - Any (Conditions) are true
  • Conditions
  • (Attacking unit) Equal to test_caster
You are basically saying that the trigger should only be executed when Attacked unit equals test_caster.
If this is false the trigger will not be executed.
The OR block will be ignored unless you put the Attacked unit condition within the OR block, meaning the trigger will now be executed if one of the 2 conditions are true.

Yeah I understand how it works now but logically it makes more sense to me if it goes "Is attacked OR Is attacking".. ^^ But thanks for explainging :)
 
Status
Not open for further replies.
Top