Killing Unit/Player via Conjoined Behaviour

Dave312

Censored for your safe viewing
Reaction score
269
In my map, I have a system where "Targets" are randomly created and a reward is given to the player that kills this target. The problem I'm having is where a particular target is created which has a Conjoined behaviour which cause the target to share it's life with other units. If a player kills a unit which the target shares its life with, the player is deemed to have killed the target and should receive the reward. So for example say I have 2 units, A and B. Unit A is the target but it shares its life with Unit B (via a conjoined behaviour). If a player kills unit B, unit A will also be killed and the player should receive the reward. However because in my triggers I am using Owner Of (Killing Unit) to determine the killing player (with a Unit Dies event), the game seems to think Unit A was killed by the conjoined behaviour which means the killing player becomes Player 16 (Neutral Player) instead of the player that killed Unit B. Anyone have any ideas how I can get the correct killing player? Thanks in advance.
 

X-maul

AKA: Demtrod
Reaction score
201
I'm not sure, but the Modify Unit effect has a field Effect: Kill Credit Unit + to determine which unit the kill credit should go to. You might be able to use this to solve your problem.
 

Dave312

Censored for your safe viewing
Reaction score
269
That's not a bad idea, but I'm having a little difficulty in getting this property to work in general (this property is also on behaviours). Also from what little I have been able to determine from how existing objects use this property, I think it I have to tie a set unit to get the kill credit, rather than have the unit that killed Unit B get the credit.
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
I've never used conjoined behaviors before, so I'm not sure how they work. I'm wondering if it's possible to get a linked unit with triggers.

So, I just looked it up some more as I was writing this and it seems like conjoined always share with all other units with the same behavior in a specific range.

Couldn't you create a special case of the trigger where if the killed unit has the conjoined behavior and (Owned of (Killing Unit)) != 16, then pick all units in the behavior range and check if they're also dead, in that case give a reward to the killing player of the first unit.

This could cause problems if your range isn't max so that the units don't die at the same time, say if unit A takes 50% damage and then unit B comes within range and takes 50% damage. Now unit A is dead and unit B is at 50% but unit A's reward wont be given out since unit B didn't die. I don't know if this'll be a problem since I'm not sure of how your map works.
 

Dave312

Censored for your safe viewing
Reaction score
269
That's a good idea. I was originally thinking that I was going to have to either completely revamp my system or create a special set of triggers that would only handle this case (which would be a pain in the ass). Rather I can just create a custom function to get the triggering player which will check for this case.

The units coming in and out of range won't be an issue. Every unit with a conjoined behaviour will always have the same life. So in your example, when Unit B comes within range and is given the behaviour, its life will be reduced to match the life as Unit A. Also if Unit A has 100 max life, and Unit B has 50 max life, as soon has the behaviour is applied, Unit A's maximum health will become 50 (it will still be shown as 100 but it is impossible for its life to be any higher as long as the behaviour is applied).

The main trigger will only fire when the "Target" is killed, so getting the killing player of the first unit will become tricky. I am going to have create a special trigger which will fire when a unit with the conjoined behaviour dies. If the killing player is not player 16, then it will store the killing player into a global variable. The Get Killing Player function will then get the killing player from this variable if the killing player of Unit A is found to be player 16. I think that should work.

Thanks for the help.


EDIT: It works without any issues
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top