]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/mutators/events.qh
Merge branch 'master' into Mario/target_teleporter_v2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / mutators / events.qh
1 #pragma once
2
3 #include <common/mutators/base.qh>
4
5 /**
6  * Called when a client command is parsed
7  * NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
8  * NOTE: return true if you handled the command, return false to continue handling
9  * NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
10  * // example:
11  * MUTATOR_HOOKFUNCTION(foo, CSQC_ConsoleCommand) {
12  *     if (MUTATOR_RETURNVALUE) return false; // command was already handled
13  *     string cmd_name = M_ARGV(0, string);
14  *     int cmd_argc = M_ARGV(1, int);
15  *     if (cmd_name == "echocvar" && cmd_argc >= 2) {
16  *         print(cvar_string(argv(1)), "\n");
17  *         return true;
18  *     }
19  *     if (cmd_name == "echostring" && cmd_argc >= 2) {
20  *         print(substring(cmd_string, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), "\n");
21  *         return true;
22  *     }
23  *     return false;
24  * }
25  */
26 #define EV_CSQC_ConsoleCommand(i, o) \
27         /** command name */ i(string, MUTATOR_ARGV_0_string) \
28         /** argc (also, argv() can be used) */ i(int, MUTATOR_ARGV_1_int) \
29         /** whole command, use only if you really have to */ i(string, MUTATOR_ARGV_2_string) \
30         /**/
31 MUTATOR_HOOKABLE(CSQC_ConsoleCommand, EV_CSQC_ConsoleCommand);
32
33 /* Called when the crosshair is being updated */
34 MUTATOR_HOOKABLE(UpdateCrosshair, EV_NO_ARGS);
35
36 /** Called when a projectile is linked with CSQC */
37 #define EV_Ent_Projectile(i, o) \
38         /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
39         /**/
40 MUTATOR_HOOKABLE(Ent_Projectile, EV_Ent_Projectile);
41
42 /** Called when a projectile's properties are being modified */
43 #define EV_EditProjectile(i, o) \
44         /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
45         /**/
46 MUTATOR_HOOKABLE(EditProjectile, EV_EditProjectile);
47
48 /* Called when projectiles are precached */
49 MUTATOR_HOOKABLE(PrecacheProjectiles, EV_NO_ARGS);
50
51 /** Called when updating the attached tags index */
52 #define EV_TagIndex_Update(i, o) \
53         /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
54         /**/
55 MUTATOR_HOOKABLE(TagIndex_Update, EV_TagIndex_Update);
56
57 /** Called when setting the attached tags */
58 #define EV_TagIndex_Apply(i, o) \
59         /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
60         /**/
61 MUTATOR_HOOKABLE(TagIndex_Apply, EV_TagIndex_Apply);
62
63 /** Called when setting up skeleton bones */
64 #define EV_Skeleton_CheckBones(i, o) \
65         /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
66         /**/
67 MUTATOR_HOOKABLE(Skeleton_CheckBones, EV_Skeleton_CheckBones);
68
69 /** Called when setting up bones from the loaded model */
70 #define EV_Skeleton_CheckModel(i, o) \
71         /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
72         /**/
73 MUTATOR_HOOKABLE(Skeleton_CheckModel, EV_Skeleton_CheckModel);
74
75 /** Called when clearing the global parameters for a model */
76 MUTATOR_HOOKABLE(ClearModelParams, EV_NO_ARGS);
77
78 /** Called when getting the global parameters for a model */
79 #define EV_GetModelParams(i, o) \
80         /** input */  i(string, MUTATOR_ARGV_0_string) \
81         /** command */  i(string, MUTATOR_ARGV_1_string) \
82         /**/
83 MUTATOR_HOOKABLE(GetModelParams, EV_GetModelParams);
84
85 /** Called checking if 3rd person mode should be forced on */
86 #define EV_WantEventchase(i, o) \
87         /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
88         /**/
89 MUTATOR_HOOKABLE(WantEventchase, EV_WantEventchase);
90
91 /** allow customizing 3rd person mode effect */
92 #define EV_CustomizeEventchase(i, o) \
93         /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
94         /* current_view_origin_override */ o(vector, MUTATOR_ARGV_0_vector) \
95         /* view_offset_override */ o(vector, MUTATOR_ARGV_1_vector) \
96         /* chase_distance_override */ o(float, MUTATOR_ARGV_0_float) \
97         /**/
98 MUTATOR_HOOKABLE(CustomizeEventchase, EV_CustomizeEventchase);
99
100 #define EV_AnnouncerOption(i, o) \
101         /** announcer string */  i(string, MUTATOR_ARGV_0_string) \
102         /** announcer string */ o(string, MUTATOR_ARGV_0_string) \
103         /**/
104 MUTATOR_HOOKABLE(AnnouncerOption, EV_AnnouncerOption);
105
106 MUTATOR_HOOKABLE(Ent_Init, EV_NO_ARGS);
107
108 #define EV_HUD_Draw_overlay(i, o) \
109         /**/ o(vector, MUTATOR_ARGV_0_vector) \
110         /**/ o(float, MUTATOR_ARGV_1_float) \
111         /**/
112 MUTATOR_HOOKABLE(HUD_Draw_overlay, EV_HUD_Draw_overlay);
113
114 MUTATOR_HOOKABLE(HUD_Powerups_add, EV_NO_ARGS);
115
116 /** Return true to not draw any vortex beam */
117 #define EV_Particles_VortexBeam(i, o) \
118         /** beam shot origin */  i(vector, MUTATOR_ARGV_0_vector) \
119         /** beam end position */ i(vector, MUTATOR_ARGV_1_vector) \
120         /**/
121 MUTATOR_HOOKABLE(Particles_VortexBeam, EV_Particles_VortexBeam);
122
123 /** Return true to not draw any impact effect */
124 #define EV_Weapon_ImpactEffect(i, o) \
125         /** weapon */                   i(entity, MUTATOR_ARGV_0_entity) \
126         /** damage entity */    i(entity, MUTATOR_ARGV_1_entity) \
127         /**/
128 MUTATOR_HOOKABLE(Weapon_ImpactEffect, EV_Weapon_ImpactEffect);
129
130 /* NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
131 */
132 #define EV_HUD_Command(i, o) \
133         /** argc (also, argv() can be used) */ i(int, MUTATOR_ARGV_0_int) \
134         /**/
135 MUTATOR_HOOKABLE(HUD_Command, EV_HUD_Command);
136
137 /** Draw the grapple hook, allows changing hook texture and colour */
138 #define EV_DrawGrapplingHook(i, o) \
139         /** hook */                     i(entity, MUTATOR_ARGV_0_entity) \
140         /** texture */                  i(string, MUTATOR_ARGV_1_string) \
141         /***/                                   o(string, MUTATOR_ARGV_1_string) \
142         /** colour */                   i(vector, MUTATOR_ARGV_2_vector) \
143         /***/                                   o(vector, MUTATOR_ARGV_2_vector) \
144         /** team */                     i(float, MUTATOR_ARGV_3_float) \
145         /**/
146 MUTATOR_HOOKABLE(DrawGrapplingHook, EV_DrawGrapplingHook);
147
148 /** Called when an entity is updated (either by SVQC networking or PVS) */
149 #define EV_Ent_Update(i, o) \
150         /** entity id */                i(entity, MUTATOR_ARGV_0_entity) \
151         /** is new to client */ i(bool, MUTATOR_ARGV_1_bool) \
152         /**/
153 MUTATOR_HOOKABLE(Ent_Update, EV_Ent_Update);
154
155 /** Return true to not draw crosshair */
156 MUTATOR_HOOKABLE(DrawCrosshair, EV_NO_ARGS);
157
158 /** Return true to not draw scoreboard */
159 MUTATOR_HOOKABLE(DrawScoreboard, EV_NO_ARGS);
160
161 /** Called when drawing info messages, allows adding new info messages */
162 #define EV_DrawInfoMessages(i, o) \
163         /** pos */                          i(vector, MUTATOR_ARGV_0_vector) \
164         /** mySize */                   i(vector, MUTATOR_ARGV_1_vector) \
165         /**/
166 MUTATOR_HOOKABLE(DrawInfoMessages, EV_DrawInfoMessages);
167
168 /** Called when drawing info messages, allows adding new info messages */
169 #define EV_HUD_WriteCvars(i, o) \
170         /** file */                     i(float, MUTATOR_ARGV_0_float) \
171         /**/
172 MUTATOR_HOOKABLE(HUD_WriteCvars, EV_HUD_WriteCvars);
173
174 /** Called when the view model is being animated (setorigin is called after the hook, so you only need to modify origin here if desired) */
175 #define EV_DrawViewModel(i, o) \
176         /** entity id */                i(entity, MUTATOR_ARGV_0_entity) \
177         /**/
178 MUTATOR_HOOKABLE(DrawViewModel, EV_DrawViewModel);
179
180 /** Called when updating the view's liquid contents, return true to disable the standard checks and apply your own */
181 MUTATOR_HOOKABLE(HUD_Contents, EV_NO_ARGS);
182
183 /** Return true to disable player model/color forcing */
184 #define EV_ForcePlayermodels_Skip(i, o) \
185         /** entity id */                i(entity, MUTATOR_ARGV_0_entity) \
186         /** is local */                 i(bool, MUTATOR_ARGV_1_bool) \
187         /**/
188 MUTATOR_HOOKABLE(ForcePlayermodels_Skip, EV_ForcePlayermodels_Skip);
189
190 /** Called when damage info is received on the client, useful for playing explosion effects */
191 #define EV_DamageInfo(i, o) \
192         /** entity id */                i(entity, MUTATOR_ARGV_0_entity) \
193         /** death type */               i(int, MUTATOR_ARGV_1_int) \
194         /** hit origin */               i(vector, MUTATOR_ARGV_2_vector) \
195         /**/
196 MUTATOR_HOOKABLE(DamageInfo, EV_DamageInfo);