From 4bd11aeeefd1c90b1dd3a55beaf13f5e48de083b Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 31 Jul 2020 20:21:38 +1000 Subject: [PATCH] Some more cleanup to map objects, allow trigger_delay and trigger_counter to be deactivated --- qcsrc/client/bgmscript.qh | 9 +-------- qcsrc/common/mapobjects/_mod.inc | 1 + qcsrc/common/mapobjects/_mod.qh | 1 + qcsrc/common/mapobjects/bgmscript.qc | 1 + qcsrc/common/mapobjects/bgmscript.qh | 8 ++++++++ qcsrc/common/mapobjects/misc/laser.qc | 14 -------------- qcsrc/common/mapobjects/misc/laser.qh | 12 ++++++++++++ qcsrc/common/mapobjects/models.qc | 12 ++---------- qcsrc/common/mapobjects/models.qh | 2 ++ qcsrc/common/mapobjects/trigger/counter.qc | 8 ++++++-- qcsrc/common/mapobjects/trigger/counter.qh | 2 +- qcsrc/common/mapobjects/trigger/delay.qc | 6 ++++++ qcsrc/common/mapobjects/trigger/gamestart.qc | 11 +++-------- qcsrc/common/mapobjects/trigger/keylock.qc | 12 +----------- 14 files changed, 45 insertions(+), 54 deletions(-) create mode 100644 qcsrc/common/mapobjects/bgmscript.qc create mode 100644 qcsrc/common/mapobjects/bgmscript.qh diff --git a/qcsrc/client/bgmscript.qh b/qcsrc/client/bgmscript.qh index a3044d537..e1be9c805 100644 --- a/qcsrc/client/bgmscript.qh +++ b/qcsrc/client/bgmscript.qh @@ -1,15 +1,8 @@ #pragma once -entityclass(BGMScript); -classfield(BGMScript) .string bgmscript; -classfield(BGMScript) .float bgmscriptattack; -classfield(BGMScript) .float bgmscriptdecay; -classfield(BGMScript) .float bgmscriptsustain; -classfield(BGMScript) .float bgmscriptrelease; +#include classfield(BGMScript) .float just_toggled; -#ifdef CSQC void BGMScript_InitEntity(entity e); float doBGMScript(entity e); -#endif diff --git a/qcsrc/common/mapobjects/_mod.inc b/qcsrc/common/mapobjects/_mod.inc index 1aab2b927..ebcbac55d 100644 --- a/qcsrc/common/mapobjects/_mod.inc +++ b/qcsrc/common/mapobjects/_mod.inc @@ -1,4 +1,5 @@ // generated file; do not modify +#include #include #include #include diff --git a/qcsrc/common/mapobjects/_mod.qh b/qcsrc/common/mapobjects/_mod.qh index ebb7a4325..873218225 100644 --- a/qcsrc/common/mapobjects/_mod.qh +++ b/qcsrc/common/mapobjects/_mod.qh @@ -1,4 +1,5 @@ // generated file; do not modify +#include #include #include #include diff --git a/qcsrc/common/mapobjects/bgmscript.qc b/qcsrc/common/mapobjects/bgmscript.qc new file mode 100644 index 000000000..939444d6a --- /dev/null +++ b/qcsrc/common/mapobjects/bgmscript.qc @@ -0,0 +1 @@ +#include "bgmscript.qh" diff --git a/qcsrc/common/mapobjects/bgmscript.qh b/qcsrc/common/mapobjects/bgmscript.qh new file mode 100644 index 000000000..e64bbbf53 --- /dev/null +++ b/qcsrc/common/mapobjects/bgmscript.qh @@ -0,0 +1,8 @@ +#pragma once + +entityclass(BGMScript); +classfield(BGMScript) .string bgmscript; +classfield(BGMScript) .float bgmscriptattack; +classfield(BGMScript) .float bgmscriptdecay; +classfield(BGMScript) .float bgmscriptsustain; +classfield(BGMScript) .float bgmscriptrelease; diff --git a/qcsrc/common/mapobjects/misc/laser.qc b/qcsrc/common/mapobjects/misc/laser.qc index 403a46813..812dce76b 100644 --- a/qcsrc/common/mapobjects/misc/laser.qc +++ b/qcsrc/common/mapobjects/misc/laser.qc @@ -10,7 +10,6 @@ REGISTER_NET_LINKED(ENT_CLIENT_LASER) #ifdef SVQC -.float modelscale; void misc_laser_aim(entity this) { vector a; @@ -291,19 +290,6 @@ spawnfunc(misc_laser) } #elif defined(CSQC) -// a laser goes from origin in direction angles -// it has color 'beam_color' -// and stops when something is in the way -entityclass(Laser); -classfield(Laser) .int cnt; // end effect -classfield(Laser) .vector colormod; -classfield(Laser) .int state; // on-off -classfield(Laser) .int count; // flags for the laser -classfield(Laser) .vector velocity; // laser endpoint if it is FINITE -classfield(Laser) .float alpha; -classfield(Laser) .float scale; // scaling factor of the thickness -classfield(Laser) .float modelscale; // scaling factor of the dlight - void Draw_Laser(entity this) { if(this.active == ACTIVE_NOT) diff --git a/qcsrc/common/mapobjects/misc/laser.qh b/qcsrc/common/mapobjects/misc/laser.qh index 0ff57646a..d5b34f2e8 100644 --- a/qcsrc/common/mapobjects/misc/laser.qh +++ b/qcsrc/common/mapobjects/misc/laser.qh @@ -1,5 +1,17 @@ #pragma once +// a laser goes from origin in direction angles +// it has color 'beam_color' +// and stops when something is in the way +entityclass(Laser); +classfield(Laser) .int cnt; // end effect +classfield(Laser) .vector colormod; +classfield(Laser) .int state; // on-off +classfield(Laser) .int count; // flags for the laser +classfield(Laser) .vector velocity; // laser endpoint if it is FINITE +classfield(Laser) .float alpha; +classfield(Laser) .float scale; // scaling factor of the thickness +classfield(Laser) .float modelscale; // scaling factor of the dlight const int LASER_FINITE = BIT(1); const int LASER_NOTRACE = BIT(2); diff --git a/qcsrc/common/mapobjects/models.qc b/qcsrc/common/mapobjects/models.qc index 790978b99..bcaca193f 100644 --- a/qcsrc/common/mapobjects/models.qc +++ b/qcsrc/common/mapobjects/models.qc @@ -6,18 +6,10 @@ #include #include "subs.qh" #include "triggers.qh" - -entityclass(BGMScript); -classfield(BGMScript) .string bgmscript; -classfield(BGMScript) .float bgmscriptattack; -classfield(BGMScript) .float bgmscriptdecay; -classfield(BGMScript) .float bgmscriptsustain; -classfield(BGMScript) .float bgmscriptrelease; +#include "bgmscript.qh" #include -#include "../../lib/csqcmodel/sv_model.qh" - -.float modelscale; +#include void g_model_setcolormaptoactivator(entity this, entity actor, entity trigger) { diff --git a/qcsrc/common/mapobjects/models.qh b/qcsrc/common/mapobjects/models.qh index 45346dc8e..8d2e98d15 100644 --- a/qcsrc/common/mapobjects/models.qh +++ b/qcsrc/common/mapobjects/models.qh @@ -1,5 +1,7 @@ #pragma once +.float modelscale; + #ifdef CSQC entityclass(Wall); classfield(Wall) .float lip; diff --git a/qcsrc/common/mapobjects/trigger/counter.qc b/qcsrc/common/mapobjects/trigger/counter.qc index 44cbd9045..765d3180e 100644 --- a/qcsrc/common/mapobjects/trigger/counter.qc +++ b/qcsrc/common/mapobjects/trigger/counter.qc @@ -1,9 +1,11 @@ #include "counter.qh" -#ifdef SVQC -void counter_reset(entity this); +#ifdef SVQC void counter_use(entity this, entity actor, entity trigger) { + if(this.active != ACTIVE_ACTIVE) + return; + entity store = this; if(this.spawnflags & COUNTER_PER_PLAYER) { @@ -66,6 +68,7 @@ void counter_reset(entity this) setthink(this, func_null); this.nextthink = 0; this.counter_cnt = 0; + this.active = ACTIVE_ACTIVE; } /*QUAKED spawnfunc_trigger_counter (.5 .5 .5) ? nomessage COUNTER_FIRE_AT_COUNT @@ -86,5 +89,6 @@ spawnfunc(trigger_counter) this.counter_cnt = 0; this.use = counter_use; this.reset = counter_reset; + this.active = ACTIVE_ACTIVE; } #endif diff --git a/qcsrc/common/mapobjects/trigger/counter.qh b/qcsrc/common/mapobjects/trigger/counter.qh index 403a87a89..a34e95b83 100644 --- a/qcsrc/common/mapobjects/trigger/counter.qh +++ b/qcsrc/common/mapobjects/trigger/counter.qh @@ -1,7 +1,7 @@ #pragma once #ifdef SVQC -spawnfunc(trigger_counter); +void counter_reset(entity this); .float counter_cnt; diff --git a/qcsrc/common/mapobjects/trigger/delay.qc b/qcsrc/common/mapobjects/trigger/delay.qc index 2cd4cfd13..7e593a56c 100644 --- a/qcsrc/common/mapobjects/trigger/delay.qc +++ b/qcsrc/common/mapobjects/trigger/delay.qc @@ -1,4 +1,5 @@ #include "delay.qh" + #ifdef SVQC void delay_delayeduse(entity this) { @@ -8,6 +9,9 @@ void delay_delayeduse(entity this) void delay_use(entity this, entity actor, entity trigger) { + if(this.active != ACTIVE_ACTIVE) + return; + this.enemy = actor; this.goalentity = trigger; setthink(this, delay_delayeduse); @@ -19,6 +23,7 @@ void delay_reset(entity this) this.enemy = this.goalentity = NULL; setthink(this, func_null); this.nextthink = 0; + this.active = ACTIVE_ACTIVE; } spawnfunc(trigger_delay) @@ -28,5 +33,6 @@ spawnfunc(trigger_delay) this.use = delay_use; this.reset = delay_reset; + this.active = ACTIVE_ACTIVE; } #endif diff --git a/qcsrc/common/mapobjects/trigger/gamestart.qc b/qcsrc/common/mapobjects/trigger/gamestart.qc index 72d76d183..e7ed67c45 100644 --- a/qcsrc/common/mapobjects/trigger/gamestart.qc +++ b/qcsrc/common/mapobjects/trigger/gamestart.qc @@ -1,14 +1,10 @@ #include "gamestart.qh" + #ifdef SVQC void gamestart_use(entity this, entity actor, entity trigger) { SUB_UseTargets(this, this, trigger); - delete(this); -} - -void gamestart_use_this(entity this) -{ - gamestart_use(this, NULL, NULL); + delete(this); // TODO: deleting this means it can't be used upon map reset! } spawnfunc(trigger_gamestart) @@ -22,7 +18,6 @@ spawnfunc(trigger_gamestart) this.nextthink = game_starttime + this.wait; } else - InitializeEntity(this, gamestart_use_this, INITPRIO_FINDTARGET); + InitializeEntity(this, adaptor_think2use, INITPRIO_FINDTARGET); } - #endif diff --git a/qcsrc/common/mapobjects/trigger/keylock.qc b/qcsrc/common/mapobjects/trigger/keylock.qc index f7ecd7c1f..626a588dc 100644 --- a/qcsrc/common/mapobjects/trigger/keylock.qc +++ b/qcsrc/common/mapobjects/trigger/keylock.qc @@ -169,16 +169,6 @@ spawnfunc(trigger_keylock) trigger_keylock_link(this); } #elif defined(CSQC) -void keylock_remove(entity this) -{ - strfree(this.target); - strfree(this.target2); - strfree(this.target3); - strfree(this.target4); - strfree(this.killtarget); - strfree(this.targetname); -} - NET_HANDLE(ENT_CLIENT_KEYLOCK, bool isnew) { this.itemkeys = ReadInt24_t(); @@ -189,6 +179,6 @@ NET_HANDLE(ENT_CLIENT_KEYLOCK, bool isnew) return = true; this.classname = "trigger_keylock"; - this.entremove = keylock_remove; + this.entremove = trigger_remove_generic; } #endif -- 2.39.2