• 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.

Changing Unit Ownership

Status
Not open for further replies.

Swe

Swe

Level 2
Joined
Dec 2, 2010
Messages
6
Hi.
I`m new on triggering (though I grasp the basics) and wonder how I can make a building, owned by a player, to change owner when it`s killed to the player who destroyed it.

Apologee for my bad english
 
Level 27
Joined
Jul 6, 2008
Messages
11,326
This is a bad bad idea. I mean player will get a dead building...
If you want to make so when building is changing owner when it is damaged enough and then gets HP set back to 100%, you can replace Unit Dies with Unit Recieves Damage.
And in Conditions add "Trrigering unit hp is under (amount of hp, like 50)". And at the end you should also add "Set HP of trrigering unit to 100%".
 

Swe

Swe

Level 2
Joined
Dec 2, 2010
Messages
6
  • Is this what are you looking for
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A structure) Equal to True
    • Actions
      • Unit - Change ownership of (Triggering unit) to (Owner of (Killing unit)) and Change color

Just noticed that this trigger diden`t work. However, I solved this by creating a more complicated trigger (instead of those below). This works fine though but thanks anyways
 
Level 11
Joined
Oct 31, 2010
Messages
1,057
attachment.php

what you want right ?
there are some error but i won't edit it
 

Attachments

  • Trigger.PNG
    Trigger.PNG
    8.5 KB · Views: 150
Last edited:
Level 33
Joined
Mar 27, 2008
Messages
8,035
That trigger doesn't make any sense. The life of a dying unit is always less than 50. ;P

Use event: Unit is attacked. If life of attacked unit is less than XX%, do actions. So, yeah, what Tleno said.

Make sure to use Trigger - Add new Event action =D


[TRIGGER=]
What you want
Events
Unit - A unit Dies
Conditions
[Life of [Triggering unit]]Less than 50.00
Action
Unit - Set life of [Triggering unit] to 100%
Unit - Change ownership of [Triggering unit] to [Triggering player] and Change color
Selection - Select [Triggering unit] for Player 1 [Red][/TRIGGER]
what you want right ?
If the unit DIES, that makes no sense to control the unit anymore, and it doesn't matter which unit is it, because it's DEAD
So, make a trigger that detects current HP of the unit
Say, if below 1%~5% of its max HP, set the building to 100% HP and change owner
And by this, the building doesn't "die" yet, it just changes owner + renewable HP (set to 100% HP)
Be sure to use the Event - Unit Is attacked, but make it two trigger, followed by Trigger - Add New Event for Attacked unit Takes damage event
 
Level 7
Joined
Jan 29, 2010
Messages
213
Use this one, I think this is what you need:
  • aaa
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacked unit)) Equal to Town Hall
      • (Life of (Attacked unit)) Less than or equal to 100.00
    • Actions
      • Unit - Set life of (Attacked unit) to 100.00%
      • Unit - Change ownership of (Attacked unit) to (Owner of (Attacking unit)) and Change color
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
You can't use single trigger for the event Unit Is attacked
Because, the trigger will be fired even before the damage is done to the unit
Therefore, NO damage calculation is calculated for that trigger
You're doing it right but, just remove the Set life and Change owner and replace with Trigger - Add New Event (requires another new trigger)
Find the Event Specific unit - Action
Make it, Attacked unit Takes damage (Event Response)
Then at the second trigger, input the set life and change ownership
By this way, it's calculated normally.
 

Swe

Swe

Level 2
Joined
Dec 2, 2010
Messages
6
As I said, I (kind of) solved the problem, although it resulted in a more complicated trigger.
 
Status
Not open for further replies.
Top