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