]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/mutators/events.qh
Merge branch 'master' into Mario/hagar_notfixed
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / mutators / events.qh
1 #pragma once
2
3 #include <common/mutators/base.qh>
4
5 // globals
6
7 string cmd_name;
8 int cmd_argc;
9 string cmd_string;
10
11 /**
12  * Called when a client command is parsed
13  * NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
14  * NOTE: return true if you handled the command, return false to continue handling
15  * NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
16  * // example:
17  * MUTATOR_HOOKFUNCTION(foo, CSQC_ConsoleCommand) {
18  *     if (MUTATOR_RETURNVALUE) return false; // command was already handled
19  *     if (cmd_name == "echocvar" && cmd_argc >= 2) {
20  *         print(cvar_string(argv(1)), "\n");
21  *         return true;
22  *     }
23  *     if (cmd_name == "echostring" && cmd_argc >= 2) {
24  *         print(substring(cmd_string, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), "\n");
25  *         return true;
26  *     }
27  *     return false;
28  * }
29  */
30 #define EV_CSQC_ConsoleCommand(i, o) \
31         /** command name */ i(string, cmd_name) \
32         /** also, argv() can be used */ i(int, cmd_argc) \
33         /** whole command, use only if you really have to */ i(string, cmd_string) \
34         /**/
35 MUTATOR_HOOKABLE(CSQC_ConsoleCommand, EV_CSQC_ConsoleCommand);
36
37 /* Called when the crosshair is being updated */
38 MUTATOR_HOOKABLE(UpdateCrosshair, EV_NO_ARGS);
39
40 /** Called when a projectile is linked with CSQC */
41 #define EV_Ent_Projectile(i, o) \
42         /** entity id */ i(entity, __self) \
43         /**/
44 MUTATOR_HOOKABLE(Ent_Projectile, EV_Ent_Projectile);
45
46 /** Called when a projectile's properties are being modified */
47 #define EV_EditProjectile(i, o) \
48         /** entity id */ i(entity, __self) \
49         /**/
50 MUTATOR_HOOKABLE(EditProjectile, EV_EditProjectile);
51
52 /* Called when projectiles are precached */
53 MUTATOR_HOOKABLE(PrecacheProjectiles, EV_NO_ARGS);
54
55 /** Called when updating the attached tags index */
56 #define EV_TagIndex_Update(i, o) \
57         /** entity id */ i(entity, __self) \
58         /**/
59 MUTATOR_HOOKABLE(TagIndex_Update, EV_TagIndex_Update);
60
61 /** Called when setting the attached tags */
62 #define EV_TagIndex_Apply(i, o) \
63         /** entity id */ i(entity, __self) \
64         /**/
65 MUTATOR_HOOKABLE(TagIndex_Apply, EV_TagIndex_Apply);
66
67 /** Called when setting up skeleton bones */
68 #define EV_Skeleton_CheckBones(i, o) \
69         /** entity id */ i(entity, __self) \
70         /**/
71 MUTATOR_HOOKABLE(Skeleton_CheckBones, EV_Skeleton_CheckBones);
72
73 /** Called when setting up bones from the loaded model */
74 #define EV_Skeleton_CheckModel(i, o) \
75         /** entity id */ i(entity, __self) \
76         /**/
77 MUTATOR_HOOKABLE(Skeleton_CheckModel, EV_Skeleton_CheckModel);
78
79 /** Called when clearing the global parameters for a model */
80 MUTATOR_HOOKABLE(ClearModelParams, EV_NO_ARGS);
81
82 /** Called when getting the global parameters for a model */
83 #define EV_GetModelParams(i, o) \
84         /** entity id */ i(string, checkmodel_input) \
85         /** entity id */ i(string, checkmodel_command) \
86         /**/
87 string checkmodel_input, checkmodel_command;
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, __self) \
93         /**/
94 MUTATOR_HOOKABLE(WantEventchase, EV_WantEventchase);
95
96 #define EV_AnnouncerOption(i, o) \
97         /**/ i(string, ret_string) \
98         /**/ o(string, ret_string) \
99         /**/
100 MUTATOR_HOOKABLE(AnnouncerOption, EV_AnnouncerOption);
101
102 MUTATOR_HOOKABLE(Ent_Init, EV_NO_ARGS);
103
104 #define EV_HUD_Draw_overlay(i, o) \
105         /**/ o(vector, MUTATOR_ARGV_0_vector) \
106         /**/ o(float, MUTATOR_ARGV_0_float) \
107         /**/
108 MUTATOR_HOOKABLE(HUD_Draw_overlay, EV_HUD_Draw_overlay);
109
110 MUTATOR_HOOKABLE(HUD_Powerups_add, EV_NO_ARGS);
111
112 /** Return true to not draw any vortex beam */
113 #define EV_Particles_VortexBeam(i, o) \
114         /**/ i(vector, vbeam_shotorg) \
115         /**/ i(vector, vbeam_endpos) \
116         /**/
117 vector vbeam_shotorg;
118 vector vbeam_endpos;
119 MUTATOR_HOOKABLE(Particles_VortexBeam, EV_Particles_VortexBeam);
120
121 /** Return true to not draw any impact effect */
122 #define EV_Weapon_ImpactEffect(i, o) \
123         /**/ i(entity, w_hitwep) \
124         /**/
125 entity w_hitwep;
126 MUTATOR_HOOKABLE(Weapon_ImpactEffect, EV_Weapon_ImpactEffect);
127
128 /* NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
129 */
130 #define EV_HUD_Command(i, o) \
131         /** also, argv() can be used */ i(int, cmd_argc) \
132         /**/
133 MUTATOR_HOOKABLE(HUD_Command, EV_HUD_Command);