]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator_minstagib.qc
Merge branch 'master' into Mario/mutator_minstagib
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_minstagib.qc
index e1e4ebf5c6f178a81576b7916eac6439ce11816f..efeec3decd04945f19c25486ba2560b8d79203b2 100644 (file)
@@ -28,6 +28,8 @@ void minstagib_stop_countdown(entity e)
 }
 void minstagib_ammocheck(void)
 {
+       if not(IS_PLAYER(self))
+               return; // not a player
        if (time < self.minstagib_nextthink)
                return;
 
@@ -41,65 +43,72 @@ void minstagib_ammocheck(void)
                if (self.health == 5)
                {
                        Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
-                       AnnounceTo(self, "terminated");
+                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_MINSTAGIB_TERMINATED);
                }
                else if (self.health == 10)
                {
                        Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
-                       AnnounceTo(self, "1");
+                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_1);
                }
                else if (self.health == 20)
                {
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       AnnounceTo(self, "2");
+                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_2);
                }
                else if (self.health == 30)
                {
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       AnnounceTo(self, "3");
+                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_3);
                }
                else if (self.health == 40)
                {
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       AnnounceTo(self, "4");
+                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_4);
                }
                else if (self.health == 50)
                {
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       AnnounceTo(self, "5");
+                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_5);
                }
                else if (self.health == 60)
                {
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       AnnounceTo(self, "6");
+                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_6);
                }
                else if (self.health == 70)
                {
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       AnnounceTo(self, "7");
+                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_7);
                }
                else if (self.health == 80)
                {
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       AnnounceTo(self, "8");
+                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_8);
                }
                else if (self.health == 90)
                {
                        Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_MINSTA_FINDAMMO);
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       AnnounceTo(self, "9");
+                       Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_9);
                }
                else if (self.health == 100)
                {
-                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_MINSTA_FINDAMMO_FIRST);
+                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_MULTI, MULTI_MINSTA_FINDAMMO);
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
-                       if not(self.flags & FL_GODMODE)
-                               AnnounceTo(self, "10");
                }
        }
        self.minstagib_nextthink = time + 1;
 }
 
+MUTATOR_HOOKFUNCTION(minstagib_MatchEnd)
+{
+       entity head;
+       FOR_EACH_PLAYER(head)
+               minstagib_stop_countdown(head);
+               
+       return FALSE;
+}
+
 MUTATOR_HOOKFUNCTION(minstagib_BotShouldAttack)
 {
        if(checkentity.items & IT_STRENGTH)
@@ -302,6 +311,19 @@ MUTATOR_HOOKFUNCTION(minstagib_FilterItem)
        return TRUE;
 }
 
+MUTATOR_HOOKFUNCTION(minstagib_CustomizeWaypoint)
+{
+       entity e = WaypointSprite_getviewentity(other);
+       
+       // if you have the invisibility powerup, sprites ALWAYS are restricted to your team
+       // but only apply this to real players, not to spectators
+       if((self.owner.flags & FL_CLIENT) && (self.owner.items & IT_STRENGTH) && (e == other))
+       if(IsDifferentTeam(self.owner, e))
+               return TRUE;
+       
+       return FALSE;
+}
+
 MUTATOR_HOOKFUNCTION(minstagib_ItemCountdown)
 {
        switch(self.items)
@@ -313,33 +335,30 @@ MUTATOR_HOOKFUNCTION(minstagib_ItemCountdown)
        return FALSE;
 }
 
-MUTATOR_HOOKFUNCTION(minstagib_GiveItem)
+MUTATOR_HOOKFUNCTION(minstagib_ItemTouch)
 {
-       if(giveitem.ammo_cells)
+       if(self.ammo_cells)
        {
                // play some cool sounds ;)
                if (IS_CLIENT(other))
                {
                        if(other.health <= 5)
-                               AnnounceTo(other, "lastsecond");
+                               Send_Notification(NOTIF_ONE, other, MSG_ANNCE, ANNCE_MINSTAGIB_LASTSECOND);
                        else if(other.health < 50)
-                               AnnounceTo(other, "narrowly");
+                               Send_Notification(NOTIF_ONE, other, MSG_ANNCE, ANNCE_MINSTAGIB_NARROWLY);
                }
 
                if(other.health < 100)
                        other.health = 100;
-                       
-               player_pickedup = TRUE;
        }
        
-       if(giveitem.max_health)
+       if(self.max_health)
        {
                other.armorvalue = bound(other.armorvalue, 999, other.armorvalue + autocvar_g_minstagib_extralives);
-               sprint(other, "^3You picked up some extra lives\n");
-               player_pickedup = TRUE;
+               Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_EXTRALIVES);
        }
                
-       return TRUE;
+       return FALSE;
 }
 
 MUTATOR_HOOKFUNCTION(minstagib_OnEntityPreSpawn)
@@ -379,14 +398,16 @@ MUTATOR_HOOKFUNCTION(minstagib_BuildMutatorsPrettyString)
 
 MUTATOR_DEFINITION(mutator_minstagib)
 {
+       MUTATOR_HOOK(MatchEnd, minstagib_MatchEnd, CBC_ORDER_ANY);
        MUTATOR_HOOK(BotShouldAttack, minstagib_BotShouldAttack, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerPhysics, minstagib_PlayerPhysics, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerSpawn, minstagib_PlayerSpawn, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerDamage_Calculate, minstagib_PlayerDamage, CBC_ORDER_ANY);
        MUTATOR_HOOK(MakePlayerObserver, minstagib_MakePlayerObserver, CBC_ORDER_ANY);
        MUTATOR_HOOK(SetStartItems, minstagib_SetStartItems, CBC_ORDER_ANY);
-       MUTATOR_HOOK(Item_GiveTo, minstagib_GiveItem, CBC_ORDER_ANY);
+       MUTATOR_HOOK(ItemTouch, minstagib_ItemTouch, CBC_ORDER_ANY);
        MUTATOR_HOOK(FilterItem, minstagib_FilterItem, CBC_ORDER_ANY);
+       MUTATOR_HOOK(CustomizeWaypoint, minstagib_CustomizeWaypoint, CBC_ORDER_ANY);
        MUTATOR_HOOK(Item_RespawnCountdown, minstagib_ItemCountdown, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerDamage_SplitHealthArmor, minstagib_SplitHealthArmor, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerPowerups, minstagib_PlayerPowerups, CBC_ORDER_ANY);