• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

When building will be below some % of hp, it will change collor, which have attacker.

Status
Not open for further replies.
Level 2
Joined
Aug 8, 2018
Messages
12
Hello, i need help with trigger.

I want building "red scout tower," which is attacked by blue will change owner for the blue, when the building is under some % of hp.

Red building --> attacked by blue (some other collor) --> at some % of hp will change collor of attacker

(I would like to make it for all collors/other players)

I tried with destroying building, but it does not work for me.

Im newbye.

Thanks for some advices!
 

Attachments

  • obrázek_2021-10-14_211711.png
    obrázek_2021-10-14_211711.png
    43.1 KB · Views: 18
Level 25
Joined
Mar 29, 2020
Messages
1,466
something like this should do it:

event - unit is attacked.

conditions :
  • attacked unit = watchtower x.
  • life of attacked unit is < y%.

actions:
-change ownership of attacked unit to (owner of attacking unit) and change color.

- (if you want to) set life of attacked unit to 100%.
 
Level 2
Joined
Aug 8, 2018
Messages
12
I tried this, but it is not working.

Maybe the first condition is not correct.
 

Attachments

  • obrázek_2021-10-15_113512.png
    obrázek_2021-10-15_113512.png
    49.3 KB · Views: 19
Level 14
Joined
Oct 16, 2010
Messages
749
Hi

You don't need to check if the tower is a structure if it is a preset structure anyway?

With the life condition you want "percentage life" instead of "life", currently yours will only work if the tower is under 4HP not 4%

Lastly on the action you need to change "matching player" to "owner of unit - attacking unit", matching player is used for getting particular unit groups and things :)

Also not sure on this one but your unit may continue to attack the structure after it has been converted depending on what order it has? Just something you might need to test :)
 
Level 25
Joined
Mar 29, 2020
Messages
1,466
first of all, see here how to post a trigger: BB codes (it's all the way at the bottom). that way it will be much more clear for people trying to help you.

there are three issues with your trigger:

- your first condition does not check what kind of unit the attacked unit is, it just checks that village tower 0517 is a unit of type structure. if there is only 1 unit of this type in the map than you have defined the unit type in the event and don't even really need this condition. if you want it to be on all units of this unit type you should use a unit type comparison (not a boolean comparison).

- your second condition does not check for 40% life, but rather for 4 hp. I'm not sure if that was intentional.

- your action changes the ownership to "matching player". you have not defined any matching player, so this won't do anything.


-----

I just created a demo and this turned out to be a little more tricky than I thought. if the unit is attacked by something with enough attack it can go straight from over x% to dead. and then it "misses it's chance" to trigger.

So to circumvent that problem I needed to make it a little more complex, but now it should work consistently:

  • change owner when attacked
    • Events
      • Unit - A unit Dies
      • Unit - A unit Is attacked
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Dying unit)) Equal to Farm
          • And - All (Conditions) are true
            • Conditions
              • (Percentage life of (Attacked unit)) Less than 10.00
              • (Unit-type of (Attacked unit)) Equal to Farm
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Attacked unit) is dead) Equal to True
        • Then - Actions
          • Unit - Create 1 Farm for (Owner of (Killing unit)) at (Center of Region 000 <gen>) facing Default building facing degrees
          • Game - Display to (All players) the text: revived
        • Else - Actions
          • Game - Display to (All players) the text: converted
          • Unit - Change ownership of (Attacked unit) to (Owner of (Attacking unit)) and Change color
          • Unit - Set life of (Attacked unit) to 100.00%

I added a demo map which has this and you can reset it by typing "reset" in chat.
 

Attachments

  • change owner low health.w3m
    18.5 KB · Views: 11
Last edited:
Level 2
Joined
Aug 8, 2018
Messages
12
I have one more question.

When building is attacked i made trigger which will spawn some units, when Barracks is Less than or equal to 50%hp

But, that units are spawnich by every attack. How should i make it them to spawn only once?
 

Attachments

  • obrázek_2021-10-15_192011.png
    obrázek_2021-10-15_192011.png
    66.9 KB · Views: 11

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,876
If you want the trigger to only happen once then turn it off once it runs. This will still run the rest of the actions but prevent the trigger from happening again.
  • Trigger - Turn off this trigger

If you want it to be reoccurring but with certain conditions required you'll need... conditions. A boolean variable or something of the sort to determine the state of the structure. Also, I noticed that you're referencing SPECIFIC units in your Events. Is this intentional? There's more advanced methods to designing triggers that allow the use of single triggers for multiple things. These would often use GENERIC Events and have some kind of system for figuring out what needs to be done given the current circumstances. For example, if you wanted the players to be able to build these capturable structures you couldn't rely on specific unit events. Instead, you could delve into the world of Arrays/Hashtables and have one single generic trigger handle the capturing/spawning (reinforcing) of all of your structures.
 
Last edited:
Status
Not open for further replies.
Top