Don't allow to summon dead hunter pets

Port From (https://github.com/TrinityCore/TrinityCore/commit/92fc09b1b5507c11c9e7ca63e6de0ec7574f0810)
This commit is contained in:
hondacrx
2022-01-02 19:12:50 -05:00
parent 75d3497d38
commit 81ab3b4080
4 changed files with 50 additions and 4 deletions
+19
View File
@@ -123,4 +123,23 @@ namespace Framework.Constants
CantControlExotic = 11, // "you are unable to control exotic creatures"
InternalError = 12, // "Internal pet error"
}
public enum PetTameResult
{
Ok = 0,
InvalidCreature = 1,
TooMany = 2,
CreatureAlreadyOwned = 3,
NotTameable = 4,
AnotherSummonActive = 5,
UnitsCantTame = 6,
NoPetAvailable = 7,
InternalError = 8,
TooHighLevel = 9,
Dead = 10,
NotDead = 11,
CantControlExotic = 12,
InvalidSlot = 13,
EliteTooHighLevel = 14
}
}
+18 -3
View File
@@ -17,11 +17,13 @@
using Framework.Constants;
using Framework.Database;
using Framework.Dynamic;
using Game.Achievements;
using Game.AI;
using Game.Arenas;
using Game.BattleFields;
using Game.BattleGrounds;
using Game.BattlePets;
using Game.Chat;
using Game.DataStorage;
using Game.Garrisons;
@@ -38,7 +40,6 @@ using Game.Spells;
using System;
using System.Collections.Generic;
using System.Linq;
using Framework.Dynamic;
namespace Game.Entities
{
@@ -952,7 +953,7 @@ namespace Game.Entities
return null;
}
public void SetBattlePetData(BattlePets.BattlePetMgr.BattlePet pet = null)
public void SetBattlePetData(BattlePet pet = null)
{
if (pet != null)
{
@@ -4683,11 +4684,18 @@ namespace Game.Entities
return null;
}
public Pet SummonPet(uint entry, float x, float y, float z, float ang, PetType petType, uint duration)
public Pet SummonPet(uint entry, float x, float y, float z, float ang, PetType petType, uint duration, bool aliveOnly = false)
{
Pet pet = new(this, petType);
if (petType == PetType.Summon && pet.LoadPetFromDB(this, entry))
{
if (aliveOnly && !pet.IsAlive())
{
pet.DespawnOrUnsummon();
SendTameFailure(PetTameResult.Dead);
return null;
}
if (duration > 0)
pet.SetDuration(duration);
@@ -4836,6 +4844,13 @@ namespace Game.Entities
}
}
void SendTameFailure(PetTameResult result)
{
PetTameFailure petTameFailure = new();
petTameFailure.Result = result;
SendPacket(petTameFailure);
}
public void AddPetAura(PetAura petSpell)
{
m_petAuras.Add(petSpell);
@@ -354,6 +354,18 @@ namespace Game.Networking.Packets
public PetTalk Action;
}
class PetTameFailure : ServerPacket
{
public PetTameFailure() : base(ServerOpcodes.PetTameFailure) { }
public override void Write()
{
_worldPacket.WriteUInt8(Result);
}
public byte Result;
}
//Structs
public class PetSpellCooldown
{
+1 -1
View File
@@ -2309,7 +2309,7 @@ namespace Game.Spells
float x, y, z;
owner.GetClosePoint(out x, out y, out z, owner.GetCombatReach());
Pet pet = owner.SummonPet(petentry, x, y, z, owner.Orientation, PetType.Summon, 0);
Pet pet = owner.SummonPet(petentry, x, y, z, owner.Orientation, PetType.Summon, 0, true);
if (!pet)
return;