Core/BattlePets: Misc fixes
Port From (https://github.com/TrinityCore/TrinityCore/commit/924182f692bde38d8fed85d5dbe7531a09790501)
This commit is contained in:
@@ -1743,7 +1743,7 @@ namespace Framework.Constants
|
|||||||
CannotDismissPet = 0x20, // NYI
|
CannotDismissPet = 0x20, // NYI
|
||||||
UseDemonTimeout = 0x40, // NYI
|
UseDemonTimeout = 0x40, // NYI
|
||||||
UnlimitedSummons = 0x80, // NYI
|
UnlimitedSummons = 0x80, // NYI
|
||||||
UseCreatureLevel = 0x100, // NYI
|
UseCreatureLevel = 0x100,
|
||||||
JoinSummonerSpawnGroup = 0x200, // NYI
|
JoinSummonerSpawnGroup = 0x200, // NYI
|
||||||
DoNotToggle = 0x400, // NYI
|
DoNotToggle = 0x400, // NYI
|
||||||
DespawnWhenExpired = 0x800, // NYI
|
DespawnWhenExpired = 0x800, // NYI
|
||||||
@@ -1756,7 +1756,7 @@ namespace Framework.Constants
|
|||||||
CastRideVehicleSpellOnSummoner = 0x40000, // NYI
|
CastRideVehicleSpellOnSummoner = 0x40000, // NYI
|
||||||
GuardianActsLikePet = 0x80000, // NYI
|
GuardianActsLikePet = 0x80000, // NYI
|
||||||
DontSnapSessileToGround = 0x100000, // NYI
|
DontSnapSessileToGround = 0x100000, // NYI
|
||||||
SummonFromBattlePetJournal = 0x200000, // NYI
|
SummonFromBattlePetJournal = 0x200000,
|
||||||
UnitClutter = 0x400000, // NYI
|
UnitClutter = 0x400000, // NYI
|
||||||
DefaultNameColor = 0x800000, // NYI
|
DefaultNameColor = 0x800000, // NYI
|
||||||
UseOwnInvisibilityDetection = 0x1000000, // NYI. Ignore Owner's Invisibility Detection
|
UseOwnInvisibilityDetection = 0x1000000, // NYI. Ignore Owner's Invisibility Detection
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ using Framework.Database;
|
|||||||
using Game.DataStorage;
|
using Game.DataStorage;
|
||||||
using Game.Entities;
|
using Game.Entities;
|
||||||
using Game.Networking.Packets;
|
using Game.Networking.Packets;
|
||||||
|
using Game.Spells;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -659,10 +660,17 @@ namespace Game.BattlePets
|
|||||||
if (speciesEntry == null)
|
if (speciesEntry == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO: set proper CreatureID for spell SPELL_SUMMON_BATTLE_PET (default EffectMiscValueA is 40721 - Murkimus the Gladiator)
|
|
||||||
Player player = _owner.GetPlayer();
|
Player player = _owner.GetPlayer();
|
||||||
player.SetBattlePetData(pet);
|
player.SetBattlePetData(pet);
|
||||||
player.CastSpell(_owner.GetPlayer(), speciesEntry.SummonSpellID != 0 ? speciesEntry.SummonSpellID : SharedConst.SpellSummonBattlePet);
|
|
||||||
|
CastSpellExtraArgs args = new();
|
||||||
|
uint summonSpellId = speciesEntry.SummonSpellID;
|
||||||
|
if (summonSpellId == 0)
|
||||||
|
{
|
||||||
|
summonSpellId = SharedConst.SpellSummonBattlePet;
|
||||||
|
args.AddSpellMod(SpellValueMod.BasePoint0, (int)speciesEntry.CreatureID);
|
||||||
|
}
|
||||||
|
player.CastSpell(_owner.GetPlayer(), summonSpellId, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DismissPet()
|
public void DismissPet()
|
||||||
|
|||||||
@@ -188,12 +188,8 @@ namespace Game.Entities
|
|||||||
|
|
||||||
Unit owner = GetSummonerUnit();
|
Unit owner = GetSummonerUnit();
|
||||||
if (owner != null && IsTrigger() && m_spells[0] != 0)
|
if (owner != null && IsTrigger() && m_spells[0] != 0)
|
||||||
{
|
|
||||||
SetLevel(owner.GetLevel());
|
|
||||||
if (owner.IsTypeId(TypeId.Player))
|
if (owner.IsTypeId(TypeId.Player))
|
||||||
m_ControlledByPlayer = true;
|
m_ControlledByPlayer = true;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (m_Properties == null)
|
if (m_Properties == null)
|
||||||
return;
|
return;
|
||||||
@@ -211,15 +207,20 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
owner.m_SummonSlot[slot] = GetGUID();
|
owner.m_SummonSlot[slot] = GetGUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_Properties.GetFlags().HasFlag(SummonPropertiesFlags.UseCreatureLevel))
|
||||||
|
SetLevel(owner.GetLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint faction = m_Properties.Faction;
|
uint faction = m_Properties.Faction;
|
||||||
if (m_Properties.GetFlags().HasFlag(SummonPropertiesFlags.UseSummonerFaction)) // TODO: Determine priority between faction and flag
|
if (owner && m_Properties.GetFlags().HasFlag(SummonPropertiesFlags.UseSummonerFaction)) // TODO: Determine priority between faction and flag
|
||||||
if (owner)
|
faction = owner.GetFaction();
|
||||||
faction = owner.GetFaction();
|
|
||||||
|
|
||||||
if (faction != 0)
|
if (faction != 0)
|
||||||
SetFaction(faction);
|
SetFaction(faction);
|
||||||
|
|
||||||
|
if (m_Properties.GetFlags().HasFlag(SummonPropertiesFlags.SummonFromBattlePetJournal))
|
||||||
|
RemoveNpcFlag(NPCFlags.WildBattlePet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void InitSummon()
|
public virtual void InitSummon()
|
||||||
|
|||||||
@@ -83,8 +83,6 @@ namespace Game.Entities
|
|||||||
m_type = TotemType.Active;
|
m_type = TotemType.Active;
|
||||||
|
|
||||||
m_duration = duration;
|
m_duration = duration;
|
||||||
|
|
||||||
SetLevel(GetOwner().GetLevel());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void InitSummon()
|
public override void InitSummon()
|
||||||
|
|||||||
@@ -146,18 +146,29 @@ namespace Game.Entities
|
|||||||
if (GetMinionGUID().IsEmpty())
|
if (GetMinionGUID().IsEmpty())
|
||||||
SetMinionGUID(minion.GetGUID());
|
SetMinionGUID(minion.GetGUID());
|
||||||
|
|
||||||
if (minion.m_Properties != null && minion.m_Properties.Title == SummonTitle.Companion)
|
var properties = minion.m_Properties;
|
||||||
|
if (properties != null && properties.Title == SummonTitle.Companion)
|
||||||
{
|
{
|
||||||
SetCritterGUID(minion.GetGUID());
|
SetCritterGUID(minion.GetGUID());
|
||||||
Player thisPlayer = ToPlayer();
|
Player thisPlayer = ToPlayer();
|
||||||
if (thisPlayer != null)
|
if (thisPlayer != null)
|
||||||
{
|
{
|
||||||
var pet = thisPlayer.GetSession().GetBattlePetMgr().GetPet(thisPlayer.GetSummonedBattlePetGUID());
|
if (properties.GetFlags().HasFlag(SummonPropertiesFlags.SummonFromBattlePetJournal))
|
||||||
if (pet != null)
|
|
||||||
{
|
{
|
||||||
minion.SetBattlePetCompanionGUID(thisPlayer.GetSummonedBattlePetGUID());
|
var pet = thisPlayer.GetSession().GetBattlePetMgr().GetPet(thisPlayer.GetSummonedBattlePetGUID());
|
||||||
minion.SetBattlePetCompanionNameTimestamp((uint)pet.NameTimestamp);
|
if (pet != null)
|
||||||
minion.SetWildBattlePetLevel(pet.PacketInfo.Level);
|
{
|
||||||
|
minion.SetBattlePetCompanionGUID(thisPlayer.GetSummonedBattlePetGUID());
|
||||||
|
minion.SetBattlePetCompanionNameTimestamp((uint)pet.NameTimestamp);
|
||||||
|
minion.SetWildBattlePetLevel(pet.PacketInfo.Level);
|
||||||
|
|
||||||
|
uint display = pet.PacketInfo.DisplayID;
|
||||||
|
if (display != 0)
|
||||||
|
{
|
||||||
|
minion.SetDisplayId(display);
|
||||||
|
minion.SetNativeDisplayId(display);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1598,9 +1598,6 @@ namespace Game.Spells
|
|||||||
if (summon == null || !summon.HasUnitTypeMask(UnitTypeMask.Minion))
|
if (summon == null || !summon.HasUnitTypeMask(UnitTypeMask.Minion))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
summon.SelectLevel(); // some summoned creaters have different from 1 DB data for level/hp
|
|
||||||
summon.SetNpcFlags((NPCFlags)((int)summon.GetCreatureTemplate().Npcflag & 0xFFFFFFFF));
|
|
||||||
summon.SetNpcFlags2((NPCFlags2)((int)summon.GetCreatureTemplate().Npcflag >> 32));
|
|
||||||
summon.SetImmuneToAll(true);
|
summon.SetImmuneToAll(true);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -4504,21 +4501,6 @@ namespace Game.Spells
|
|||||||
unitCaster = unitCaster.ToTotem().GetOwner();
|
unitCaster = unitCaster.ToTotem().GetOwner();
|
||||||
|
|
||||||
// in another case summon new
|
// in another case summon new
|
||||||
uint level = unitCaster.GetLevel();
|
|
||||||
|
|
||||||
// level of pet summoned using engineering item based at engineering skill level
|
|
||||||
if (m_CastItem != null && unitCaster.IsPlayer())
|
|
||||||
{
|
|
||||||
ItemTemplate proto = m_CastItem.GetTemplate();
|
|
||||||
if (proto != null)
|
|
||||||
if (proto.GetRequiredSkill() == (uint)SkillType.Engineering)
|
|
||||||
{
|
|
||||||
ushort skill202 = unitCaster.ToPlayer().GetSkillValue(SkillType.Engineering);
|
|
||||||
if (skill202 != 0)
|
|
||||||
level = (uint)(skill202 / 5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float radius = 5.0f;
|
float radius = 5.0f;
|
||||||
int duration = m_spellInfo.CalcDuration(m_originalCaster);
|
int duration = m_spellInfo.CalcDuration(m_originalCaster);
|
||||||
|
|
||||||
@@ -4537,8 +4519,30 @@ namespace Game.Spells
|
|||||||
TempSummon summon = map.SummonCreature(entry, pos, properties, (uint)duration, unitCaster, m_spellInfo.Id, 0, privateObjectOwner);
|
TempSummon summon = map.SummonCreature(entry, pos, properties, (uint)duration, unitCaster, m_spellInfo.Id, 0, privateObjectOwner);
|
||||||
if (summon == null)
|
if (summon == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (summon.HasUnitTypeMask(UnitTypeMask.Guardian))
|
if (summon.HasUnitTypeMask(UnitTypeMask.Guardian))
|
||||||
|
{
|
||||||
|
uint level = summon.GetLevel();
|
||||||
|
if (properties != null && !properties.GetFlags().HasFlag(SummonPropertiesFlags.UseCreatureLevel))
|
||||||
|
level = unitCaster.GetLevel();
|
||||||
|
|
||||||
|
// level of pet summoned using engineering item based at engineering skill level
|
||||||
|
if (m_CastItem && unitCaster.IsPlayer())
|
||||||
|
{
|
||||||
|
ItemTemplate proto = m_CastItem.GetTemplate();
|
||||||
|
if (proto != null)
|
||||||
|
{
|
||||||
|
if (proto.GetRequiredSkill() == (uint)SkillType.Engineering)
|
||||||
|
{
|
||||||
|
ushort skill202 = unitCaster.ToPlayer().GetSkillValue(SkillType.Engineering);
|
||||||
|
if (skill202 != 0)
|
||||||
|
level = skill202 / 5u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
((Guardian)summon).InitStatsForLevel(level);
|
((Guardian)summon).InitStatsForLevel(level);
|
||||||
|
}
|
||||||
|
|
||||||
if (summon.HasUnitTypeMask(UnitTypeMask.Minion) && m_targets.HasDst())
|
if (summon.HasUnitTypeMask(UnitTypeMask.Minion) && m_targets.HasDst())
|
||||||
((Minion)summon).SetFollowAngle(unitCaster.GetAbsoluteAngle(summon.GetPosition()));
|
((Minion)summon).SetFollowAngle(unitCaster.GetAbsoluteAngle(summon.GetPosition()));
|
||||||
|
|||||||
@@ -4149,6 +4149,33 @@ namespace Scripts.Spells.Generic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Script]// 118301 - Summon Battle Pet
|
||||||
|
class spell_summon_battle_pet : SpellScript
|
||||||
|
{
|
||||||
|
void HandleSummon(uint effIndex)
|
||||||
|
{
|
||||||
|
uint creatureId = (uint)GetSpellValue().EffectBasePoints[effIndex];
|
||||||
|
if (Global.ObjectMgr.GetCreatureTemplate(creatureId) != null)
|
||||||
|
{
|
||||||
|
PreventHitDefaultEffect(effIndex);
|
||||||
|
|
||||||
|
Unit caster = GetCaster();
|
||||||
|
var properties = CliDB.SummonPropertiesStorage.LookupByKey((uint)GetEffectInfo().MiscValueB);
|
||||||
|
uint duration = (uint)GetSpellInfo().CalcDuration(caster);
|
||||||
|
Position pos = GetHitDest().GetPosition();
|
||||||
|
|
||||||
|
Creature summon = caster.GetMap().SummonCreature(creatureId, pos, properties, duration, caster, GetSpellInfo().Id);
|
||||||
|
if (summon != null)
|
||||||
|
summon.SetImmuneToAll(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Register()
|
||||||
|
{
|
||||||
|
OnEffectHit.Add(new EffectHandler(HandleSummon, 0, SpellEffectName.Summon));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 40307 - Stasis Field
|
// 40307 - Stasis Field
|
||||||
class StasisFieldSearcher : ICheck<Unit>
|
class StasisFieldSearcher : ICheck<Unit>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user