From 5da6fcf87e97adb7c2f00ffff7d392c294e38499 Mon Sep 17 00:00:00 2001 From: Steam Deck User Date: Sat, 4 Mar 2023 23:54:37 -0500 Subject: [PATCH] SERVER: Add func_train; func_rotating --- progs/fte-server.src | 1 + progs/standard.src | 1 + source/server/entities/func.qc | 448 +++++++++++++++++++++++++ source/server/entities/map_entities.qc | 223 ------------ 4 files changed, 450 insertions(+), 223 deletions(-) create mode 100644 source/server/entities/func.qc diff --git a/progs/fte-server.src b/progs/fte-server.src index ead73ff..5396765 100644 --- a/progs/fte-server.src +++ b/progs/fte-server.src @@ -22,6 +22,7 @@ ../source/server/entities/explosive_barrel.qc ../source/server/entities/teleporter.qc ../source/server/entities/map_entities.qc +../source/server/entities/func.qc ../source/server/entities/traps.qc ../source/server/entities/lights.qc ../source/server/entities/doors.qc diff --git a/progs/standard.src b/progs/standard.src index c4c827e..7ac6475 100644 --- a/progs/standard.src +++ b/progs/standard.src @@ -26,6 +26,7 @@ ../source/server/entities/explosive_barrel.qc ../source/server/entities/teleporter.qc ../source/server/entities/map_entities.qc +../source/server/entities/func.qc ../source/server/entities/traps.qc ../source/server/entities/lights.qc ../source/server/entities/doors.qc diff --git a/source/server/entities/func.qc b/source/server/entities/func.qc new file mode 100644 index 0000000..83eaebf --- /dev/null +++ b/source/server/entities/func.qc @@ -0,0 +1,448 @@ +/* + server/entities/func.qc + + Source file for func_* map entities. + + 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 + 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 + +*/ + +// ================================= +// func_illusionary +// ================================= + +void() func_illusionary = +{ + self.angles = '0 0 0'; + self.movetype = MOVETYPE_NONE; + self.solid = SOLID_NOT; + setmodel (self, self.model); + +#ifdef FTE + + HalfLife_DoRender(); + +#endif // FTE + +}; + +// ================================= +// func_detail +// ================================= + +void() func_detail = +{ + self.angles = '0 0 0'; + self.movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything + self.solid = SOLID_BSP; + setmodel (self, self.model); + +#ifdef FTE + + HalfLife_DoRender(); + +#endif // FTE + +}; + +void() func_wall = { func_detail(); } + +// ================================= +// func_rotating +// ================================= + +.vector spawnorigin; + +void () hl_rotating = +{ + float mvspd, realmvspd; + + mvspd = 180; + + if (!self.speed) + realmvspd = 300; + else + realmvspd = self.speed; + + if (self.spawnflags & 2) + mvspd *= -1; + + if (self.spawnflags & 4) + self.pos1_z += mvspd; + else if (self.spawnflags & 8) + self.pos1_x += mvspd; + else { + self.pos1_y += mvspd; + } + + SUB_CalcAngleMove (self.pos1, realmvspd, hl_rotating); +}; + + +void () func_rotating_use = +{ + if (self.electro_targeted == 0) { + hl_rotating(); + self.electro_targeted = 1; + } else { + self.avelocity = '0 0 0'; + self.think = SUB_Null; + self.electro_targeted = 0; + } +}; + +void() rot_crush = +{ + DamageHandler(self, other, 1, S_ZOMBIE); +} + +void () func_rotating = +{ + self.angles = '0 0 0'; + self.movetype = MOVETYPE_PUSH; + +#ifdef FTE + + HalfLife_DoRender(); + +#endif // FTE + + self.blocked = rot_crush; + + if (self.spawnflags & 64) + self.solid = 0; + else + self.solid = 4; + + setmodel(self, self.model); + + if (self.spawnflags & 1) { // start on + func_rotating_use(); + } + + self.use = func_rotating_use; + + + if (self.spawnorigin != '0 0 0') + setorigin(self, self.spawnorigin); +}; + +// ================================= +// func_train +// ================================= + +.float dmg; + +void() train_next; +void() func_train_find; + +void() train_blocked = +{ + if (time < self.death_timer) + return; + + self.death_timer = time + 0.5; + + DamageHandler(self, other, self.dmg, S_ZOMBIE); +}; + +void() train_use = +{ + if (self.think != func_train_find) + return; // already activated + + train_next(); +}; + +void() train_wait = +{ + if (self.wait) { + self.nextthink = self.ltime + self.wait; + sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM); + } else { + self.nextthink = self.ltime + 0.1; + } + + self.think = train_next; +}; + +void() train_next = +{ + entity targ; + + // motolegacy -- looks like id liked reusing ent fields too! + if (self.electro_targeted == 1) { + train_wait(); + return; + } + + targ = find (world, targetname, self.target); + self.target = targ.target; + + if (!self.target) { + objerror ("train_next: no next target"); + } + + if (targ.wait) + self.wait = targ.wait; + else + self.wait = 0; + + sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM); + SUB_CalcMove (targ.origin - self.mins, self.speed, train_wait); +}; + +void() func_train_find = +{ + entity targ; + + targ = find (world, targetname, self.target); + self.target = targ.target; + + setorigin (self, targ.origin - self.mins); + if (!self.targetname) { + // not triggered, so start immediately + self.nextthink = self.ltime + 0.1; + self.think = train_next; + } +}; + +void() func_train = +{ + if (!self.speed) + self.speed = 100; + + if (!self.target) { + objerror ("func_train without a target"); + } + + if (!self.dmg) + self.dmg = 2; + + if (self.sounds == 0) { + self.noise = ("sounds/null.wav"); + precache_sound ("sounds/null.wav"); + self.noise1 = ("sounds/null.wav"); + precache_sound ("sounds/null.wav"); + } + + if (self.sounds == 1) { + self.noise = ("sounds/misc/debris.wav"); + precache_sound ("sounds/misc/debris.wav"); + self.noise1 = ("sounds/misc/debris.wav"); + precache_sound ("sounds/misc/debris.wav"); + } + + self.cnt = 1; + self.solid = SOLID_BSP; + self.movetype = MOVETYPE_PUSH; + self.blocked = train_blocked; + self.use = train_use; + self.classname = "train"; + + setmodel (self, self.model); + setsize (self, self.mins , self.maxs); + setorigin (self, self.origin); + +#ifdef FTE + + HalfLife_DoRender(); + +#endif // FTE + +// start trains on the second frame, to make sure their targets have had +// a chance to spawn + self.nextthink = self.ltime + 0.1; + self.think = func_train_find; +}; + +// ================================= +// func_button +// ================================= + +void() button_wait; +void() button_return; + +void() button_wait = +{ + self.state = STATE_TOP; + self.nextthink = self.ltime + self.wait; + self.think = button_return; + activator = self.enemy; + SUB_UseTargets(); + self.frame = 1; // use alternate textures +}; + +void() button_done = +{ + self.state = STATE_BOTTOM; +}; + +void() button_return = +{ + self.state = STATE_DOWN; + SUB_CalcMove (self.pos1, self.speed, button_done); + self.frame = 0; // use normal textures + + if (self.health) + self.takedamage = DAMAGE_YES; // can be shot again +}; + + +void() button_blocked = +{ // do nothing, just don't ome all the way back out +}; + + +void() button_fire = +{ + if (self.state == STATE_UP || self.state == STATE_TOP) + return; + + sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM); + + self.state = STATE_UP; + SUB_CalcMove (self.pos2, self.speed, button_wait); +}; + + +void() button_use = +{ + self.enemy = activator; + button_fire (); +}; + +void() button_touch = +{ + if (other.classname != "player") + return; + + if(self.cost) { + if(self.state == STATE_BOTTOM||self.state == STATE_DOWN) { + centerprint(other,"Press use to buy [cost:"); + centerprint(other,ftos(self.cost)); + centerprint(other,"]\n"); + + if (other.button7) { + + if(other.points >= self.cost) { + self.enemy = other; + addmoney(other, 0 - self.cost, FALSE); + button_fire(); + + return; + } else { + centerprint(other, STR_NOTENOUGHPOINTS); + } + } + } + } else { + self.enemy = other; + button_fire (); + } +}; + +void() button_killed = +{ + self.health = self.max_health; + self.takedamage = DAMAGE_NO; // wil be reset upon return + button_fire (); +}; + +void() func_button = +{ + SetMovedir (); + + self.movetype = MOVETYPE_PUSH; + self.solid = SOLID_BSP; + setmodel (self, self.model); + + self.blocked = button_blocked; + self.use = button_use; + + if (self.health) { + self.max_health = self.health; + self.th_die = button_killed; + self.takedamage = DAMAGE_YES; + } else { + self.touch = button_touch; + } + + if (!self.speed) + self.speed = 40; + if (!self.wait) + self.wait = 1; + if (!self.lip) + self.lip = 4; + + self.state = STATE_BOTTOM; + + self.pos1 = self.origin; + self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip); + +#ifdef FTE + + HalfLife_DoRender(); + +#endif // FTE + +}; + +// ================================= +// func_ending +// ================================= + +void() touch_ending = +{ + if (other.classname != "player" || self.activated) + return; + + useprint(other, 20, self.cost, 0); + + if (other.button7) { + + if (other.points < self.cost) + return; + + addmoney(other, -self.cost, 0); + + local entity tempe; + tempe = self; + self = other; + EndGameSetup(); + self = tempe; + + self.activated = true; + } +} + +void() func_ending = +{ + precache_model (self.model); + + self.movetype = MOVETYPE_NONE; // so it doesn't get pushed by anything + self.solid = SOLID_TRIGGER; + self.classname = "func_ending"; + setmodel(self, self.model); + setsize(self, VEC_HULL2_MIN, VEC_HULL2_MAX); + + self.touch = touch_ending; +}; diff --git a/source/server/entities/map_entities.qc b/source/server/entities/map_entities.qc index 6c6af6e..ee7e75e 100644 --- a/source/server/entities/map_entities.qc +++ b/source/server/entities/map_entities.qc @@ -28,189 +28,6 @@ string(float wep, float gorvmodel) GetWeaponModel; void() ReturnWeaponModel; -void() func_wall = -{ - self.angles = '0 0 0'; - self.movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything - self.solid = SOLID_BSP; - setmodel (self, self.model); - -#ifdef FTE - - HalfLife_DoRender(); - -#endif // FTE - -}; - -void() func_illusionary = -{ - self.angles = '0 0 0'; - self.movetype = MOVETYPE_NONE; - self.solid = SOLID_NOT; - setmodel (self, self.model); - -#ifdef FTE - - HalfLife_DoRender(); - -#endif // FTE - -}; - -// button and multiple button - -void() button_wait; -void() button_return; - -void() button_wait = -{ - self.state = STATE_TOP; - self.nextthink = self.ltime + self.wait; - self.think = button_return; - activator = self.enemy; - SUB_UseTargets(); - self.frame = 1; // use alternate textures -}; - -void() button_done = -{ - self.state = STATE_BOTTOM; -}; - -void() button_return = -{ - self.state = STATE_DOWN; - SUB_CalcMove (self.pos1, self.speed, button_done); - self.frame = 0; // use normal textures - if (self.health) - self.takedamage = DAMAGE_YES; // can be shot again -}; - - -void() button_blocked = -{ // do nothing, just don't ome all the way back out -}; - - -void() button_fire = -{ - if (self.state == STATE_UP || self.state == STATE_TOP) - return; - - sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM); - - self.state = STATE_UP; - SUB_CalcMove (self.pos2, self.speed, button_wait); -}; - - -void() button_use = -{ - self.enemy = activator; - button_fire (); -}; - -void() button_touch = -{ - if (other.classname != "player") - return; - - if(self.cost) - { - if(self.state == STATE_BOTTOM||self.state == STATE_DOWN) - { - centerprint(other,"Press use to buy [cost:"); - centerprint(other,ftos(self.cost)); - centerprint(other,"]\n"); - if (other.button7) - { - if(other.points >= self.cost) - { - self.enemy = other; - addmoney(other, 0 - self.cost, FALSE); - button_fire(); - return; - } - else - { - centerprint(other, STR_NOTENOUGHPOINTS); - - } - } - } - } - else - { - self.enemy = other; - button_fire (); - } -}; - -void() button_killed = -{ - self.health = self.max_health; - self.takedamage = DAMAGE_NO; // wil be reset upon return - button_fire (); -}; - - -/*QUAKED func_button (0 .5 .8) ? -When a button is touched, it moves some distance in the direction of it's angle, triggers all of it's targets, waits some time, then returns to it's original position where it can be triggered again. - -"angle" determines the opening direction -"target" all entities with a matching targetname will be used -"speed" override the default 40 speed -"wait" override the default 1 second wait (-1 = never return) -"lip" override the default 4 pixel lip remaining at end of move -"health" if set, the button must be killed instead of touched -"sounds" -0) steam metal -1) wooden clunk -2) metallic click -3) in-out -*/ - -void() func_button = -{ - SetMovedir (); - - self.movetype = MOVETYPE_PUSH; - self.solid = SOLID_BSP; - setmodel (self, self.model); - - self.blocked = button_blocked; - self.use = button_use; - - if (self.health) - { - self.max_health = self.health; - self.th_die = button_killed; - self.takedamage = DAMAGE_YES; - } - else - self.touch = button_touch; - - if (!self.speed) - self.speed = 40; - if (!self.wait) - self.wait = 1; - if (!self.lip) - self.lip = 4; - - self.state = STATE_BOTTOM; - - self.pos1 = self.origin; - self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip); - -#ifdef FTE - - HalfLife_DoRender(); - -#endif // FTE - -}; - void() flame_update = { #ifndef FTE @@ -692,46 +509,6 @@ void() trigger_song = { remove(self); } -/* ================ - Buyable Ending - ================ */ -void() touch_ending = -{ - if (other.classname != "player" || self.activated) - return; - - useprint(other, 20, self.cost, 0); - - if (other.button7) { - - if (other.points < self.cost) - return; - - addmoney(other, -self.cost, 0); - - local entity tempe; - tempe = self; - self = other; - EndGameSetup(); - self = tempe; - - self.activated = true; - } -} - -void() func_ending = -{ - precache_model (self.model); - - self.movetype = MOVETYPE_NONE; // so it doesn't get pushed by anything - self.solid = SOLID_TRIGGER; - self.classname = "func_ending"; - setmodel(self, self.model); - setsize(self, VEC_HULL2_MIN, VEC_HULL2_MAX); - - self.touch = touch_ending; -}; - // // ============================================================ // misc_model()