]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/mutators/events.qh
Merge branch 'TimePath/gamesettings' into 'master'
[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 `if (MUTATOR_RETURNVALUE) return false;`
44  * NOTE: hooks MUST start with `if (!ReadMutatorEquals(mutator_argv_int_0, name_of_mutator)) return false;`
45  * NOTE: return true if you handled the command, return false to continue handling
46  */
47 #define EV_CSQC_Parse_TempEntity(i, o) \
48     /** mutator id */ i(int, mutator_argv_int_0) \
49     /**/
50 MUTATOR_HOOKABLE(CSQC_Parse_TempEntity, EV_CSQC_Parse_TempEntity);
51
52 /**
53  * Called when a shared entity is updated
54  * NOTE: hooks MUST start with `if (MUTATOR_RETURNVALUE) return false;`
55  * NOTE: hooks MUST start with `if (!ReadMutatorEquals(mutator_argv_int_0, name_of_mutator)) return false;`
56  * NOTE: return true if you handled the command, return false to continue handling
57  */
58 #define EV_CSQC_Ent_Update(i, o) \
59     /** mutator id */ i(int, mutator_argv_int_0) \
60     /** bIsNewEntity */ i(bool, mutator_argv_bool_0) \
61     /**/
62 MUTATOR_HOOKABLE(CSQC_Ent_Update, EV_CSQC_Ent_Update);
63
64 /** Called when a projectile is linked with CSQC */
65 #define EV_Ent_Projectile(i, o) \
66     /** entity id */ i(entity, self) \
67     /**/
68 MUTATOR_HOOKABLE(Ent_Projectile, EV_Ent_Projectile);
69
70 /** Called when a projectile's properties are being modified */
71 #define EV_EditProjectile(i, o) \
72     /** entity id */ i(entity, self) \
73     /**/
74 MUTATOR_HOOKABLE(EditProjectile, EV_EditProjectile);
75
76 /* Called when projectiles are precached */
77 MUTATOR_HOOKABLE(PrecacheProjectiles, EV_NO_ARGS);
78
79 /** Called when updating the attached tags index */
80 #define EV_TagIndex_Update(i, o) \
81     /** entity id */ i(entity, self) \
82     /**/
83 MUTATOR_HOOKABLE(TagIndex_Update, EV_TagIndex_Update);
84
85 /** Called when setting the attached tags */
86 #define EV_TagIndex_Apply(i, o) \
87     /** entity id */ i(entity, self) \
88     /**/
89 MUTATOR_HOOKABLE(TagIndex_Apply, EV_TagIndex_Apply);
90
91 /** Called when setting up skeleton bones */
92 #define EV_Skeleton_CheckBones(i, o) \
93     /** entity id */ i(entity, self) \
94     /**/
95 MUTATOR_HOOKABLE(Skeleton_CheckBones, EV_Skeleton_CheckBones);
96
97 /** Called when setting up bones from the loaded model */
98 #define EV_Skeleton_CheckModel(i, o) \
99     /** entity id */ i(entity, self) \
100     /**/
101 MUTATOR_HOOKABLE(Skeleton_CheckModel, EV_Skeleton_CheckModel);
102
103 /** Called when clearing the global parameters for a model */
104 MUTATOR_HOOKABLE(ClearModelParams, EV_NO_ARGS);
105
106 /** Called when getting the global parameters for a model */
107 #define EV_GetModelParams(i, o) \
108     /** entity id */ i(string, checkmodel_input) \
109     /** entity id */ i(string, checkmodel_command) \
110     /**/
111 string checkmodel_input, checkmodel_command;
112 MUTATOR_HOOKABLE(GetModelParams, EV_GetModelParams);
113
114 #endif