]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move bloodloss to the mutator system
authorMario <mario.mario@y7mail.com>
Thu, 6 Jun 2013 02:53:09 +0000 (12:53 +1000)
committerMario <mario.mario@y7mail.com>
Thu, 6 Jun 2013 02:53:09 +0000 (12:53 +1000)
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc
qcsrc/server/cl_physics.qc
qcsrc/server/defs.qh
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/base.qh
qcsrc/server/mutators/gamemode_freezetag.qc
qcsrc/server/mutators/mutator_bloodloss.qc [new file with mode: 0644]
qcsrc/server/mutators/mutators.qh
qcsrc/server/progs.src
qcsrc/server/teamplay.qc

index 9c0515281829e7f08736c31a627763040b1592ea..b110ecf5897a6d921f23f9405f1c8ccabff507e1 100644 (file)
@@ -1233,3 +1233,4 @@ float autocvar_g_touchexplode_radius;
 float autocvar_g_touchexplode_damage;
 float autocvar_g_touchexplode_edgedamage;
 float autocvar_g_touchexplode_force;
+#define autocvar_g_bloodloss cvar("g_bloodloss")
index 2477b29b05d55b297575a46f92c7692febc36182..296340ed707931e8364f3b30a7f5c13491e03c6e 100644 (file)
@@ -2346,8 +2346,6 @@ void PlayerPreThink (void)
                float do_crouch = self.BUTTON_CROUCH;
                if(self.hook.state)
                        do_crouch = 0;
-               if(self.health <= g_bloodloss)
-                       do_crouch = 1;
                if(self.vehicle)
                        do_crouch = 0;
                if(self.freezetag_frozen)
@@ -2379,15 +2377,6 @@ void PlayerPreThink (void)
                        }
                }
 
-               if(self.health <= g_bloodloss && self.deadflag == DEAD_NO)
-               {
-                       if(self.bloodloss_timer < time)
-                       {
-                               self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
-                               self.bloodloss_timer = time + 0.5 + random() * 0.5;
-                       }
-               }
-
                FixPlayermodel();
 
                GrapplingHookFrame();
index 5ce7b7d475f4d6848442b8fa9761106e5927ed2c..002c187812c70a727bc5c7a58ee7b0414c914894 100644 (file)
@@ -23,8 +23,8 @@ When you press the jump key
 */
 void PlayerJump (void)
 {
-       if(self.freezetag_frozen)
-               return; // no jumping in freezetag when frozen
+       if(MUTATOR_CALLHOOK(PlayerJump))
+               return;
 
        float mjumpheight;
        float doublejump;
@@ -110,9 +110,6 @@ void PlayerJump (void)
                if (!(self.flags & FL_JUMPRELEASED))
                        return;
 
-       if(self.health <= g_bloodloss)
-               return;
-
        // sv_jumpspeedcap_min/sv_jumpspeedcap_max act as baseline
        // velocity bounds.  Final velocity is bound between (jumpheight *
        // min + jumpheight) and (jumpheight * max + jumpheight);
index 23d1cd0eb6555edd607d72df1b0482ef32b607e8..24f251670d0199edcfe880013c7e7986927d2a86 100644 (file)
@@ -16,7 +16,7 @@ noref float require_spawnfunc_prefix; // if this float exists, only functions wi
 
 // Globals
 
-float g_cloaked, g_footsteps, g_jump_grunt, g_grappling_hook, g_minstagib, g_norecoil, g_bloodloss;
+float g_cloaked, g_footsteps, g_jump_grunt, g_grappling_hook, g_minstagib, g_norecoil;
 float g_warmup_limit;
 float g_warmup_allguns;
 float g_warmup_allow_timeout;
@@ -549,7 +549,6 @@ float client_cefc_accumulatortime;
 
 .float spectatee_status;
 .float zoomstate;
-.float bloodloss_timer;
 .float restriction;
 
 .entity clientdata;
index 176da91ef89a9c2b664ccc9a8571ca69927a27a0..522443b9ce66416ada5071a694bf19f71080f8ff 100644 (file)
@@ -920,6 +920,7 @@ void readlevelcvars(void)
        CHECK_MUTATOR_ADD("g_superspectate", mutator_superspec, 1);
        CHECK_MUTATOR_ADD("g_pinata", mutator_pinata, !cvar("g_minstagib"));
        CHECK_MUTATOR_ADD("g_midair", mutator_midair, 1);
+       CHECK_MUTATOR_ADD("g_bloodloss", mutator_bloodloss, !cvar("g_minstagib"));
        CHECK_MUTATOR_ADD("g_sandbox", sandbox, 1);
        
        #undef CHECK_MUTATOR_ADD
@@ -955,7 +956,6 @@ void readlevelcvars(void)
        g_grappling_hook = cvar("g_grappling_hook");
        g_jetpack = cvar("g_jetpack");
        g_norecoil = cvar("g_norecoil");
-       g_bloodloss = cvar("g_bloodloss");
        sv_maxidle = cvar("sv_maxidle");
        sv_maxidle_spectatorsareidle = cvar("sv_maxidle_spectatorsareidle");
        sv_autotaunt = cvar("sv_autotaunt");
index ee0da7e0cd9eb1ae4d67217bed3841521b53a95b..13fd07e3db8b68373e6eb3d7fe250efc8a4dcaa2 100644 (file)
@@ -72,6 +72,9 @@ MUTATOR_HOOKABLE(PlayerDies);
                entity frag_attacker;
                entity frag_target; // same as self
                float frag_deathtype;
+               
+MUTATOR_HOOKABLE(PlayerJump);
+       // called when a player presses the jump key
 
 MUTATOR_HOOKABLE(GiveFragsForKill);
        // called when someone was fragged by "self", and is expected to change frag_score to adjust scoring for the kill
index 82147826ee56345cad3162601515a20c05e631db..544c5ba17fd0ad642a785cde621066a85eecad58 100644 (file)
@@ -539,6 +539,14 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerDamage_Calculate)
        return 1;
 }
 
