From bf3c240a5ab4e78cce4e1c9e8bb76a0368ff458d Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 26 Aug 2015 12:08:36 +1000 Subject: [PATCH] Add some hooks to allow custom bones --- qcsrc/client/mutators/events.qh | 23 +++++++++++++++++++++++ qcsrc/client/player_skeleton.qc | 2 ++ qcsrc/common/util.qc | 9 +++++++++ qcsrc/server/mutators/events.qh | 11 +++++++++++ 4 files changed, 45 insertions(+) diff --git a/qcsrc/client/mutators/events.qh b/qcsrc/client/mutators/events.qh index 363af87a0..86be898d9 100644 --- a/qcsrc/client/mutators/events.qh +++ b/qcsrc/client/mutators/events.qh @@ -88,4 +88,27 @@ MUTATOR_HOOKABLE(TagIndex_Update, EV_TagIndex_Update); /**/ MUTATOR_HOOKABLE(TagIndex_Apply, EV_TagIndex_Apply); +/** Called when setting up skeleton bones */ +#define EV_Skeleton_CheckBones(i, o) \ + /** entity id */ i(entity, self) \ + /**/ +MUTATOR_HOOKABLE(Skeleton_CheckBones, EV_Skeleton_CheckBones); + +/** Called when setting up bones from the loaded model */ +#define EV_Skeleton_CheckModel(i, o) \ + /** entity id */ i(entity, self) \ + /**/ +MUTATOR_HOOKABLE(Skeleton_CheckModel, EV_Skeleton_CheckModel); + +/** Called when clearing the global parameters for a model */ +MUTATOR_HOOKABLE(ClearModelParams, EV_NO_ARGS); + +/** Called when getting the global parameters for a model */ +#define EV_GetModelParams(i, o) \ + /** entity id */ i(string, checkmodel_input) \ + /** entity id */ i(string, checkmodel_command) \ + /**/ +string checkmodel_input, checkmodel_command; +MUTATOR_HOOKABLE(GetModelParams, EV_GetModelParams); + #endif diff --git a/qcsrc/client/player_skeleton.qc b/qcsrc/client/player_skeleton.qc index 4039c905c..96b91d1c8 100644 --- a/qcsrc/client/player_skeleton.qc +++ b/qcsrc/client/player_skeleton.qc @@ -23,6 +23,7 @@ void skeleton_loadinfo(entity e) e.bone_weapon = gettagindex(e, "tag_weapon"); if(!e.bone_weapon) e.bone_weapon = gettagindex(e, "bip01 r hand"); + MUTATOR_CALLHOOK(Skeleton_CheckBones, e); for(i = 0; i < MAX_AIM_BONES; ++i) { e.(bone_aim[i]) = 0; @@ -37,6 +38,7 @@ void skeleton_loadinfo(entity e) e.fixbone = get_model_parameters_fixbone; if(get_model_parameters_bone_weapon) e.bone_weapon = gettagindex(e, get_model_parameters_bone_weapon); + MUTATOR_CALLHOOK(Skeleton_CheckModel, e); for(i = 0; i < MAX_AIM_BONES; ++i) { if(get_model_parameters_bone_aim[i]) diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index 5479698ac..c1ae4ad1a 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -5,6 +5,7 @@ #include "../client/defs.qh" #include "constants.qh" #include "../warpzonelib/mathlib.qh" + #include "../client/mutators/events.qh" #include "mapinfo.qh" #include "notifications.qh" #include "deathtypes.qh" @@ -16,6 +17,7 @@ #include "constants.qh" #include "../server/autocvars.qh" #include "../server/defs.qh" + #include "../server/mutators/events.qh" #include "notifications.qh" #include "deathtypes.qh" #include "mapinfo.qh" @@ -2059,6 +2061,10 @@ float get_model_parameters(string m, float sk) } get_model_parameters_fixbone = 0; +#ifndef MENUQC + MUTATOR_CALLHOOK(ClearModelParams); +#endif + if (!m) return 1; @@ -2120,6 +2126,9 @@ float get_model_parameters(string m, float sk) get_model_parameters_bone_upperbody = s; if(c == "bone_weapon") get_model_parameters_bone_weapon = s; + #ifndef MENUQC + MUTATOR_CALLHOOK(GetModelParams, c, s); + #endif for(int i = 0; i < MAX_AIM_BONES; ++i) if(c == strcat("bone_aim", ftos(i))) { diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 71542d543..fb3fbd107 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -536,4 +536,15 @@ enum { MUT_ACCADD_INVALID, // return this flag to make the function always continue MUT_ACCADD_INDIFFERENT // return this flag to make the function always return }; + +/** Called when clearing the global parameters for a model */ +MUTATOR_HOOKABLE(ClearModelParams, EV_NO_ARGS); + +/** Called when getting the global parameters for a model */ +#define EV_GetModelParams(i, o) \ + /** entity id */ i(string, checkmodel_input) \ + /** entity id */ i(string, checkmodel_command) \ + /**/ +string checkmodel_input, checkmodel_command; +MUTATOR_HOOKABLE(GetModelParams, EV_GetModelParams); #endif -- 2.39.2