Xonotic
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
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"))) {
10  g_grappling_hook = true;
11  if(!autocvar_g_grappling_hook_useammo)
12  WEP_HOOK.ammo_factor = 0;
13  }
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
OffhandHook OFFHAND_HOOK
Definition: hook.qh:67
entity hook
Definition: hook.qh:19
#define REGISTER_MUTATOR(id, dependence)
Definition: base.qh:263
float start_ammo_fuel
Definition: world.qh:90
entity() spawn
int start_items
Definition: world.qh:84
#define AUTOCVAR(...)
Definition: cvar.qh:161
#define MUTATOR_ONROLLBACK_OR_REMOVE
Definition: base.qh:286
float warmup_start_ammo_fuel
Definition: world.qh:109
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define M_ARGV(x, type)
Definition: events.qh:17
float g_grappling_hook
Definition: world.qh:116
#define MUTATOR_HOOKFUNCTION(...)
Definition: base.qh:310
#define MUTATOR_ONADD
Definition: base.qh:284
ERASEABLE bool expr_evaluate(string s)
Evaluate an expression of the form: [+ | -]? [var[op]val | [op]var | val | var] ...
Definition: cvar.qh:48