GS-EntBase: Convert more entities to the new Touch() method.

This commit is contained in:
Marco Cawthorne 2022-04-24 22:10:35 -07:00
parent 659be3db46
commit 87d9614b23
Signed by: eukara
GPG Key ID: C196CD8BA993248A
18 changed files with 113 additions and 88 deletions

View File

@ -126,6 +126,8 @@ class func_breakable:NSSurfacePropEntity
int m_pressType;
int m_pressDamage;*/
bool m_iCanTouch;
void(void) func_breakable;
/* overrides */
@ -138,7 +140,7 @@ class func_breakable:NSSurfacePropEntity
virtual void(string, string) Restore;
virtual void(void) Explode;
virtual void(void) PlayerTouch;
virtual void(entity) Touch;
/*virtual void(void) PressureDeath;*/
};
@ -253,38 +255,41 @@ func_breakable::Trigger(entity act, int state)
}
void
func_breakable::PlayerTouch(void)
func_breakable::Touch(entity eToucher)
{
static void TriggerWrap(void) {
/* TODO: 'this' should be the person who touched the ent instead */
Trigger(this, TRIG_TOGGLE);
}
if (other.classname == classname) {
if (m_iCanTouch == false)
return;
if (eToucher.classname == classname) {
return;
}
if (other.solid == SOLID_CORPSE) {
if (vlen(other.velocity) > 100) {
if (eToucher.solid == SOLID_CORPSE) {
if (vlen(eToucher.velocity) > 100) {
Trigger(this, TRIG_ON);
}
}
if (HasSpawnFlags(SF_TOUCH)) {
int fDamage = (float)(vlen(other.velocity) * 0.01f);
int fDamage = (float)(vlen(eToucher.velocity) * 0.01f);
if (fDamage >= health) {
touch = __NULL__;
Damage_Apply(this, other, fDamage, 0, DMG_CRUSH);
m_iCanTouch = false;
Damage_Apply(this, eToucher, fDamage, 0, DMG_CRUSH);
if ((GetSurfaceData(SURFDATA_MATERIAL) == GSMATERIAL_GLASS) || (GetSurfaceData(SURFDATA_MATERIAL) == GSMATERIAL_COMPUTER)) {
Damage_Apply(other, this, fDamage / 4, 0, DMG_CRUSH);
Damage_Apply(eToucher, this, fDamage / 4, 0, DMG_CRUSH);
}
}
}
if (HasSpawnFlags(SF_PRESSURE) && (other.absmin[2] >= maxs[2] - 2)) {
touch = __NULL__;
if (HasSpawnFlags(SF_PRESSURE) && (eToucher.absmin[2] >= maxs[2] - 2)) {
m_iCanTouch = false;
think = TriggerWrap;
if (m_flDelay == 0) {
@ -304,8 +309,8 @@ func_breakable::Respawn(void)
SetModel(GetSpawnModel());
SetOrigin(GetSpawnOrigin());
ClearAngles();
touch = PlayerTouch;
think = __NULL__;
m_iCanTouch = true;
if (HasSpawnFlags(SF_TRIGGER)) {
takedamage = DAMAGE_NO;

View File

@ -93,6 +93,8 @@ class func_button:NSSurfacePropEntity
string m_strSndPressed;
string m_strSndUnpressed;
bool m_iCanTouch;
/* input/output */
string m_strOnPressed;
string m_strOnDamaged;
@ -206,6 +208,7 @@ func_button::Arrived(void)
SetOrigin(m_vecDest);
velocity = [0,0,0];
nextthink = 0;
m_iCanTouch = true;
UseOutput(this, m_strOnIn);
m_iState = STATE_RAISED;
@ -227,6 +230,7 @@ func_button::Returned(void)
SetOrigin(m_vecDest);
velocity = [0,0,0];
nextthink = 0;
m_iCanTouch = true;
m_iState = STATE_LOWERED;
SetFrame(FRAME_OFF);
@ -235,7 +239,7 @@ func_button::Returned(void)
void
func_button::MoveBack(void)
{
touch = __NULL__;
m_iCanTouch = false;
m_iState = STATE_DOWN;
m_iValue = 0;
@ -256,7 +260,7 @@ func_button::MoveAway(void)
if (m_iState == STATE_UP) {
return;
}
touch = __NULL__;
m_iCanTouch = false;
if (m_iState == STATE_RAISED) {
nextthink = (ltime + m_flWait);
@ -324,6 +328,9 @@ func_button::Touch(entity eToucher)
return;
}
if (m_iCanTouch == false)
return;
if (eToucher.movetype == MOVETYPE_WALK) {
Trigger(eToucher, TRIG_TOGGLE);
}

View File

@ -40,7 +40,7 @@ class func_conveyor:NSRenderableEntity
virtual void(string,string) Restore;
virtual void(void) Respawn;
virtual void(entity, int) Trigger;
virtual void(void) touch;
virtual void(entity) Touch;
virtual void(void) SetMovementDirection;
virtual void(entity, string, string) Input;
virtual void(string, string) SpawnKey;
@ -83,12 +83,12 @@ func_conveyor::SetMovementDirection(void)
}
void
func_conveyor::touch(void)
func_conveyor::Touch(entity eToucher)
{
if (HasSpawnFlags(SF_CONVEYOR_VISUAL))
return;
other.basevelocity = m_vecMoveDir * (m_flSpeed * -0.2);
eToucher.basevelocity = m_vecMoveDir * (m_flSpeed * -0.2);
}
void

View File

@ -55,7 +55,7 @@ class func_plat:NSRenderableEntity
virtual void(vector, void(void)) Move;
virtual void(void) MoveToggle;
virtual void(void) Respawn;
virtual void(void) touch;
virtual void(entity) Touch;
virtual void(string, string) SpawnKey;
};
@ -151,9 +151,9 @@ func_plat::Trigger(entity act, int state)
}
void
func_plat::touch(void)
func_plat::Touch(entity eToucher)
{
if (other.movetype != MOVETYPE_WALK) {
if (eToucher.movetype != MOVETYPE_WALK) {
return;
}

View File

@ -76,7 +76,7 @@ class func_rot_button:NSRenderableEntity
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(string, string) SpawnKey;
virtual void(void) touch;
virtual void(entity) Touch;
virtual void(void) Respawn;
virtual void(void) Death;
@ -175,8 +175,10 @@ func_rot_button::OnPlayerUse(void)
}
void
func_rot_button::touch(void)
func_rot_button::Touch(entity eToucher)
{
eActivator = eToucher;
if (HasSpawnFlags(FNCROTBUT_TOUCHABLE))
TurnToggle();
}

View File

@ -81,7 +81,7 @@ class func_rotating:NSRenderableEntity
virtual void(void) Rotate;
virtual void(entity) Blocked;
virtual void(void) BlockedTouch;
virtual void(entity) Touch;
virtual void(void) SetMovementDirection;
};
@ -169,9 +169,11 @@ func_rotating::Blocked(entity eBlocker)
}
void
func_rotating::BlockedTouch(void)
func_rotating::Touch(entity eToucher)
{
Blocked(other);
if (HasSpawnFlags(FR_FANPAIN)) {
Blocked(eToucher);
}
}
void
@ -199,10 +201,6 @@ func_rotating::Respawn(void)
think = Rotate;
nextthink = ltime + 1.5f;
}
if (HasSpawnFlags(FR_FANPAIN)) {
touch = BlockedTouch;
}
}
void

View File

@ -113,7 +113,7 @@ class scripted_sequence:NSPointTrigger
virtual void(entity) RunOnEntity;
virtual void(void) InitIdle;
virtual void(void) touch;
virtual void(entity) Touch;
};
void
@ -316,20 +316,20 @@ scripted_sequence::InitIdle(void)
}
void
scripted_sequence::touch(void)
scripted_sequence::Touch(entity eToucher)
{
NSMonster f;
if (other.classname != m_strMonster)
if (eToucher.classname != m_strMonster)
return;
f = (NSMonster)other;
f = (NSMonster)eToucher;
/* we already ARE on a sequence. */
if (f.m_iSequenceState != SEQUENCESTATE_NONE)
return;
RunOnEntity(other);
RunOnEntity(eToucher);
}
void

View File

@ -38,7 +38,7 @@ class target_cdaudio:NSPointTrigger
void(void) target_cdaudio;
virtual void(void) touch;
virtual void(entity) Touch;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
};
@ -67,9 +67,9 @@ target_cdaudio::Restore(string strKey, string strValue)
}
void
target_cdaudio::touch(void)
target_cdaudio::Touch(entity eToucher)
{
if (!(other.flags & FL_CLIENT)) {
if (!(eToucher.flags & FL_CLIENT)) {
return;
}

View File

@ -31,7 +31,7 @@ class trigger_autosave:NSBrushTrigger
void(void) trigger_autosave;
virtual void(void) touch;
virtual void(entity) Touch;
virtual void(void) Respawn;
};
@ -55,7 +55,7 @@ trigger_autosave::Restore(string strKey, string strValue)
}
void
trigger_autosave::touch(void)
trigger_autosave::Touch(entity eToucher)
{
if (GetMaster() == FALSE)
return;
@ -70,14 +70,15 @@ trigger_autosave::touch(void)
msg_entity = this;
multicast(origin, MULTICAST_ALL);
dprint(sprintf("^2trigger_autosave::^3touch^7: %s called autosave\n",
other.netname));
dprint(sprintf("^2trigger_autosave::^3Touch^7: %s called autosave\n",
eToucher.netname));
localcmd("save autosave\n");
//readcmd("save autosave\n");
Hide();
SetSolid(SOLID_NOT);
UseTargets(other, TRIG_TOGGLE, m_flDelay);
UseTargets(eToucher, TRIG_TOGGLE, m_flDelay);
}
void

