]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a hook for buff model customization, use a flag instead of an IS_PLAYER check...
authorMario <zacjardine@y7mail.com>
Sun, 30 Aug 2015 09:58:08 +0000 (19:58 +1000)
committerMario <zacjardine@y7mail.com>
Sun, 30 Aug 2015 10:00:21 +0000 (20:00 +1000)
qcsrc/common/monsters/sv_monsters.qc
qcsrc/server/cl_client.qc
qcsrc/server/constants.qh
qcsrc/server/mutators/events.qh
qcsrc/server/mutators/mutator_buffs.qc
qcsrc/server/t_items.qc

index e7ea9f8c48520182793b32e30a25a6457e6e1774..d0b39828d1acbcf1da0b7ff5706ae558ab0d066b 100644 (file)
@@ -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));
 
index 4b9d9294c16bc322c2a978ce1f76ae167c75afdb..3674755f2c61516ef03048a0a4e0f5ecaabd763a 100644 (file)
@@ -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;
index c1def6b821e469d43d1183f371ff1039e0009d53..ac6be94dd22b99b375d3906a3303d9e17c78579a 100644 (file)
@@ -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;
index 3d086337075e7c6602f4f4ec00dfe483daabb445..234f56bebd20baed44fefc3c8707a70f690ee904 100644 (file)
@@ -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
index 72bbaf16d4386e60c759c20401eccd86f6386273..4433055b61b27f570298759fdff64f1fd78f251a 100644 (file)
@@ -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)
index 858a76198b9a78aaa1dd61d26729c77dba9a2794..c78b2fda9c9fb83ee3c3048ab3c36aeafd99c84c 100644 (file)
@@ -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))
        {