• 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] Targeting Skeletons Created by Graveyard

Status
Not open for further replies.
Level 2
Joined
Jan 8, 2018
Messages
12
Hi,
I'm creating a unit which can possess corpses. It has an ability which targets the closest available (as in not claimed for possession by another unit with the same ability) corpse in an AoE around itself, then causes the unit to beeline for the corpse, whereupon both the unit and the corpse are destroyed and a skeleton is spawned. When the skeleton is destroyed, the original unit is returned, with the unit's original health, and with the Enter Corpse spell put on cooldown.
It works fine, except it doesn't work on corpses coming out of the Graveyard's Create Corpse ability.
My current code to filter for skeletons is "GetUnitState(u, UNIT_STATE_LIFE) <= 0". If true, it's a corpse, if not, it's not. Obviously, this filter is insufficient.
What's the most efficient way to group together ALL corpses (and only corpses) in an AoE, regardless of how they're spawned?
Thanks.
 
Level 2
Joined
Jan 8, 2018
Messages
12
Also, what's wrong with using IsUnitType(u, UNIT_TYPE_DEAD)?
Ah, that works pretty well. Works on the corpses from the Graveyard, too. The only problem now is that I can e.g. possess the corpse of a skeletal minion ("Can't raise" units). I can also possess units the moment they die, unlike for Rod of Necromancy, where you have to wait until the death animation completes. I think I'm still missing a key component, but I can't find it in the function list.
Thanks for the help.
 
Level 2
Joined
Jan 8, 2018
Messages
12
Are Skeletal Minions considered summoned units?
No, the idea is that the possessing unit doesn't have an attack, and it uses the skeleton as an extra health pool, increased movement speed, and an attack. The skeleton's intended to last until it's destroyed or the skeleton is 'released' (suicide button). I think what I'll just end up having to do is remove the remains of certain units immediately upon dying, like skeletons. It works, but it's not a very elegant solution.
Edit: actually, I think it makes more sense to just have an additional filter to exclude units with the unitTypeID of the summoned skeleton. I can extend the list as I go if there are other corpses I don't want to be possessible. Not a very extensible solution, but whatever.

What editor are you using?
WEX. I only started doing this a few days ago, so I haven't really explored other options.
 
Last edited:
It's a little hard to determine an elegant solution without knowing fully the mechanic and the code associated with it. However, it seems you were able to figure it out :p

If you are using WEX, the TESH that comes with it has a function list. Just go to the Trigger Editor, open up a custom text sheet, and you should see an option for Function List like so:

Capture.PNG
 
Level 13
Joined
Jul 15, 2007
Messages
763
I had a bug in my map relating to the Create Corpse ability, where corpses were for some reason getting hit by spells even though they were dead.

Upon further investigation i found that Graveyard Corpses will actually regenerate for a split second after they spawn, (if your Corpse unit has 0.25 HP regeneration, it will have 0.000025 HP after it spawns, you can check this yourself). Usually this isn't a problem if you properly check for a dead unit (i.e. its HP is below 0.405) but if you do "GetUnitState(u, UNIT_STATE_LIFE) <= 0" that will return false, and it's GUI sort-of-equivalent ("Is unit dead?") does the same.

If you set its HP regen to 0, it's HP will stay at 0, so if your Corpse unit has HP regen, turn it off, and your check should work as intended. If it already has 0 HP regen, then i'm all out of ideas!
 
Last edited:
If I recall, there is some sort of event type for detecting the start of the decay of a unit. If it's not available in GUI, here it is in jass

JASS:
call TriggerRegisterAnyUnitEventBJ(<trig>, EVENT_PLAYER_UNIT_DECAY)

When the unit dies (Death Event fires), and it is not a Hero, I would guess that they will fire this event before being removed from the game. You could store the dying unit in a temporary group A (Group is permanent, the unit's stay in that group is temporary). If that unit is removed before decaying, and you detect it (Unit Event by Bribe), you would remove that unit from that temporary group. When the unit starts to decay, remove the newly decaying unit from that temporary group and add that unit to another group B. Of course, when it fully decays and is removed, remove that unit from the temporary group B.

So, when you'll need to check if the unit is a corpse, you just check if the unit is in the temporary group B.
 
Status
Not open for further replies.
Top