[HOWTO] Dead Bodies
This tutorial assumes you're an intermediate level scripter and will not explain basic syntax, logic, etc.
I'm going to be explaining how to make a dead body on top of the body that normally is on the ground after someone dies. It's sorta hacky, but I've found it works pretty well. Problems I've had with my method shouldn't cause any trouble in CS, since my implementations have been done in TS. This implementation is designed to be mod inspecific. The first thing you have to do is hook the DeathMsg event, obviously. However, a delay must be added, otherwise the body will just instantly appear when someone dies - as if they fell over at lightspeed. Code:
With this in place, we can now detect when a player dies, and (hopefully) after the animation has taken place. The first problem arises from getting rid of the player's body. This can easily be solved in CS by blocking the ClCorpse message (I think, haven't tried it). In other mods, however, you have to drop the origin of the player and the dead body will follow. Code:
Now that the player's corpse is out of the way, we're going to spawn another entity to take its place. I'd use a message, but we want it to be able to have a box with which players can't move into and other stuff (for example a name of the person that died when you mouse-over the corpse). Code:
A couple notes: I don't know why I set it to MOVETYPE_FLY, so you can probably get rid of that. Also, it may be more effective to run a trace_line to the ground and just add 13.0 units to the z value of the result, but I figure it's less work for a marginal optimization when you just use drop_to_floor. So that's basically it on how to do it. You can add some more stuff like a timer that'll get rid of it after a certain time (so the server doesn't get too crowded or crash due to too many ents). The finished plugin (based on my Murder Mod, an unreleased plugin for TSRP) would look something like this: Code:
Some general notes: This method has not been tested on anything other than TS, but it should generally be mod inspecific. I really doubt this would work on CS, but with a few tweaks it probably would. You can also use mod specific messages (as I stated prior to this), but you lose some functionality and portability. Also, the sequence used (100) is for TS only and will have to be changed for any other mod. As always, if you have any questions, comments or whatever, post them up. |
Re: [HOWTO] Dead Bodies
Sweet.
I wouldn't of guessed at all how to do this. Thanks. |
Re: [HOWTO] Dead Bodies
nice tut hawk
|
Re: [HOWTO] Dead Bodies
As you can see in my plugin Dod Weapon/Corpse Stay, the origin and angles are both included in the ClCorpse message and can thus be immediately routed to the new dead body corpse. Apart from that, you're doing basically the same thing as I am in the plugin.
Overall nice tutorial Hawk. |
Re: [HOWTO] Dead Bodies
I posted this because ClCorpse isn't in every mod. I don't know if you're trying to imply that I read your plugin and then posted this using it, but I can assure you I haven't.
|
Re: [HOWTO] Dead Bodies
Lower thy sword, Hawk. I was not implying that...I was simply reinforcing my compliment with the "that's how I did it too" idea.
flaming deleted by mod |
Re: [HOWTO] Dead Bodies
I like it.
Though would it not be possible to avoid the "remove body" task, and just set its nextthink to the CVAR? And register the think for dead_body to be EntRemove? Swish tutorial - I might play with the idea. Maybe allow users to define an "I killed you" message which gets attached to the corpse? I'll think of something, I'm sure. |
Re: [HOWTO] Dead Bodies
Yeah, you can always do that.
|
All times are GMT -4. The time now is 00:56. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.