]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix crouching not being applied while in bloodloss
authorMario <mario.mario@y7mail.com>
Mon, 6 Jan 2020 12:29:58 +0000 (22:29 +1000)
committerMario <mario.mario@y7mail.com>
Mon, 6 Jan 2020 12:29:58 +0000 (22:29 +1000)
qcsrc/common/mutators/events.qh
qcsrc/common/mutators/mutator/bloodloss/bloodloss.qc
qcsrc/common/physics/player.qc

index cf858487058de2bbeac734fff836481bae3e4504..6ee9574d057ed13876ea96d22e8ac7bc1dd72f42 100644 (file)
@@ -112,3 +112,11 @@ MUTATOR_HOOKABLE(WeaponSound, EV_WeaponSound);
     /**/          o(string, MUTATOR_ARGV_1_string) \
     /**/
 MUTATOR_HOOKABLE(WeaponModel, EV_WeaponModel);
+
+/** decides whether a player can crouch or not */
+#define EV_PlayerCanCrouch(i, o) \
+    /** player */      i(entity, MUTATOR_ARGV_0_entity) \
+    /** do_crouch */   i(bool, MUTATOR_ARGV_1_bool) \
+    /**/               o(bool, MUTATOR_ARGV_1_bool) \
+    /**/
+MUTATOR_HOOKABLE(PlayerCanCrouch, EV_PlayerCanCrouch);
index c92a088693e4846dd40b7b4bc2c874fa8edf68fc..2a0ebec455a3016b192630684880ab66703dcbd5 100644 (file)
@@ -18,21 +18,23 @@ MUTATOR_HOOKFUNCTION(bloodloss, PlayerPreThink)
                return; // during intermission, the player's health changes to strange values for the engine, let's not cause damage during this phase!
 
        if(IS_PLAYER(player))
-       if(GetResource(player, RES_HEALTH) <= autocvar_g_bloodloss && !IS_DEAD(player))
+       if(GetResource(player, RES_HEALTH) <= autocvar_g_bloodloss && !IS_DEAD(player) && time >= player.bloodloss_timer)
        {
-               PHYS_INPUT_BUTTON_CROUCH(player) = true;
-
-               if(time >= player.bloodloss_timer)
-               {
-                       if(player.vehicle)
-                               vehicles_exit(player.vehicle, VHEF_RELEASE); // TODO: boots player out of their vehicle each health rot tick!
-                       if(player.event_damage)
-                               player.event_damage(player, player, player, 1, DEATH_ROT.m_id, DMG_NOWEP, player.origin, '0 0 0');
-                       player.bloodloss_timer = time + 0.5 + random() * 0.5;
-               }
+               if(player.vehicle)
+                       vehicles_exit(player.vehicle, VHEF_RELEASE); // TODO: boots player out of their vehicle each health rot tick!
+               if(player.event_damage)
+                       player.event_damage(player, player, player, 1, DEATH_ROT.m_id, DMG_NOWEP, player.origin, '0 0 0');
+               player.bloodloss_timer = time + 0.5 + random() * 0.5;
        }
 }
 
+MUTATOR_HOOKFUNCTION(bloodloss, PlayerCanCrouch)
+{
+       entity player = M_ARGV(0, entity);
+       if(GetResource(player, RES_HEALTH) <= autocvar_g_bloodloss)
+               M_ARGV(1, bool) = true; // do_crouch
+}
+
 MUTATOR_HOOKFUNCTION(bloodloss, PlayerJump)
 {
        entity player = M_ARGV(0, entity);
@@ -53,6 +55,11 @@ MUTATOR_HOOKFUNCTION(bloodloss, BuildMutatorsPrettyString)
 #endif
 
 #ifdef CSQC
+MUTATOR_HOOKFUNCTION(bloodloss, PlayerCanCrouch)
+{
+       if(STAT(HEALTH) <= STAT(BLOODLOSS))
+               M_ARGV(1, bool) = true; // do_crouch
+}
 MUTATOR_HOOKFUNCTION(bloodloss, PlayerJump)
 {
        if(STAT(HEALTH) <= STAT(BLOODLOSS))
index 5ba6e82685b3204ce2caa5da04c5862253f0c974..9f7ddab502d31764b79c546bfd40fc3b8e7b176e 100644 (file)
@@ -145,6 +145,9 @@ void PM_ClientMovement_UpdateStatus(entity this)
                do_crouch = false;
     }
 
+    MUTATOR_CALLHOOK(PlayerCanCrouch, this, do_crouch);
+    do_crouch = M_ARGV(1, bool);
+
        if (do_crouch) {
                if (!IS_DUCKED(this)) {
                        SET_DUCKED(this);