Core/Spells: Implemented SpellReagentsCurrency.db2

Port From (https://github.com/TrinityCore/TrinityCore/commit/8492c273dd50227ca01ead785eda6c4de9361e74)
This commit is contained in:
hondacrx
2021-10-10 17:02:33 -04:00
parent feec594e98
commit 706567186c
7 changed files with 77 additions and 3 deletions
@@ -1048,6 +1048,9 @@ namespace Framework.Database
PrepareStatement(HotfixStatements.SEL_SPELL_REAGENTS, "SELECT ID, SpellID, Reagent1, Reagent2, Reagent3, Reagent4, Reagent5, Reagent6, Reagent7, Reagent8, " +
"ReagentCount1, ReagentCount2, ReagentCount3, ReagentCount4, ReagentCount5, ReagentCount6, ReagentCount7, ReagentCount8 FROM spell_reagents");
// SpellReagentsCurrency.db2
PrepareStatement(HotfixStatements.SEL_SPELL_REAGENTS_CURRENCY, "SELECT ID, SpellID, CurrencyTypesID, CurrencyCount FROM spell_reagents_currency");
// SpellScaling.db2
PrepareStatement(HotfixStatements.SEL_SPELL_SCALING, "SELECT ID, SpellID, MinScalingLevel, MaxScalingLevel, ScalesFromItemLevel FROM spell_scaling");
@@ -1749,6 +1752,8 @@ namespace Framework.Database
SEL_SPELL_REAGENTS,
SEL_SPELL_REAGENTS_CURRENCY,
SEL_SPELL_SCALING,
SEL_SPELL_SHAPESHIFT,
+2
View File
@@ -293,6 +293,7 @@ namespace Game.DataStorage
SpellRadiusStorage = ReadDB2<SpellRadiusRecord>("SpellRadius.db2", HotfixStatements.SEL_SPELL_RADIUS);
SpellRangeStorage = ReadDB2<SpellRangeRecord>("SpellRange.db2", HotfixStatements.SEL_SPELL_RANGE, HotfixStatements.SEL_SPELL_RANGE_LOCALE);
SpellReagentsStorage = ReadDB2<SpellReagentsRecord>("SpellReagents.db2", HotfixStatements.SEL_SPELL_REAGENTS);
SpellReagentsCurrencyStorage = ReadDB2<SpellReagentsCurrencyRecord>("SpellReagentsCurrency.db2", HotfixStatements.SEL_SPELL_REAGENTS_CURRENCY);
SpellScalingStorage = ReadDB2<SpellScalingRecord>("SpellScaling.db2", HotfixStatements.SEL_SPELL_SCALING);
SpellShapeshiftStorage = ReadDB2<SpellShapeshiftRecord>("SpellShapeshift.db2", HotfixStatements.SEL_SPELL_SHAPESHIFT);
SpellShapeshiftFormStorage = ReadDB2<SpellShapeshiftFormRecord>("SpellShapeshiftForm.db2", HotfixStatements.SEL_SPELL_SHAPESHIFT_FORM, HotfixStatements.SEL_SPELL_SHAPESHIFT_FORM_LOCALE);
@@ -665,6 +666,7 @@ namespace Game.DataStorage
public static DB6Storage<SpellRadiusRecord> SpellRadiusStorage;
public static DB6Storage<SpellRangeRecord> SpellRangeStorage;
public static DB6Storage<SpellReagentsRecord> SpellReagentsStorage;
public static DB6Storage<SpellReagentsCurrencyRecord> SpellReagentsCurrencyStorage;
public static DB6Storage<SpellScalingRecord> SpellScalingStorage;
public static DB6Storage<SpellShapeshiftRecord> SpellShapeshiftStorage;
public static DB6Storage<SpellShapeshiftFormRecord> SpellShapeshiftFormStorage;
@@ -482,6 +482,14 @@ namespace Game.DataStorage
public ushort[] ReagentCount = new ushort[SpellConst.MaxReagents];
}
public sealed class SpellReagentsCurrencyRecord
{
public uint Id;
public int SpellID;
public ushort CurrencyTypesID;
public ushort CurrencyCount;
}
public sealed class SpellScalingRecord
{
public uint Id;
+29 -3
View File
@@ -3367,7 +3367,6 @@ namespace Game.Spells
packet.FailedArg1 = (int)param1;
else
{
uint missingItem = 0;
for (uint i = 0; i < SpellConst.MaxReagents; i++)
{
if (spellInfo.Reagent[i] <= 0)
@@ -3378,12 +3377,25 @@ namespace Game.Spells
if (!caster.HasItemCount(itemid, itemcount))
{
missingItem = itemid;
packet.FailedArg1 = (int)itemid; // first missing item
break;
}
}
}
packet.FailedArg1 = (int)missingItem; // first missing item
if (param2.HasValue)
packet.FailedArg2 = (int)param2;
else if (!param1.HasValue)
{
foreach (var reagentsCurrency in spellInfo.ReagentsCurrency)
{
if (!caster.HasCurrency(reagentsCurrency.CurrencyTypesID, reagentsCurrency.CurrencyCount))
{
packet.FailedArg1 = -1;
packet.FailedArg2 = reagentsCurrency.CurrencyTypesID;
break;
}
}
}
break;
}
@@ -4240,6 +4252,9 @@ namespace Game.Spells
p_caster.DestroyItemCount(itemid, itemcount, true);
}
foreach (var reagentsCurrency in m_spellInfo.ReagentsCurrency)
p_caster.ModifyCurrency((CurrencyTypes)reagentsCurrency.CurrencyTypesID, -reagentsCurrency.CurrencyCount, false, true);
}
void HandleThreatSpells()
@@ -6002,6 +6017,17 @@ namespace Game.Spells
return SpellCastResult.Reagents;
}
}
foreach (var reagentsCurrency in m_spellInfo.ReagentsCurrency)
{
if (!player.HasCurrency(reagentsCurrency.CurrencyTypesID, reagentsCurrency.CurrencyCount))
{
param1 = -1;
param2 = reagentsCurrency.CurrencyTypesID;
return SpellCastResult.Reagents;
}
}
}
// check totem-item requirements (items presence in inventory)
+3
View File
@@ -208,6 +208,8 @@ namespace Game.Spells
}
}
ReagentsCurrency = data.ReagentsCurrency;
// SpellShapeshiftEntry
SpellShapeshiftRecord _shapeshift = data.Shapeshift;
if (_shapeshift != null)
@@ -3883,6 +3885,7 @@ namespace Game.Spells
public uint[] TotemCategory = new uint[SpellConst.MaxTotems];
public int[] Reagent = new int[SpellConst.MaxReagents];
public uint[] ReagentCount = new uint[SpellConst.MaxReagents];
public List<SpellReagentsCurrencyRecord> ReagentsCurrency = new();
public ItemClass EquippedItemClass { get; set; }
public int EquippedItemSubClassMask { get; set; }
public int EquippedItemInventoryTypeMask { get; set; }
+7
View File
@@ -2255,6 +2255,9 @@ namespace Game.Entities
foreach (SpellReagentsRecord reagents in CliDB.SpellReagentsStorage.Values)
GetLoadHelper(reagents.SpellID, 0).Reagents = reagents;
foreach (SpellReagentsCurrencyRecord reagentsCurrency in CliDB.SpellReagentsCurrencyStorage.Values)
GetLoadHelper((uint)reagentsCurrency.SpellID, 0).ReagentsCurrency.Add(reagentsCurrency);
foreach (SpellScalingRecord scaling in CliDB.SpellScalingStorage.Values)
GetLoadHelper(scaling.SpellID, 0).Scaling = scaling;
@@ -2336,6 +2339,9 @@ namespace Game.Entities
if (data.Value.Reagents == null)
data.Value.Reagents = fallbackData.Reagents;
if (data.Value.ReagentsCurrency.Empty())
data.Value.ReagentsCurrency = fallbackData.ReagentsCurrency;
if (data.Value.Scaling == null)
data.Value.Scaling = fallbackData.Scaling;
@@ -4672,6 +4678,7 @@ namespace Game.Entities
public SpellMiscRecord Misc;
public SpellPowerRecord[] Powers = new SpellPowerRecord[SpellConst.MaxPowersPerSpell];
public SpellReagentsRecord Reagents;
public List<SpellReagentsCurrencyRecord> ReagentsCurrency = new();
public SpellScalingRecord Scaling;
public SpellShapeshiftRecord Shapeshift;
public SpellTargetRestrictionsRecord TargetRestrictions;
@@ -0,0 +1,23 @@
--
-- Table structure for table `spell_reagents_currency`
--
DROP TABLE IF EXISTS `spell_reagents_currency`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `spell_reagents_currency` (
`ID` int(10) unsigned NOT NULL DEFAULT '0',
`SpellID` int(11) NOT NULL DEFAULT '0',
`CurrencyTypesID` smallint(5) unsigned NOT NULL DEFAULT '0',
`CurrencyCount` smallint(5) 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 */;
--
-- Table data for table `spell_reagents_currency`
--
INSERT INTO `spell_reagents_currency`
SELECT hb.`RecordId`, CONV(HEX(SUBSTRING(hb.`Blob`, 1, 4)), 16, 10), CONV(HEX(SUBSTRING(hb.`Blob`, 5, 2)), 16, 10), CONV(HEX(SUBSTRING(hb.`Blob`, 7, 2)), 16, 10), hb.`VerifiedBuild` FROM `hotfix_blob` hb WHERE hb.`TableHash`=0x2049B60C AND hb.`locale`='enUS';
DELETE FROM `hotfix_blob` WHERE `TableHash`=0x2049B60C;