View File

@ -35,7 +35,7 @@ class trigger_cdaudio:NSBrushTrigger
virtual void(string, string) Restore;
virtual void(entity, int) Trigger;
virtual void(void) Respawn;
virtual void(void) touch;
virtual void(entity) Touch;
virtual void(string, string) SpawnKey;
};
@ -78,9 +78,9 @@ trigger_cdaudio::Trigger(entity act, int unused)
}
void
trigger_cdaudio::touch(void)
trigger_cdaudio::Touch(entity eToucher)
{
Trigger(other, TRIG_TOGGLE);
Trigger(eToucher, TRIG_TOGGLE);
}
void

View File

@ -89,7 +89,7 @@ class trigger_changelevel:NSBrushTrigger
virtual void(string, string) SpawnKey;
virtual void(void) Change;
virtual void(void) TouchTrigger;
virtual void(entity) Touch;
virtual int(entity, entity) IsInside;
};
@ -212,22 +212,21 @@ trigger_changelevel::Trigger(entity act, int unused)
}
void
trigger_changelevel::TouchTrigger(void)
trigger_changelevel::Touch(entity eToucher)
{
if (!(other.flags & FL_CLIENT))
if (HasSpawnFlags(LC_USEONLY))
return;
Trigger(other, TRIG_TOGGLE);
if (!(eToucher.flags & FL_CLIENT))
return;
Trigger(eToucher, TRIG_TOGGLE);
}
void
trigger_changelevel::Respawn(void)
{
InitBrushTrigger();
if (!HasSpawnFlags(LC_USEONLY)) {
touch = TouchTrigger;
}
}
void

