]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
powerups: fix #2857 and move g_powerups cvar out of server/items/items.qc
authorbones_was_here <bones_was_here@xonotic.au>
Tue, 4 Jul 2023 12:26:24 +0000 (22:26 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Sun, 16 Jul 2023 09:11:00 +0000 (19:11 +1000)
This sets ITEM_FLAG_NORMAL initially and adds ITEM_FLAG_MUTATORBLOCKED
about as late as possible: must be done after mapinfo settemps are
applied, see b95beb262077d8f733bbee7cb0d5f4c05b7b3e2f
and before StartItem() calls have_pickup_item().

Moves a little more powerup-specific code out of common code.

Removes some default powerup balance settings which don't need to be in QC.

Clarifies var naming inside powerup m_iteminit() funcs.

qcsrc/common/mutators/mutator/powerups/powerup/invisibility.qh
qcsrc/common/mutators/mutator/powerups/powerup/shield.qh
qcsrc/common/mutators/mutator/powerups/powerup/speed.qh
qcsrc/common/mutators/mutator/powerups/powerup/strength.qh
qcsrc/server/items/items.qc

index 53264eeb2e2ccd69f72de9d5a1fa2768c7fbd85a..bf8d8fb10a903820e9ad9e546c444c05b9274c19 100644 (file)
@@ -16,15 +16,13 @@ SOUND(Invisibility, Item_Sound("powerup"));
 #ifdef SVQC
 .float invisibility_finished;
 
-bool autocvar_g_powerups_invisibility = 1;
-float autocvar_g_balance_powerup_invisibility_alpha = 0.15;
-float autocvar_g_balance_powerup_invisibility_time = 30;
-void powerup_invisibility_init(Pickup this, entity item)
+bool autocvar_g_powerups_invisibility;
+float autocvar_g_balance_powerup_invisibility_alpha;
+float autocvar_g_balance_powerup_invisibility_time;
+void powerup_invisibility_init(Pickup def, entity item)
 {
-    if(autocvar_g_powerups_invisibility)
-        this.spawnflags = ITEM_FLAG_NORMAL;
-    else
-        this.spawnflags = ITEM_FLAG_MUTATORBLOCKED;
+    if(!autocvar_g_powerups || !autocvar_g_powerups_invisibility)
+        def.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
 
     if(!item.invisibility_finished)
         item.invisibility_finished = (item.count) ? item.count : autocvar_g_balance_powerup_invisibility_time;
@@ -36,6 +34,7 @@ REGISTER_ITEM(Invisibility, Powerup) {
     this.m_iteminit         =   powerup_invisibility_init;
 #endif
 #ifdef GAMEQC
+    this.spawnflags         =   ITEM_FLAG_NORMAL;
     this.m_itemid           =   IT_INVISIBILITY;
     this.m_model            =   MDL_BUFF; // TODO: MDL_Invisibility_ITEM when new model available
     this.m_skin             =   12;
index d665fb894d37c77eccfe563ed892cb78f4f73183..de2f5dc29a40b544cce37631070c358460b731fb 100644 (file)
@@ -14,16 +14,14 @@ SOUND(Shield, Item_Sound("powerup_shield"));
 #endif
 
 #ifdef SVQC
-bool autocvar_g_powerups_shield = 1;
+bool autocvar_g_powerups_shield;
 float autocvar_g_balance_powerup_invincible_takedamage;
-float autocvar_g_balance_powerup_invincible_takeforce = 0.33;
+float autocvar_g_balance_powerup_invincible_takeforce;
 float autocvar_g_balance_powerup_invincible_time;
-void powerup_shield_init(Pickup this, entity item)
+void powerup_shield_init(Pickup def, entity item)
 {
-    if(autocvar_g_powerups_shield)
-        this.spawnflags = ITEM_FLAG_NORMAL;
-    else
-        this.spawnflags = ITEM_FLAG_MUTATORBLOCKED;
+    if(!autocvar_g_powerups || !autocvar_g_powerups_shield)
+        def.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
 
     if(!item.invincible_finished)
         item.invincible_finished = (item.count) ? item.count : autocvar_g_balance_powerup_invincible_time;
@@ -35,6 +33,7 @@ REGISTER_ITEM(Shield, Powerup) {
     this.m_iteminit         =   powerup_shield_init;
 #endif
 #ifdef GAMEQC
+    this.spawnflags         =   ITEM_FLAG_NORMAL;
     this.m_itemid           =   IT_INVINCIBLE;
     this.m_model            =   MDL_Shield_ITEM;
     this.m_sound            =   SND_Shield;
index 4bda28e35917ffeb02904adad7210048948e0a25..c816fec53a7ffc8f3fc6d48c2dad5bbe853c1f11 100644 (file)
@@ -16,16 +16,14 @@ SOUND(Speed, Item_Sound("powerup_shield"));
 #ifdef SVQC
 .float speed_finished;
 
-bool autocvar_g_powerups_speed = 1;
-float autocvar_g_balance_powerup_speed_attackrate = 0.8;
-float autocvar_g_balance_powerup_speed_highspeed = 1.5;
-float autocvar_g_balance_powerup_speed_time = 30;
-void powerup_speed_init(Pickup this, entity item)
+bool autocvar_g_powerups_speed;
+float autocvar_g_balance_powerup_speed_attackrate;
+float autocvar_g_balance_powerup_speed_highspeed;
+float autocvar_g_balance_powerup_speed_time;
+void powerup_speed_init(Pickup def, entity item)
 {
-    if(autocvar_g_powerups_speed)
-        this.spawnflags = ITEM_FLAG_NORMAL;
-    else
-        this.spawnflags = ITEM_FLAG_MUTATORBLOCKED;
+    if(!autocvar_g_powerups || !autocvar_g_powerups_speed)
+        def.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
 
     if(!item.speed_finished)
         item.speed_finished = (item.count) ? item.count : autocvar_g_balance_powerup_speed_time;
@@ -37,6 +35,7 @@ REGISTER_ITEM(Speed, Powerup) {
     this.m_iteminit         =   powerup_speed_init;
 #endif
 #ifdef GAMEQC
+    this.spawnflags         =   ITEM_FLAG_NORMAL;
     this.m_itemid           =   IT_SPEED;
     this.m_model            =   MDL_BUFF; // TODO: MDL_Speed_ITEM when new model available
     this.m_skin             =   9;
index aea3bcf2f31c74190afddef9749186b428f411f2..79ef229f1cbbf751b5b0a39ac5b76ab7f6fa70d4 100644 (file)
@@ -14,18 +14,16 @@ SOUND(Strength, Item_Sound("powerup"));
 #endif
 
 #ifdef SVQC
-bool autocvar_g_powerups_strength = 1;
+bool autocvar_g_powerups_strength;
 float autocvar_g_balance_powerup_strength_damage;
 float autocvar_g_balance_powerup_strength_force;
 float autocvar_g_balance_powerup_strength_selfdamage;
 float autocvar_g_balance_powerup_strength_selfforce;
 float autocvar_g_balance_powerup_strength_time;
-void powerup_strength_init(Pickup this, entity item)
+void powerup_strength_init(Pickup def, entity item)
 {
-    if(autocvar_g_powerups_strength)
-        this.spawnflags = ITEM_FLAG_NORMAL;
-    else
-        this.spawnflags = ITEM_FLAG_MUTATORBLOCKED;
+    if(!autocvar_g_powerups || !autocvar_g_powerups_strength)
+        def.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
 
     if(!item.strength_finished)
         item.strength_finished = (item.count) ? item.count : autocvar_g_balance_powerup_strength_time;
@@ -37,6 +35,7 @@ REGISTER_ITEM(Strength, Powerup) {
     this.m_iteminit         =   powerup_strength_init;
 #endif
 #ifdef GAMEQC
+    this.spawnflags         =   ITEM_FLAG_NORMAL;
     this.m_itemid           =   IT_STRENGTH;
     this.m_model            =   MDL_Strength_ITEM;
     this.m_sound            =   SND_Strength;
index b5f8d7e83e4288655d3923199416ca619a653759..b05da99c5d443221f31999512d67efbf3e309e97 100644 (file)
@@ -100,14 +100,7 @@ bool have_pickup_item(entity this)
        if (this.itemdef.spawnflags & ITEM_FLAG_MUTATORBLOCKED)
                return false;
 
-       if(this.itemdef.instanceOfPowerup)
-       {
-               if(autocvar_g_powerups > 0)
-                       return true;
-               if(autocvar_g_powerups == 0)
-                       return false;
-       }
-       else
+       if(!this.itemdef.instanceOfPowerup)
        {
                if(autocvar_g_pickup_items > 0)
                        return true;