Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
bloodloss.qc
Go to the documentation of this file.
1#include "bloodloss.qh"
2
3#ifdef GAMEQC
4#ifdef SVQC
6#elif defined(CSQC)
7REGISTER_MUTATOR(bloodloss, true);
8#endif
9
10#ifdef SVQC
12
14{
15 entity player = M_ARGV(0, entity);
16
17 if(game_stopped)
18 return; // during intermission, the player's health changes to strange values for the engine, let's not cause damage during this phase!
19
20 if(IS_PLAYER(player))
21 if(GetResource(player, RES_HEALTH) <= autocvar_g_bloodloss && !IS_DEAD(player) && time >= player.bloodloss_timer)
22 {
23 if(player.vehicle)
24 vehicles_exit(player.vehicle, VHEF_RELEASE); // TODO: boots player out of their vehicle each health rot tick!
25 if(player.event_damage)
26 player.event_damage(player, player, player, 1, DEATH_ROT.m_id, DMG_NOWEP, player.origin, '0 0 0');
27 player.bloodloss_timer = time + 0.5 + random() * 0.5;
28 }
29}
30
31MUTATOR_HOOKFUNCTION(bloodloss, PlayerCanCrouch)
32{
33 entity player = M_ARGV(0, entity);
34 if(GetResource(player, RES_HEALTH) <= autocvar_g_bloodloss)
35 M_ARGV(1, bool) = true; // do_crouch
36}
37
39{
40 entity player = M_ARGV(0, entity);
41
42 if(GetResource(player, RES_HEALTH) <= autocvar_g_bloodloss)
43 return true;
44}
45
46MUTATOR_HOOKFUNCTION(bloodloss, BuildMutatorsString)
47{
48 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":bloodloss");
49}
50
51MUTATOR_HOOKFUNCTION(bloodloss, BuildMutatorsPrettyString)
52{
53 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Blood loss");
54}
55#endif
56
57#ifdef CSQC
58MUTATOR_HOOKFUNCTION(bloodloss, PlayerCanCrouch)
59{
60 if(STAT(HEALTH) > 0 && STAT(HEALTH) <= STAT(BLOODLOSS))
61 M_ARGV(1, bool) = true; // do_crouch
62}
64{
65 if(STAT(HEALTH) > 0 && STAT(HEALTH) <= STAT(BLOODLOSS))
66 return true;
67}
68#endif
69
70#endif
71#ifdef MENUQC
72METHOD(MutatorBloodLoss, describe, string(MutatorBloodLoss this))
73{
74 TC(MutatorBloodLoss, this);
76 PAR(_("%s is a mutator in which players below a certain health threshold (for example 25) will suffer blood loss."), COLORED_NAME(this));
77 PAR(_("Blood loss makes players stunned, severely impairs their movement, and rapidly takes away health points until they either die or gain enough health to go above the health threshold."));
78 return PAGE_TEXT;
79}
80#endif
#define REGISTER_MUTATOR(...)
Definition base.qh:295
#define MUTATOR_HOOKFUNCTION(...)
Definition base.qh:335
float bloodloss_timer
Definition bloodloss.qc:11
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
#define COLORED_NAME(this)
Definition color.qh:195
#define M_ARGV(x, type)
Definition events.qh:17
bool PlayerJump(entity this)
Definition player.qc:378
#define IS_DEAD(s)
Definition player.qh:245
#define IS_PLAYER(s)
Definition player.qh:243
float autocvar_g_bloodloss
Definition stats.qh:328
float game_stopped
Definition stats.qh:81
float time
#define DMG_NOWEP
Definition damage.qh:104
#define PlayerPreThink
Definition _all.inc:254
#define TC(T, sym)
Definition _all.inc:82
#define STAT(...)
Definition stats.qh:82
float random(void)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define METHOD(cname, name, prototype)
Definition oo.qh:269
#define PAGE_TEXT
Definition string.qh:643
#define PAR(...)
Adds an individually translatable paragraph to PAGE_TEXT without having to deal with strcat and sprin...
Definition string.qh:649
#define PAGE_TEXT_INIT()
Definition string.qh:642
void vehicles_exit(entity vehic, bool eject)
const int VHEF_RELEASE
User pressed exit key 3 times fast (not implemented) or vehicle is dying.