From: Mario Date: Sun, 16 Sep 2018 04:14:41 +0000 (+1000) Subject: Un-revert previous change, and give trigger_counter a new spawnflag to keep the count... X-Git-Tag: xonotic-v0.8.5~1858 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=daf7ad89dfa8a207a5a85d0288fa98f283ac983a;p=xonotic%2Fxonotic-data.pk3dir.git Un-revert previous change, and give trigger_counter a new spawnflag to keep the count on the player --- diff --git a/qcsrc/common/mapobjects/trigger/counter.qc b/qcsrc/common/mapobjects/trigger/counter.qc index 4c89c4c27..9156439f9 100644 --- a/qcsrc/common/mapobjects/trigger/counter.qc +++ b/qcsrc/common/mapobjects/trigger/counter.qc @@ -4,13 +4,21 @@ void counter_reset(entity this); void counter_use(entity this, entity actor, entity trigger) { - this.count -= 1; - if (this.count < 0) + entity store = this; + if(this.spawnflags & COUNTER_PER_PLAYER) + { + if(!IS_PLAYER(actor)) + return; + store = actor; + } + + store.counter_cnt += 1; + if (store.counter_cnt > this.count) return; bool doactivate = (this.spawnflags & COUNTER_FIRE_AT_COUNT); - if (this.count == 0) + if (store.counter_cnt == this.count) { if(IS_PLAYER(actor) && !(this.spawnflags & SPAWNFLAG_NOMESSAGE)) Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COMPLETED); @@ -27,10 +35,10 @@ void counter_use(entity this, entity actor, entity trigger) { if(IS_PLAYER(actor) && !(this.spawnflags & SPAWNFLAG_NOMESSAGE)) { - if(this.count >= 4) + if((this.count - store.counter_cnt) >= 4) Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COUNTER); else - Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COUNTER_FEWMORE, this.count); + Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COUNTER_FEWMORE, this.count - store.counter_cnt); } } @@ -42,7 +50,7 @@ void counter_reset(entity this) { setthink(this, func_null); this.nextthink = 0; - this.count = this.cnt; + this.counter_cnt = 0; } /*QUAKED spawnfunc_trigger_counter (.5 .5 .5) ? nomessage COUNTER_FIRE_AT_COUNT @@ -59,8 +67,8 @@ spawnfunc(trigger_counter) { if (!this.count) this.count = 2; - this.cnt = this.count; + this.counter_cnt = 0; this.use = counter_use; this.reset = counter_reset; } diff --git a/qcsrc/common/mapobjects/trigger/counter.qh b/qcsrc/common/mapobjects/trigger/counter.qh index 9edf776b3..d36bd0293 100644 --- a/qcsrc/common/mapobjects/trigger/counter.qh +++ b/qcsrc/common/mapobjects/trigger/counter.qh @@ -2,6 +2,9 @@ #ifdef SVQC spawnfunc(trigger_counter); + +.float counter_cnt; #endif const int COUNTER_FIRE_AT_COUNT = BIT(2); +const int COUNTER_PER_PLAYER = BIT(3); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 045d00150..ccaf3c0fa 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -37,6 +37,7 @@ #include "../common/mapobjects/func/conveyor.qh" #include "../common/mapobjects/teleporters.qh" #include "../common/mapobjects/target/spawnpoint.qh" +#include #include "../common/vehicles/all.qh" @@ -705,6 +706,8 @@ void PutPlayerInServer(entity this) this.speedrunning = false; + this.counter_cnt = 0; + target_voicescript_clear(this); // reset fields the weapons may use diff --git a/qcsrc/server/compat/quake3.qc b/qcsrc/server/compat/quake3.qc index 1ce6f5be0..c85034b84 100644 --- a/qcsrc/server/compat/quake3.qc +++ b/qcsrc/server/compat/quake3.qc @@ -185,11 +185,12 @@ spawnfunc(target_give) } -//spawnfunc(target_fragsFilter) -//{ -// this.count = this.frags; -// spawnfunc_trigger_counter(this); -//} +spawnfunc(target_fragsFilter) +{ + this.spawnflags |= COUNTER_PER_PLAYER; + this.count = this.frags; + spawnfunc_trigger_counter(this); +} //spawnfunc(item_flight) /* handled by buffs mutator */ //spawnfunc(item_haste) /* handled by buffs mutator */