]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/hook/sv_hook.qc
Merge branch 't0uYK8Ne/set_slick_friction' into 'master'
[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, BuildGameplayTipsString)
34 {
35     M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3grappling hook^8 is enabled, press 'e' (+hook) to use it\n");
36 }
37
38 MUTATOR_HOOKFUNCTION(hook, SetStartItems)
39 {
40     if(autocvar_g_grappling_hook_useammo)
41     {
42         start_items |= ITEM_JetpackRegen.m_itemid;
43         start_ammo_fuel = max(start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
44         warmup_start_ammo_fuel = max(warmup_start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
45     }
46 }
47
48 MUTATOR_HOOKFUNCTION(hook, PlayerSpawn)
49 {
50     entity player = M_ARGV(0, entity);
51
52     player.offhand = OFFHAND_HOOK;
53 }
54
55 MUTATOR_HOOKFUNCTION(hook, FilterItem)
56 {
57     entity item = M_ARGV(0, entity);
58
59     return item.weapon == WEP_HOOK.m_id;
60 }
61
62 #endif