From 7fffb6a0b0f4d72e28501d31ae6cc0b613eae582 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 2 Sep 2013 01:15:21 +1000 Subject: [PATCH] Link control points as well --- qcsrc/client/Main.qc | 1 + qcsrc/client/progs.src | 2 + qcsrc/common/constants.qh | 1 + qcsrc/server/command/cmd.qc | 2 +- qcsrc/server/controlpoint.qc | 120 ++++++++++++++++++++ qcsrc/server/controlpoint.qh | 10 ++ qcsrc/server/mutators/gamemode_onslaught.qc | 30 +++-- qcsrc/server/progs.src | 2 + 8 files changed, 155 insertions(+), 13 deletions(-) create mode 100644 qcsrc/server/controlpoint.qc create mode 100644 qcsrc/server/controlpoint.qh diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 671b3f6d5..fcb8709fc 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -827,6 +827,7 @@ void CSQC_Ent_Update(float bIsNewEntity) case ENT_CLIENT_TURRET: ent_turret(); break; case ENT_CLIENT_MONSTER: ent_monster(); break; case ENT_CLIENT_GENERATOR: ent_generator(); break; + case ENT_CLIENT_CONTROLPOINT: ent_controlpoint(); break; case ENT_CLIENT_MODEL: CSQCModel_Read(bIsNewEntity); break; case ENT_CLIENT_ITEM: ItemRead(bIsNewEntity); break; case ENT_CLIENT_BUMBLE_RAYGUN: bumble_raygun_read(bIsNewEntity); break; diff --git a/qcsrc/client/progs.src b/qcsrc/client/progs.src index 0b68e7e96..62332dcb4 100644 --- a/qcsrc/client/progs.src +++ b/qcsrc/client/progs.src @@ -52,6 +52,7 @@ tturrets.qh ../server/tturrets/include/turrets_early.qh ../server/movelib.qc ../server/generator.qh +../server/controlpoint.qh main.qh vehicles/vehicles.qh ../common/csqcmodel_settings.qh @@ -127,6 +128,7 @@ command/cl_cmd.qc tturrets.qc ../server/generator.qc +../server/controlpoint.qc player_skeleton.qc ../common/animdecide.qc diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 385d3b2e1..aa9a2d29e 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -103,6 +103,7 @@ const float ENT_CLIENT_AUXILIARYXHAIR = 50; const float ENT_CLIENT_VEHICLE = 60; const float ENT_CLIENT_MONSTER = 70; const float ENT_CLIENT_GENERATOR = 80; +const float ENT_CLIENT_CONTROLPOINT = 90; const float SPRITERULE_DEFAULT = 0; const float SPRITERULE_TEAMPLAY = 1; diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 88801e125..ea7227221 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -280,7 +280,7 @@ void ClientCommand_mobspawn(float request, float argc) else if not(autocvar_g_monsters) { Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_MONSTERS_DISABLED); } else if(self.vehicle) { sprint(self, "You can't spawn monsters while driving a vehicle.\n"); } else if(autocvar_g_campaign) { sprint(self, "You can't spawn monsters in campaign mode.\n"); } - else if(self.deadflag) { sprint(self, "You can't spawn monsters while dead.\n"); } + else if(self.deadflag != DEAD_NO) { sprint(self, "You can't spawn monsters while dead.\n"); } else if(self.monstercount >= autocvar_g_monsters_max_perplayer) { sprint(self, "You have spawned too many monsters, kill some before trying to spawn any more.\n"); } else if(totalspawned >= autocvar_g_monsters_max) { sprint(self, "The global maximum monster count has been reached, kill some before trying to spawn any more.\n"); } else // all worked out, so continue diff --git a/qcsrc/server/controlpoint.qc b/qcsrc/server/controlpoint.qc new file mode 100644 index 000000000..ecf3feef0 --- /dev/null +++ b/qcsrc/server/controlpoint.qc @@ -0,0 +1,120 @@ +#ifdef CSQC +float controlpoint_precached; + +void controlpoint_precache() +{ + if(controlpoint_precached) + return; // already precached + + precache_model("models/onslaught/controlpoint_pad.md3"); + precache_model("models/onslaught/controlpoint_pad2.md3"); + + controlpoint_precached = TRUE; +} + +void controlpoint_draw() +{ +} + +void controlpoint_construct() +{ + self.netname = "Control Point"; + + setorigin(self, self.origin); + setmodel(self, "models/onslaught/controlpoint_pad.md3"); + setsize(self, CONTROLPOINT_MIN, CONTROLPOINT_MAX); + + self.move_movetype = MOVETYPE_NOCLIP; + self.solid = SOLID_BBOX; + self.movetype = MOVETYPE_NOCLIP; + self.move_origin = self.origin; + self.move_time = time; + self.drawmask = MASK_NORMAL; + self.alpha = 1; + self.draw = controlpoint_draw; + self.health = 255; +} + +.vector glowmod; +void controlpoint_changeteam() +{ + if(self.team) + { + self.glowmod = Team_ColorRGB(self.team - 1); + self.teamradar_color = Team_ColorRGB(self.team - 1); + self.colormap = 1024 + (self.team - 1) * 17; + setmodel(self, "models/onslaught/controlpoint_pad2.md3"); + setsize(self, CONTROLPOINT_MIN, CONTROLPOINT_MAX); + } + else + { + self.colormap = 1024; + self.glowmod = '1 1 0'; + self.teamradar_color = '1 1 0'; + setmodel(self, "models/onslaught/controlpoint_pad.md3"); + setsize(self, CONTROLPOINT_MIN, CONTROLPOINT_MAX); + } +} + +void ent_controlpoint() +{ + float sf; + sf = ReadByte(); + + if(sf & CPSF_SETUP) + { + self.origin_x = ReadCoord(); + self.origin_y = ReadCoord(); + self.origin_z = ReadCoord(); + setorigin(self, self.origin); + + self.team = ReadByte(); + + if not(self.count) + self.count = 40; + + controlpoint_changeteam(); + controlpoint_precache(); + controlpoint_construct(); + } + + if(sf & CPSF_STATUS) + { + float _tmp; + _tmp = ReadByte(); + if(_tmp != self.team) + { + self.team = _tmp; + controlpoint_changeteam(); + } + } +} +#endif // CSQC + +#ifdef SVQC +float controlpoint_send(entity to, float sf) +{ + WriteByte(MSG_ENTITY, ENT_CLIENT_CONTROLPOINT); + WriteByte(MSG_ENTITY, sf); + if(sf & CPSF_SETUP) + { + WriteCoord(MSG_ENTITY, self.origin_x); + WriteCoord(MSG_ENTITY, self.origin_y); + WriteCoord(MSG_ENTITY, self.origin_z); + + WriteByte(MSG_ENTITY, self.team); + } + + if(sf & CPSF_STATUS) + { + WriteByte(MSG_ENTITY, self.team); + } + + return TRUE; +} + +void controlpoint_link() +{ + Net_LinkEntity(self, TRUE, 0, controlpoint_send); +} +#endif // SVQC diff --git a/qcsrc/server/controlpoint.qh b/qcsrc/server/controlpoint.qh new file mode 100644 index 000000000..88ae0f1f2 --- /dev/null +++ b/qcsrc/server/controlpoint.qh @@ -0,0 +1,10 @@ +const vector CONTROLPOINT_MIN = '-63 -63 -9'; +const vector CONTROLPOINT_MAX = '65 63 26'; + +float CPSF_STATUS = 4; +float CPSF_SETUP = 8; + +#ifdef CSQC +void ent_controlpoint(); +void controlpoint_precache(); +#endif \ No newline at end of file diff --git a/qcsrc/server/mutators/gamemode_onslaught.qc b/qcsrc/server/mutators/gamemode_onslaught.qc index a30c6c6e6..5f4a7eede 100644 --- a/qcsrc/server/mutators/gamemode_onslaught.qc +++ b/qcsrc/server/mutators/gamemode_onslaught.qc @@ -832,8 +832,8 @@ void onslaught_generator_reset() self.enemy.solid = SOLID_NOT; self.think = onslaught_generator_delayed; self.nextthink = time + 0.2; - setmodel(self, "models/onslaught/generator.md3"); - setsize(self, GENERATOR_MIN, GENERATOR_MAX); + //setmodel(self, "models/onslaught/generator.md3"); + //setsize(self, GENERATOR_MIN, GENERATOR_MAX); self.SendFlags |= GSF_STATUS; @@ -896,7 +896,7 @@ void spawnfunc_onslaught_generator() self.solid = SOLID_BBOX; self.movetype = MOVETYPE_NONE; self.lasthealth = self.max_health = self.health = autocvar_g_onslaught_gen_health; - setmodel(self, "models/onslaught/generator.md3"); + //setmodel(self, "models/onslaught/generator.md3"); setsize(self, GENERATOR_MIN, GENERATOR_MAX); setorigin(self, self.origin); self.takedamage = DAMAGE_AIM; @@ -1039,8 +1039,9 @@ void onslaught_controlpoint_icon_damage(entity inflictor, entity attacker, float self.owner.waslinked = self.owner.islinked; - if(self.owner.model != "models/onslaught/controlpoint_pad.md3") - setmodel(self.owner, "models/onslaught/controlpoint_pad.md3"); + self.owner.SendFlags |= CPSF_STATUS; + //if(self.owner.model != "models/onslaught/controlpoint_pad.md3") + //setmodel(self.owner, "models/onslaught/controlpoint_pad.md3"); //setsize(self, '-32 -32 0', '32 32 8'); remove(self); @@ -1230,8 +1231,9 @@ void onslaught_controlpoint_icon_buildthink() self.alpha = self.health / self.max_health; // colormod flash when shot self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1)); - if(self.owner.model != "models/onslaught/controlpoint_pad2.md3") - setmodel(self.owner, "models/onslaught/controlpoint_pad2.md3"); + self.owner.SendFlags |= CPSF_STATUS; + //if(self.owner.model != "models/onslaught/controlpoint_pad2.md3") + //setmodel(self.owner, "models/onslaught/controlpoint_pad2.md3"); //setsize(self, '-32 -32 0', '32 32 8'); if(random() < 0.9 - self.health / self.max_health) @@ -1292,12 +1294,14 @@ void onslaught_controlpoint_reset() self.enemy.colormap = self.colormap; self.think = self.enemy.think = func_null; self.nextthink = 0; // don't like func_null :P - setmodel(self, "models/onslaught/controlpoint_pad.md3"); + //setmodel(self, "models/onslaught/controlpoint_pad.md3"); //setsize(self, '-32 -32 0', '32 32 8'); WaypointSprite_UpdateMaxHealth(self.sprite, 0); onslaught_updatelinks(); + + self.SendFlags |= CPSF_STATUS; activator = self; SUB_UseTargets(); // to reset the structures, playerspawns etc. @@ -1322,8 +1326,8 @@ void spawnfunc_onslaught_controlpoint() remove(self); return; } - precache_model("models/onslaught/controlpoint_pad.md3"); - precache_model("models/onslaught/controlpoint_pad2.md3"); + //precache_model("models/onslaught/controlpoint_pad.md3"); + //precache_model("models/onslaught/controlpoint_pad2.md3"); precache_model("models/onslaught/controlpoint_shield.md3"); precache_model("models/onslaught/controlpoint_icon.md3"); precache_model("models/onslaught/controlpoint_icon_dmg1.md3"); @@ -1342,8 +1346,8 @@ void spawnfunc_onslaught_controlpoint() self.solid = SOLID_BBOX; self.movetype = MOVETYPE_NONE; - setmodel(self, "models/onslaught/controlpoint_pad.md3"); - //setsize(self, '-32 -32 0', '32 32 8'); + //setmodel(self, "models/onslaught/controlpoint_pad.md3"); + setsize(self, CONTROLPOINT_MIN, CONTROLPOINT_MAX); if(!self.noalign) { setorigin(self, self.origin + '0 0 20'); @@ -1374,6 +1378,8 @@ void spawnfunc_onslaught_controlpoint() WaypointSprite_SpawnFixed(string_null, self.origin + '0 0 128', self, sprite, RADARICON_NONE, '0 0 0'); WaypointSprite_UpdateRule(self.sprite, NUM_TEAM_2, SPRITERULE_TEAMPLAY); + + controlpoint_link(); onslaught_updatelinks(); diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index b8ce21ec2..fa85e4ba0 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -60,6 +60,7 @@ tturrets/include/turrets_early.qh vehicles/vehicles_def.qh generator.qh +controlpoint.qh campaign.qh ../common/campaign_common.qh @@ -215,6 +216,7 @@ spawnpoints.qc portals.qc generator.qc +controlpoint.qc target_spawn.qc func_breakable.qc -- 2.39.2