SERVER: Add support for specifying custom Barricade health

This commit is contained in:
MotoLegacy 2023-12-09 10:37:54 -05:00
parent c8633f1f58
commit 6a2375416b

View file

@ -1,9 +1,9 @@
/*
server/entities/window.qc
barricades
Barricades
Copyright (C) 2021 NZ:P Team
Copyright (C) 2021-2023 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
@ -27,6 +27,8 @@
.float rebuild_time;
#define BARRICADE_SPAWNFLAG_NOTREAL 1
void() spawn_boxes =
{
makevectors(self.angles);
@ -320,7 +322,8 @@ void() window_touch =
if(other.classname == "player" && !other.downed && self.health != -10)
{
if(self.health < 6)
// cypress (09 dec 2023) -- support for limited barricade health.
if(self.health < self.health_delay)
{
useprint (other, 5, 0, 0);
@ -339,18 +342,70 @@ void() window_touch =
}
};
//
// Barricade_GetFrameForHealth(barricade_health)
// What it says on the tin -- if we're spawning with only
// one board, make sure we're on the frame with only one board,
// two for two, etc.
//
float(float barricade_health) Barricade_GetFrameForHealth =
{
switch(barricade_health) {
case -1:
return 41;
case 1:
return 34;
case 2:
return 27;
case 3:
return 20;
case 4:
return 13;
case 5:
return 6;
case 6:
return 0;
default:
return 41;
}
return 0;
}
void() item_barricade =
{
if (self.spawnflags & 1) {
if (self.spawnflags & BARRICADE_SPAWNFLAG_NOTREAL) {
self.health = -10; // Window is deactivated, to only hop over it
} else {
//
// Set Default Stats for Compatibility
//
// Model
if (!self.model)
self.model = "models/misc/window.mdl";
// Repair Sound
if (!self.oldmodel)
self.oldmodel = "sounds/misc/barricade.wav";
// Destroy Sound
if (!self.aistatus)
self.aistatus = "sounds/misc/barricade_destroy.wav";
// Starting Health (-1 = start none, needs to be this way for compatibility)
if (!self.health || self.health > 6 || self.health < -1)
self.health = 6;
// Max Health
if (!self.health_delay || self.health_delay > 6 || self.health_delay < 0)
self.health_delay = 6;
// cypress -- i was going to add a check if the start health was greater
// than max here, but i figured someone might want to make a weird ass
// challenge map where barricades become irreperable after destruction..
// .. not a bad idea, actually.
precache_model(self.model);
precache_sound(self.oldmodel);
precache_sound(self.aistatus);
@ -361,7 +416,7 @@ void() item_barricade =
self.solid = SOLID_TRIGGER;
if (self.health != -10) {
self.health = 6;
self.frame = Barricade_GetFrameForHealth(self.health);
setmodel(self, self.model);
}