From: Mario Date: Thu, 6 Jun 2013 02:53:09 +0000 (+1000) Subject: Move bloodloss to the mutator system X-Git-Tag: xonotic-v0.8.0~366^2~42 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=603381c1f811d36ec4eb8087579e0f2b83d1c423;p=xonotic%2Fxonotic-data.pk3dir.git Move bloodloss to the mutator system --- diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 9c0515281..b110ecf58 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -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") diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 2477b29b0..296340ed7 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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(); diff --git a/qcsrc/server/cl_physics.qc b/qcsrc/server/cl_physics.qc index 5ce7b7d47..002c18781 100644 --- a/qcsrc/server/cl_physics.qc +++ b/qcsrc/server/cl_physics.qc @@ -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); diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 23d1cd0eb..24f251670 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -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; diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 176da91ef..522443b9c 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -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"); diff --git a/qcsrc/server/mutators/base.qh b/qcsrc/server/mutators/base.qh index ee0da7e0c..13fd07e3d 100644 --- a/qcsrc/server/mutators/base.qh +++ b/qcsrc/server/mutators/base.qh @@ -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 diff --git a/qcsrc/server/mutators/gamemode_freezetag.qc b/qcsrc/server/mutators/gamemode_freezetag.qc index 82147826e..544c5ba17 100644 --- a/qcsrc/server/mutators/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/gamemode_freezetag.qc @@ -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 index 000000000..adffdece9 --- /dev/null +++ b/qcsrc/server/mutators/mutator_bloodloss.qc @@ -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; +} diff --git a/qcsrc/server/mutators/mutators.qh b/qcsrc/server/mutators/mutators.qh index a27373dc3..0c17b7ccf 100644 --- a/qcsrc/server/mutators/mutators.qh +++ b/qcsrc/server/mutators/mutators.qh @@ -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); diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index c7aa13a3c..ab86e6e58 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -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 diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index bb27e73ed..b481f46b3 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -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)