From c8d66db83f8a671d97f88a358b5d4941debb0640 Mon Sep 17 00:00:00 2001 From: Freddy Date: Tue, 6 Mar 2018 15:42:58 +0100 Subject: [PATCH] Move entity spawnflags to a common file --- qcsrc/common/triggers/func/bobbing.qc | 4 +- qcsrc/common/triggers/func/bobbing.qh | 1 + qcsrc/common/triggers/func/button.qc | 1 + qcsrc/common/triggers/func/button.qh | 2 - qcsrc/common/triggers/func/door.qc | 4 +- qcsrc/common/triggers/func/door.qh | 13 +---- qcsrc/common/triggers/func/door_rotating.qh | 6 --- qcsrc/common/triggers/func/door_secret.qc | 16 +++--- qcsrc/common/triggers/func/door_secret.qh | 8 +-- qcsrc/common/triggers/platforms.qh | 4 +- qcsrc/common/triggers/spawnflags.qh | 59 +++++++++++++++++++++ qcsrc/common/triggers/teleporters.qh | 5 +- qcsrc/common/triggers/trigger/jumppads.qc | 1 - qcsrc/common/triggers/trigger/jumppads.qh | 4 +- qcsrc/common/triggers/trigger/viewloc.qh | 5 +- qcsrc/common/triggers/triggers.qh | 8 +-- 16 files changed, 80 insertions(+), 61 deletions(-) create mode 100644 qcsrc/common/triggers/spawnflags.qh diff --git a/qcsrc/common/triggers/func/bobbing.qc b/qcsrc/common/triggers/func/bobbing.qc index ff8841a57..b647e15a8 100644 --- a/qcsrc/common/triggers/func/bobbing.qc +++ b/qcsrc/common/triggers/func/bobbing.qc @@ -59,9 +59,9 @@ spawnfunc(func_bobbing) this.dmgtime2 = time; // how far to bob - if (this.spawnflags & 1) // X + if (this.spawnflags & BOBBING_XAXIS) this.movedir = '1 0 0' * this.height; - else if (this.spawnflags & 2) // Y + else if (this.spawnflags & BOBBING_YAXIS) this.movedir = '0 1 0' * this.height; else // Z this.movedir = '0 0 1' * this.height; diff --git a/qcsrc/common/triggers/func/bobbing.qh b/qcsrc/common/triggers/func/bobbing.qh index 6f70f09be..7c39519e1 100644 --- a/qcsrc/common/triggers/func/bobbing.qh +++ b/qcsrc/common/triggers/func/bobbing.qh @@ -1 +1,2 @@ #pragma once +#include "../spawnflags.qh" diff --git a/qcsrc/common/triggers/func/button.qc b/qcsrc/common/triggers/func/button.qc index 4f2d01fcd..8e5e3530e 100644 --- a/qcsrc/common/triggers/func/button.qc +++ b/qcsrc/common/triggers/func/button.qc @@ -1,4 +1,5 @@ #include "button.qh" +#include "../spawnflags.qh" #ifdef SVQC // button and multiple button diff --git a/qcsrc/common/triggers/func/button.qh b/qcsrc/common/triggers/func/button.qh index 75a6006eb..6f70f09be 100644 --- a/qcsrc/common/triggers/func/button.qh +++ b/qcsrc/common/triggers/func/button.qh @@ -1,3 +1 @@ #pragma once - -const int BUTTON_DONTACCUMULATEDMG = 128; diff --git a/qcsrc/common/triggers/func/door.qc b/qcsrc/common/triggers/func/door.qc index 6b3161669..5b4fae043 100644 --- a/qcsrc/common/triggers/func/door.qc +++ b/qcsrc/common/triggers/func/door.qc @@ -239,12 +239,12 @@ void door_fire(entity this, entity actor, entity trigger) door_go_up(e, actor, trigger); } else { // if the BIDIR spawnflag (==2) is set and the trigger has set trigger_reverse, reverse the opening direction - if ((e.spawnflags & BIDIR) && trigger.trigger_reverse!=0 && e.lip != 666 && e.state == STATE_BOTTOM) { + if ((e.spawnflags & DOOR_ROTATING_BIDIR) && trigger.trigger_reverse!=0 && e.lip != 666 && e.state == STATE_BOTTOM) { e.lip = 666; // e.lip is used to remember reverse opening direction for door_rotating e.pos2 = '0 0 0' - e.pos2; } // if BIDIR_IN_DOWN (==8) is set, prevent the door from reoping during closing if it is triggered from the wrong side - if (!((e.spawnflags & BIDIR) && (e.spawnflags & BIDIR_IN_DOWN) && e.state == STATE_DOWN + if (!((e.spawnflags & DOOR_ROTATING_BIDIR) && (e.spawnflags & DOOR_ROTATING_BIDIR_IN_DOWN) && e.state == STATE_DOWN && (((e.lip == 666) && (trigger.trigger_reverse == 0)) || ((e.lip != 666) && (trigger.trigger_reverse != 0))))) { door_rotating_go_up(e, trigger); diff --git a/qcsrc/common/triggers/func/door.qh b/qcsrc/common/triggers/func/door.qh index 23ba20df1..faf137d6b 100644 --- a/qcsrc/common/triggers/func/door.qh +++ b/qcsrc/common/triggers/func/door.qh @@ -1,17 +1,6 @@ #pragma once +#include "../spawnflags.qh" -// door constants -const int DOOR_START_OPEN = BIT(0); -const int DOOR_DONT_LINK = BIT(2); -const int DOOR_TOGGLE = BIT(5); - -const int DOOR_NOSPLASH = BIT(8); // generic anti-splashdamage spawnflag - -const int DOOR_NONSOLID = BIT(10); -const int DOOR_CRUSH = BIT(11); // can't use PLAT_CRUSH cause that is the same as DOOR_DONT_LINK - -const int SPAWNFLAGS_GOLD_KEY = BIT(3); -const int SPAWNFLAGS_SILVER_KEY = BIT(4); #ifdef CSQC // stuff for preload diff --git a/qcsrc/common/triggers/func/door_rotating.qh b/qcsrc/common/triggers/func/door_rotating.qh index eaffcf606..a5cf76932 100644 --- a/qcsrc/common/triggers/func/door_rotating.qh +++ b/qcsrc/common/triggers/func/door_rotating.qh @@ -1,12 +1,6 @@ #pragma once -const int BIDIR = BIT(1); -const int BIDIR_IN_DOWN = BIT(3); - -const int DOOR_ROTATING_XAXIS = BIT(6); -const int DOOR_ROTATING_YAXIS = BIT(7); - #ifdef GAMEQC void door_rotating_go_down(entity this); void door_rotating_go_up(entity this, entity oth); diff --git a/qcsrc/common/triggers/func/door_secret.qc b/qcsrc/common/triggers/func/door_secret.qc index 35b2296f8..78e0dd64e 100644 --- a/qcsrc/common/triggers/func/door_secret.qc +++ b/qcsrc/common/triggers/func/door_secret.qc @@ -35,12 +35,12 @@ void fd_secret_use(entity this, entity actor, entity trigger) _sound(this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM); this.nextthink = this.ltime + 0.1; - temp = 1 - (this.spawnflags & SECRET_1ST_LEFT); // 1 or -1 + temp = 1 - (this.spawnflags & DOOR_SECRET_1ST_LEFT); // 1 or -1 makevectors(this.mangle); if (!this.t_width) { - if (this.spawnflags & SECRET_1ST_DOWN) + if (this.spawnflags & DOOR_SECRET_1ST_DOWN) this.t_width = fabs(v_up * this.size); else this.t_width = fabs(v_right * this.size); @@ -49,7 +49,7 @@ void fd_secret_use(entity this, entity actor, entity trigger) if (!this.t_length) this.t_length = fabs(v_forward * this.size); - if (this.spawnflags & SECRET_1ST_DOWN) + if (this.spawnflags & DOOR_SECRET_1ST_DOWN) this.dest1 = this.origin - v_up * this.t_width; else this.dest1 = this.origin + v_right * (this.t_width * temp); @@ -87,7 +87,7 @@ void fd_secret_move3(entity this) { if (this.noise3 != "") _sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM); - if (!(this.spawnflags & SECRET_OPEN_ONCE) && this.wait >= 0) + if (!(this.spawnflags & DOOR_SECRET_OPEN_ONCE) && this.wait >= 0) { this.nextthink = this.ltime + this.wait; setthink(this, fd_secret_move4); @@ -120,7 +120,7 @@ void fd_secret_move6(entity this) void fd_secret_done(entity this) { - if (this.spawnflags&SECRET_YES_SHOOT) + if (this.spawnflags&DOOR_SECRET_YES_SHOOT) { this.health = 10000; this.takedamage = DAMAGE_YES; @@ -166,7 +166,7 @@ void secret_touch(entity this, entity toucher) void secret_reset(entity this) { - if (this.spawnflags & SECRET_YES_SHOOT) + if (this.spawnflags & DOOR_SECRET_YES_SHOOT) { this.health = 10000; this.takedamage = DAMAGE_YES; @@ -248,9 +248,9 @@ spawnfunc(func_door_secret) { } else - this.spawnflags |= SECRET_YES_SHOOT; + this.spawnflags |= DOOR_SECRET_YES_SHOOT; - if (this.spawnflags & SECRET_YES_SHOOT) + if (this.spawnflags & DOOR_SECRET_YES_SHOOT) { //this.canteamdamage = true; // TODO this.health = 10000; diff --git a/qcsrc/common/triggers/func/door_secret.qh b/qcsrc/common/triggers/func/door_secret.qh index 92134648f..7c39519e1 100644 --- a/qcsrc/common/triggers/func/door_secret.qh +++ b/qcsrc/common/triggers/func/door_secret.qh @@ -1,8 +1,2 @@ #pragma once - - -const int SECRET_OPEN_ONCE = BIT(0); // stays open - LEGACY, set wait to -1 instead -const int SECRET_1ST_LEFT = BIT(1); // 1st move is left of arrow -const int SECRET_1ST_DOWN = BIT(2); // 1st move is down from arrow -const int SECRET_NO_SHOOT = BIT(3); // only opened by trigger -const int SECRET_YES_SHOOT = BIT(4); // shootable even if targeted +#include "../spawnflags.qh" diff --git a/qcsrc/common/triggers/platforms.qh b/qcsrc/common/triggers/platforms.qh index 72e17cd9e..83e77ef66 100644 --- a/qcsrc/common/triggers/platforms.qh +++ b/qcsrc/common/triggers/platforms.qh @@ -1,4 +1,5 @@ #pragma once +#include "spawnflags.qh" .float dmgtime2; @@ -8,8 +9,5 @@ void plat_trigger_use(entity this, entity actor, entity trigger); void plat_go_up(entity this); void plat_go_down(entity this); void plat_crush(entity this, entity blocker); -const float PLAT_LOW_TRIGGER = 1; - -const int PLAT_CRUSH = BIT(2); .float dmg; diff --git a/qcsrc/common/triggers/spawnflags.qh b/qcsrc/common/triggers/spawnflags.qh new file mode 100644 index 000000000..051a24309 --- /dev/null +++ b/qcsrc/common/triggers/spawnflags.qh @@ -0,0 +1,59 @@ +#pragma once + +// bobbing +const int BOBBING_XAXIS = BIT(0); +const int BOBBING_YAXIS = BIT(1); + +// button +const int BUTTON_DONTACCUMULATEDMG = BIT(7); + +// door, door_rotating and door_secret +const int DOOR_START_OPEN = BIT(0); +const int DOOR_DONT_LINK = BIT(2); +const int SPAWNFLAGS_GOLD_KEY = BIT(3); // Quake 1 compat, can only be used with func_door! +const int SPAWNFLAGS_SILVER_KEY = BIT(4); // Quake 1 compat, can only be used with func_door! +const int DOOR_TOGGLE = BIT(5); + +const int DOOR_NOSPLASH = BIT(8); // generic anti-splashdamage spawnflag + +const int DOOR_NONSOLID = BIT(10); +const int DOOR_CRUSH = BIT(11); // can't use PLAT_CRUSH cause that is the same as DOOR_DONT_LINK + +const int DOOR_ROTATING_BIDIR = BIT(1); +const int DOOR_ROTATING_BIDIR_IN_DOWN = BIT(3); + +const int DOOR_ROTATING_XAXIS = BIT(6); +const int DOOR_ROTATING_YAXIS = BIT(7); + +const int DOOR_SECRET_OPEN_ONCE = BIT(0); // stays open - LEGACY, set wait to -1 instead +const int DOOR_SECRET_1ST_LEFT = BIT(1); // 1st move is left of arrow +const int DOOR_SECRET_1ST_DOWN = BIT(2); // 1st move is down from arrow +const int DOOR_SECRET_NO_SHOOT = BIT(3); // only opened by trigger +const int DOOR_SECRET_YES_SHOOT = BIT(4); // shootable even if targeted + +// jumppads +const int PUSH_ONCE = BIT(0); +const int PUSH_SILENT = BIT(1); // not used? + +// viewloc +const int VIEWLOC_NOSIDESCROLL = BIT(0); // NOTE: currently unimplemented +const int VIEWLOC_FREEAIM = BIT(1); +const int VIEWLOC_FREEMOVE = BIT(2); + +// platforms +const int PLAT_LOW_TRIGGER = BIT(0); +const int PLAT_CRUSH = BIT(2); + +// teleport +const int TELEPORT_FLAG_SOUND = BIT(0); +const int TELEPORT_FLAG_PARTICLES = BIT(1); +const int TELEPORT_FLAG_TDEATH = BIT(2); +const int TELEPORT_FLAG_FORCE_TDEATH = BIT(3); + +// triggers +const int SF_TRIGGER_INIT = BIT(0); +const int SF_TRIGGER_UPDATE = BIT(1); +const int SF_TRIGGER_RESET = BIT(2); + +const int SPAWNFLAG_NOMESSAGE = BIT(0); +const int SPAWNFLAG_NOTOUCH = BIT(0); // why are these the same? diff --git a/qcsrc/common/triggers/teleporters.qh b/qcsrc/common/triggers/teleporters.qh index 6f5b2b595..6056e0696 100644 --- a/qcsrc/common/triggers/teleporters.qh +++ b/qcsrc/common/triggers/teleporters.qh @@ -1,13 +1,10 @@ #pragma once +#include "spawnflags.qh" IntrusiveList g_teleporters; STATIC_INIT(g_teleporters) { g_teleporters = IL_NEW(); } .entity pusher; -const float TELEPORT_FLAG_SOUND = 1; -const float TELEPORT_FLAG_PARTICLES = 2; -const float TELEPORT_FLAG_TDEATH = 4; -const float TELEPORT_FLAG_FORCE_TDEATH = 8; #define TELEPORT_FLAGS_WARPZONE 0 #define TELEPORT_FLAGS_PORTAL (TELEPORT_FLAG_SOUND | TELEPORT_FLAG_PARTICLES | TELEPORT_FLAG_TDEATH | TELEPORT_FLAG_FORCE_TDEATH) diff --git a/qcsrc/common/triggers/trigger/jumppads.qc b/qcsrc/common/triggers/trigger/jumppads.qc index fde6e1fb9..53e93d4a2 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qc +++ b/qcsrc/common/triggers/trigger/jumppads.qc @@ -1,7 +1,6 @@ #include "jumppads.qh" // TODO: split target_push and put it in the target folder #ifdef SVQC -#include "jumppads.qh" #include void trigger_push_use(entity this, entity actor, entity trigger) diff --git a/qcsrc/common/triggers/trigger/jumppads.qh b/qcsrc/common/triggers/trigger/jumppads.qh index 50ed0a343..99aa5cb81 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qh +++ b/qcsrc/common/triggers/trigger/jumppads.qh @@ -1,11 +1,9 @@ #pragma once +#include "../spawnflags.qh" IntrusiveList g_jumppads; STATIC_INIT(g_jumppads) { g_jumppads = IL_NEW(); } -const float PUSH_ONCE = 1; -const float PUSH_SILENT = 2; - .float pushltime; .float istypefrag; .float height; diff --git a/qcsrc/common/triggers/trigger/viewloc.qh b/qcsrc/common/triggers/trigger/viewloc.qh index 69c6c821e..d8e2bb3d8 100644 --- a/qcsrc/common/triggers/trigger/viewloc.qh +++ b/qcsrc/common/triggers/trigger/viewloc.qh @@ -1,11 +1,8 @@ #pragma once +#include "../spawnflags.qh" .entity viewloc; -const int VIEWLOC_NOSIDESCROLL = BIT(0); // NOTE: currently unimplemented -const int VIEWLOC_FREEAIM = BIT(1); -const int VIEWLOC_FREEMOVE = BIT(2); - #ifdef CSQC .entity goalentity; .entity enemy; diff --git a/qcsrc/common/triggers/triggers.qh b/qcsrc/common/triggers/triggers.qh index 2b8274f4b..b609d1d54 100644 --- a/qcsrc/common/triggers/triggers.qh +++ b/qcsrc/common/triggers/triggers.qh @@ -1,11 +1,5 @@ #pragma once - -const float SF_TRIGGER_INIT = 1; -const float SF_TRIGGER_UPDATE = 2; -const float SF_TRIGGER_RESET = 4; - -const float SPAWNFLAG_NOMESSAGE = 1; -const float SPAWNFLAG_NOTOUCH = 1; +#include "spawnflags.qh" .bool pushable; -- 2.39.2