Clean up armoury_entity, func_bomb_target, func_buyzone, func_escapezone, func_hostage_rescue, info_buyzone, info_hostage_rescue, info_map_parameter and item_suit.

This commit is contained in:
Marco Cawthorne 2022-08-27 11:22:12 -07:00
parent cd01daac6a
commit e9e49ab216
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
9 changed files with 172 additions and 118 deletions

View File

@ -104,6 +104,7 @@ class armoury_entity:NSRenderableEntity
int m_iID; int m_iID;
void(void) armoury_entity; void(void) armoury_entity;
virtual void(void) Spawned;
virtual void(float) Save; virtual void(float) Save;
virtual void(string,string) Restore; virtual void(string,string) Restore;
virtual void(entity) Touch; virtual void(entity) Touch;
@ -113,18 +114,25 @@ class armoury_entity:NSRenderableEntity
void void
armoury_entity::armoury_entity(void) armoury_entity::armoury_entity(void)
{
m_iID = 0;
m_iCount = 1;
m_iLeft = 0;
}
void
armoury_entity::Spawned(void)
{ {
if (autocvar_fcs_nopickups == TRUE) { if (autocvar_fcs_nopickups == TRUE) {
Destroy(); Destroy();
return; return;
} }
super::Spawned();
precache_model(g_cstrike_armourymodels[m_iID]);
precache_sound("items/gunpickup2.wav"); precache_sound("items/gunpickup2.wav");
precache_sound("items/tr_kevlar.wav"); precache_sound("items/tr_kevlar.wav");
m_iID = 0;
m_iCount = 1;
m_iLeft = 0;
} }
void void
@ -196,18 +204,20 @@ armoury_entity::Touch(entity eToucher)
m_iLeft--; m_iLeft--;
if (m_iLeft <= 0) { if (m_iLeft <= 0) {
Hide(); Disappear();
} }
} }
void void
armoury_entity::Respawn(void) armoury_entity::Respawn(void)
{ {
SetOrigin(GetSpawnOrigin());
SetSolid(SOLID_TRIGGER);
SetModel(g_cstrike_armourymodels[m_iID]); SetModel(g_cstrike_armourymodels[m_iID]);
SetSize([-16,-16,0], [16,16,16]); SetSize([-16,-16,0], [16,16,16]);
SetSolid(SOLID_TRIGGER);
m_iLeft = m_iCount;
DropToFloor(); DropToFloor();
m_iLeft = m_iCount;
} }
void void
@ -221,7 +231,7 @@ armoury_entity::SpawnKey(string strKey, string strValue)
m_iID = stoi(strValue); m_iID = stoi(strValue);
if (m_iID < 0 || m_iID >= 19) { if (m_iID < 0 || m_iID >= 19) {
print(sprintf("^1armoury_entity with invalid item %i. ignoring\n", m_iID)); NSLog("^1armoury_entity with invalid item %i. ignoring\n", m_iID);
Destroy(); Destroy();
} }
break; break;

View File

@ -27,7 +27,8 @@ Used in the bomb defusal mode (de_* maps).
Once the bomb explodes inside this volume, it'll trigger its targets. Once the bomb explodes inside this volume, it'll trigger its targets.
*/ */
class func_bomb_target:NSBrushTrigger class
func_bomb_target:NSBrushTrigger
{ {
void(void) func_bomb_target; void(void) func_bomb_target;
@ -35,10 +36,23 @@ class func_bomb_target:NSBrushTrigger
virtual void(entity) Touch; virtual void(entity) Touch;
}; };
void
func_bomb_target::func_bomb_target(void)
{
g_cs_bombzones++;
}
void
func_bomb_target::Respawn(void)
{
InitBrushTrigger();
}
void void
func_bomb_target::Touch(entity eToucher) func_bomb_target::Touch(entity eToucher)
{ {
player pl = (player)eToucher; player pl = (player)eToucher;
if (!(eToucher.flags & FL_CLIENT)) { if (!(eToucher.flags & FL_CLIENT)) {
return; return;
} }
@ -49,15 +63,3 @@ func_bomb_target::Touch(entity eToucher)
pl.gflags |= GF_BOMBZONE; pl.gflags |= GF_BOMBZONE;
} }
void
func_bomb_target::Respawn(void)
{
InitBrushTrigger();
}
void
func_bomb_target::func_bomb_target(void)
{
g_cs_bombzones++;
}

View File

@ -40,7 +40,8 @@ Choices for 'team' include:
2 = Counter-Terrorist 2 = Counter-Terrorist
*/ */
class func_buyzone:NSBrushTrigger class
func_buyzone:NSBrushTrigger
{ {
void(void) func_buyzone; void(void) func_buyzone;
@ -49,14 +50,8 @@ class func_buyzone:NSBrushTrigger
}; };
void void
func_buyzone::Touch(entity eToucher) func_buyzone::func_buyzone(void)
{ {
player pl = (player)eToucher;
if (!(eToucher.flags & FL_CLIENT))
return;
if (team == 0 || team == pl.team)
pl.gflags |= GF_BUYZONE;
} }
void void
@ -66,8 +61,13 @@ func_buyzone::Respawn(void)
} }
void void
func_buyzone::func_buyzone(void) func_buyzone::Touch(entity eToucher)
{ {
NSBrushTrigger::NSBrushTrigger(); player pl = (player)eToucher;
InitBrushTrigger();
if (!(eToucher.flags & FL_CLIENT))
return;
if (team == 0 || team == pl.team)
pl.gflags |= GF_BUYZONE;
} }

