From 52e212f6cd3dc7ee8634e1791cd78add7bfef07d Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 23 Apr 2022 18:46:34 -0400 Subject: [PATCH] Server: Explosive Barrel Parity --- progs/fte-server.src | 1 + progs/nx.src | 1 + progs/psp.src | 1 + progs/vita.src | 1 + source/server/entities/explosive_barrel.qc | 122 +++++++++++++++++++++ source/server/entities/map_entities.qc | 47 -------- source/server/weapons/weapon_core.qc | 2 +- 7 files changed, 127 insertions(+), 48 deletions(-) create mode 100644 source/server/entities/explosive_barrel.qc diff --git a/progs/fte-server.src b/progs/fte-server.src index 9048fba..ae28e15 100644 --- a/progs/fte-server.src +++ b/progs/fte-server.src @@ -16,6 +16,7 @@ ../source/server/entities/sub_functions.qc ../source/server/entities/sounds.qc ../source/server/entities/triggers.qc +../source/server/entities/explosive_barrel.qc ../source/server/entities/map_entities.qc ../source/server/entities/traps.qc ../source/server/entities/lights.qc diff --git a/progs/nx.src b/progs/nx.src index 51a9b04..227711c 100644 --- a/progs/nx.src +++ b/progs/nx.src @@ -20,6 +20,7 @@ ../source/server/entities/sub_functions.qc ../source/server/entities/sounds.qc ../source/server/entities/triggers.qc +../source/server/entities/explosive_barrel.qc ../source/server/entities/map_entities.qc ../source/server/entities/traps.qc ../source/server/entities/lights.qc diff --git a/progs/psp.src b/progs/psp.src index bc11ca0..7945370 100644 --- a/progs/psp.src +++ b/progs/psp.src @@ -20,6 +20,7 @@ ../source/server/entities/sub_functions.qc ../source/server/entities/sounds.qc ../source/server/entities/triggers.qc +../source/server/entities/explosive_barrel.qc ../source/server/entities/map_entities.qc ../source/server/entities/traps.qc ../source/server/entities/lights.qc diff --git a/progs/vita.src b/progs/vita.src index 3243655..372c1f8 100644 --- a/progs/vita.src +++ b/progs/vita.src @@ -20,6 +20,7 @@ ../source/server/entities/sub_functions.qc ../source/server/entities/sounds.qc ../source/server/entities/triggers.qc +../source/server/entities/explosive_barrel.qc ../source/server/entities/map_entities.qc ../source/server/entities/traps.qc ../source/server/entities/lights.qc diff --git a/source/server/entities/explosive_barrel.qc b/source/server/entities/explosive_barrel.qc new file mode 100644 index 0000000..30beac3 --- /dev/null +++ b/source/server/entities/explosive_barrel.qc @@ -0,0 +1,122 @@ +/* + server/entities/explosive_barrel.qc + + Explosive Barrel entity + logic + + Copyright (C) 2021-2022 NZ:P Team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + +*/ + +// +// Barrel_Explode() +// Remove the entity, play explosion +// +void() Barrel_Explode = +{ + sound (self, CHAN_WEAPON, self.oldmodel, 1, ATTN_NORM); + DamgageExplode (self, self.enemy, 1, 250, 250); + + #ifdef PC + te_customflash(self.origin, 128, 300, '1 1 1'); + #endif + + CallExplosion(self.origin); + + SUB_Remove (); +}; + +// +// Barrel_Think +// Handles barrel particles and health countdown +// +void() Barrel_Think = +{ + // Spawn the flame particles + if (self.ltime > 10) { + #ifndef PC + particle (self.origin, v_up, 111, 0); + #else + te_flamejet(self.origin + '0 0 45', v_up, 10); + #endif + self.ltime = 0; + } + self.ltime++; + + // Deplete some health over time + if (self.currentammo > 20) { + self.health -= 10 + (rint((random() * 10))); + self.currentammo = 0; + } + self.currentammo++; + + // Remove ourselves and play explosion effects. + if (self.health <= 0) { + Barrel_Explode(); + } + + // Iterate + self.think = Barrel_Think; + self.nextthink = time + 0.05; +} + +// +// Barrel_Hit() +// Called when damage is dealt to Explosive Barrels. +// +void() Barrel_Hit = +{ + // Start the Barrel Explosion timer + self.think = Barrel_Think; + self.nextthink = time + 0.01; +} + +// +// explosive_barrel() +// Spawn Function for the Explosive Barrel. +// +void() explosive_barrel = +{ + // + // Set Default Stats for Compatibility + // + + // Model + if (!self.model) + self.model = "models/props/barrel_m.mdl"; + + // Health + if (!self.health) + self.health = 300; + + // Explosion Sound + if (!self.oldmodel) { + self.oldmodel = "sounds/weapons/grenade/explode.wav"; + } + + self.movetype = MOVETYPE_NONE; // so it doesn't get pushed by anything + self.solid = SOLID_BBOX; + self.classname = "explosive_barrel"; + Precache_Set(self.model); + setsize (self, '-10 -10 ', '10 10 38'); + + self.takedamage = DAMAGE_YES; + self.state = 0; +}; diff --git a/source/server/entities/map_entities.qc b/source/server/entities/map_entities.qc index 6169d2d..0ac3a76 100644 --- a/source/server/entities/map_entities.qc +++ b/source/server/entities/map_entities.qc @@ -519,53 +519,6 @@ void() buy_weapon = precache_sound("sounds/misc/ching.wav"); }; - - -void() BarrelExplode = -{ - sound (self, CHAN_WEAPON, "sounds/weapons/grenade/explode.wav", 1, ATTN_NORM); - DamgageExplode (self, self.enemy, 500, 650, 200); - - #ifdef PC - te_customflash(self.origin, 128, 300, '1 1 1'); - #endif - - CallExplosion(self.origin); - - SUB_Remove (); -}; - -void() barrel_hit = -{ - if (self.health <= 0) { - BarrelExplode(); - } else if (self.health <= 200) { - makevectors(self.angles); - self.think = barrel_hit; - self.nextthink = time + 0.1; - self.health = self.health - 1; - if (self.health > 100) - particle (self.origin + '0 0 30', v_up*8, 111, 0); - else - particle (self.origin + '0 0 30', v_up*8, 112, 0); - - } -} - -void() explosive_barrel = -{ - precache_model ("models/props/barrel_m.mdl"); - - self.movetype = MOVETYPE_NONE; // so it doesn't get pushed by anything - self.solid=SOLID_BBOX; - self.classname = "explosive_barrel"; - setmodel (self, "models/props/barrel_m.mdl"); - setsize (self, '-10 -10 ', '10 10 38'); - - self.takedamage = DAMAGE_YES; - self.health = 300; -}; - .float radioState; .float length; .string tune; diff --git a/source/server/weapons/weapon_core.qc b/source/server/weapons/weapon_core.qc index 667e88a..599bdc6 100644 --- a/source/server/weapons/weapon_core.qc +++ b/source/server/weapons/weapon_core.qc @@ -876,7 +876,7 @@ void(float damage, vector dir, vector org, vector plane, entity hit_ent, float s self = hit_ent; self.health = self.health - damage; - barrel_hit (); + Barrel_Hit(); self = oldself; return;