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

[JASS] Problem with kill credit.

Status
Not open for further replies.
Level 8
Joined
Oct 20, 2004
Messages
66
I have a problem where a summoned unit's timer runs out and credit for the "kill" is given to player 1 (red). Here's the sample code:

  • Events
    • Unit - A unit Dies
JASS:
local integer PlayerNumber = GetConvertedPlayerId(GetOwningPlayer(GetKillingUnit()))

This action alone will set PlayerNumber to 1, which is the converted player number of Red. After doing some tests (using pings to find the location of the killing unit), I've noticed that when a summoned unit's timer expires, the killing unit is a non-existant unit at origin (0,0) owned by Red.

Here's what I'm trying to do: I want to have players be able to take credit for summoned unit kills, but I don't want anyone taking credit if they simply expire. How would I do that?

EDIT: nm, GetKillingUnit() is null. What through me off is that either GetOwningPlayer(null) returns Red, or GetConvertedPlayerId(null) returns 1. In any case, problem solved.
 
Last edited:
Level 5
Joined
May 27, 2007
Messages
132
Here's a suggestion:

Create 2 triggers, one to appoint kill credit, and another give the message and add, if you have a leaderboard, the point for the kill.

The first one would just do as you've done, and figure out who killed the person, the trigger it launches would display the message and deliver the point onto any leaderboards you've set up.

Give the the first one a condition of

Unit is Summoned Unit Equal to False, using a simple boolean comparison.

It will then run as soon as a unit dies, figure out who died, and only run the message and point if it's not a summoned unit.

Now set a 3rd trigger, and set it up the same way as the first 2, except the boolean comparison would be

Unit is a Summoned unit Equal to True.

And then however you want to run the message of "Player X has killed player Y's summoned unit" and/or add points to a scoreboard is up to you.
 
Status
Not open for further replies.
Top