View File

@ -26,10 +26,19 @@ Terrorist escape zone.
Used in the Escape mode (es_* maps). Used in the Escape mode (es_* maps).
*/ */
class func_escapezone:NSBrushTrigger class
func_escapezone:NSBrushTrigger
{ {
void(void) func_escapezone;
virtual void(void) Respawn; virtual void(void) Respawn;
}; };
void
func_escapezone::func_escapezone(void)
{
}
void void
func_escapezone::Respawn(void) func_escapezone::Respawn(void)

View File

@ -28,14 +28,26 @@ If neither a func_hostage_rescue or a info_hostage_rescue is placed,
zones will be placed in Counter-Terrorist player spawn nodes automatically. zones will be placed in Counter-Terrorist player spawn nodes automatically.
*/ */
class func_hostage_rescue:NSBrushTrigger class
func_hostage_rescue:NSBrushTrigger
{ {
void(void) func_hostage_rescue; void(void) func_hostage_rescue;
virtual void(entity) Touch;
virtual void(void) Respawn; virtual void(void) Respawn;
virtual void(entity) Touch;
}; };
void
func_hostage_rescue::func_hostage_rescue(void)
{
}
void
func_hostage_rescue::Respawn(void)
{
InitBrushTrigger();
}
void void
func_hostage_rescue::Touch(entity eToucher) func_hostage_rescue::Touch(entity eToucher)
{ {
@ -51,7 +63,7 @@ func_hostage_rescue::Touch(entity eToucher)
hostage_entity hosty = (hostage_entity)eToucher; hostage_entity hosty = (hostage_entity)eToucher;
if (hosty.solid == SOLID_NOT) { if (hosty.GetSolid() == SOLID_NOT) {
return; return;
} }
@ -68,18 +80,5 @@ func_hostage_rescue::Touch(entity eToucher)
* bonus for every hostage that was rescued, even if they lose the round. */ * bonus for every hostage that was rescued, even if they lose the round. */
Money_QueTeamReward(TEAM_CT, 850); Money_QueTeamReward(TEAM_CT, 850);
hosty.Hide(); hosty.Disappear();
}
void
func_hostage_rescue::Respawn(void)
{
InitBrushTrigger();
}
void
func_hostage_rescue::func_hostage_rescue(void)
{
NSBrushTrigger::NSBrushTrigger();
InitBrushTrigger();
} }

View File

@ -25,26 +25,36 @@ Buy zone.
See func_buyzone for more information. See func_buyzone for more information.
*/ */
class info_buyzone class
info_buyzone:NSPointTrigger
{ {
void(void) info_buyzone; void(void) info_buyzone;
virtual void(void) touch;
virtual void(void) Respawn;
virtual void(entity) Touch;
}; };
void void
info_buyzone::touch(void) info_buyzone::info_buyzone(void)
{ {
player pl = (player)other; }
if (!(other.flags & FL_CLIENT))
void
info_buyzone::Respawn(void)
{
SetSolid(SOLID_TRIGGER);
SetSize([-128,-128,-128], [128,128,128]);
SetOrigin(GetSpawnOrigin());
}
void
info_buyzone::Touch(entity eToucher)
{
player pl = (player)eToucher;
if (!(eToucher.flags & FL_CLIENT))
return; return;
if (team == 0 || team == pl.team) if (team == 0 || team == pl.team)
pl.gflags |= GF_BUYZONE; pl.gflags |= GF_BUYZONE;
} }
void
info_buyzone::info_buyzone(void)
{
solid = SOLID_TRIGGER;
setsize(this, [-128,-128,-128], [128,128,128]);
}

View File

