Core/Spells: Fixed ErrorCube spell missiles

Port From (https://github.com/TrinityCore/TrinityCore/commit/ce794f3978e853341b2dc0c782e7bda34303b3f8)
This commit is contained in:
hondacrx
2021-11-18 14:30:42 -05:00
parent 83f9cbe66f
commit 9268b931c8
10 changed files with 427 additions and 166 deletions
+15
View File
@@ -2229,4 +2229,19 @@ namespace Framework.Constants
HideUntilLearned = 0x4000,
MatchPlayerHighPetLevel = 0x8000
}
public enum SpellVisualEffectNameType
{
Model = 0,
Item = 1,
Creature = 2,
UnitItemMainHand = 3,
UnitItemOffHand = 4,
UnitItemRanged = 5,
UnitAmmoBasic = 6,
UnitAmmoPreferred = 7,
UnitItemMainHandIgnoreDisarmed = 8,
UnitItemOffHandIgnoreDisarmed = 9,
UnitItemRangedIgnoreDisarmed = 10
}
}
@@ -1928,7 +1928,7 @@ namespace Framework.Constants
{
Unk0 = 0x01, // 0
Unk1 = 0x02, // 1
Unk2 = 0x04, // 2
UsesRangedSlotCosmeticOnly = 0x04, // 2
Unk3 = 0x08, // 3
WaterSpout = 0x10, // 4
Unk5 = 0x20, // 5
@@ -1120,8 +1120,23 @@ namespace Framework.Database
"Targets, Width, SpellID FROM spell_target_restrictions");
// SpellTotems.db2
PrepareStatement(HotfixStatements.SEL_SPELL_TOTEMS, "SELECT ID, SpellID, RequiredTotemCategoryID1, RequiredTotemCategoryID2, Totem1, Totem2" +
" FROM spell_totems");
PrepareStatement(HotfixStatements.SEL_SPELL_TOTEMS, "SELECT ID, SpellID, RequiredTotemCategoryID1, RequiredTotemCategoryID2, Totem1, Totem2 FROM spell_totems");
// SpellVisual.db2
PrepareStatement(HotfixStatements.SEL_SPELL_VISUAL, "SELECT ID, MissileCastOffset1, MissileCastOffset2, MissileCastOffset3, MissileImpactOffset1, " +
"MissileImpactOffset2, MissileImpactOffset3, AnimEventSoundID, Flags, MissileAttachment, MissileDestinationAttachment, " +
"MissileCastPositionerID, MissileImpactPositionerID, MissileTargetingKit, HostileSpellVisualID, CasterSpellVisualID, SpellVisualMissileSetID, " +
"DamageNumberDelay, LowViolenceSpellVisualID, RaidSpellVisualMissileSetID, ReducedUnexpectedCameraMovementSpellVisualID FROM spell_visual");
// SpellVisualEffectName.db2
PrepareStatement(HotfixStatements.SEL_SPELL_VISUAL_EFFECT_NAME, "SELECT ID, ModelFileDataID, BaseMissileSpeed, Scale, MinAllowedScale, MaxAllowedScale, " +
"Alpha, Flags, TextureFileDataID, EffectRadius, Type, GenericID, RibbonQualityID, DissolveEffectID, ModelPosition, Unknown901 FROM spell_visual_effect_name");
// SpellVisualMissile.db2
PrepareStatement(HotfixStatements.SEL_SPELL_VISUAL_MISSILE, "SELECT CastOffset1, CastOffset2, CastOffset3, ImpactOffset1, ImpactOffset2, ImpactOffset3, ID, " +
"SpellVisualEffectNameID, SoundEntriesID, Attachment, DestinationAttachment, CastPositionerID, ImpactPositionerID, FollowGroundHeight, " +
"FollowGroundDropSpeed, FollowGroundApproach, Flags, SpellMissileMotionID, AnimKitID, ClutterLevel, DecayTimeAfterImpact, " +
"SpellVisualMissileSetID FROM spell_visual_missile");
// SpellVisualKit.db2
PrepareStatement(HotfixStatements.SEL_SPELL_VISUAL_KIT, "SELECT ID, FallbackPriority, FallbackSpellVisualKitId, DelayMin, DelayMax, Flags1, Flags2" +
@@ -1853,6 +1868,12 @@ namespace Framework.Database
SEL_SPELL_TOTEMS,
SEL_SPELL_VISUAL,
SEL_SPELL_VISUAL_EFFECT_NAME,
SEL_SPELL_VISUAL_MISSILE,
SEL_SPELL_VISUAL_KIT,
SEL_SPELL_X_SPELL_VISUAL,
+6
View File
@@ -310,6 +310,9 @@ namespace Game.DataStorage
SpellShapeshiftFormStorage = ReadDB2<SpellShapeshiftFormRecord>("SpellShapeshiftForm.db2", HotfixStatements.SEL_SPELL_SHAPESHIFT_FORM, HotfixStatements.SEL_SPELL_SHAPESHIFT_FORM_LOCALE);
SpellTargetRestrictionsStorage = ReadDB2<SpellTargetRestrictionsRecord>("SpellTargetRestrictions.db2", HotfixStatements.SEL_SPELL_TARGET_RESTRICTIONS);
SpellTotemsStorage = ReadDB2<SpellTotemsRecord>("SpellTotems.db2", HotfixStatements.SEL_SPELL_TOTEMS);
SpellVisualStorage = ReadDB2<SpellVisualRecord>("SpellVisual.db2", HotfixStatements.SEL_SPELL_VISUAL);
SpellVisualEffectNameStorage = ReadDB2<SpellVisualEffectNameRecord>("SpellVisualEffectName.db2", HotfixStatements.SEL_SPELL_VISUAL_EFFECT_NAME);
SpellVisualMissileStorage = ReadDB2<SpellVisualMissileRecord>("SpellVisualMissile.db2", HotfixStatements.SEL_SPELL_VISUAL_MISSILE);
SpellVisualKitStorage = ReadDB2<SpellVisualKitRecord>("SpellVisualKit.db2", HotfixStatements.SEL_SPELL_VISUAL_KIT);
SpellXSpellVisualStorage = ReadDB2<SpellXSpellVisualRecord>("SpellXSpellVisual.db2", HotfixStatements.SEL_SPELL_X_SPELL_VISUAL);
SummonPropertiesStorage = ReadDB2<SummonPropertiesRecord>("SummonProperties.db2", HotfixStatements.SEL_SUMMON_PROPERTIES);
@@ -695,6 +698,9 @@ namespace Game.DataStorage
public static DB6Storage<SpellShapeshiftFormRecord> SpellShapeshiftFormStorage;
public static DB6Storage<SpellTargetRestrictionsRecord> SpellTargetRestrictionsStorage;
public static DB6Storage<SpellTotemsRecord> SpellTotemsStorage;
public static DB6Storage<SpellVisualRecord> SpellVisualStorage;
public static DB6Storage<SpellVisualEffectNameRecord> SpellVisualEffectNameStorage;
public static DB6Storage<SpellVisualMissileRecord> SpellVisualMissileStorage;
public static DB6Storage<SpellVisualKitRecord> SpellVisualKitStorage;
public static DB6Storage<SpellXSpellVisualRecord> SpellXSpellVisualStorage;
public static DB6Storage<SummonPropertiesRecord> SummonPropertiesStorage;
+9
View File
@@ -507,6 +507,9 @@ namespace Game.DataStorage
foreach (SpellProcsPerMinuteModRecord ppmMod in SpellProcsPerMinuteModStorage.Values)
_spellProcsPerMinuteMods.Add(ppmMod.SpellProcsPerMinuteID, ppmMod);
foreach (SpellVisualMissileRecord spellVisualMissile in SpellVisualMissileStorage.Values)
_spellVisualMissilesBySet.Add(spellVisualMissile.SpellVisualMissileSetID, spellVisualMissile);
for (var i = 0; i < (int)Class.Max; ++i)
{
_talentsByPosition[i] = new List<TalentRecord>[PlayerConst.MaxTalentTiers][];
@@ -2009,6 +2012,11 @@ namespace Game.DataStorage
return _spellProcsPerMinuteMods.LookupByKey(spellprocsPerMinuteId);
}
public List<SpellVisualMissileRecord> GetSpellVisualMissiles(int spellVisualMissileSetId)
{
return _spellVisualMissilesBySet.LookupByKey(spellVisualMissileSetId);
}
public List<TalentRecord> GetTalentsByPosition(Class class_, uint tier, uint column)
{
return _talentsByPosition[(int)class_][tier][column];
@@ -2409,6 +2417,7 @@ namespace Game.DataStorage
List<Tuple<int, uint>> _specsBySpecSet = new();
List<byte> _spellFamilyNames = new();
MultiMap<uint, SpellProcsPerMinuteModRecord> _spellProcsPerMinuteMods = new();
MultiMap<uint, SpellVisualMissileRecord> _spellVisualMissilesBySet = new();
List<TalentRecord>[][][] _talentsByPosition = new List<TalentRecord>[(int)Class.Max][][];
List<uint> _toys = new();
Dictionary<uint, TransmogIllusionRecord> _transmogIllusionsByEnchantmentId = new();
@@ -555,6 +555,69 @@ namespace Game.DataStorage
public uint[] Totem = new uint[SpellConst.MaxTotems];
}
public sealed class SpellVisualRecord
{
public uint Id;
public float[] MissileCastOffset = new float[3];
public float[] MissileImpactOffset = new float[3];
public uint AnimEventSoundID;
public int Flags;
public sbyte MissileAttachment;
public sbyte MissileDestinationAttachment;
public uint MissileCastPositionerID;
public uint MissileImpactPositionerID;
public int MissileTargetingKit;
public uint HostileSpellVisualID;
public uint CasterSpellVisualID;
public ushort SpellVisualMissileSetID;
public ushort DamageNumberDelay;
public uint LowViolenceSpellVisualID;
public uint RaidSpellVisualMissileSetID;
public int ReducedUnexpectedCameraMovementSpellVisualID;
}
public sealed class SpellVisualEffectNameRecord
{
public uint Id;
public int ModelFileDataID;
public float BaseMissileSpeed;
public float Scale;
public float MinAllowedScale;
public float MaxAllowedScale;
public float Alpha;
public uint Flags;
public int TextureFileDataID;
public float EffectRadius;
public uint Type;
public int GenericID;
public uint RibbonQualityID;
public int DissolveEffectID;
public int ModelPosition;
public sbyte Unknown901;
}
public sealed class SpellVisualMissileRecord
{
public float[] CastOffset = new float[3];
public float[] ImpactOffset = new float[3];
public uint Id;
public ushort SpellVisualEffectNameID;
public uint SoundEntriesID;
public sbyte Attachment;
public sbyte DestinationAttachment;
public ushort CastPositionerID;
public ushort ImpactPositionerID;
public int FollowGroundHeight;
public uint FollowGroundDropSpeed;
public ushort FollowGroundApproach;
public uint Flags;
public ushort SpellMissileMotionID;
public uint AnimKitID;
public sbyte ClutterLevel;
public int DecayTimeAfterImpact;
public uint SpellVisualMissileSetID;
}
public sealed class SpellVisualKitRecord
{
public uint Id;
+14 -2
View File
@@ -3493,7 +3493,7 @@ namespace Game.Spells
if (((IsTriggered() && !m_spellInfo.IsAutoRepeatRangedSpell()) || m_triggeredByAuraSpell != null) && !m_fromClient)
castFlags |= SpellCastFlags.Pending;
if (m_spellInfo.HasAttribute(SpellAttr0.ReqAmmo) || m_spellInfo.HasAttribute(SpellCustomAttributes.NeedsAmmoData))
if (m_spellInfo.HasAttribute(SpellAttr0.ReqAmmo) || m_spellInfo.HasAttribute(SpellAttr10.UsesRangedSlotCosmeticOnly) || m_spellInfo.HasAttribute(SpellCustomAttributes.NeedsAmmoData))
castFlags |= SpellCastFlags.Projectile;
if ((m_caster.IsTypeId(TypeId.Player) || (m_caster.IsTypeId(TypeId.Unit) && m_caster.ToCreature().IsPet())) && m_powerCost.Any(cost => cost.Power != PowerType.Health))
@@ -3594,7 +3594,7 @@ namespace Game.Spells
if (((IsTriggered() && !m_spellInfo.IsAutoRepeatRangedSpell()) || m_triggeredByAuraSpell != null) && !m_fromClient)
castFlags |= SpellCastFlags.Pending;
if (m_spellInfo.HasAttribute(SpellAttr0.ReqAmmo) || m_spellInfo.HasAttribute(SpellCustomAttributes.NeedsAmmoData))
if (m_spellInfo.HasAttribute(SpellAttr0.ReqAmmo) || m_spellInfo.HasAttribute(SpellAttr10.UsesRangedSlotCosmeticOnly) || m_spellInfo.HasAttribute(SpellCustomAttributes.NeedsAmmoData))
castFlags |= SpellCastFlags.Projectile; // arrows/bullets visual
if ((m_caster.IsTypeId(TypeId.Player) || (m_caster.IsTypeId(TypeId.Unit) && m_caster.ToCreature().IsPet())) && m_powerCost.Any(cost => cost.Power != PowerType.Health))
@@ -3734,6 +3734,8 @@ namespace Game.Spells
Unit unitCaster = m_caster.ToUnit();
if (unitCaster != null)
{
uint nonRangedAmmoDisplayID = 0;
InventoryType nonRangedAmmoInventoryType = 0;
for (byte i = (int)WeaponAttackType.BaseAttack; i < (int)WeaponAttackType.Max; ++i)
{
uint itemId = unitCaster.GetVirtualItemId(i);
@@ -3759,6 +3761,10 @@ namespace Game.Spells
ammoDisplayID = 5998; // is this need fixing?
ammoInventoryType = InventoryType.Ammo;
break;
default:
nonRangedAmmoDisplayID = Global.DB2Mgr.GetItemDisplayId(itemId, unitCaster.GetVirtualItemAppearanceMod(i));
nonRangedAmmoInventoryType = itemEntry.inventoryType;
break;
}
if (ammoDisplayID != 0)
@@ -3767,6 +3773,12 @@ namespace Game.Spells
}
}
}
if (ammoDisplayID == 0 && ammoInventoryType == 0)
{
ammoDisplayID = nonRangedAmmoDisplayID;
ammoInventoryType = nonRangedAmmoInventoryType;
}
}
}
+5
View File
@@ -3803,6 +3803,11 @@ namespace Game.Spells
return false;
}
public List<SpellXSpellVisualRecord> GetSpellVisuals()
{
return _visuals;
}
public bool HasAttribute(SpellAttr0 attribute) { return Convert.ToBoolean(Attributes & attribute); }
public bool HasAttribute(SpellAttr1 attribute) { return Convert.ToBoolean(AttributesEx & attribute); }
public bool HasAttribute(SpellAttr2 attribute) { return Convert.ToBoolean(AttributesEx2 & attribute); }
+36
View File
@@ -2897,6 +2897,42 @@ namespace Game.Entities
}
spellInfo._InitializeExplicitTargetMask();
if (spellInfo.Speed > 0.0f)
{
bool visualNeedsAmmo(SpellXSpellVisualRecord spellXspellVisual)
{
SpellVisualRecord spellVisual = CliDB.SpellVisualStorage.LookupByKey(spellXspellVisual.SpellVisualID);
if (spellVisual == null)
return false;
var spellVisualMissiles = Global.DB2Mgr.GetSpellVisualMissiles(spellVisual.SpellVisualMissileSetID);
if (spellVisualMissiles.Empty())
return false;
foreach (SpellVisualMissileRecord spellVisualMissile in spellVisualMissiles)
{
var spellVisualEffectName = CliDB.SpellVisualEffectNameStorage.LookupByKey(spellVisualMissile.SpellVisualEffectNameID);
if (spellVisualEffectName == null)
continue;
SpellVisualEffectNameType type = (SpellVisualEffectNameType)spellVisualEffectName.Type;
if (type == SpellVisualEffectNameType.UnitAmmoBasic || type == SpellVisualEffectNameType.UnitAmmoPreferred)
return true;
}
return false;
}
foreach (SpellXSpellVisualRecord spellXspellVisual in spellInfo.GetSpellVisuals())
{
if (visualNeedsAmmo(spellXspellVisual))
{
spellInfo.AttributesCu |= SpellCustomAttributes.NeedsAmmoData;
break;
}
}
}
}
// addition for binary spells, omit spells triggering other spells
@@ -0,0 +1,94 @@
--
-- Table structure for table `spell_visual`
--
DROP TABLE IF EXISTS `spell_visual`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `spell_visual` (
`ID` int(10) unsigned NOT NULL DEFAULT '0',
`MissileCastOffset1` float NOT NULL DEFAULT '0',
`MissileCastOffset2` float NOT NULL DEFAULT '0',
`MissileCastOffset3` float NOT NULL DEFAULT '0',
`MissileImpactOffset1` float NOT NULL DEFAULT '0',
`MissileImpactOffset2` float NOT NULL DEFAULT '0',
`MissileImpactOffset3` float NOT NULL DEFAULT '0',
`AnimEventSoundID` int(10) unsigned NOT NULL DEFAULT '0',
`Flags` int(11) NOT NULL DEFAULT '0',
`MissileAttachment` tinyint(4) NOT NULL DEFAULT '0',
`MissileDestinationAttachment` tinyint(4) NOT NULL DEFAULT '0',
`MissileCastPositionerID` int(10) unsigned NOT NULL DEFAULT '0',
`MissileImpactPositionerID` int(10) unsigned NOT NULL DEFAULT '0',
`MissileTargetingKit` int(11) NOT NULL DEFAULT '0',
`HostileSpellVisualID` int(10) unsigned NOT NULL DEFAULT '0',
`CasterSpellVisualID` int(10) unsigned NOT NULL DEFAULT '0',
`SpellVisualMissileSetID` smallint(5) unsigned NOT NULL DEFAULT '0',
`DamageNumberDelay` smallint(5) unsigned NOT NULL DEFAULT '0',
`LowViolenceSpellVisualID` int(10) unsigned NOT NULL DEFAULT '0',
`RaidSpellVisualMissileSetID` int(10) unsigned NOT NULL DEFAULT '0',
`ReducedUnexpectedCameraMovementSpellVisualID` int(11) NOT NULL DEFAULT '0',
`VerifiedBuild` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`,`VerifiedBuild`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `spell_visual_effect_name`
--
DROP TABLE IF EXISTS `spell_visual_effect_name`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `spell_visual_effect_name` (
`ID` int(10) unsigned NOT NULL DEFAULT '0',
`ModelFileDataID` int(11) NOT NULL DEFAULT '0',
`BaseMissileSpeed` float NOT NULL DEFAULT '0',
`Scale` float NOT NULL DEFAULT '0',
`MinAllowedScale` float NOT NULL DEFAULT '0',
`MaxAllowedScale` float NOT NULL DEFAULT '0',
`Alpha` float NOT NULL DEFAULT '0',
`Flags` int(10) unsigned NOT NULL DEFAULT '0',
`TextureFileDataID` int(11) NOT NULL DEFAULT '0',
`EffectRadius` float NOT NULL DEFAULT '0',
`Type` int(10) unsigned NOT NULL DEFAULT '0',
`GenericID` int(11) NOT NULL DEFAULT '0',
`RibbonQualityID` int(10) unsigned NOT NULL DEFAULT '0',
`DissolveEffectID` int(11) NOT NULL DEFAULT '0',
`ModelPosition` int(11) NOT NULL DEFAULT '0',
`Unknown901` tinyint(4) NOT NULL DEFAULT '0',
`VerifiedBuild` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`,`VerifiedBuild`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `spell_visual_missile`
--
DROP TABLE IF EXISTS `spell_visual_missile`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `spell_visual_missile` (
`CastOffset1` float NOT NULL DEFAULT '0',
`CastOffset2` float NOT NULL DEFAULT '0',
`CastOffset3` float NOT NULL DEFAULT '0',
`ImpactOffset1` float NOT NULL DEFAULT '0',
`ImpactOffset2` float NOT NULL DEFAULT '0',
`ImpactOffset3` float NOT NULL DEFAULT '0',
`ID` int(10) unsigned NOT NULL DEFAULT '0',
`SpellVisualEffectNameID` smallint(5) unsigned NOT NULL DEFAULT '0',
`SoundEntriesID` int(10) unsigned NOT NULL DEFAULT '0',
`Attachment` tinyint(4) NOT NULL DEFAULT '0',
`DestinationAttachment` tinyint(4) NOT NULL DEFAULT '0',
`CastPositionerID` smallint(5) unsigned NOT NULL DEFAULT '0',
`ImpactPositionerID` smallint(5) unsigned NOT NULL DEFAULT '0',
`FollowGroundHeight` int(11) NOT NULL DEFAULT '0',
`FollowGroundDropSpeed` int(10) unsigned NOT NULL DEFAULT '0',
`FollowGroundApproach` smallint(5) unsigned NOT NULL DEFAULT '0',
`Flags` int(10) unsigned NOT NULL DEFAULT '0',
`SpellMissileMotionID` smallint(5) unsigned NOT NULL DEFAULT '0',
`AnimKitID` int(10) unsigned NOT NULL DEFAULT '0',
`ClutterLevel` tinyint(4) NOT NULL DEFAULT '0',
`DecayTimeAfterImpact` int(11) NOT NULL DEFAULT '0',
`SpellVisualMissileSetID` int(10) unsigned NOT NULL DEFAULT '0',
`VerifiedBuild` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`,`VerifiedBuild`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;