mangos服务端的生物技能伤害倍率系统参考代码。。
Index: Chat.cpp===================================================================
--- Chat.cpp (revision 730)
+++ Chat.cpp (working copy)
@@ -479,9 +479,10 @@
{ "player_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadPlayerLootTemplateCommand, "", NULL }, //重载玩家掉率
{ "creature_addtemp", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCreatureAddtempCommand, "", NULL }, //重载灾变系统
{ "spell_cost", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSpellCostCommand, "", NULL }, //使用技能的消耗数据库从载
- { "item_price", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadBuyItemPriceCommand, "", NULL }, //购买物品消耗系统
+ { "item_price", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadBuyItemPriceCommand, "", NULL }, //购买物品消耗系统
{ "attack_power", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAttackPowerCommand, "", NULL }, //职业伤害治疗倍率系统
{ "player_vip_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadPlayerVipTemplateCommand, "", NULL }, //会员倍率系统
+ { "creature_spell_dmg", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCreatureSpellDmgCommand, "", NULL }, //生物技能伤害倍率系统
{ NULL, 0, false, NULL, "", NULL }
};
Index: Chat.h
===================================================================
--- Chat.h (revision 730)
+++ Chat.h (working copy)
@@ -407,6 +407,7 @@
bool HandleReloadBuyItemPriceCommand(const char* args); //购买物品消耗系统
bool HandleReloadAttackPowerCommand(const char* args); //职业伤害治疗倍率系统
bool HandleReloadPlayerVipTemplateCommand(const char* args); //会员倍率系统
+ bool HandleReloadCreatureSpellDmgCommand(const char* args); //生物技能伤害倍率系统
bool HandleResetAchievementsCommand(const char * args);
bool HandleResetAllCommand(const char * args);
Index: Level3.cpp
===================================================================
--- Level3.cpp (revision 730)
+++ Level3.cpp (working copy)
@@ -175,6 +175,7 @@
HandleReloadBuyItemPriceCommand("a"); //购买物品消耗系统
HandleReloadAttackPowerCommand("a"); //职业伤害治疗倍率系统
HandleReloadPlayerVipTemplateCommand("a"); //会员倍率系统
+ HandleReloadCreatureSpellDmgCommand("a"); //生物技能伤害倍率系统
return true;
}
@@ -900,6 +901,17 @@
return true;
}
+bool ChatHandler::HandleReloadCreatureSpellDmgCommand(const char* /*arg*/) //生物技能伤害倍率系统
+{
+ sLog.outString( "Re-Loading creauter spell dmg table...");
+
+ sObjectMgr.LoadCreatureSpellDmgSystem();
+
+ SendGlobalSysMessage("DB table `creauter_spell_dmg` reloaded.");
+
+ return true;
+}
+
bool ChatHandler::HandleReloadLocalesAchievementRewardCommand(const char*)
{
sLog.outString( "Re-Loading Locales Achievement Reward Data..." );
Index: ObjectMgr.cpp
===================================================================
--- ObjectMgr.cpp (revision 730)
+++ ObjectMgr.cpp (working copy)
@@ -7670,6 +7670,52 @@
sLog.outString( ">> Loaded %u player vip template from `player_vip_template`", total_count);
}//会员倍率系统
+void ObjectMgr::LoadCreatureSpellDmgSystem() //生物技能伤害倍率系统
+{
+ m_Creature_Spell_Dmg.clear();
+ QueryResult *result = WorldDatabase.Query("SELECT entry, spell_dmg FROM creature_spell_dmg");
+
+ uint32 total_count = 0;
+
+ if( !result )
+ {
+ barGoLink bar( 1 );
+ bar.step();
+
+ sLog.outString();
+ sLog.outString( ">> Loaded %u creature spell damage", total_count );
+ return;
+ }
+
+ barGoLink bar( result->GetRowCount() );
+
+ Field* fields;
+ do
+ {
+ CreatureSpellDmg temp; //定义内存
+ bar.step();
+ fields = result->Fetch();
+ uint32 entry = fields[0].GetUInt32();
+ CreatureInfo const* cInfo = GetCreatureTemplate(entry);
+ if(!cInfo)
+ {
+ sLog.outErrorDb("Table `creature_spell_dmg` has creature with non existing creature_template %u, skipped.", entry);
+ continue;
+ }
+ temp.CreatureEntry = entry;
+ temp.SpellMult = fields[1].GetFloat();
+
+ m_Creature_Spell_Dmg[entry] = temp; //把值放到内存
+
+ ++total_count;
+ } while ( result->NextRow() );
+
+ delete result;
+
+ sLog.outString();
+ sLog.outString( ">> Loaded %u creatru spell damage from `creature_spell_dmg`", total_count);
+}//生物技能伤害倍率系统
+
void ObjectMgr::LoadFishingBaseSkillLevel()
{
mFishingBaseForArea.clear(); // for reload case
Index: ObjectMgr.h
===================================================================
--- ObjectMgr.h (revision 730)
+++ ObjectMgr.h (working copy)
@@ -147,6 +147,12 @@
uint32 gMaxPrimaryTradeSkillVip;
};
+struct CreatureSpellDmg //生物技能伤害倍率系统
+{
+ uint32 CreatureEntry;
+ float SpellMult;
+};
+
struct ScriptInfo
{
uint32 id;
@@ -476,6 +482,8 @@
typedef UNORDERED_MAP<uint32, PlayerVipTemplate> PlayerVipTemplateMap;//会员倍率系统
+ typedef UNORDERED_MAP<uint32, CreatureSpellDmg> CreatureSpellDmgMap;//生物技能伤害倍率系统
+
typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptMap;
typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap;
@@ -754,6 +762,15 @@
return result;
}
+ float GetCreatureSpellDmg(uint32 entry) const //生物技能伤害倍率系统
+ {
+ float result=1.0f;
+ CreatureSpellDmgMap::const_iterator itr = m_Creature_Spell_Dmg.find(entry);
+ if( itr != m_Creature_Spell_Dmg.end( ) )
+ result = itr->second.SpellMult;
+ return result;
+ }
+
uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const
{
QuestAreaTriggerMap::const_iterator itr = mQuestAreaTriggerMap.find(Trigger_ID);
@@ -1133,7 +1150,9 @@
void LoadPlayerVipTemplateEntrys(); //重载会员倍率系统
- int GetIndexForLocale(LocaleConstant loc);
+ void LoadCreatureSpellDmgSystem(); //生物技能伤害倍率系统
+
+ int GetIndexForLocale(LocaleConstant loc);
LocaleConstant GetLocaleForIndex(int i);
uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2);
@@ -1284,6 +1303,8 @@
PlayerVipTemplateMap m_Player_Vip_Template;//会员倍率系统
+ CreatureSpellDmgMap m_Creature_Spell_Dmg;//生物技能伤害倍率系统
+
GraveYardMap mGraveYardMap;
GameTeleMap m_GameTeleMap;
Index: Unit.cpp
===================================================================
--- Unit.cpp (revision 730)
+++ Unit.cpp (working copy)
@@ -9133,8 +9395,16 @@
if( GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet() )
DoneTotalMod *= ((Creature*)this)->GetSpellDamageMod(((Creature*)this)->GetCreatureInfo()->rank);
- if (!(spellProto->AttributesEx6 & SPELL_ATTR_EX6_NO_DMG_PERCENT_MODS))
+ if (sConfig.GetIntDefault("Creature.Spell.Dmg", 0) == 1)//生物技能伤害倍率系统
{
+ uint32 CreatureID = ((Creature*)this)->GetCreatureInfo()->Entry;
+ float SpellDmgMult = sObjectMgr.GetCreatureSpellDmg(CreatureID);
+ if (SpellDmgMult)
+ DoneTotalMod *=SpellDmgMult;
+ }//生物技能伤害倍率系统
+
+ if (!(spellProto->AttributesEx6 & SPELL_ATTR_EX6_NO_DMG_PERCENT_MODS))
+ {
AuraList const& mModDamagePercentDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
for(AuraList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i)
{
@@ -9272,6 +9542,22 @@
}
}
|