]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator_minstagib.qc
MinstaGib really should use SetModname... :(
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_minstagib.qc
index 83886077c4683274635a0c5120387a6b29f5f139..f82817d12d1ecba1fcc73fbbc04dd7f53f8fa8cf 100644 (file)
@@ -26,8 +26,10 @@ void minstagib_stop_countdown(entity e)
        Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_MINSTA_FINDAMMO);
        e.minstagib_needammo = FALSE;
 }
-void minstagib_ammocheck(void)
+void minstagib_ammocheck()
 {
+       if not(IS_PLAYER(self))
+               return; // not a player
        if (time < self.minstagib_nextthink)
                return;
 
@@ -98,6 +100,15 @@ void minstagib_ammocheck(void)
        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)
@@ -136,7 +147,7 @@ MUTATOR_HOOKFUNCTION(minstagib_PlayerPowerups)
                {
                        self.alpha = default_player_alpha;
                        self.exteriorweaponentity.alpha = default_weapon_alpha;
-                       self.items &~= IT_STRENGTH;
+                       self.items &= ~IT_STRENGTH;
                        Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_INVISIBILITY);
                }
        }
@@ -157,7 +168,7 @@ MUTATOR_HOOKFUNCTION(minstagib_PlayerPowerups)
                play_countdown(self.invincible_finished, "misc/poweroff.wav");
                if (time > self.invincible_finished)
                {
-                       self.items &~= IT_INVINCIBLE;
+                       self.items &= ~IT_INVINCIBLE;
                        Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_SPEED);
                }
        }
@@ -184,22 +195,22 @@ MUTATOR_HOOKFUNCTION(minstagib_PlayerPhysics)
 MUTATOR_HOOKFUNCTION(minstagib_SplitHealthArmor)
 {
        damage_save = 0;
-       //damage_take = frag_damage; // frag_damage isn't even set here?!
+       damage_take = frag_damage;
        
        return FALSE;
 }
 
 MUTATOR_HOOKFUNCTION(minstagib_ForbidThrowing)
 {
-       if (self.health < 1)
-               return FALSE;
-               
+       // weapon dropping on death handled by FilterItem
+       nades_CheckThrow();
+
        return TRUE;
 }
 
 MUTATOR_HOOKFUNCTION(minstagib_PlayerDamage)
 {
-       if(autocvar_g_friendlyfire == 0 && !IsDifferentTeam(frag_target, frag_attacker) && IS_PLAYER(frag_target))
+       if(autocvar_g_friendlyfire == 0 && SAME_TEAM(frag_target, frag_attacker) && IS_PLAYER(frag_target) && IS_PLAYER(frag_attacker))
                frag_damage = 0;
                
        if(IS_PLAYER(frag_target))
@@ -212,7 +223,9 @@ MUTATOR_HOOKFUNCTION(minstagib_PlayerDamage)
                        frag_damage = 0;
                }
                
-               if (frag_target.armorvalue && (frag_deathtype == WEP_MINSTANEX) && frag_damage)
+               if(IS_PLAYER(frag_attacker))
+               if(DEATH_ISWEAPON(frag_deathtype, WEP_MINSTANEX))
+               if(frag_target.armorvalue)
                {
                        frag_target.armorvalue -= 1;
                        Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_MINSTA_LIVES_REMAINING, frag_target.armorvalue);
@@ -220,27 +233,30 @@ MUTATOR_HOOKFUNCTION(minstagib_PlayerDamage)
                        frag_target.hitsound += 1;
                        frag_attacker.hitsound += 1; // TODO change this to a future specific hitsound for armor hit
                }
+               
+               if(IS_PLAYER(frag_attacker))
                if (DEATH_ISWEAPON(frag_deathtype, WEP_LASER))
                {
                        frag_damage = 0;
                        frag_mirrordamage = 0;
                        if (frag_target != frag_attacker)
                        {
-                               if ((frag_target.health >= 1) && IS_PLAYER(frag_target))
+                               if (frag_target.health >= 1)
                                        Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_MINSTA_SECONDARY);
                                frag_force = '0 0 0';
                                // keep mirrorfrag_force
-                               frag_attacker = frag_target;
+                               //frag_attacker = frag_target;
                        }
                }
        }
        
+       if(IS_PLAYER(frag_attacker))
        if(frag_mirrordamage > 0)
        {
                // just lose extra LIVES, don't kill the player for mirror damage
                if(frag_attacker.armorvalue > 0)
                {
-                       frag_attacker.armorvalue = frag_attacker.armorvalue - 1;
+                       frag_attacker.armorvalue -= 1;
                        Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_MINSTA_LIVES_REMAINING, frag_attacker.armorvalue);
                        frag_attacker.hitsound += 1;
                }
@@ -259,7 +275,8 @@ MUTATOR_HOOKFUNCTION(minstagib_SetStartItems)
        
        start_health = 100;
        start_armorvalue = 0;
-       WEPSET_COPY_AW(start_weapons, WEP_MINSTANEX);
+       start_weapons = WEPSET_MINSTANEX;
+       warmup_start_weapons = WEPSET_MINSTANEX;
        start_items |= IT_UNLIMITED_SUPERWEAPONS;
                
        return FALSE;
@@ -307,7 +324,7 @@ MUTATOR_HOOKFUNCTION(minstagib_CustomizeWaypoint)
        // 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))
+       if(DIFF_TEAM(self.owner, e))
                return TRUE;
        
        return FALSE;
@@ -324,9 +341,9 @@ 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))
@@ -339,18 +356,18 @@ MUTATOR_HOOKFUNCTION(minstagib_GiveItem)
 
                if(other.health < 100)
                        other.health = 100;
-                       
-               player_pickedup = TRUE;
+
+               return MUT_ITEMTOUCH_CONTINUE;
        }
        
-       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, other, MSG_CENTER, CENTER_EXTRALIVES);
+               return MUT_ITEMTOUCH_PICKUP;
        }
                
-       return TRUE;
+       return MUT_ITEMTOUCH_CONTINUE;
 }
 
 MUTATOR_HOOKFUNCTION(minstagib_OnEntityPreSpawn)
@@ -388,15 +405,22 @@ MUTATOR_HOOKFUNCTION(minstagib_BuildMutatorsPrettyString)
        return FALSE;
 }
 
+MUTATOR_HOOKFUNCTION(minstagib_SetModname)
+{
+       modname = "MinstaGib";
+       return TRUE;
+}
+
 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);
@@ -407,6 +431,7 @@ MUTATOR_DEFINITION(mutator_minstagib)
        MUTATOR_HOOK(OnEntityPreSpawn, minstagib_OnEntityPreSpawn, CBC_ORDER_ANY);
        MUTATOR_HOOK(BuildMutatorsString, minstagib_BuildMutatorsString, CBC_ORDER_ANY);
        MUTATOR_HOOK(BuildMutatorsPrettyString, minstagib_BuildMutatorsPrettyString, CBC_ORDER_ANY);
+       MUTATOR_HOOK(SetModname, minstagib_SetModname, CBC_ORDER_ANY);
 
        return FALSE;
 }