mirror of
https://github.com/nzp-team/quakec.git
synced 2024-11-22 03:41:15 +00:00
Server: Explosive Barrel Parity
This commit is contained in:
parent
0a5b3de482
commit
52e212f6cd
7 changed files with 127 additions and 48 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
122
source/server/entities/explosive_barrel.qc
Normal file
122
source/server/entities/explosive_barrel.qc
Normal file
|
@ -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;
|
||||
};
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue