From: Rudolf Polzer Date: Thu, 12 Jan 2012 13:47:33 +0000 (+0100) Subject: use a timer for superweapons X-Git-Tag: xonotic-v0.6.0~177^2^2~14 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9f58b36e27184e7f58686ce19fad82b49f444f80;p=xonotic%2Fxonotic-data.pk3dir.git use a timer for superweapons --- diff --git a/balance25.cfg b/balance25.cfg index 612f6f108..f65ee473f 100644 --- a/balance25.cfg +++ b/balance25.cfg @@ -205,6 +205,7 @@ set g_balance_powerup_strength_force 4 set g_balance_powerup_strength_time 30 set g_balance_powerup_strength_selfdamage 1.5 set g_balance_powerup_strength_selfforce 1.5 +set g_balance_superweapons_time 30 // }}} // {{{ jetpack/hook diff --git a/balanceFruitieX.cfg b/balanceFruitieX.cfg index e135c805b..9777b904d 100644 --- a/balanceFruitieX.cfg +++ b/balanceFruitieX.cfg @@ -205,6 +205,7 @@ set g_balance_powerup_strength_force 4 set g_balance_powerup_strength_time 30 set g_balance_powerup_strength_selfdamage 1.5 set g_balance_powerup_strength_selfforce 1.5 +set g_balance_superweapons_time 30 // }}} // {{{ jetpack/hook diff --git a/balanceXPM.cfg b/balanceXPM.cfg index 57286d56a..a15f060d0 100644 --- a/balanceXPM.cfg +++ b/balanceXPM.cfg @@ -205,6 +205,7 @@ set g_balance_powerup_strength_force 3 set g_balance_powerup_strength_time 30 set g_balance_powerup_strength_selfdamage 1.5 set g_balance_powerup_strength_selfforce 1.5 +set g_balance_superweapons_time 30 // }}} // {{{ jetpack/hook diff --git a/balanceXonotic.cfg b/balanceXonotic.cfg index 13a4f9f6f..d42284a30 100644 --- a/balanceXonotic.cfg +++ b/balanceXonotic.cfg @@ -205,6 +205,7 @@ set g_balance_powerup_strength_force 3 set g_balance_powerup_strength_time 30 set g_balance_powerup_strength_selfdamage 1.5 set g_balance_powerup_strength_selfforce 1.5 +set g_balance_superweapons_time 30 // }}} // {{{ jetpack/hook diff --git a/qcsrc/common/items.qh b/qcsrc/common/items.qh index c98ff786b..b4088fc0a 100644 --- a/qcsrc/common/items.qh +++ b/qcsrc/common/items.qh @@ -94,6 +94,7 @@ float WEP_FIRST = 1; float WEP_LAST; #define WEP_MAXCOUNT 24 float WEPBIT_ALL; +float WEPBIT_SUPERWEAPONS; #define REGISTER_WEAPON_2(id,bit,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname) \ float id; \ float bit; \ @@ -102,6 +103,8 @@ float WEPBIT_ALL; { \ WEP_LAST = (id = WEP_FIRST + WEP_COUNT); \ WEPBIT_ALL |= (bit = power2of(WEP_COUNT)); \ + if(ammotype & IT_SUPERWEAPON) \ + WEPBIT_SUPERWEAPONS |= (bit = power2of(WEP_COUNT)); \ ++WEP_COUNT; \ register_weapon(id,func,ammotype,i,weapontype,pickupbasevalue,modelname,shortname,wname); \ } \ diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 538d65307..1111909b3 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -568,6 +568,7 @@ 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; +float autocvar_g_balance_superweapons_time; float autocvar_g_balance_rocketlauncher_ammo; float autocvar_g_balance_rocketlauncher_animtime; float autocvar_g_balance_rocketlauncher_damage; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 298fd47e3..fa2acdd9b 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -474,6 +474,7 @@ void PutObserverInServer (void) self.pain_finished = 0; self.strength_finished = 0; self.invincible_finished = 0; + self.superweapons_finished = 0; self.pushltime = 0; self.think = SUB_Null; self.nextthink = 0; @@ -750,6 +751,11 @@ void PutClientInServer (void) self.weapons = start_weapons; } + if(self.weapons & WEPBIT_SUPERWEAPONS) + self.superweapons_finished = time + autocvar_g_balance_superweapons_time; + else + self.superweapons_finished = 0; + if(g_weaponarena_random) { if(g_weaponarena_random_with_laser) @@ -1887,6 +1893,31 @@ void player_powerups (void) sprint(self, "^3Shield surrounds you\n"); } } + if (self.items & IT_SUPERWEAPON) + { + play_countdown(self.superweapons_finished, "misc/poweroff.wav"); + self.effects = self.effects | EF_RED; + if (self.items & IT_UNLIMITED_SUPERWEAPONS) + { + // don't let them run out + } + else if (time > self.superweapons_finished) + { + self.items = self.items - (self.items & IT_SUPERWEAPON); + self.weapons &~= WEPBIT_SUPERWEAPONS; + sprint(self, "^3Superweapons have broken down\n"); + } + } + else + { + if (time < self.superweapons_finished) + { + self.items = self.items | IT_SUPERWEAPON; + sprint(self, "^3You now have a superweapon\n"); + } + else + self.weapons &~= WEPBIT_SUPERWEAPONS; // just in case + } } if(autocvar_g_nodepthtestplayers) diff --git a/qcsrc/server/cl_weapons.qc b/qcsrc/server/cl_weapons.qc index b1f6aabba..b3169bed5 100644 --- a/qcsrc/server/cl_weapons.qc +++ b/qcsrc/server/cl_weapons.qc @@ -170,7 +170,9 @@ float W_WeaponBit(float wpn) float W_AmmoItemCode(float wpn) { - return (get_weaponinfo(wpn)).items; + float f = (get_weaponinfo(wpn)).items; + f &~= IT_SUPERWEAPON; + return f; } void thrown_wep_think() @@ -198,7 +200,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto wep.colormap = own.colormap; wa = W_AmmoItemCode(wpn); - if(wa == IT_SUPERWEAPON || wa == 0) + if(wa == 0) { oldself = self; self = wep; @@ -288,14 +290,14 @@ float W_IsWeaponThrowable(float w) wb = W_WeaponBit(w); if(!wb) return 0; + if(wb & WEPBIT_SUPERWEAPONS) // can't throw a superweapon, they don't work + return 0; wa = W_AmmoItemCode(w); if(start_weapons & wb) { - if(wa == IT_SUPERWEAPON && start_items & IT_UNLIMITED_SUPERWEAPONS) - return 0; - if(wa != IT_SUPERWEAPON && start_items & IT_UNLIMITED_WEAPON_AMMO) - return 0; // start weapons that take no ammo can't be dropped (this prevents dropping the laser, as long as it continues to use no ammo) + if(start_items & IT_UNLIMITED_WEAPON_AMMO) + return 0; if(wa == 0) return 0; } diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 53bfde7ce..22d9e54d6 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -91,9 +91,8 @@ float maxclients; .float crouch; // Crouching or not? .float strength_finished; -//.float speed_finished; .float invincible_finished; -//.float slowmo_finished; +.float superweapons_finished; .vector finaldest, finalangle; //plat.qc stuff .void() think1; diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index e2c68b24e..791e2d5d6 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -265,7 +265,7 @@ void Item_RespawnCountdown (void) void Item_ScheduleRespawnIn(entity e, float t) { - if((e.flags & FL_POWERUP) || (e.items & IT_SUPERWEAPON)) + if((e.flags & FL_POWERUP) || (e.weapons & WEPBIT_SUPERWEAPONS)) { e.think = Item_RespawnCountdown; e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS); @@ -461,12 +461,17 @@ float Item_GiveTo(entity item, entity player) if (item.strength_finished) { pickedup = TRUE; - player.strength_finished = max(player.strength_finished, time) + autocvar_g_balance_powerup_strength_time; + player.strength_finished = max(player.strength_finished, time) + item.strength_finished; } if (item.invincible_finished) { pickedup = TRUE; - player.invincible_finished = max(player.invincible_finished, time) + autocvar_g_balance_powerup_invincible_time; + player.invincible_finished = max(player.invincible_finished, time) + item.invincible_finished; + } + if (item.superweapons_finished) + { + pickedup = TRUE; + player.superweapons_finished = max(player.superweapons_finished, time) + item.superweapons_finished; } } @@ -893,7 +898,8 @@ void minstagib_items (float itemid) // replace with invis if (itemid == IT_STRENGTH) { - self.strength_finished = 30; + if(!self.strength_finished) + self.strength_finished = autocvar_g_balance_powerup_strength_time; StartItem ("models/items/g_strength.md3", "misc/powerup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Invisibility", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, BOT_PICKUP_RATING_MID); @@ -909,7 +915,8 @@ void minstagib_items (float itemid) // replace with speed if (itemid == IT_INVINCIBLE) { - self.invincible_finished = 30; + if(!self.invincible_finished) + self.invincible_finished = autocvar_g_balance_powerup_invincible_time; StartItem ("models/items/g_invincible.md3", "misc/powerup_shield.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Speed", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, BOT_PICKUP_RATING_MID); @@ -999,12 +1006,9 @@ void weapon_defaultspawnfunc(float wpn) e = get_weaponinfo(wpn); - if(e.items & IT_SUPERWEAPON) - self.items |= IT_SUPERWEAPON; - if(!self.respawntime) { - if(self.items & IT_SUPERWEAPON) + if(self.weapons & WEPBIT_SUPERWEAPONS) { self.respawntime = g_pickup_respawntime_superweapon; self.respawntimejitter = g_pickup_respawntimejitter_superweapon; @@ -1016,6 +1020,10 @@ void weapon_defaultspawnfunc(float wpn) } } + if(self.weapons & WEPBIT_SUPERWEAPONS) + if(!self.superweapons_finished) + self.superweapons_finished = autocvar_g_balance_superweapons_time; + if(e.items) { for(i = 0, j = 1; i < 24; ++i, j *= 2) @@ -1030,7 +1038,7 @@ void weapon_defaultspawnfunc(float wpn) } // no weapon-stay on superweapons - if(self.items & IT_SUPERWEAPON) + if(self.weapons & WEPBIT_SUPERWEAPONS) self.flags |= FL_NO_WEAPON_STAY; // weapon stay isn't supported for teamed weapons @@ -1248,7 +1256,8 @@ void spawnfunc_item_strength (void) { minstagib_items(IT_STRENGTH); } else { precache_sound("weapons/strength_fire.wav"); - self.strength_finished = 30; + if(!self.strength_finished) + self.strength_finished = autocvar_g_balance_powerup_strength_time; StartItem ("models/items/g_strength.md3", "misc/powerup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Strength Powerup", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, 100000); } } @@ -1257,7 +1266,8 @@ void spawnfunc_item_invincible (void) { if(g_minstagib) { minstagib_items(IT_INVINCIBLE); } else { - self.invincible_finished = 30; + if(!self.invincible_finished) + self.invincible_finished = autocvar_g_balance_powerup_invincible_time; StartItem ("models/items/g_invincible.md3", "misc/powerup_shield.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Shield", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, 100000); } }