]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Remove some more g_lms checks & add a use for mega health (disabled by default)
authorMario <mario.mario@y7mail.com>
Sat, 4 May 2013 22:39:21 +0000 (08:39 +1000)
committerMario <mario.mario@y7mail.com>
Sat, 4 May 2013 22:39:21 +0000 (08:39 +1000)
gamemodes.cfg
qcsrc/server/arena.qc
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc
qcsrc/server/g_damage.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/gamemode_lms.qc

index af8d3e83d825411b18c8b58356711a49a46be44e..0f69b6c465021e2cb9c8df131e4970ac3c96f978 100644 (file)
@@ -333,6 +333,7 @@ set g_keyhunt_teams 0
 // ===================
 set g_lms 0 "Last Man Standing: everyone starts with a certain amount of lives, and the survivor wins"
 set g_lms_lives_override -1
+set g_lms_extra_lives 0
 set g_lms_regenerate 0
 set g_lms_campcheck_interval 10
 set g_lms_campcheck_damage 100
index 34b81bb62a1bb0d6c2b077ddc4e3d602c863c094..f7af963591e7c0cf23f599aa9b07a3863658e3e4 100644 (file)
@@ -108,8 +108,6 @@ void reset_map(float dorespawn)
                                        //NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
                                        if (self.classname == "player") {
                                                //PlayerScore_Clear(self);
-                                               if(g_lms)
-                                                       PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives());
                                                self.killcount = 0;
                                                //stop the player from moving so that he stands still once he gets respawned
                                                self.velocity = '0 0 0';
index 15ad76c8745c700de4f0c2a2d464eb42459c15e3..108a91fb7ad3ca2281650ad2fce1a278b909f1dc 100644 (file)
@@ -861,6 +861,7 @@ float autocvar_g_keyhunt_teams;
 float autocvar_g_keyhunt_teams_override;
 float autocvar_g_lms_campcheck_damage;
 float autocvar_g_lms_campcheck_distance;
+float autocvar_g_lms_extra_lives;
 float autocvar_g_lms_campcheck_interval;
 float autocvar_g_lms_join_anytime;
 float autocvar_g_lms_last_join;
index 10ed3b94a77feb3d3626fe85696f0619d3dd2769..26393d79c6b07280ae05f8fd463fe7952857ddb7 100644 (file)
@@ -406,13 +406,9 @@ void PutObserverInServer (void)
        if not(g_ca)  // don't reset teams when moving a ca player to the spectators
                self.team = -1;  // move this as it is needed to log the player spectating in eventlog
 
-       if(self.killcount != -666) {
-               if(g_lms) {
-                       if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0 && self.lms_spectate_warning != 2)
-                               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_LMS_NOLIVES, self.netname);
-                       else
-                               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_LMS_FORFEIT, self.netname);
-               } else { Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_SPECTATE, self.netname); }
+       if(self.killcount != -666)
+       {
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_SPECTATE, self.netname);
 
                if(self.just_joined == FALSE) {
                        LogTeamchange(self.playerid, -1, 4);
@@ -1966,7 +1962,7 @@ void player_regen (void)
        limita = limita * limit_mod;
        //limitf = limitf * limit_mod;
 
-       if(g_lms && g_ca)
+       if(g_lms || g_ca)
                rot_mod = 0;
 
        if (!g_minstagib && !g_ca && (!g_lms || autocvar_g_lms_regenerate))
@@ -2651,39 +2647,6 @@ void PlayerPreThink (void)
                        return;
                }
 