@ -29,28 +29,43 @@ If neither a info_hostage_rescue or a func_hostage_rescue is placed,
zones will be placed in Counter-Terrorist player spawn nodes automatically. zones will be placed in Counter-Terrorist player spawn nodes automatically.
*/ */
class info_hostage_rescue class info_hostage_rescue:NSPointTrigger
{ {
void(void) info_hostage_rescue; void(void) info_hostage_rescue;
virtual void(void) touch;
virtual void(void) Respawn;
virtual void(entity) Touch;
}; };
void void
info_hostage_rescue::touch(void) info_hostage_rescue::info_hostage_rescue(void)
{ {
if (other.flags & FL_CLIENT) { }
player pl = (player)other;
void
info_hostage_rescue::Respawn(void)
{
SetSolid(SOLID_TRIGGER);
SetSize([-128,-128,-128], [128,128,128]);
SetOrigin(GetSpawnOrigin());
}
void
info_hostage_rescue::Touch(entity eToucher)
{
if (eToucher.flags & FL_CLIENT) {
player pl = (player)eToucher;
pl.gflags |= GF_RESCUEZONE; pl.gflags |= GF_RESCUEZONE;
return; return;
} }
if (other.classname != "hostage_entity") { if (eToucher.classname != "hostage_entity") {
return; return;
} }
NSTalkMonster hosty = (NSTalkMonster)other; NSTalkMonster hosty = (NSTalkMonster)other;
if (hosty.solid == SOLID_NOT) { if (hosty.GetSolid() == SOLID_NOT) {
return; return;
} }
@ -67,13 +82,5 @@ info_hostage_rescue::touch(void)
/* In Hostage Rescue, all Counter-Terrorists receive an $850 /* In Hostage Rescue, all Counter-Terrorists receive an $850
* bonus for every hostage they rescue, even if they lose the round. */ * bonus for every hostage they rescue, even if they lose the round. */
Money_QueTeamReward(TEAM_CT, 850); Money_QueTeamReward(TEAM_CT, 850);
hosty.Disappear();
hosty.Hide();
}
void
info_hostage_rescue::info_hostage_rescue(void)
{
solid = SOLID_TRIGGER;
setsize(this, [-128,-128,-128], [128,128,128]);
} }

View File

@ -32,40 +32,52 @@ Choices for 'buying':
3 = Neither Counter-Terrorists nor Terrorists can buy items 3 = Neither Counter-Terrorists nor Terrorists can buy items
*/ */
enum typedef enum
{ {
BUY_BOTH, BUY_BOTH,
BUY_CT, BUY_CT,
BUY_T, BUY_T,
BUY_NEITHER BUY_NEITHER
}; } imp_buyrules_t;
class info_map_parameters:NSEntity class
info_map_parameters:NSEntity
{ {
float m_flBombRadius;
imp_buyrules_t m_buyRules;
void(void) info_map_parameters; void(void) info_map_parameters;
virtual void(void) Respawn;
virtual void(string, string) SpawnKey; virtual void(string, string) SpawnKey;
}; };
void
info_map_parameters::info_map_parameters(void)
{
m_flBombRadius = 500;
m_buyRules = BUY_BOTH;
}
void
info_map_parameters::Respawn(void)
{
g_cstrike_buying = m_buyRules;
g_cstrike_bombradius = m_flBombRadius;
}
void void
info_map_parameters::SpawnKey(string strKey, string strValue) info_map_parameters::SpawnKey(string strKey, string strValue)
{ {
switch (strKey) { switch (strKey) {
case "buying": case "buying":
g_cstrike_buying = stoi(strValue); m_buyRules = stoi(strValue);
breakpoint();
break; break;
case "bombradius": case "bombradius":
g_cstrike_bombradius = stof(strValue); m_flBombRadius = stof(strValue);
break; break;
default: default:
super::SpawnKey(strKey, strValue); super::SpawnKey(strKey, strValue);
break; break;
} }
} }
void
info_map_parameters:: info_map_parameters(void)
{
super::NSEntity();
}

View File

@ -20,8 +20,36 @@ class item_suit:NSRenderableEntity
virtual void(entity) Touch; virtual void(entity) Touch;
virtual void(void) Respawn; virtual void(void) Respawn;
virtual void(void) Spawned;
}; };
void
item_suit::item_suit(void)
{
/* a custom map may choose to override this */
model = "models/w_kevlar.mdl";
}
void
item_suit::Spawned(void)
{
super::Spawned();
precache_model(model);
precache_sound("items/tr_kevlar.wav");
}
void
item_suit::Respawn(void)
{
SetSolid(SOLID_TRIGGER);
SetMovetype(MOVETYPE_TOSS);
SetModel(GetSpawnModel());
SetSize(VEC_HULL_MIN, VEC_HULL_MAX);
SetOrigin(GetSpawnOrigin());
ReleaseThink();
}
void void
item_suit::Touch(entity eToucher) item_suit::Touch(entity eToucher)
{ {
@ -41,32 +69,9 @@ item_suit::Touch(entity eToucher)
UseTargets(eToucher, TRIG_TOGGLE, m_flDelay); UseTargets(eToucher, TRIG_TOGGLE, m_flDelay);
if (cvar("sv_playerslots") == 1) { if (cvar("sv_playerslots") == 1) {
remove(self); Destroy();
} else { } else {
Hide(); Disappear();
think = Respawn; ScheduleThink(Respawn, 30.0f);
nextthink = time + 30.0f;
} }
} }
void
item_suit::Respawn(void)
{
SetSolid(SOLID_TRIGGER);
SetMovetype(MOVETYPE_TOSS);
SetSize(VEC_HULL_MIN, VEC_HULL_MAX);
SetOrigin(GetSpawnOrigin());
SetModel(GetSpawnModel());
think = __NULL__;
nextthink = -1;
}
void
item_suit::item_suit(void)
{
model = "models/w_kevlar.mdl";
precache_sound("items/tr_kevlar.wav");
NSRenderableEntity::NSRenderableEntity();
Respawn();
}