]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
use a timer for superweapons
authorRudolf Polzer <divverent@alientrap.org>
Thu, 12 Jan 2012 13:47:33 +0000 (14:47 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Thu, 12 Jan 2012 13:48:11 +0000 (14:48 +0100)
balance25.cfg
balanceFruitieX.cfg
balanceXPM.cfg
balanceXonotic.cfg
qcsrc/common/items.qh
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc
qcsrc/server/cl_weapons.qc
qcsrc/server/defs.qh
qcsrc/server/t_items.qc

index 612f6f10873ea911cd66a6e4b09461cdca47f002..f65ee473fef5c9dc6beb3b5492d1c261fd8536aa 100644 (file)
@@ -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
index e135c805b1ed9b20e9bb3285b4eb1cc843a5c0d6..9777b904d78438b66489804962e25366be936354 100644 (file)
@@ -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
index 57286d56af79368e9fef2d1e501fb66d41273b81..a15f060d0f269e15068c836360fb39b888181480 100644 (file)
@@ -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
index 13a4f9f6f9a9d1c5a1d0b35eb3864cee0f7b2f8f..d42284a3066230bdd0658a16e6cdc48eeb45e3a2 100644 (file)
@@ -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
index c98ff786b9cb9c12ceaa380907930d2f0334d7bd..b4088fc0a49ab3a2a9b98df27f7a1a080ea171f1 100644 (file)
@@ -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); \
        } \
index 538d65307f1c3647d7c3264ae9c1e070ca99f42f..1111909b3ea194fcbb6df6ddc698912dcaebff24 100644 (file)
@@ -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;
index 298fd47e3c4f7273d3d461d14bf8ba041109bfc2..fa2acdd9b63270ab84fb3883c676ff90c54d679f 100644 (file)
@@ -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)
index b1f6aabba106d9728c27f967dab608f6a365a0ad..b3169bed51f36380953659cb1adf271e310a874c 100644 (file)
@@ -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;
        }
index 53bfde7ce94bd90d96c8d6f3822a6e99d71387f5..22d9e54d6c71d4c8ea4a007a157354eb23b7e6d4 100644 (file)
@@ -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;
index e2c68b24ec40461c8be232bac4eb5d46c5ce9545..791e2d5d656b03971831984ffae0dc303c7f0167 100644 (file)
@@ -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);
        }
 }