PMove: improvements to liquid/waterlevel testing

This commit is contained in:
Marco Cawthorne 2023-04-16 01:01:29 -07:00
parent 5c4d693c0e
commit 4a330ef3ce
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
3 changed files with 34 additions and 16 deletions

View File

@ -1167,6 +1167,7 @@ NSClientPlayer::Footsteps_Update(void)
StartSoundDef("step_slosh.right", CHAN_BODY, true);
step_time = time + 0.35f;
return;
} else if (waterlevel == 2) {
if (step)
StartSoundDef("step_wade.left", CHAN_BODY, true);
@ -1174,6 +1175,7 @@ NSClientPlayer::Footsteps_Update(void)
StartSoundDef("step_wade.right", CHAN_BODY, true);
step_time = time + 1.0f;
return;
} else if (waterlevel == 3) {
if (step)
StartSoundDef("step_swim.left", CHAN_BODY, true);
@ -1181,6 +1183,7 @@ NSClientPlayer::Footsteps_Update(void)
StartSoundDef("step_swim.right", CHAN_BODY, true);
step_time = time + 2.0f;
return;
} else {
/* make it so we step once we land */
if (HasFlags(FL_ONGROUND | FL_ONLADDER) == false) {

View File

@ -241,6 +241,28 @@ NSClientPlayer::Physics_WaterMove(void)
return;
}
#ifdef SERVER
if (WaterLevel() > 0) {
print(sprintf("level: %d type: %d\n", waterlevel, watertype));
if (watertype == CONTENT_LAVA) {
print("in lava\n");
if (m_flPainTime < time) {
Damage_Apply(this, world, 10 * WaterLevel(), 0, DMG_BURN);
m_flPainTime = time + 0.2;
print("lava damage\n");
}
} else if (watertype == CONTENT_SLIME) {
print("in slime\n");
if (m_flPainTime < time) {
Damage_Apply(this, world, 4 * WaterLevel(), 0, DMG_ACID);
m_flPainTime = time + 1;
print("slime damage\n");
}
}
}
#endif
/* we've just exited water */
if (WaterLevel() != 3) {
if (m_flUnderwaterTime < time) {
@ -258,6 +280,8 @@ NSClientPlayer::Physics_WaterMove(void)
}
#endif
if (!WaterLevel()){
if (GetFlags() & FL_INWATER) {
#ifdef SERVER
@ -268,20 +292,6 @@ NSClientPlayer::Physics_WaterMove(void)
return;
}
#ifdef SERVER
if (watertype == CONTENT_LAVA) {
if (m_flPainTime < time) {
Damage_Apply(this, world, 10 * WaterLevel(), 0, DMG_BURN);
m_flPainTime = time + 0.2;
}
} else if (watertype == CONTENT_SLIME) {
if (m_flPainTime < time) {
Damage_Apply(this, world, 4 * WaterLevel(), 0, DMG_ACID);
m_flPainTime = time + 1;
}
}
#endif
if (!(GetFlags() & FL_INWATER)) {
#ifdef SERVER
Sound_Play(this, CHAN_BODY, "player.waterenter");

View File

@ -56,7 +56,7 @@ PMoveCustom_Contents(vector org)
{
int oldhitcontents = self.hitcontentsmaski;
self.hitcontentsmaski = -1;
traceline(org, org, TRUE, self);
traceline(org, org, MOVE_EVERYTHING, self);
self.hitcontentsmaski = oldhitcontents;
return trace_endcontentsi;
}
@ -78,6 +78,7 @@ PMoveCustom_Categorize(void)
{
int contents;
bool inladder = false;
vector testPos;
tracebox(self.origin, self.mins, self.maxs, self.origin - [0,0,1], MOVE_NORMAL, self);
@ -134,7 +135,8 @@ PMoveCustom_Categorize(void)
self.flags &= ~FL_ONLADDER;
}
contents = PMoveCustom_Contents(self.origin + self.mins + [0,0,1]);
testPos = self.origin + [0, 0, self.mins[2] + 4];
contents = PMoveCustom_Contents(testPos);
if (contents & CONTENTBIT_WATER) {
contents = CONTENT_WATER;
@ -142,11 +144,14 @@ PMoveCustom_Categorize(void)
contents = CONTENT_SLIME;
} else if (contents & CONTENTBIT_LAVA) {
contents = CONTENT_LAVA;
} else {
contents = CONTENT_EMPTY;
}
/* how far underwater are we? */
if (contents < CONTENT_SOLID && !(self.flags & FL_ONLADDER)) {
self.watertype = contents;
if (PMoveCustom_Contents(self.origin + (self.mins + self.maxs) * 0.5)
& CONTENTBITS_FLUID)
{