View File

@ -45,7 +45,7 @@ class trigger_counter:NSBrushTrigger
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(void) touch;
virtual void(entity) Touch;
virtual void(entity,int) Trigger;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
@ -75,9 +75,9 @@ trigger_counter::Restore(string strKey, string strValue)
}
void
trigger_counter::touch(void)
trigger_counter::Touch(entity eToucher)
{
Trigger(other, TRIG_TOGGLE);
Trigger(eToucher, TRIG_TOGGLE);
}
void

View File

@ -45,7 +45,7 @@ class trigger_push:NSBrushTrigger
virtual void(float) Save;
virtual void(string, string) Restore;
virtual void(void) touch;
virtual void(entity) Touch;
virtual void(void) Respawn;
virtual void(entity, int) Trigger;
virtual void(void) SetMovementDirection;
@ -104,11 +104,11 @@ trigger_push::Trigger(entity act, int state)
}
void
trigger_push::touch(void)
trigger_push::Touch(entity eToucher)
{
eActivator = other;
eActivator = eToucher;
switch(other.movetype) {
switch(eToucher.movetype) {
case MOVETYPE_NONE:
case MOVETYPE_PUSH:
case MOVETYPE_NOCLIP:
@ -117,21 +117,21 @@ trigger_push::touch(void)
}
/* trigger_push is not supposed to work underwater */
if (other.waterlevel > 1)
if (eToucher.waterlevel > 1)
return;
if (other.solid != SOLID_NOT && other.solid != SOLID_BSP) {
if (eToucher.solid != SOLID_NOT && eToucher.solid != SOLID_BSP) {
vector vecPush;
vecPush = (m_flSpeed * m_vecMoveDir);
if (HasSpawnFlags(TP_ONCE)) {
other.velocity += vecPush;
if (other.velocity[2] > 0) {
other.flags &= ~FL_ONGROUND;
eToucher.velocity += vecPush;
if (eToucher.velocity[2] > 0) {
eToucher.flags &= ~FL_ONGROUND;
}
Hide();
} else {
other.basevelocity += vecPush;
eToucher.basevelocity += vecPush;
}
}
}

View File

@ -36,32 +36,32 @@ class trigger_teleport:NSBrushTrigger
{
void(void) trigger_teleport;
virtual void(void) touch;
virtual void(entity) Touch;
virtual void(void) Respawn;
};
void
trigger_teleport::touch(void)
trigger_teleport::Touch(entity eToucher)
{
if (GetMaster() == FALSE)
return;
if (HasSpawnFlags(TRIGTELE_NOCLIENTS) && other.flags & FL_CLIENT)
if (HasSpawnFlags(TRIGTELE_NOCLIENTS) && eToucher.flags & FL_CLIENT)
return;
if (!HasSpawnFlags(TRIGTELE_MONSTERS) && other.flags & FL_MONSTER)
if (!HasSpawnFlags(TRIGTELE_MONSTERS) && eToucher.flags & FL_MONSTER)
return;
if (other.movetype != MOVETYPE_NONE) {
eActivator = other;
if (eToucher.movetype != MOVETYPE_NONE) {
eActivator = eToucher;
entity eTarget = find(world, ::targetname, target);
if (eTarget) {
vector endpos = eTarget.origin + [0,0,16];
setorigin(other, endpos);
dprint(sprintf("^2trigger_teleport::^3touch^7: Teleported '%s' to `%v`\n",
other.netname, endpos));
setorigin(eToucher, endpos);
dprint(sprintf("^2trigger_teleport::^3Touch^7: Teleported '%s' to `%v`\n",
eToucher.netname, endpos));
} else {
print(sprintf("^2trigger_teleport::^3touch^7: Failed to teleport '%s'\n",
other.netname));
print(sprintf("^2trigger_teleport::^3Touch^7: Failed to teleport '%s'\n",
eToucher.netname));
}
}
}

View File

@ -393,16 +393,16 @@ NSRenderableEntity::RenderFXPass(void)
switch (m_iRenderFX) {
case RFX_SLOWPULSE:
alpha = sin(cltime * 0.5);
alpha = sin(cltime * 0.5) + (M_PI * 0.5);
break;
case RFX_FASTPULSE:
alpha = sin(cltime * 2.0);
alpha = sin(cltime * 2.0) + (M_PI * 0.5);
break;
case RFX_SLOWWIDEPULSE:
alpha = sin(cltime * 0.5);
alpha = (sin(cltime * 2.0));
break;
case RFX_FASTWIDEPULSE:
alpha = sin(cltime * 2.0);
alpha = sin(cltime * 2.0) + (M_PI * 0.5);
break;
case RFX_SLOWFADEAWAY:
alpha -= clframetime * 0.25;

View File

@ -36,7 +36,7 @@ class func_friction:NSEntity
void(void) func_friction;
virtual void(void) touch;
virtual void(entity) Touch;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey;
@ -46,9 +46,9 @@ class func_friction:NSEntity
};
void
func_friction::touch(void)
func_friction::Touch(entity eToucher)
{
other.friction = m_flFriction;
eToucher.friction = m_flFriction;
}
void

View File

@ -99,6 +99,7 @@ class CSpraylogo
virtual float(void) predraw;
};
#ifdef WASTES
const string g_spray_mat = \
"{\n" \
"cull disable\n" \
@ -109,6 +110,18 @@ const string g_spray_mat = \
"rgbGen vertex\n" \
"}\n" \
"}";
#else
const string g_spray_mat = \
"{\n" \
"cull disable\n" \
"polygonOffset\n" \
"{\n" \
"map $rt:%s\n" \
"blendfunc blend\n" \
"rgbGen vertex\n" \
"}\n" \
"}";
#endif
float
CSpraylogo::predraw(void)

View File

@ -38,7 +38,7 @@ class trigger_gravity:NSBrushTrigger
void(void) trigger_gravity;
virtual void(void) touch;
virtual void(entity) Touch;
virtual void(string, string) SpawnKey;
virtual void(void) Respawn;
@ -48,9 +48,9 @@ class trigger_gravity:NSBrushTrigger
};
void
trigger_gravity::touch(void)
trigger_gravity::Touch(entity eToucher)
{
other.gravity = m_flGravity;
eToucher.gravity = m_flGravity;
}
void