X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=Functions-and-other-programming-QuakeC-things-in-Xonotic.md;h=30030adefb9f776ee8b3344f8a28ba8df0a5559d;hb=cc46c42302e783b65ebc26cba7279aa4b3dd810b;hp=b4ff20e906abe5fb76fe9f4e635e04fe6c556dd9;hpb=09992155f745a1b94fdc3426dab85dd2d24d5878;p=xonotic%2Fxonotic.wiki.git diff --git a/Functions-and-other-programming-QuakeC-things-in-Xonotic.md b/Functions-and-other-programming-QuakeC-things-in-Xonotic.md index b4ff20e..30030ad 100644 --- a/Functions-and-other-programming-QuakeC-things-in-Xonotic.md +++ b/Functions-and-other-programming-QuakeC-things-in-Xonotic.md @@ -1,7 +1,7 @@ **Note:** The article is written as developer notes to ease developer tasks and save QuakeC function terms here. Some references are taken from `events.qh`. -# MUTATOR functions (from: `qcsrc/server/mutators/events.qh`) +# MUTATOR functions (from: `qcsrc/client/mutators/events.qh`, `qcsrc/common/mutators/events.qh`, `qcsrc/server/mutators/events.qh`) ### Introduction @@ -10,57 +10,57 @@ How to use MUTATOR functions: **Attention:** to use a hook, first register your mutator using `REGISTER_MUTATOR`, then create your function using `MUTATOR_HOOKFUNCTION`. -**`REGISTER_MUTATOR`** +- **`REGISTER_MUTATOR`** Registers a new `MUTATOR_HOOKFUNCTION`. -``` +```c REGISTER_MUTATOR(new_mutator_name, some_variable); ``` -**`MUTATOR_HOOKFUNCTION`** +- **`MUTATOR_HOOKFUNCTION`** Creates a function and calls `new_mutator_name` (from `REGISTER_MUTATOR`) and one of `#define MUTATOR()` (from `qcsrc/server/mutators/events.qh` main hooks). Example: +```c +MUTATOR_HOOKFUNCTION(new_mutator_name, events.qh_main_hook) +{ + // whatever does +} +``` - MUTATOR_HOOKFUNCTION(helloworld, PlayerSpawn) - { - // whatever does - } - - -**`MUTATOR_CALLHOOK`** +- **`MUTATOR_CALLHOOK`** Calls some `MUTATOR_HOOKFUNCTION`. -``` -MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hooks); +```c +MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hook); ``` There are different versions and depends how many variables need to be called in a `MUTATOR_HOOKFUNCTION`: 1 `MUTATOR_HOOKFUNCTION` and 1 variable: -``` -MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hooks, some_variable); +```c +MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hook, some_variable); ``` 1 `MUTATOR_HOOKFUNCTION` and 2 variables: -``` -MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hooks, some_variable, some_variable); +```c +MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hook, some_variable, some_variable); ``` 1 `MUTATOR_HOOKFUNCTION` and 3 variables: -``` -MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hooks, some_variable, some_variable, some_variable); +```c +MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hook, some_variable, some_variable, some_variable); ``` 1 `MUTATOR_HOOKFUNCTION` and multiple variables: -``` -MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hooks, some_variable, some_variable, some_variable, some_variable, ...); +```c +MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hook, some_variable, some_variable, some_variable, some_variable, ...); ```
@@ -69,120 +69,86 @@ MUTATOR_CALLHOOK(name_of_MUTATOR_HOOKFUNCTION_or_events.qh_main_hooks, some_vari ## List of MUTATOR functions -**`MakePlayerObserver`** +You can look the MUTATOR functions in: -Called when a player becomes observer, after shared setup. -``` -#define EV_MakePlayerObserver(i, o) \ - /** player */ i(entity, MUTATOR_ARGV_0_entity) \ - /**/ -MUTATOR_HOOKABLE(MakePlayerObserver, EV_MakePlayerObserver) -``` +**COMMON**: -**`PutClientInServer`** +**`qcsrc/common/mutators/events.qh`** : +https://timepath.github.io/scratchspace/d4/d95/common_2mutators_2events_8qh.html -Called when client spawns in server. (Not sure described) -``` -#define EV_PutClientInServer(i, o) \ - /** client wanting to spawn */ i(entity, MUTATOR_ARGV_0_entity) \ - /**/ -MUTATOR_HOOKABLE(PutClientInServer, EV_PutClientInServer); -``` -**`ForbidSpawn`** +**CLIENT**: -Returns true to prevent a spectator/observer to spawn as player. -``` - #define EV_ForbidSpawn(i, o) \ - /** player */ i(entity, MUTATOR_ARGV_0_entity) \ - /**/ -MUTATOR_HOOKABLE(ForbidSpawn, EV_ForbidSpawn); -``` +**`qcsrc/client/mutators/events.qh`** : +https://timepath.github.io/scratchspace/d8/d0e/client_2mutators_2events_8qh.html -**`AutoJoinOnConnection`** -Returns true if client should be put as player on connection. -``` -#define EV_AutoJoinOnConnection(i, o) \ - /** player */ i(entity, MUTATOR_ARGV_0_entity) \ - /**/ -MUTATOR_HOOKABLE(AutoJoinOnConnection, EV_AutoJoinOnConnection); -``` +**SERVER**: -**`ForbidRandomStartWeapons`** +**`qcsrc/server/mutators/events.qh`** : +https://timepath.github.io/scratchspace/d6/ddd/server_2mutators_2events_8qh.html -Called when player spawns to determine whether to give them random start weapons. Return true to forbid giving them. -``` -#define EV_ForbidRandomStartWeapons(i, o) \ - /** player */ i(entity, MUTATOR_ARGV_0_entity) \ - /**/ -MUTATOR_HOOKABLE(ForbidRandomStartWeapons, EV_ForbidRandomStartWeapons); -``` -**`PlayerSpawn`** +
+
-Called when a player spawns as player, after shared setup, before his weapon is chosen (so items may be changed in here) +## List of WEAPON functions - #define EV_PlayerSpawn(i, o) \ - /** player spawning */ i(entity, MUTATOR_ARGV_0_entity) \ - /** spot that was used, or NULL */ i(entity, MUTATOR_ARGV_1_entity) \ - /**/ - MUTATOR_HOOKABLE(PlayerSpawn, EV_PlayerSpawn); +This is a created functions list to modify/create weapons. There are incomplete explanations for each function. +There are contents taken from `qcsrc/common/weapons/all.qh`. -**`PlayerWeaponSelect`** +**WARNING:** The contents may content wonky code, and the interactions can change and not do the same what happens here. -Called after a player's weapon is chosen so it can be overriden here. -``` -#define EV_PlayerWeaponSelect(i, o) \ - /** player spawning */ i(entity, MUTATOR_ARGV_0_entity) \ - /**/ -MUTATOR_HOOKABLE(PlayerWeaponSelect, EV_PlayerWeaponSelect); -``` +
+
-**`reset_map_global`** +- [**W_SetupShot_Dir**](https://timepath.github.io/scratchspace/d4/d3f/tracing_8qh.html#aff0ea351757ee6caf83b25d12d18656c) -Called in reset_map. -``` -#define EV_reset_map_global(i, o) \ - /**/ -MUTATOR_HOOKABLE(reset_map_global, EV_reset_map_global); +```c +W_SetupShot_Dir( + ent, + wepent, + s_forward, + antilag, + recoil, + snd, + chan, + maxdamage, + deathtype +) ``` -**`reset_map_players`** +- [**W_SetupProjVelocity_Explicit**](https://timepath.github.io/scratchspace/d7/d31/tracing_8qc.html#a55f8f2b1828413bfb123a5fcb61b9f8e) -Called in reset_map. -``` -#define EV_reset_map_players(i, o) \ - /**/ -MUTATOR_HOOKABLE(reset_map_players, EV_reset_map_players); +```c +void W_SetupProjVelocity_Explicit( + entity proj, + vector dir, + vector upDir, + float pSpeed, + float pUpSpeed, + float pZSpeed, + float spread, + float forceAbsolute +) ``` -
-
- +- [**W_MuzzleFlash**](https://timepath.github.io/scratchspace/d0/ddd/weapons_2all_8qh_source.html)(located in `qcsrc/common/weapons/all.qh` line 406) -**`Damage_Calculate`** +In the moment when player shots the weapon, weapon flashes. +*Note:* write `#ifdef SVQC` at the start of using this function, and write with `#endif` after declared the function(only can do this if the code which needs execute can do this, although maybe you need more functions/things in the code inside this). -Called to adjust damage and force values which are applied to the player, used for e.g. strength damage/force multiplier, I'm not sure if I should change this around slightly (Naming of the entities, and also how they're done in g_damage). +```c +void W_MuzzleFlash(Weapon thiswep, entity actor, .entity weaponentity, vector shotorg, vector shotdir); +``` +- [**Weapon selection functions**](https://timepath.github.io/scratchspace/d8/d6b/selection_8qh.html) +(located in `qcsrc/server/weapons/selection.qh`) - #define EV_Damage_Calculate(i, o) \ - /** inflictor */ i(entity, MUTATOR_ARGV_0_entity) \ - /** attacker */ i(entity, MUTATOR_ARGV_1_entity) \ - /** target */ i(entity, MUTATOR_ARGV_2_entity) \ - /** deathtype */ i(float, MUTATOR_ARGV_3_float) \ - /** damage */ i(float, MUTATOR_ARGV_4_float) \ - /** damage */ o(float, MUTATOR_ARGV_4_float) \ - /** mirrordamage */ i(float, MUTATOR_ARGV_5_float) \ - /** mirrordamage */ o(float, MUTATOR_ARGV_5_float) \ - /** force */ i(vector, MUTATOR_ARGV_6_vector) \ - /** force */ o(vector, MUTATOR_ARGV_6_vector) \ - /**/ - MUTATOR_HOOKABLE(Damage_Calculate, EV_Damage_Calculate); +- [**Weapon decrease ammo, speed factor, rate factor, reload functions**](https://timepath.github.io/scratchspace/d5/de0/weaponsystem_8qc.html) +(located in `qcsrc/server/weapons/weaponsystem.qh`) -
-
AND.... STILL in process \ No newline at end of file