PDA

View Full Version : lootable corpse/container


jdoran
10-29-2013, 08:59 PM
Hello again. Back in February I asked about this, but was focused more on the appearances than function.

What I would like is a lootable body that doesn't despawn until I explicitly tell it to. This is sort of like a ground-spawn container.

I've gotten around to implementing some of these ideas, and am stumped once again at this. The idea is that a player enters a zone and the corpse spawns. The player eventually runs across it, and is able to loot some item on the body (let's say a note).

If I create a regular corpse it might decay before the player saw it. If I call the Kill() method on the NPC, then the player gets no credit for the kill, and the corpse decays immediately. I have made sure that the NPC had
an item in its inventory hoping that it wouldn't be considered empty.

The corpse is gone before I can call SetDecayTimer().

I have tried to emulate NPC::Death and create a new corpse that way, but the corpse never appears (visually) in the zone. I can look it up on the entity list. Items are transferred from the original NPC to the corpse.

If I create a mob that appears dead, then I don't see how anyone could loot it. So I'm focusing on corpses for the moment.

Does anyone have any good ideas for me to try?

jdoran
10-30-2013, 01:23 PM
One work-around that I have tried is to create a level-1 npc and then call Damage() giving the client as the damage source.

This gives me the lootable corpse, but it also sends messages to the client about "xyz was hit for 100000 points of damage", and "you have slain xxx".

I cannot have the mob kill itself and then add a looter, since the corpse decays instantly. If it weren't for the fast decay, this would be ideal.

-- A quick update: changing the spell_id to 0 removes everything but the "You have slain xxx" message. I would like to get rid of this. The idea is to silently spawn a corpse and later depop it.

jdoran
10-30-2013, 02:33 PM
I have it working correctly. I gave the npc 10hp, had the client damage it for 9hp, and then had the npc finish itself off. With spell-id 0 there are no cast/land messages. Since the npc gets the kill shot, there is no message to the client.

The result is a lootable corpse. With a suitably long decay time, and a timer to reset the decay, the corpse can stay in zone for as long as needed. When I'm done with it I reset the decay time to 1 and it poofs.

Note: I was unable to use Depop or DepopCorpse to remove the corpse. I'm not sure what was going on here. But resetting the decay time gets the job done.