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

[Trigger] Destroy 2 buildings to make main building vulnerable

Status
Not open for further replies.
Level 3
Joined
Aug 24, 2014
Messages
22
  • invulnerable
    • Events
      • Unit - Building 1 0010 <gen> Dies
      • Unit - Building 2 0011 <gen> Dies
    • Conditions
    • Actions
      • Unit - Make Building 3 0038 <gen> Vulnerable
I want both of the building to be destroyed in order to make the 3rd building vulnerable. But in the game, you only need to destroy 1 of the 2 buildings to make it vulnerable. Please help! Thanks!
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
It's better to know the problem in your trigger and then know the solution.
Actually, putting two events together doesn't mean that both should happen in order to run actions. But, if only one of them happens, actions will run. So you should know that the editor just listens to one event that happens between the events.

The solution would be to detect if both are destroyed or not.
Method 1 : Using an increasing integer , when it becomes 2 , that means both are destroyed
  • Make vulnerable
    • Events
      • Unit - Farm 0000 <gen> Dies
      • Unit - Farm 0001 <gen> Dies
    • Conditions
    • Actions
      • Set Vulnerability_Integer = (Vulnerability_Integer + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Vulnerability_Integer Equal to 2
        • Then - Actions
          • Unit - Make Altar of Kings 0002 <gen> Vulnerable
        • Else - Actions
Method 2 : Using conditions to detect whether the other building is alive or not, via 2 triggers instead of one.
  • Is it alive
    • Events
      • Unit - Farm 0000 <gen> Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Farm 0001 <gen> is dead) Equal to True
        • Then - Actions
          • Unit - Make Altar of Kings 0002 <gen> Vulnerable
        • Else - Actions
  • Is it alive 2
    • Events
      • Unit - Farm 0001 <gen> Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Farm 0000 <gen> is dead) Equal to True
        • Then - Actions
          • Unit - Make Altar of Kings 0002 <gen> Vulnerable
        • Else - Actions

I guarantee that one of these, or both, MUST work. Good luck!
 
Level 3
Joined
Aug 24, 2014
Messages
22
Thanks! The second trigger worked. In the first trigger, I dont know how to do the Set Vulnerability_Integer = (Vulnerability_Integer + 1). How do I do it?
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
Thanks! The second trigger worked. In the first trigger, I dont know how to do the Set Vulnerability_Integer = (Vulnerability_Integer + 1). How do I do it?


Haha glad to know it worked, it's just an easy thingy although I didn't try it :)

For the second trigger, you first create a variable in Variables Window, name it whatever you want, just assure the type is 'Integer'.
So it's by default '0', when a building of the two is destroyed, we increase its value by 1 using (Vulnerability_Integer = Vulnerability_Integer + 1), It's Arithmetic, If we replace variables with their values it would be (Vulnerability_Integer = 0 + 1 ). So when the second building is destroyed, the value becomes 2. That means the two buildings have been destroyed. I wish you got it.
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,892
method 2 : Using conditions to detect whether the other building is alive or not, via 2 triggers instead of one.
  • is it alive
    • events
      • unit - farm 0000 <gen> dies
    • conditions
    • actions
      • if (all conditions are true) then do (then actions) else do (else actions)
        • if - conditions
          • (farm 0001 <gen> is dead) equal to true
        • then - actions
          • unit - make altar of kings 0002 <gen> vulnerable
        • else - actions
  • is it alive 2
    • events
      • unit - farm 0001 <gen> dies
    • conditions
    • actions
      • if (all conditions are true) then do (then actions) else do (else actions)
        • if - conditions
          • (farm 0000 <gen> is dead) equal to true
        • then - actions
          • unit - make altar of kings 0002 <gen> vulnerable
        • else - actions
Why you make 2 triggers for this? It can be done in 1 trigger, simply by puting both events in one trigger, then both conditions in the ITE...
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
The second approach will break under certain circumstances. If a unit dies and then is healed it will still be dead but have life so be counted alive by that trigger condition. Only the AI unit dead test works properly and that is not included in trigger JASS by default. As such I would recommend the counter approach (method 1). He did it by making an integer global and then setting it to arithmetic of itself + 1.
 
Status
Not open for further replies.
Top