-               if(g_lms && !self.deadflag && autocvar_g_lms_campcheck_interval)
-               {
-                       vector dist;
-
-                       // calculate player movement (in 2 dimensions only, so jumping on one spot doesn't count as movement)
-                       dist = self.prevorigin - self.origin;
-                       dist_z = 0;
-                       self.lms_traveled_distance += fabs(vlen(dist));
-
-                       if((autocvar_g_campaign && !campaign_bots_may_start) || (time < game_starttime))
-                       {
-                               self.lms_nextcheck = time + autocvar_g_lms_campcheck_interval*2;
-                               self.lms_traveled_distance = 0;
-                       }
-
-                       if(time > self.lms_nextcheck)
-                       {
-                               //sprint(self, "distance: ", ftos(self.lms_traveled_distance), "\n");
-                               if(self.lms_traveled_distance < autocvar_g_lms_campcheck_distance)
-                               {
-                                       Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_LMS_CAMPCHECK);
-                                       // FIXME KadaverJack: gibbing player here causes playermodel to bounce around, instead of eye.md3
-                                       // I wasn't able to find out WHY that happens, so I put a workaround in place that shall prevent players from being gibbed :(
-                                       if(self.vehicle)
-                                               Damage(self.vehicle, self, self, autocvar_g_lms_campcheck_damage * 2, DEATH_CAMP, self.vehicle.origin, '0 0 0');
-                                       else
-                                               Damage(self, self, self, bound(0, autocvar_g_lms_campcheck_damage, self.health + self.armorvalue * autocvar_g_balance_armor_blockpercent + 5), DEATH_CAMP, self.origin, '0 0 0');
-                               }
-                               self.lms_nextcheck = time + autocvar_g_lms_campcheck_interval;
-                               self.lms_traveled_distance = 0;
-                       }
-               }
-
                self.prevorigin = self.origin;
 
                float do_crouch = self.BUTTON_CROUCH;
index 62abce46cb9b6bbb505c6f63a4c0872f03155ab3..33be3086e4162ed804d4d342f94afb3bc15b922e 100644 (file)
@@ -681,14 +681,6 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float
                        }
                }
 
-               if(targ.classname == "player")
-               if(attacker.classname == "player")
-               if(attacker != targ)
-               {
-                       targ.lms_traveled_distance = autocvar_g_lms_campcheck_distance;
-                       attacker.lms_traveled_distance = autocvar_g_lms_campcheck_distance;
-               }
-
                if(targ.classname == "player")
                if (g_minstagib)
                {
index 2663e79ea5b9f745770e6b6c1c9675253681c570..61e48ad8c7a695945e00aea70054e95b196baeed 100644 (file)
@@ -750,7 +750,7 @@ void readplayerstartcvars()
        s = cvar_string("g_weaponarena");
        if (s == "0" || s == "")
        {
-               if(g_lms || g_ca)
+               if(g_ca)
                        s = "most";
        }
 
index 6266fbfc20b3818694957f18af660f792b7c5aaf..88f5fcc3a41a1c1e8d2eccab6b9ca036103b7828 100644 (file)
@@ -18,6 +18,15 @@ float LMS_NewPlayerLives()
 }
 
 // mutator hooks
+MUTATOR_HOOKFUNCTION(lms_PlayerSpawn)
+{
+       if(IS_PLAYER(self))
+       if(restart_mapalreadyrestarted || (time < game_starttime))
+               PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives());
+               
+       return FALSE;
+}
+
 MUTATOR_HOOKFUNCTION(lms_RemovePlayer)
 {
        // Only if the player cannot play at all
@@ -26,6 +35,12 @@ MUTATOR_HOOKFUNCTION(lms_RemovePlayer)
        else
                self.frags = FRAGS_LMS_LOSER;
                
+       if(self.killcount != -666)
+               if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0 && self.lms_spectate_warning != 2)
+                       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_LMS_NOLIVES, self.netname);
+               else
+                       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_LMS_FORFEIT, self.netname);
+               
        return FALSE;
 }
 
@@ -48,6 +63,50 @@ MUTATOR_HOOKFUNCTION(lms_PlayerThink)
        if(self.deadflag == DEAD_DYING)
                self.deadflag = DEAD_RESPAWNING;
                
