Half-Life: Add support for player respawns when coop is 1, as well as custom player model support in coop.

This commit is contained in:
Marco Cawthorne 2020-08-02 15:21:35 +02:00
parent e8bafa044d
commit 743d7a33d0
2 changed files with 33 additions and 10 deletions

View File

@ -459,10 +459,7 @@ CBaseMonster::Physics(void)
input_timelength = frametime;
/* override whatever we did above with this */
if (m_iSequenceState == SEQUENCESTATE_IDLE) {
input_angles = angles = v_angle = m_vecSequenceAngle;
SetFrame(m_flSequenceEnd);
} else if (m_iSequenceState == SEQUENCESTATE_ENDING) {
if (m_iSequenceState == SEQUENCESTATE_ENDING) {
input_angles = angles = v_angle = m_vecSequenceAngle;
SetFrame(m_flSequenceEnd);
} else if (movetype == MOVETYPE_WALK) {

View File

@ -21,16 +21,30 @@ HLSingleplayerRules::PlayerDeath(base_player pl)
pl.solid = SOLID_NOT;
pl.takedamage = DAMAGE_NO;
pl.flags &= ~FL_FLASHLIGHT;
pl.armor = pl.activeweapon = pl.g_items = 0;
pl.armor = pl.activeweapon = pl.g_items = pl.weapon = 0;
pl.health = 0;
Sound_Play(pl, CHAN_AUTO, "player.die");
if (pl.health < -50) {
pl.health = 0;
FX_GibHuman(pl.origin);
return;
if (cvar("coop") == 1) {
pl.think = PutClientInServer;
pl.nextthink = time + 4.0f;
}
pl.health = 0;
if (pl.health < -50) {
FX_GibHuman(pl.origin);
}
/* Let's handle corpses on the clientside */
entity corpse = spawn();
setorigin(corpse, pl.origin + [0,0,32]);
setmodel(corpse, pl.model);
setsize(corpse, VEC_HULL_MIN, VEC_HULL_MAX);
corpse.movetype = MOVETYPE_TOSS;
corpse.solid = SOLID_TRIGGER;
corpse.modelindex = pl.modelindex;
corpse.frame = ANIM_DIESIMPLE;
corpse.angles = pl.angles;
corpse.velocity = pl.velocity;
}
void
@ -44,6 +58,18 @@ HLSingleplayerRules::PlayerSpawn(base_player pl)
pl.flags = FL_CLIENT;
pl.viewzoom = 1.0;
pl.model = "models/player.mdl";
if (cvar("coop") == 1) {
string mymodel = infokey(pl, "model");
if (mymodel) {
mymodel = sprintf("models/player/%s/%s.mdl", mymodel, mymodel);
if (whichpack(mymodel)) {
pl.model = mymodel;
}
}
}
setmodel(pl, pl.model);
setsize(pl, VEC_HULL_MIN, VEC_HULL_MAX);