]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Un-revert previous change, and give trigger_counter a new spawnflag to keep the count...
authorMario <zacjardine@y7mail.com>
Sun, 16 Sep 2018 04:14:41 +0000 (14:14 +1000)
committerMario <zacjardine@y7mail.com>
Sun, 16 Sep 2018 04:14:41 +0000 (14:14 +1000)
qcsrc/common/mapobjects/trigger/counter.qc
qcsrc/common/mapobjects/trigger/counter.qh
qcsrc/server/client.qc
qcsrc/server/compat/quake3.qc

index 4c89c4c27ed20efc86f73a678c615d68aa82673b..9156439f99e3bf19bb9bdc8425efe1fdcd06d53d 100644 (file)
@@ -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;
 }
index 9edf776b36509b5c4dc58fc4c75bc19c57c83526..d36bd0293cc933ead43f3e2248b46d157cdc91c3 100644 (file)
@@ -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);
index 045d00150b12dcbe1c2ab7090d32c9949a424d9f..ccaf3c0fa92b864d2c7e7f90d6f5cea670bb53bc 100644 (file)
@@ -37,6 +37,7 @@
 #include "../common/mapobjects/func/conveyor.qh"
 #include "../common/mapobjects/teleporters.qh"
 #include "../common/mapobjects/target/spawnpoint.qh"
+#include <common/mapobjects/trigger/counter.qh>
 
 #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
index 1ce6f5be0664013ab1569012d3390847a09bdaf4..c85034b840947e3f1b71f93ac647f6176fc8cb47 100644 (file)
@@ -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 */