+       if not(self.deadflag)
+       if(autocvar_g_lms_campcheck_interval)
+       {
+               vector dist;
+
+               // calculate player movement (in 2 dimensions only, so jumping on one spot doesn't count as movement)
+               dist = self.prevorigin - self.origin;
+               dist_z = 0;
+               self.lms_traveled_distance += fabs(vlen(dist));
+
+               if((autocvar_g_campaign && !campaign_bots_may_start) || (time < game_starttime))
+               {
+                       self.lms_nextcheck = time + autocvar_g_lms_campcheck_interval*2;
+                       self.lms_traveled_distance = 0;
+               }
+
+               if(time > self.lms_nextcheck)
+               {
+                       if(self.lms_traveled_distance < autocvar_g_lms_campcheck_distance)
+                       {
+                               Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_LMS_CAMPCHECK);
+                               if(self.vehicle)
+                                       Damage(self.vehicle, self, self, autocvar_g_lms_campcheck_damage * 2, DEATH_CAMP, self.vehicle.origin, '0 0 0');
+                               else
+                                       Damage(self, self, self, bound(0, autocvar_g_lms_campcheck_damage, self.health + self.armorvalue * autocvar_g_balance_armor_blockpercent + 5), DEATH_CAMP, self.origin, '0 0 0');
+                       }
+                       self.lms_nextcheck = time + autocvar_g_lms_campcheck_interval;
+                       self.lms_traveled_distance = 0;
+               }
+       }
+               
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(lms_PlayerDamage)
+{
+       if(IS_PLAYER(frag_target))
+       if(IS_PLAYER(frag_attacker))
+       if(frag_attacker != frag_target)
+       {
+               frag_target.lms_traveled_distance = autocvar_g_lms_campcheck_distance;
+               frag_attacker.lms_traveled_distance = autocvar_g_lms_campcheck_distance;
+       }
+               
        return FALSE;
 }
 
@@ -80,6 +139,12 @@ MUTATOR_HOOKFUNCTION(lms_GiveFragsForKill)
 
 MUTATOR_HOOKFUNCTION(lms_SetStartItems)
 {
+       string s;
+       
+       s = cvar_string("g_weaponarena");
+       if (s == "0" || s == "")
+               s = "most";
+       
        start_items &~= IT_UNLIMITED_AMMO;
        start_ammo_shells = cvar("g_lms_start_ammo_shells");
        start_ammo_nails = cvar("g_lms_start_ammo_nails");
@@ -100,10 +165,25 @@ MUTATOR_HOOKFUNCTION(lms_KeepScore)
 
 MUTATOR_HOOKFUNCTION(lms_FilterItem)
 {
-       // no items in LMS
+       if(autocvar_g_lms_extra_lives)
+       if(self.classname == "item_health_mega")
+       {
+               self.max_health = 1;
+               return FALSE;
+       }
+       
        return TRUE;
 }
 
+MUTATOR_HOOKFUNCTION(lms_ItemTouch)
+{
+       // give extra lives for mega health
+       if(self.items & IT_HEALTH)
+               PlayerScore_Add(other, SP_LMS_LIVES, autocvar_g_lms_extra_lives);
+       
+       return FALSE;
+}
+
 MUTATOR_HOOKFUNCTION(lms_BotSpawn)
 {
        // temporary hack to give bots lives
@@ -135,14 +215,17 @@ void lms_Initialize()
 
 MUTATOR_DEFINITION(gamemode_lms)
 {
+       MUTATOR_HOOK(PlayerSpawn, lms_PlayerSpawn, CBC_ORDER_ANY);
        MUTATOR_HOOK(MakePlayerObserver, lms_RemovePlayer, CBC_ORDER_ANY);
        MUTATOR_HOOK(ClientConnect, lms_ClientConnect, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerPreThink, lms_PlayerThink, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayerDamage_Calculate, lms_PlayerDamage, CBC_ORDER_ANY);
        MUTATOR_HOOK(ForbidThrowCurrentWeapon, lms_ForbidThrowing, CBC_ORDER_ANY);
        MUTATOR_HOOK(GiveFragsForKill, lms_GiveFragsForKill, CBC_ORDER_ANY);
        MUTATOR_HOOK(SetStartItems, lms_SetStartItems, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerClearScore, lms_KeepScore, CBC_ORDER_ANY);
        MUTATOR_HOOK(FilterItem, lms_FilterItem, CBC_ORDER_ANY);
+       MUTATOR_HOOK(ItemTouch, lms_ItemTouch, CBC_ORDER_ANY);
        MUTATOR_HOOK(HavocBot_ChooseRule, lms_BotSpawn, CBC_ORDER_ANY);
 
        MUTATOR_ONADD