From: bones_was_here Date: Tue, 4 Jul 2023 12:26:24 +0000 (+1000) Subject: powerups: fix #2857 and move g_powerups cvar out of server/items/items.qc X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=15e8bc08862fbec1a40805e8f7912590529e8163;p=xonotic%2Fxonotic-data.pk3dir.git powerups: fix #2857 and move g_powerups cvar out of server/items/items.qc 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. --- diff --git a/qcsrc/common/mutators/mutator/powerups/powerup/invisibility.qh b/qcsrc/common/mutators/mutator/powerups/powerup/invisibility.qh index 53264eeb2..bf8d8fb10 100644 --- a/qcsrc/common/mutators/mutator/powerups/powerup/invisibility.qh +++ b/qcsrc/common/mutators/mutator/powerups/powerup/invisibility.qh @@ -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; diff --git a/qcsrc/common/mutators/mutator/powerups/powerup/shield.qh b/qcsrc/common/mutators/mutator/powerups/powerup/shield.qh index d665fb894..de2f5dc29 100644 --- a/qcsrc/common/mutators/mutator/powerups/powerup/shield.qh +++ b/qcsrc/common/mutators/mutator/powerups/powerup/shield.qh @@ -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; diff --git a/qcsrc/common/mutators/mutator/powerups/powerup/speed.qh b/qcsrc/common/mutators/mutator/powerups/powerup/speed.qh index 4bda28e35..c816fec53 100644 --- a/qcsrc/common/mutators/mutator/powerups/powerup/speed.qh +++ b/qcsrc/common/mutators/mutator/powerups/powerup/speed.qh @@ -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; diff --git a/qcsrc/common/mutators/mutator/powerups/powerup/strength.qh b/qcsrc/common/mutators/mutator/powerups/powerup/strength.qh index aea3bcf2f..79ef229f1 100644 --- a/qcsrc/common/mutators/mutator/powerups/powerup/strength.qh +++ b/qcsrc/common/mutators/mutator/powerups/powerup/strength.qh @@ -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; diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index b5f8d7e83..b05da99c5 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -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;