]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add basic relay activation support to standard items
authorMario <mario.mario@y7mail.com>
Wed, 31 Jul 2024 05:27:46 +0000 (15:27 +1000)
committerMario <mario.mario@y7mail.com>
Wed, 31 Jul 2024 05:27:46 +0000 (15:27 +1000)
qcsrc/server/items/items.qc

index f43fa3b3dc0cbc2d708f0a28bb541eaa26f8bc9e..8506926e9442cf80966c27a4744f37ea0d0b54cc 100644 (file)
@@ -980,6 +980,18 @@ void item_use(entity this, entity actor, entity trigger)
        gettouch(this)(this, actor);
 }
 
+void item_setactive(entity this, int act)
+{
+       int old_status = this.active;
+       if(act == ACTIVE_TOGGLE)
+               this.active = (this.active == ACTIVE_ACTIVE) ? ACTIVE_NOT : ACTIVE_ACTIVE;
+       else
+               this.active = act;
+
+       if(this.active != old_status)
+               Item_Show(this, ((this.active == ACTIVE_ACTIVE) ? 1 : -1));
+}
+
 void StartItem(entity this, entity def)
 {
        if (def.m_spawnfunc_hookreplace)
@@ -1146,6 +1158,9 @@ void StartItem(entity this, entity def)
                if(this.targetname != "" && (this.spawnflags & 16))
                        this.use = item_use;
 
+               this.setactive = item_setactive;
+               this.active = ACTIVE_ACTIVE;
+
                if(autocvar_spawn_debug >= 2)
                {
                        // why not flags & fl_item?