From fef95603e7f05c4e45029b1bb28493f5504ec557 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Tue, 26 Apr 2022 11:23:21 -0700 Subject: [PATCH] Clean up some of the monster code, document and simplify viewmodel bob code. Just general cleanups. --- src/client/viewmodel.qc | 33 +++-- src/server/ammo.qc | 164 ++++++++++++++++-------- src/server/gamerules_multiplayer.qc | 4 +- src/server/gamerules_singleplayer.qc | 4 +- src/server/item_battery.qc | 18 +-- src/server/item_healthkit.qc | 19 +-- src/server/item_weaponbox.qc | 25 ++-- src/server/monster_barney_dead.qc | 42 ++---- src/server/monster_scientist.qc | 27 ++-- src/server/monster_sitting_scientist.qc | 39 +++--- src/server/xen_hair.qc | 26 ++-- src/server/xen_plantlight.qc | 26 ++-- src/server/xen_spore_large.qc | 26 ++-- src/server/xen_spore_medium.qc | 26 ++-- src/server/xen_spore_small.qc | 26 ++-- src/shared/player.qc | 10 +- 16 files changed, 310 insertions(+), 205 deletions(-) diff --git a/src/client/viewmodel.qc b/src/client/viewmodel.qc index 75b4ade..33f4c94 100644 --- a/src/client/viewmodel.qc +++ b/src/client/viewmodel.qc @@ -14,6 +14,12 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/* very primitive bobbing code, similar to Quake. Some ideas: + - allow for a second bob that runs at a separate cycle speed + - second bob could be applied to the side, would give a Doom III/HL2/TS + like viewmodel bob that people may like +*/ + var float autocvar_v_bob = 0.01; var float autocvar_v_bobcycle = 0.8; var float autocvar_v_bobup = 0.5; @@ -34,6 +40,7 @@ Viewmodel_CalcBob(void) { vector vecVel; float flBob; + int iCycle; int s = (float)getproperty(VF_ACTIVESEAT); pViewBob = &g_viewBobVars[s]; @@ -45,23 +52,30 @@ Viewmodel_CalcBob(void) var_cycle = autocvar_v_bobcycle; var_up = autocvar_v_bobup; + /* how many cycles have we done in total */ + iCycle = (pViewBob->m_flBobTime / var_cycle); + + /* increment the input value for our cycle */ pViewBob->m_flBobTime += clframetime; - pViewBob->m_flBobCycle = pViewBob->m_flBobTime - (int)(pViewBob->m_flBobTime / var_cycle) * var_cycle; + + /* calculate the point in the cycle based on the input time */ + pViewBob->m_flBobCycle = pViewBob->m_flBobTime - (iCycle * var_cycle); pViewBob->m_flBobCycle /= var_cycle; - if (pViewBob->m_flBobCycle < var_up) { - pViewBob->m_flBobCycle = MATH_PI * pViewBob->m_flBobCycle / var_up; - } else { - pViewBob->m_flBobCycle = MATH_PI + MATH_PI * (pViewBob->m_flBobCycle - var_up)/(1.0 - var_up); - } + /* prepare for our cycle value to be placed into sin() to get the wave motion */ + pViewBob->m_flBobCycle = MATH_PI * (pViewBob->m_flBobCycle / var_up); + /* we based the speed on the clients movement speed, but ignore any height/jump velocity */ vecVel = pSeat->m_vecPredictedVelocity; vecVel[2] = 0; + pViewBob->m_flSpeed = vlen(vecVel); - flBob = pViewBob->m_flSpeed * var_bob; - flBob = flBob * 0.3 + flBob * 0.7 * sin(pViewBob->m_flBobCycle); - pViewBob->m_flBob = bound(-7, flBob, 4); + /* bob equals speed times strength times cycle */ + flBob = ((pViewBob->m_flSpeed * var_bob) * sin(pViewBob->m_flBobCycle)); + + /* clamp between -8 and 4 units */ + pViewBob->m_flBob = bound(-8, flBob, 4); /* make sure it's adjusted for scale */ pViewBob->m_flBob *= autocvar_r_viewmodelscale; @@ -75,6 +89,7 @@ Viewmodel_ApplyBob(entity gun) gun.angles[2] = -pViewBob->m_flBob; } + /* apply the gun offset based on our bob */ gun.origin += [0,0,-1] + (v_forward * (pViewBob->m_flBob * 0.4)) + (v_forward * autocvar_v_gunofs[0]) + (v_right * autocvar_v_gunofs[1]) diff --git a/src/server/ammo.qc b/src/server/ammo.qc index 2cd8cb9..b0a7bca 100644 --- a/src/server/ammo.qc +++ b/src/server/ammo.qc @@ -14,26 +14,28 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -class item_ammo:CBaseEntity +class item_ammo:NSRenderableEntity { void(void) item_ammo; + virtual void(void) Respawn; virtual void(entity) Touch; }; -void item_ammo::Touch(entity eToucher) +void +item_ammo::Touch(entity eToucher) { - if not (other.flags & FL_CLIENT) { + if not (eToucher.flags & FL_CLIENT) { return; } - player pl = (player)other; - Sound_Play(other, CHAN_ITEM, "ammo.pickup"); + player pl = (player)eToucher; + Sound_Play(eToucher, CHAN_ITEM, "ammo.pickup"); Weapons_RefreshAmmo(pl); - Logging_Pickup(other, this, __NULL__); + Logging_Pickup(eToucher, this, __NULL__); if (real_owner || cvar("sv_playerslots") == 1) { - remove(self); + Destroy(); } else { Hide(); think = Respawn; @@ -41,7 +43,8 @@ void item_ammo::Touch(entity eToucher) } } -void item_ammo::Respawn(void) +void +item_ammo::Respawn(void) { SetSolid(SOLID_TRIGGER); SetMovetype(MOVETYPE_TOSS); @@ -58,14 +61,15 @@ void item_ammo::Respawn(void) droptofloor(); } -void item_ammo::item_ammo(void) +void +item_ammo::item_ammo(void) { Sound_Precache("ammo.pickup"); Sound_Precache("ammo.respawn"); precache_model(model); m_oldModel = model; SetModel(GetSpawnModel()); - CBaseEntity::CBaseEntity(); + super::NSRenderableEntity(); } /*QUAKED ammo_357 (0 0 0.8) (-16 -16 0) (16 16 32) @@ -75,25 +79,31 @@ HALF-LIFE (1998) ENTITY Ammo for the .357 Magnum Revolver. A single ammo_357 will provide 6 bullets. +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/w_357ammobox.mdl" */ + class ammo_357:item_ammo { void(void) ammo_357; virtual void(entity) Touch; }; -void ammo_357::ammo_357(void) +void +ammo_357::ammo_357(void) { model = "models/w_357ammobox.mdl"; item_ammo::item_ammo(); } -void ammo_357::Touch(entity eToucher) + +void +ammo_357::Touch(entity eToucher) { - if not (other.flags & FL_CLIENT) { + if not (eToucher.flags & FL_CLIENT) { return; } - if (other.classname == "player") { - player pl = (player)other; + if (eToucher.classname == "player") { + player pl = (player)eToucher; if (pl.ammo_357 < MAX_A_357) { pl.ammo_357 = bound(0, pl.ammo_357 + 6, MAX_A_357); item_ammo::Touch(eToucher); @@ -108,25 +118,31 @@ HALF-LIFE (1998) ENTITY Ammo for the 9mm Handgun and the 9mm AR. A single ammo_9mmAR will provide 50 bullets. +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/w_9mmarclip.mdl" */ + class ammo_9mmAR:item_ammo { void(void) ammo_9mmAR; virtual void(entity) Touch; }; -void ammo_9mmAR::ammo_9mmAR(void) +void +ammo_9mmAR::ammo_9mmAR(void) { model = "models/w_9mmarclip.mdl"; item_ammo::item_ammo(); } -void ammo_9mmAR::Touch(entity eToucher) + +void +ammo_9mmAR::Touch(entity eToucher) { - if not (other.flags & FL_CLIENT) { + if not (eToucher.flags & FL_CLIENT) { return; } - if (other.classname == "player") { - player pl = (player)other; + if (eToucher.classname == "player") { + player pl = (player)eToucher; if (pl.ammo_9mm < MAX_A_9MM) { pl.ammo_9mm = bound(0, pl.ammo_9mm + 50, MAX_A_9MM); item_ammo::Touch(eToucher); @@ -142,25 +158,31 @@ HALF-LIFE (1998) ENTITY Ammo for the 9mm Handgun and the 9mm AR. A single ammo_9mmbox will provide 200 bullets. +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/w_chainammo.mdl" */ + class ammo_9mmbox:item_ammo { void(void) ammo_9mmbox; virtual void(entity) Touch; }; -void ammo_9mmbox::ammo_9mmbox(void) +void +ammo_9mmbox::ammo_9mmbox(void) { model = "models/w_chainammo.mdl"; item_ammo::item_ammo(); } -void ammo_9mmbox::Touch(entity eToucher) + +void +ammo_9mmbox::Touch(entity eToucher) { - if not (other.flags & FL_CLIENT) { + if not (eToucher.flags & FL_CLIENT) { return; } - if (other.classname == "player") { - player pl = (player)other; + if (eToucher.classname == "player") { + player pl = (player)eToucher; if (pl.ammo_9mm < MAX_A_9MM) { pl.ammo_9mm = bound(0, pl.ammo_9mm + 200, MAX_A_9MM); item_ammo::Touch(eToucher); @@ -175,25 +197,31 @@ HALF-LIFE (1998) ENTITY Ammo for the 9mm Handgun and the 9mm AR. A single ammo_9mmclip will provide 17 bullets. +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/w_9mmclip.mdl" */ + class ammo_9mmclip:item_ammo { void(void) ammo_9mmclip; virtual void(entity) Touch; }; -void ammo_9mmclip::ammo_9mmclip(void) +void +ammo_9mmclip::ammo_9mmclip(void) { model = "models/w_9mmclip.mdl"; item_ammo::item_ammo(); } -void ammo_9mmclip::Touch(entity eToucher) + +void +ammo_9mmclip::Touch(entity eToucher) { - if not (other.flags & FL_CLIENT) { + if not (eToucher.flags & FL_CLIENT) { return; } - if (other.classname == "player") { - player pl = (player)other; + if (eToucher.classname == "player") { + player pl = (player)eToucher; if (pl.ammo_9mm < MAX_A_9MM) { pl.ammo_9mm = bound(0, pl.ammo_9mm + 17, MAX_A_9MM); item_ammo::Touch(eToucher); @@ -208,25 +236,31 @@ HALF-LIFE (1998) ENTITY Ammo for the 9mm AR's secondary fire. A single ammo_ARgrenades will provide 2 AR grenades. +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/w_argrenade.mdl" */ + class ammo_ARgrenades:item_ammo { void(void) ammo_ARgrenades; virtual void(entity) Touch; }; -void ammo_ARgrenades::ammo_ARgrenades(void) +void +ammo_ARgrenades::ammo_ARgrenades(void) { model = "models/w_argrenade.mdl"; item_ammo::item_ammo(); } -void ammo_ARgrenades::Touch(entity eToucher) + +void +ammo_ARgrenades::Touch(entity eToucher) { - if not (other.flags & FL_CLIENT) { + if not (eToucher.flags & FL_CLIENT) { return; } - if (other.classname == "player") { - player pl = (player)other; + if (eToucher.classname == "player") { + player pl = (player)eToucher; if (pl.ammo_m203_grenade < MAX_A_M203_GRENADE) { pl.ammo_m203_grenade = bound(0, pl.ammo_m203_grenade + 2, MAX_A_M203_GRENADE); item_ammo::Touch(eToucher); @@ -242,25 +276,31 @@ HALF-LIFE (1998) ENTITY Ammo for the Shotgun. A single ammo_buckshot will provide 12 shells. +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/w_shotbox.mdl" */ + class ammo_buckshot:item_ammo { void(void) ammo_buckshot; virtual void(entity) Touch; }; -void ammo_buckshot::ammo_buckshot(void) +void +ammo_buckshot::ammo_buckshot(void) { model = "models/w_shotbox.mdl"; item_ammo::item_ammo(); } -void ammo_buckshot::Touch(entity eToucher) + +void +ammo_buckshot::Touch(entity eToucher) { - if not (other.flags & FL_CLIENT) { + if not (eToucher.flags & FL_CLIENT) { return; } - if (other.classname == "player") { - player pl = (player)other; + if (eToucher.classname == "player") { + player pl = (player)eToucher; if (pl.ammo_buckshot < MAX_A_BUCKSHOT) { pl.ammo_buckshot = bound(0, pl.ammo_buckshot + 12, MAX_A_BUCKSHOT); item_ammo::Touch(eToucher); @@ -275,25 +315,31 @@ HALF-LIFE (1998) ENTITY Ammo for the Crossbow. A single ammo_crossbow will provide 5 bolts. +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/w_crossbow_clip.mdl" */ + class ammo_crossbow:item_ammo { void(void) ammo_crossbow; virtual void(entity) Touch; }; -void ammo_crossbow::ammo_crossbow(void) +void +ammo_crossbow::ammo_crossbow(void) { model = "models/w_crossbow_clip.mdl"; item_ammo::item_ammo(); } -void ammo_crossbow::Touch(entity eToucher) + +void +ammo_crossbow::Touch(entity eToucher) { - if not (other.flags & FL_CLIENT) { + if not (eToucher.flags & FL_CLIENT) { return; } - if (other.classname == "player") { - player pl = (player)other; + if (eToucher.classname == "player") { + player pl = (player)eToucher; if (pl.ammo_bolt < MAX_A_BOLT) { pl.ammo_bolt = bound(0, pl.ammo_bolt + 5, MAX_A_BOLT); item_ammo::Touch(eToucher); @@ -308,25 +354,31 @@ HALF-LIFE (1998) ENTITY Ammo for the Tau Cannon and the Gluon Gun. A single ammo_gaussclip will provide 20 cells. +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/w_gaussammo.mdl" */ + class ammo_gaussclip:item_ammo { void(void) ammo_gaussclip; virtual void(entity) Touch; }; -void ammo_gaussclip::ammo_gaussclip(void) +void +ammo_gaussclip::ammo_gaussclip(void) { model = "models/w_gaussammo.mdl"; item_ammo::item_ammo(); } -void ammo_gaussclip::Touch(entity eToucher) + +void +ammo_gaussclip::Touch(entity eToucher) { - if not (other.flags & FL_CLIENT) { + if not (eToucher.flags & FL_CLIENT) { return; } - player pl = (player)other; + player pl = (player)eToucher; if (pl.ammo_uranium < MAX_A_URANIUM) { pl.ammo_uranium = bound(0, pl.ammo_uranium + 20, MAX_A_URANIUM); item_ammo::Touch(eToucher); @@ -340,25 +392,31 @@ HALF-LIFE (1998) ENTITY Ammo for the RPG. A single ammo_rpgclip will provide 1 rocket. +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/w_rpgammo.mdl" */ + class ammo_rpgclip:item_ammo { void(void) ammo_rpgclip; virtual void(entity) Touch; }; -void ammo_rpgclip::ammo_rpgclip(void) +void +ammo_rpgclip::ammo_rpgclip(void) { model = "models/w_rpgammo.mdl"; item_ammo::item_ammo(); } -void ammo_rpgclip::Touch(entity eToucher) + +void +ammo_rpgclip::Touch(entity eToucher) { - if not (other.flags & FL_CLIENT) { + if not (eToucher.flags & FL_CLIENT) { return; } - player pl = (player)other; + player pl = (player)eToucher; if (pl.ammo_rocket < MAX_A_ROCKET) { pl.ammo_rocket = bound(0, pl.ammo_rocket + 1, MAX_A_ROCKET); item_ammo::Touch(eToucher); diff --git a/src/server/gamerules_multiplayer.qc b/src/server/gamerules_multiplayer.qc index c4bf10f..5ba183a 100644 --- a/src/server/gamerules_multiplayer.qc +++ b/src/server/gamerules_multiplayer.qc @@ -102,8 +102,8 @@ HLMultiplayerRules::PlayerSpawn(base_player pp) pl.classname = "player"; pl.health = pl.max_health = 100; pl.takedamage = DAMAGE_YES; - pl.solid = SOLID_SLIDEBOX; - pl.movetype = MOVETYPE_WALK; + pl.SetSolid(SOLID_SLIDEBOX); + pl.SetMovetype(MOVETYPE_WALK); pl.flags = FL_CLIENT; pl.viewzoom = 1.0; pl.model = "models/player.mdl"; diff --git a/src/server/gamerules_singleplayer.qc b/src/server/gamerules_singleplayer.qc index 1fdf6a0..44b58eb 100644 --- a/src/server/gamerules_singleplayer.qc +++ b/src/server/gamerules_singleplayer.qc @@ -53,8 +53,8 @@ HLSingleplayerRules::PlayerSpawn(base_player pl) pl.classname = "player"; pl.health = pl.max_health = 100; pl.takedamage = DAMAGE_YES; - pl.solid = SOLID_SLIDEBOX; - pl.movetype = MOVETYPE_WALK; + pl.SetSolid(SOLID_SLIDEBOX); + pl.SetMovetype(MOVETYPE_WALK); pl.flags = FL_CLIENT; pl.viewzoom = 1.0; pl.model = "models/player.mdl"; diff --git a/src/server/item_battery.qc b/src/server/item_battery.qc index d6e613b..2a29a71 100644 --- a/src/server/item_battery.qc +++ b/src/server/item_battery.qc @@ -26,8 +26,10 @@ Skill 3 (Hard): 10 The values can be tweaked in the skill.cfg file. +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/w_battery.mdl" */ -class item_battery:CBaseEntity +class item_battery:NSRenderableEntity { void(void) item_battery; @@ -37,11 +39,11 @@ class item_battery:CBaseEntity void item_battery::Touch(entity eToucher) { - if (other.classname != "player") { + if (eToucher.classname != "player") { return; } - base_player pl = (base_player)other; + base_player pl = (base_player)eToucher; if (pl.armor >= 100) { return; @@ -52,11 +54,11 @@ void item_battery::Touch(entity eToucher) pl.armor = 100; } - Logging_Pickup(other, this, __NULL__); - Sound_Play(other, CHAN_ITEM, "item.battery"); + Logging_Pickup(eToucher, this, __NULL__); + Sound_Play(eToucher, CHAN_ITEM, "item.battery"); if (real_owner || cvar("sv_playerslots") == 1) { - remove(self); + Destroy(); } else { Hide(); think = Respawn; @@ -79,7 +81,7 @@ void item_battery::Respawn(void) if (!real_owner && time > 30.0f) Sound_Play(this, CHAN_ITEM, "item.respawn"); - droptofloor(); + DropToFloor(); } void item_battery::item_battery(void) @@ -87,5 +89,5 @@ void item_battery::item_battery(void) Sound_Precache("item.battery"); Sound_Precache("item.respawn"); model = "models/w_battery.mdl"; - CBaseEntity::CBaseEntity(); + super::NSRenderableEntity(); } diff --git a/src/server/item_healthkit.qc b/src/server/item_healthkit.qc index f58cdb6..450a6c3 100644 --- a/src/server/item_healthkit.qc +++ b/src/server/item_healthkit.qc @@ -21,30 +21,33 @@ HALF-LIFE (1998) ENTITY Healthkit item. Adds 20 of health to the player. +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/w_medkit.mdl" */ -class item_healthkit:CBaseEntity +class item_healthkit:NSRenderableEntity { void(void) item_healthkit; + virtual void(void) Respawn; virtual void(entity) Touch; }; void item_healthkit::Touch(entity eToucher) { - if (other.classname != "player") { + if (eToucher.classname != "player") { return; } - if (other.health >= other.max_health) { + if (eToucher.health >= eToucher.max_health) { return; } - Damage_Apply(other, this, -20, 0, DMG_GENERIC); + Damage_Apply(eToucher, this, -20, 0, DMG_GENERIC); Sound_Play(this, CHAN_ITEM, "item.healthkit"); - Logging_Pickup(other, this, __NULL__); + Logging_Pickup(eToucher, this, __NULL__); if (real_owner || cvar("sv_playerslots") == 1) { - remove(self); + Destroy(); } else { Hide(); think = Respawn; @@ -67,7 +70,7 @@ void item_healthkit::Respawn(void) if (!real_owner && time > 30.0f) Sound_Play(this, CHAN_ITEM, "item.respawn"); - droptofloor(); + DropToFloor(); } void item_healthkit::item_healthkit(void) @@ -75,5 +78,5 @@ void item_healthkit::item_healthkit(void) Sound_Precache("item.healthkit"); Sound_Precache("item.respawn"); model = "models/w_medkit.mdl"; - CBaseEntity::CBaseEntity(); + super::NSRenderableEntity(); } diff --git a/src/server/item_weaponbox.qc b/src/server/item_weaponbox.qc index f043861..63332a8 100644 --- a/src/server/item_weaponbox.qc +++ b/src/server/item_weaponbox.qc @@ -14,7 +14,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -class item_weaponbox:CBaseEntity +class item_weaponbox:NSRenderableEntity { int ammo_9mm; int ammo_357; @@ -39,18 +39,20 @@ class item_weaponbox:CBaseEntity #endif void(void) item_weaponbox; + virtual void(entity) Touch; virtual void(player) setup; }; -void item_weaponbox::Touch(entity eToucher) +void +item_weaponbox::Touch(entity eToucher) { - if (other.classname != "player") { + if (eToucher.classname != "player") { return; } - player pl = (player)other; - Logging_Pickup(other, this, __NULL__); + player pl = (player)eToucher; + Logging_Pickup(eToucher, this, __NULL__); sound(pl, CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM); pl.ammo_9mm += ammo_9mm; @@ -97,10 +99,11 @@ void item_weaponbox::Touch(entity eToucher) pl.g_items |= weapon_items; Weapons_RefreshAmmo(pl); - remove(this); + Destroy(); } -void item_weaponbox::setup(player pl) +void +item_weaponbox::setup(player pl) { /* TODO: Should the magazine bits be transferred too? */ ammo_9mm = pl.ammo_9mm; @@ -141,16 +144,20 @@ void item_weaponbox::setup(player pl) #endif } -void item_weaponbox::item_weaponbox(void) +void +item_weaponbox::item_weaponbox(void) { SetModel("models/w_weaponbox.mdl"); SetSize([-16,-16,0], [16,16,16]); SetSolid(SOLID_TRIGGER); SetMovetype(MOVETYPE_TOSS); botinfo = BOTINFO_AMMO; + + super::NSRenderableEntity(); } -void weaponbox_spawn(player spawner) +void +weaponbox_spawn(player spawner) { item_weaponbox weaponbox = spawn(item_weaponbox); weaponbox.SetOrigin(spawner.origin); diff --git a/src/server/monster_barney_dead.qc b/src/server/monster_barney_dead.qc index d4678ed..8b890cc 100644 --- a/src/server/monster_barney_dead.qc +++ b/src/server/monster_barney_dead.qc @@ -22,33 +22,16 @@ Barney's corpse */ -class monster_barney_dead:CBaseEntity +class monster_barney_dead:NSTalkMonster { int m_iPose; + void(void) monster_barney_dead; - virtual void(void) Hide; virtual void(void) Respawn; - virtual void(void) Gib; virtual void(string, string) SpawnKey; }; -void -monster_barney_dead::Gib(void) -{ - takedamage = DAMAGE_NO; - FX_GibHuman(origin, vectoangles(origin - g_dmg_eAttacker.origin), g_dmg_iDamage * 2.0f); - Hide(); -} - -void -monster_barney_dead::Hide(void) -{ - SetModel(""); - solid = SOLID_NOT; - movetype = MOVETYPE_NONE; -} - void monster_barney_dead::Respawn(void) { @@ -58,16 +41,17 @@ monster_barney_dead::Respawn(void) v_angle[2] = Math_FixDelta(v_angle[2]); SetOrigin(GetSpawnOrigin()); - angles = v_angle; - solid = SOLID_CORPSE; - movetype = MOVETYPE_NONE; + SetAngles(v_angle); + SetSolid(SOLID_CORPSE); + SetMovetype(MOVETYPE_NONE); SetModel(GetSpawnModel()); - setsize(this, VEC_HULL_MIN + [0,0,36], VEC_HULL_MAX + [0,0,36]); - takedamage = DAMAGE_YES; - health = 0; - velocity = [0,0,0]; - iBleeds = TRUE; + SetSize(VEC_HULL_MIN + [0,0,36], VEC_HULL_MAX + [0,0,36]); + SetTakedamage(DAMAGE_YES); + SetHealth(0); + SetVelocity([0,0,0]); SetFrame(35 + m_iPose); + + iBleeds = TRUE; } void @@ -78,7 +62,7 @@ monster_barney_dead::SpawnKey(string strKey, string strValue) m_iPose = stoi(strValue); break; default: - CBaseMonster::SpawnKey(strKey, strValue); + super::SpawnKey(strKey, strValue); } } @@ -86,5 +70,5 @@ void monster_barney_dead::monster_barney_dead(void) { model = "models/barney.mdl"; - CBaseMonster::CBaseMonster(); + super::NSTalkMonster(); } diff --git a/src/server/monster_scientist.qc b/src/server/monster_scientist.qc index 83346a6..c59023e 100644 --- a/src/server/monster_scientist.qc +++ b/src/server/monster_scientist.qc @@ -69,27 +69,27 @@ enum SCIA_DEADTABLE3 }; -class monster_scientist:CBaseNPC +class monster_scientist:NSTalkMonster { void(void) monster_scientist; virtual void(void) Respawn; - virtual void(void) OnPlayerUse; virtual void(void) Pain; virtual void(void) Death; + virtual void(void) PlayerUse; virtual void(string, string) SpawnKey; }; void -monster_scientist::OnPlayerUse(void) +monster_scientist::PlayerUse(void) { if (spawnflags & MSF_PREDISASTER) { Sentence("!SC_POK"); return; } - CBaseNPC::OnPlayerUse(); + super::OnPlayerUse(); } void @@ -105,12 +105,12 @@ monster_scientist::Pain(void) return; } - if (style != MONSTER_DEAD) + if (style != MONSTER_DEAD) { Sound_Speak(this, "monster_scientist.pain"); - - frame = SCIA_FLINCH + floor(random(0, 6)); - m_iFlags |= MONSTER_FEAR; - m_flAnimTime = time + 0.25f; + SetFrame(SCIA_FLINCH + floor(random(0, 6))); + m_iFlags |= MONSTER_FEAR; + m_flAnimTime = time + 0.25f; + } } void @@ -124,15 +124,14 @@ monster_scientist::Death(void) } /* now mark our state as 'dead' */ - CBaseNPC::Death(); + super::Death(); } void monster_scientist::Respawn(void) { - CBaseNPC::Respawn(); + super::Respawn(); m_iFlags |= MONSTER_CANFOLLOW; - PlayerUse = OnPlayerUse; } void @@ -143,7 +142,7 @@ monster_scientist::SpawnKey(string strKey, string strValue) SetBody(stoi(strValue) + 1); break; default: - CBaseEntity::SpawnKey(strKey, strValue); + super::SpawnKey(strKey, strValue); } } @@ -189,7 +188,7 @@ monster_scientist::monster_scientist(void) base_maxs = [16,16,72]; base_health = Skill_GetValue("scientist_health", 20); - CBaseNPC::CBaseNPC(); + super::NSTalkMonster(); /* has the body not been overriden, etc. choose a character for us */ if (m_iBody == -1) { diff --git a/src/server/monster_sitting_scientist.qc b/src/server/monster_sitting_scientist.qc index d853c89..010bb58 100644 --- a/src/server/monster_sitting_scientist.qc +++ b/src/server/monster_sitting_scientist.qc @@ -33,12 +33,11 @@ enum DSCIA_DEADHANG }; -class monster_sitting_scientist:CBaseMonster +class monster_sitting_scientist:NSTalkMonster { int m_iPose; void(void) monster_sitting_scientist; - virtual void(void) Hide; virtual void(void) Respawn; virtual void(void) Death; virtual void(void) Gib; @@ -48,28 +47,20 @@ class monster_sitting_scientist:CBaseMonster void monster_sitting_scientist::Gib(void) { - takedamage = DAMAGE_NO; - FX_GibHuman(origin, vectoangles(origin - g_dmg_eAttacker.origin), g_dmg_iDamage * 2.0f); + SetTakedamage(DAMAGE_NO); + FX_GibHuman(GetOrigin(), vectoangles(GetOrigin() - g_dmg_eAttacker.origin), g_dmg_iDamage * 2.0f); Hide(); } void monster_sitting_scientist::Death(void) { - if (health < -50) { + if (GetHealth() < -50) { Gib(); return; } } -void -monster_sitting_scientist::Hide(void) -{ - SetModel(""); - solid = SOLID_NOT; - movetype = MOVETYPE_NONE; -} - void monster_sitting_scientist::Respawn(void) { @@ -79,17 +70,17 @@ monster_sitting_scientist::Respawn(void) v_angle[2] = Math_FixDelta(v_angle[2]); SetOrigin(GetSpawnOrigin()); - angles = v_angle; - solid = SOLID_BBOX; - movetype = MOVETYPE_NONE; + SetAngles(v_angle); + SetSolid(SOLID_BBOX); + SetMovetype(MOVETYPE_NONE); SetModel(GetSpawnModel()); - setsize(this, [-14,-14,0],[14,14,36]); - takedamage = DAMAGE_YES; - health = 0; - velocity = [0,0,0]; + SetSize([-14,-14,0],[14,14,36]); + SetTakedamage(DAMAGE_YES); + SetHealth(0); + SetVelocity([0,0,0]); + SetFrame(74); + DropToFloor(); iBleeds = TRUE; - frame = 74; - droptofloor(); } void @@ -106,7 +97,7 @@ monster_sitting_scientist::SpawnKey(string strKey, string strValue) SetSkin(stoi(strValue)); break; default: - CBaseMonster::SpawnKey(strKey, strValue); + super::SpawnKey(strKey, strValue); } } @@ -114,7 +105,7 @@ void monster_sitting_scientist::monster_sitting_scientist(void) { model = "models/scientist.mdl"; - CBaseMonster::CBaseMonster(); + super::NSTalkMonster(); /* has the body not been overriden, etc. choose a character for us */ if (m_iBody == -1) { diff --git a/src/server/xen_hair.qc b/src/server/xen_hair.qc index 5e9ed73..c184dc5 100644 --- a/src/server/xen_hair.qc +++ b/src/server/xen_hair.qc @@ -20,18 +20,28 @@ HALF-LIFE (1998) ENTITY Xen Hair +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/hair.mdl" */ -class xen_hair:CBaseEntity +class xen_hair:NSRenderableEntity { void(void) xen_hair; + + virtual void(void) Respawn; }; -void xen_hair::xen_hair(void) +void +xen_hair::Respawn(void) { - CBaseEntity::CBaseEntity(); - precache_model("models/hair.mdl"); - solid = SOLID_SLIDEBOX; - movetype = MOVETYPE_WALK; - SetModel("models/hair.mdl"); - SetOrigin(origin); + SetSolid(SOLID_SLIDEBOX); + SetMovetype(MOVETYPE_WALK); + SetModel(GetSpawnModel()); + SetOrigin(GetSpawnOrigin()); +} + +void +xen_hair::xen_hair(void) +{ + model = "models/hair.mdl"; + super::NSRenderableEntity(); } diff --git a/src/server/xen_plantlight.qc b/src/server/xen_plantlight.qc index 9f90972..20262f9 100644 --- a/src/server/xen_plantlight.qc +++ b/src/server/xen_plantlight.qc @@ -20,18 +20,28 @@ HALF-LIFE (1998) ENTITY Xen Plant Light +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/light.mdl" */ -class xen_plantlight:CBaseEntity +class xen_plantlight:NSRenderableEntity { void(void) xen_plantlight; + + virtual void(void) Respawn; }; -void xen_plantlight::xen_plantlight(void) +void +xen_plantlight::Respawn(void) { - CBaseEntity::CBaseEntity(); - precache_model("models/light.mdl"); - solid = SOLID_SLIDEBOX; - movetype = MOVETYPE_WALK; - SetModel("models/light.mdl"); - SetOrigin(origin); + SetSolid(SOLID_SLIDEBOX); + SetMovetype(MOVETYPE_WALK); + SetModel(GetSpawnModel()); + SetOrigin(GetSpawnOrigin()); +} + +void +xen_plantlight::xen_plantlight(void) +{ + model = "models/light.mdl"; + super::NSRenderableEntity(); } diff --git a/src/server/xen_spore_large.qc b/src/server/xen_spore_large.qc index 753dd4b..189c474 100644 --- a/src/server/xen_spore_large.qc +++ b/src/server/xen_spore_large.qc @@ -20,18 +20,28 @@ HALF-LIFE (1998) ENTITY Large Xen Spore +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/fungus(large).mdl" */ -class xen_spore_large:CBaseEntity +class xen_spore_large:NSRenderableEntity { void(void) xen_spore_large; + + virtual void(void) Respawn; }; -void xen_spore_large::xen_spore_large(void) +void +xen_spore_large::Respawn(void) { - CBaseEntity::CBaseEntity(); - precache_model("models/fungus(large).mdl"); - solid = SOLID_SLIDEBOX; - movetype = MOVETYPE_WALK; - SetModel("models/fungus(large).mdl"); - SetOrigin(origin); + SetSolid(SOLID_SLIDEBOX); + SetMovetype(MOVETYPE_WALK); + SetModel(GetSpawnModel()); + SetOrigin(GetSpawnOrigin()); } + +void +xen_spore_large::xen_spore_large(void) +{ + model = "models/fungus(large).mdl"; + super::NSRenderableEntity(); +} \ No newline at end of file diff --git a/src/server/xen_spore_medium.qc b/src/server/xen_spore_medium.qc index bcbaab1..695df98 100644 --- a/src/server/xen_spore_medium.qc +++ b/src/server/xen_spore_medium.qc @@ -20,18 +20,28 @@ HALF-LIFE (1998) ENTITY Medium Xen Spore +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/fungus.mdl" */ -class xen_spore_medium:CBaseEntity +class xen_spore_medium:NSRenderableEntity { void(void) xen_spore_medium; + + virtual void(void) Respawn; }; -void xen_spore_medium::xen_spore_medium(void) +void +xen_spore_medium::Respawn(void) { - CBaseEntity::CBaseEntity(); - precache_model("models/fungus.mdl"); - solid = SOLID_SLIDEBOX; - movetype = MOVETYPE_WALK; - SetModel("models/fungus.mdl"); - SetOrigin(origin); + SetSolid(SOLID_SLIDEBOX); + SetMovetype(MOVETYPE_WALK); + SetModel(GetSpawnModel()); + SetOrigin(GetSpawnOrigin()); +} + +void +xen_spore_medium::xen_spore_medium(void) +{ + model = "models/fungus.mdl"; + super::NSRenderableEntity(); } diff --git a/src/server/xen_spore_small.qc b/src/server/xen_spore_small.qc index 972a380..b564502 100644 --- a/src/server/xen_spore_small.qc +++ b/src/server/xen_spore_small.qc @@ -20,18 +20,28 @@ HALF-LIFE (1998) ENTITY Small Xen Spore +-------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- +model="models/fungus(small).mdl" */ -class xen_spore_small:CBaseEntity +class xen_spore_small:NSRenderableEntity { void(void) xen_spore_small; + + virtual void(void) Respawn; }; -void xen_spore_small::xen_spore_small(void) +void +xen_spore_small::Respawn(void) { - CBaseEntity::CBaseEntity(); - precache_model("models/fungus(small).mdl"); - solid = SOLID_SLIDEBOX; - movetype = MOVETYPE_WALK; - SetModel("models/fungus(small).mdl"); - SetOrigin(origin); + SetSolid(SOLID_SLIDEBOX); + SetMovetype(MOVETYPE_WALK); + SetModel(GetSpawnModel()); + SetOrigin(GetSpawnOrigin()); +} + +void +xen_spore_small::xen_spore_small(void) +{ + model = "models/fungus(small).mdl"; + super::NSRenderableEntity(); } diff --git a/src/shared/player.qc b/src/shared/player.qc index 7687e0b..e0c68be 100644 --- a/src/shared/player.qc +++ b/src/shared/player.qc @@ -500,15 +500,11 @@ player::SendEntity float player::SendEntity(entity ePEnt, float fChanged) { - /* remove our entity to other clients if we're dead */ - if (health <= 0 && ePEnt != this) { + /* don't broadcast invisible players */ + if (IsFakeSpectator() && ePEnt != this) return (0); - } - - /* target client isn't real, they have no client-side. abandon */ - if (clienttype(ePEnt) != CLIENTTYPE_REAL) { + if (!GetModelindex() && ePEnt != this) return (0); - } /* other players don't need to know about these attributes */ if (ePEnt != self && ePEnt.classname != "spectator") {