Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
sv_hook.qc
Go to the documentation of this file.
1#include "sv_hook.qh"
2
3// can't use the autocvar as it doesn't work in the campaign
4//AUTOCVAR(g_grappling_hook, bool, false, "let players spawn with the Grappling Hook which allows them to pull themselves up");
5#ifdef SVQC
7
8AUTOCVAR(g_grappling_hook_useammo, bool, false, "use ammunition with the offhand Grappling Hook");
9
10REGISTER_MUTATOR(hook, expr_evaluate(cvar_string("g_grappling_hook")) && !MUTATOR_IS_ENABLED(offhand_blaster))
11{
13 g_grappling_hook = true;
14 if(!autocvar_g_grappling_hook_useammo)
15 WEP_HOOK.ammo_factor = 0;
16 }
18 g_grappling_hook = false;
19 if(!autocvar_g_grappling_hook_useammo)
20 WEP_HOOK.ammo_factor = 1; // we don't need to change it
21 }
22
23 return false;
24}
25
26MUTATOR_HOOKFUNCTION(hook, BuildMutatorsString)
27{
28 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":grappling_hook");
29}
30
31MUTATOR_HOOKFUNCTION(hook, BuildMutatorsPrettyString)
32{
33 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Hook");
34}
35
37{
38 if(autocvar_g_grappling_hook_useammo)
39 {
40 start_items |= ITEM_FuelRegen.m_itemid;
41 start_ammo_fuel = max(start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
42 warmup_start_ammo_fuel = max(warmup_start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
43 }
44}
45
47{
48 entity player = M_ARGV(0, entity);
49
50 player.offhand = OFFHAND_HOOK;
51}
52
54{
55 entity item = M_ARGV(0, entity);
56
57 return item.weapon == WEP_HOOK.m_id;
58}
59
60#endif
#define MUTATOR_ONADD
Definition base.qh:309
#define MUTATOR_ONROLLBACK_OR_REMOVE
Definition base.qh:311
#define MUTATOR_IS_ENABLED(this)
Definition base.qh:193
#define REGISTER_MUTATOR(...)
Definition base.qh:295
#define MUTATOR_HOOKFUNCTION(...)
Definition base.qh:335
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define M_ARGV(x, type)
Definition events.qh:17
entity hook
Definition player.qh:238
OffhandHook OFFHAND_HOOK
Definition hook.qh:83
ERASEABLE bool expr_evaluate(string s)
Evaluate an expression of the form: [+ | -]?
Definition cvar.qh:48
#define AUTOCVAR(...)
Definition cvar.qh:164
float cvar(string name)
const string cvar_string(string name)
float max(float f,...)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
float g_grappling_hook
Definition world.qh:112
float start_ammo_fuel
Definition world.qh:87
int start_items
Definition world.qh:82
float warmup_start_ammo_fuel
Definition world.qh:105