+MUTATOR_HOOKFUNCTION(freezetag_PlayerJump)
+{
+       if(self.freezetag_frozen)
+               return TRUE; // no jumping in freezetag when frozen
+       
+       return FALSE;
+}
+
 MUTATOR_HOOKFUNCTION(freezetag_ForbidThrowCurrentWeapon)
 {
        if (self.freezetag_frozen)
@@ -619,6 +627,7 @@ MUTATOR_DEFINITION(gamemode_freezetag)
        MUTATOR_HOOK(PlayerPreThink, freezetag_PlayerPreThink, CBC_ORDER_FIRST);
        MUTATOR_HOOK(PlayerPhysics, freezetag_PlayerPhysics, CBC_ORDER_FIRST);
        MUTATOR_HOOK(PlayerDamage_Calculate, freezetag_PlayerDamage_Calculate, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayerJump, freezetag_PlayerJump, CBC_ORDER_ANY);
        MUTATOR_HOOK(ForbidThrowCurrentWeapon, freezetag_ForbidThrowCurrentWeapon, CBC_ORDER_ANY);
        MUTATOR_HOOK(ItemTouch, freezetag_ItemTouch, CBC_ORDER_ANY);
        MUTATOR_HOOK(HavocBot_ChooseRule, freezetag_BotRoles, CBC_ORDER_ANY);
diff --git a/qcsrc/server/mutators/mutator_bloodloss.qc b/qcsrc/server/mutators/mutator_bloodloss.qc
new file mode 100644 (file)
index 0000000..adffdec
--- /dev/null
@@ -0,0 +1,48 @@
+.float bloodloss_timer;
+
+MUTATOR_HOOKFUNCTION(bloodloss_PlayerThink)
+{
+       if(IS_PLAYER(self))
+       if(self.health <= autocvar_g_bloodloss && self.deadflag == DEAD_NO)
+       {
+               self.BUTTON_CROUCH = TRUE;
+               
+               if(time >= self.bloodloss_timer)
+               {
+                       self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
+                       self.bloodloss_timer = time + 0.5 + random() * 0.5;
+               }
+       }
+       
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(bloodloss_PlayerJump)
+{
+       if(self.health <= autocvar_g_bloodloss)
+               return TRUE;
+               
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(bloodloss_BuildMutatorsString)
+{
+       ret_string = strcat(ret_string, ":bloodloss");
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(bloodloss_BuildMutatorsPrettyString)
+{
+       ret_string = strcat(ret_string, ", Blood loss");
+       return FALSE;
+}
+
+MUTATOR_DEFINITION(mutator_bloodloss)
+{
+       MUTATOR_HOOK(PlayerPreThink, bloodloss_PlayerThink, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayerJump, bloodloss_PlayerJump, CBC_ORDER_ANY);
+       MUTATOR_HOOK(BuildMutatorsString, bloodloss_BuildMutatorsString, CBC_ORDER_ANY);
+       MUTATOR_HOOK(BuildMutatorsPrettyString, bloodloss_BuildMutatorsPrettyString, CBC_ORDER_ANY);
+
+       return FALSE;
+}
index a27373dc3262e634425a66fa8b0ebe47cbb0489b..0c17b7ccf8fe20ce1c8e3dae690813d18b4c6a17 100644 (file)
@@ -23,5 +23,6 @@ MUTATOR_DECLARATION(mutator_minstagib);
 MUTATOR_DECLARATION(mutator_touchexplode);
 MUTATOR_DECLARATION(mutator_pinata);
 MUTATOR_DECLARATION(mutator_midair);
+MUTATOR_DECLARATION(mutator_bloodloss);
 
 MUTATOR_DECLARATION(sandbox);
index c7aa13a3c7b092941b2f3e6167591dc37d0863d1..ab86e6e58cc5b5c5d078935afc3fdf63479f8d82 100644 (file)
@@ -250,6 +250,7 @@ mutators/mutator_minstagib.qc
 mutators/mutator_touchexplode.qc
 mutators/mutator_pinata.qc
 mutators/mutator_midair.qc
+mutators/mutator_bloodloss.qc
 
 ../warpzonelib/anglestransform.qc
 ../warpzonelib/mathlib.qc
index bb27e73ed7df69918a586fc1c4fc7bef085f14e3..b481f46b3aa6185423d2999558fa0a559d9c46a7 100644 (file)
@@ -288,8 +288,6 @@ string getwelcomemessage(void)
                modifications = strcat(modifications, ", Hook");
        if(g_weapon_stay && !g_cts)
                modifications = strcat(modifications, ", Weapons stay");
-       if(g_bloodloss > 0)
-               modifications = strcat(modifications, ", Blood loss");
        if(g_jetpack)
                modifications = strcat(modifications, ", Jet pack");
        if(autocvar_g_powerups == 0)