X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmapobjects%2Ftrigger%2Fcounter.qc;h=765d3180e2619d118edeeeda0c521d5e6858a74c;hp=9156439f99e3bf19bb9bdc8425efe1fdcd06d53d;hb=4bd11aeeefd1c90b1dd3a55beaf13f5e48de083b;hpb=c72d8802ab6a8df4072e8342a5fe8750619c5855 diff --git a/qcsrc/common/mapobjects/trigger/counter.qc b/qcsrc/common/mapobjects/trigger/counter.qc index 9156439f99..765d3180e2 100644 --- a/qcsrc/common/mapobjects/trigger/counter.qc +++ b/qcsrc/common/mapobjects/trigger/counter.qc @@ -1,15 +1,32 @@ #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) { if(!IS_PLAYER(actor)) return; - store = actor; + entity mycounter = NULL; + IL_EACH(g_counters, it.realowner == actor && it.owner == this, + { + mycounter = it; + break; + }); + if(!mycounter) + { + mycounter = new_pure(counter); + IL_PUSH(g_counters, mycounter); + mycounter.owner = this; + mycounter.realowner = actor; + mycounter.reset = counter_reset; // NOTE: this may be useless as the player deletes their counters upon respawning + mycounter.counter_cnt = 0; + } + store = mycounter; } store.counter_cnt += 1; @@ -27,8 +44,8 @@ void counter_use(entity this, entity actor, entity trigger) if(this.respawntime) { - setthink(this, counter_reset); - this.nextthink = time + this.respawntime; + setthink(store, counter_reset); + store.nextthink = time + this.respawntime; } } else @@ -51,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 @@ -71,5 +89,6 @@ spawnfunc(trigger_counter) this.counter_cnt = 0; this.use = counter_use; this.reset = counter_reset; + this.active = ACTIVE_ACTIVE; } #endif