]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/hook/sv_hook.qc
Transifex autosync
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / hook / sv_hook.qc
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
6 AUTOCVAR(g_grappling_hook_useammo, bool, false, "Use ammunition with the off-hand grappling hook");
7
8 REGISTER_MUTATOR(hook, expr_evaluate(cvar_string("g_grappling_hook"))) {
9     MUTATOR_ONADD {
10         g_grappling_hook = true;
11         if(!autocvar_g_grappling_hook_useammo)
12             WEP_HOOK.ammo_factor = 0;
13     }
14     MUTATOR_ONROLLBACK_OR_REMOVE {
15         g_grappling_hook = false;
16         if(!autocvar_g_grappling_hook_useammo)
17             WEP_HOOK.ammo_factor = 1; // we don't need to change it
18     }
19
20     return false;
21 }
22
23 MUTATOR_HOOKFUNCTION(hook, BuildMutatorsString)
24 {
25     M_ARGV(0, string) = strcat(M_ARGV(0, string), ":grappling_hook");
26 }
27
28 MUTATOR_HOOKFUNCTION(hook, BuildMutatorsPrettyString)
29 {
30     M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Hook");
31 }
32
33 MUTATOR_HOOKFUNCTION(hook, SetStartItems)
34 {
35     if(autocvar_g_grappling_hook_useammo)
36     {
37         start_items |= ITEM_JetpackRegen.m_itemid;
38         start_ammo_fuel = max(start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
39         warmup_start_ammo_fuel = max(warmup_start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
40     }
41 }
42
43 MUTATOR_HOOKFUNCTION(hook, PlayerSpawn)
44 {
45     entity player = M_ARGV(0, entity);
46
47     player.offhand = OFFHAND_HOOK;
48 }
49
50 MUTATOR_HOOKFUNCTION(hook, FilterItem)
51 {
52     entity item = M_ARGV(0, entity);
53
54     return item.weapon == WEP_HOOK.m_id;
55 }
56
57 #endif