From: Mario Date: Sun, 30 Aug 2015 09:58:08 +0000 (+1000) Subject: Add a hook for buff model customization, use a flag instead of an IS_PLAYER check... X-Git-Tag: xonotic-v0.8.2~1971 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=047f2425737254405262e4f84b34b45b60698d33;p=xonotic%2Fxonotic-data.pk3dir.git Add a hook for buff model customization, use a flag instead of an IS_PLAYER check for picking up items --- diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index e7ea9f8c4..d0b39828d 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -867,7 +867,7 @@ void Monster_Move(float runspeed, float walkspeed, float stpspeed) if(vlen(self.origin - self.moveto) > 100) { - float do_run = !!(self.enemy); + float do_run = (self.enemy || self.monster_moveto); if((self.flags & FL_ONGROUND) || ((self.flags & FL_FLY) || (self.flags & FL_SWIM))) Monster_CalculateVelocity(self, self.moveto, self.origin, true, ((do_run) ? runspeed : walkspeed)); diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 4b9d9294c..3674755f2 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -467,7 +467,7 @@ void PutClientInServer (void) self.frags = FRAGS_PLAYER; if(INDEPENDENT_PLAYERS) MAKE_INDEPENDENT_PLAYER(self); - self.flags = FL_CLIENT; + self.flags = FL_CLIENT | FL_PICKUPITEMS; if(autocvar__notarget) self.flags |= FL_NOTARGET; self.takedamage = DAMAGE_AIM; diff --git a/qcsrc/server/constants.qh b/qcsrc/server/constants.qh index c1def6b82..ac6be94dd 100644 --- a/qcsrc/server/constants.qh +++ b/qcsrc/server/constants.qh @@ -7,6 +7,7 @@ const int FL_PROJECTILE = 32768; const int FL_TOSSED = 65536; const int FL_NO_WEAPON_STAY = 131072; const int FL_SPAWNING = 262144; +const int FL_PICKUPITEMS = 524288; const int SVC_SOUND = 6; const int SVC_STOPSOUND = 16; diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 3d0863370..234f56beb 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -608,4 +608,18 @@ int hook_tarzan; entity hook_pullentity; float hook_velmultiplier; MUTATOR_HOOKABLE(GrappleHookThink, EV_GrappleHookThink); + +#define EV_BuffModel_Customize(i, o) \ + /**/ i(entity, self) \ + /**/ i(entity, buff_player) \ + /**/ +entity buff_player; +MUTATOR_HOOKABLE(BuffModel_Customize, EV_BuffModel_Customize); + +/** called at when a buff is touched. Called early, can edit buff properties. */ +#define EV_BuffTouch(i, o) \ + /** item */ i(entity, self) \ + /** player */ i(entity, other) \ + /**/ +MUTATOR_HOOKABLE(BuffTouch, EV_BuffTouch); #endif diff --git a/qcsrc/server/mutators/mutator_buffs.qc b/qcsrc/server/mutators/mutator_buffs.qc index 72bbaf16d..4433055b6 100644 --- a/qcsrc/server/mutators/mutator_buffs.qc +++ b/qcsrc/server/mutators/mutator_buffs.qc @@ -15,10 +15,10 @@ entity buff_FirstFromFlags(int _buffs) return BUFF_NULL; } -float buffs_BuffModel_Customize() +bool buffs_BuffModel_Customize() { entity player, myowner; - float same_team; + bool same_team; player = WaypointSprite_getviewentity(other); myowner = self.owner; @@ -27,6 +27,9 @@ float buffs_BuffModel_Customize() if(myowner.alpha <= 0.5 && !same_team && myowner.alpha != 0) return false; + if(MUTATOR_CALLHOOK(BuffModel_Customize, self, player)) + return false; + if(player == myowner || (IS_SPEC(other) && other.enemy == myowner)) { // somewhat hide the model, but keep the glow @@ -153,7 +156,6 @@ void buff_Touch() if((self.team && DIFF_TEAM(other, self)) || (other.frozen) || (other.vehicle) - || (!IS_PLAYER(other)) || (!self.buff_active) ) { @@ -161,6 +163,12 @@ void buff_Touch() return; } + if(MUTATOR_CALLHOOK(BuffTouch, self, other)) + return; + + if(!IS_PLAYER(other)) + return; // incase mutator changed other + if (other.buffs) { if (other.cvar_cl_buffs_autoreplace && other.buffs != self.buffs) diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 858a76198..c78b2fda9 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -690,18 +690,13 @@ void Item_Touch (void) } } - if (!IS_PLAYER(other)) - return; - if (other.frozen) - return; - if (other.deadflag) - return; - if (self.solid != SOLID_TRIGGER) - return; - if (self.owner == other) - return; - if (time < self.item_spawnshieldtime) - return; + if(!(other.flags & FL_PICKUPITEMS) + || other.frozen + || other.deadflag + || (self.solid != SOLID_TRIGGER) + || (self.owner == other) + || (time < self.item_spawnshieldtime) + ) { return;} switch(MUTATOR_CALLHOOK(ItemTouch, self, other)) {