]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/mutators/events.qh
2fbeaaa7c15299b35ecf853ac4bfb137c8e0fd58
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / mutators / events.qh
1 #ifndef CLIENT_MUTATORS_EVENTS_H
2 #define CLIENT_MUTATORS_EVENTS_H
3
4 #include "../../common/mutators/base.qh"
5
6 // globals
7
8 string cmd_name;
9 int cmd_argc;
10 string cmd_string;
11
12 /**
13  * Called when a client command is parsed
14  * NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
15  * NOTE: return true if you handled the command, return false to continue handling
16  * NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
17  * // example:
18  * MUTATOR_HOOKFUNCTION(foo, CSQC_ConsoleCommand) {
19  *     if (MUTATOR_RETURNVALUE) return false; // command was already handled
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, cmd_name) \
33         /** also, argv() can be used */ i(int, cmd_argc) \
34         /** whole command, use only if you really have to */ i(string, cmd_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 /**
42  * Called when a temp entity is parsed
43  * NOTE: hooks MUST start with:
44  *     if (MUTATOR_RETURNVALUE) return;
45  *     if (!ReadMutatorEquals(mutator_argv_int_0, name_of_mutator)) return;
46  *     return = true;
47  */
48 #define EV_CSQC_Parse_TempEntity(i, o) \
49         /** mutator id */ i(int, mutator_argv_int_0) \
50         /**/
51 MUTATOR_HOOKABLE(CSQC_Parse_TempEntity, EV_CSQC_Parse_TempEntity);
52
53 /**
54  * Called when a shared entity is updated
55  *     if (MUTATOR_RETURNVALUE) return;
56  *     if (!ReadMutatorEquals(mutator_argv_int_0, name_of_mutator)) return;
57  *     return = true;
58  */
59 #define EV_CSQC_Ent_Update(i, o) \
60         /** mutator id */ i(int, mutator_argv_int_0) \
61         /** bIsNewEntity */ i(bool, mutator_argv_bool_0) \
62         /**/
63 MUTATOR_HOOKABLE(CSQC_Ent_Update, EV_CSQC_Ent_Update);
64
65 /** Called when a projectile is linked with CSQC */
66 #define EV_Ent_Projectile(i, o) \
67         /** entity id */ i(entity, __self) \
68         /**/
69 MUTATOR_HOOKABLE(Ent_Projectile, EV_Ent_Projectile);
70
71 /** Called when a projectile's properties are being modified */
72 #define EV_EditProjectile(i, o) \
73         /** entity id */ i(entity, __self) \
74         /**/
75 MUTATOR_HOOKABLE(EditProjectile, EV_EditProjectile);
76
77 /* Called when projectiles are precached */
78 MUTATOR_HOOKABLE(PrecacheProjectiles, EV_NO_ARGS);
79
80 /** Called when updating the attached tags index */
81 #define EV_TagIndex_Update(i, o) \
82         /** entity id */ i(entity, __self) \
83         /**/
84 MUTATOR_HOOKABLE(TagIndex_Update, EV_TagIndex_Update);
85
86 /** Called when setting the attached tags */
87 #define EV_TagIndex_Apply(i, o) \
88         /** entity id */ i(entity, __self) \
89         /**/
90 MUTATOR_HOOKABLE(TagIndex_Apply, EV_TagIndex_Apply);
91
92 /** Called when setting up skeleton bones */
93 #define EV_Skeleton_CheckBones(i, o) \
94         /** entity id */ i(entity, __self) \
95         /**/
96 MUTATOR_HOOKABLE(Skeleton_CheckBones, EV_Skeleton_CheckBones);
97
98 /** Called when setting up bones from the loaded model */
99 #define EV_Skeleton_CheckModel(i, o) \
100         /** entity id */ i(entity, __self) \
101         /**/
102 MUTATOR_HOOKABLE(Skeleton_CheckModel, EV_Skeleton_CheckModel);
103
104 /** Called when clearing the global parameters for a model */
105 MUTATOR_HOOKABLE(ClearModelParams, EV_NO_ARGS);
106
107 /** Called when getting the global parameters for a model */
108 #define EV_GetModelParams(i, o) \
109         /** entity id */ i(string, checkmodel_input) \
110         /** entity id */ i(string, checkmodel_command) \
111         /**/
112 string checkmodel_input, checkmodel_command;
113 MUTATOR_HOOKABLE(GetModelParams, EV_GetModelParams);
114
115 /** called when a player presses the jump key */
116 #define EV_PlayerJump(i, o) \
117         /**/ i(float, player_multijump) \
118         /**/ i(float, player_jumpheight) \
119         /**/ o(float, player_multijump) \
120         /**/ o(float, player_jumpheight) \
121         /**/
122 float player_multijump;
123 float player_jumpheight;
124 MUTATOR_HOOKABLE(PlayerJump, EV_PlayerJump);
125
126 /** Called checking if 3rd person mode should be forced on */
127 #define EV_WantEventchase(i, o) \
128         /** entity id */ i(entity, __self) \
129         /**/
130 MUTATOR_HOOKABLE(WantEventchase, EV_WantEventchase);
131
132 #define EV_AnnouncerOption(i, o) \
133         /**/ i(string, ret_string) \
134         /**/ o(string, ret_string) \
135         /**/
136 MUTATOR_HOOKABLE(AnnouncerOption, EV_AnnouncerOption);
137
138 MUTATOR_HOOKABLE(Ent_Init, EV_NO_ARGS);
139 #endif