From 964f7bc31fcade7e42a419c34e91dba2fb005e0c Mon Sep 17 00:00:00 2001 From: arrai Date: Wed, 22 Oct 2008 01:20:18 +0200 Subject: [PATCH] * [sql/updates/2008_10_22_01_mangos_quest_template.sql] Implemented honor rewards from quests --- .../2008_10_22_01_mangos_quest_template.sql | 2 ++ src/game/Formulas.h | 7 +++++ src/game/GossipDef.cpp | 13 ++++++--- src/game/ObjectMgr.cpp | 8 +++--- src/game/Player.cpp | 4 +++ src/game/QuestDef.cpp | 33 +++++++++++----------- src/game/QuestDef.h | 2 ++ src/game/SpellAuras.cpp | 24 ---------------- 8 files changed, 45 insertions(+), 48 deletions(-) create mode 100644 sql/updates/2008_10_22_01_mangos_quest_template.sql diff --git a/sql/updates/2008_10_22_01_mangos_quest_template.sql b/sql/updates/2008_10_22_01_mangos_quest_template.sql new file mode 100644 index 0000000..3693ab2 --- /dev/null +++ b/sql/updates/2008_10_22_01_mangos_quest_template.sql @@ -0,0 +1,2 @@ +ALTER TABLE `quest_template` + ADD `RewHonorableKills` INT UNSIGNED NOT NULL AFTER `RewRepValue5`; diff --git a/src/game/Formulas.h b/src/game/Formulas.h index e7c1789..5ba6ffd 100644 --- a/src/game/Formulas.h +++ b/src/game/Formulas.h @@ -23,6 +23,13 @@ namespace MaNGOS { + namespace Honor + { + inline uint32 hk_honor_at_level(uint32 level, uint32 count=1) + { + return ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f ))); + } + } namespace XP { typedef enum XPColorChar { RED, ORANGE, YELLOW, GREEN, GRAY }; diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp index 8804927..173e69f 100644 --- a/src/game/GossipDef.cpp +++ b/src/game/GossipDef.cpp @@ -22,6 +22,7 @@ #include "Opcodes.h" #include "WorldPacket.h" #include "WorldSession.h" +#include "Formulas.h" GossipMenu::GossipMenu() { @@ -464,7 +465,8 @@ void PlayerMenu::SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID data << uint32(pQuest->GetRewOrReqMoney()); } - data << uint32(0); // Honor points reward, not implemented + // rewarded honor points. Multiply with 10 to satisfy client + data << uint32(10*MaNGOS::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorableKills())); data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0) data << uint32(pQuest->GetRewSpellCast()); // casted spell data << uint32(pQuest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles) @@ -539,7 +541,8 @@ void PlayerMenu::SendQuestQueryResponse( Quest const *pQuest ) data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0) data << uint32(pQuest->GetRewSpellCast()); // casted spell - data << uint32(0); // Honor points reward, not implemented + // rewarded honor points + data << uint32(MaNGOS::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorableKills())); data << uint32(pQuest->GetSrcItemId()); data << uint32(pQuest->GetFlags() & 0xFFFF); data << uint32(pQuest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles) @@ -673,11 +676,13 @@ void PlayerMenu::SendQuestGiverOfferReward( Quest const* pQuest, uint64 npcGUID, } data << uint32(pQuest->GetRewOrReqMoney()); - data << uint32(0x00); // new 2.3.0. Honor points + + // rewarded honor points. Multiply with 10 to satisfy client + data << uint32(10*MaNGOS::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorableKills())); data << uint32(0x08); // unused by client? data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0) data << uint32(pQuest->GetRewSpellCast()); // casted spell - data << uint32(0); // Honor points reward, not implemented + data << uint32(0x00); // unk, NOT honor pSession->SendPacket( &data ); sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId() ); } diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index dc5feee..9ce7fad 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -2735,11 +2735,11 @@ void ObjectMgr::LoadQuests() "RewItemId1, RewItemId2, RewItemId3, RewItemId4, RewItemCount1, RewItemCount2, RewItemCount3, RewItemCount4," // 89 90 91 92 93 94 95 96 97 98 "RewRepFaction1, RewRepFaction2, RewRepFaction3, RewRepFaction4, RewRepFaction5, RewRepValue1, RewRepValue2, RewRepValue3, RewRepValue4, RewRepValue5," - // 99 100 101 102 103 104 105 106 107 108 - "RewOrReqMoney, RewMoneyMaxLevel, RewSpell, RewSpellCast, RewMailTemplateId, RewMailDelaySecs, PointMapId, PointX, PointY, PointOpt," - // 109 110 111 112 113 114 115 116 117 118 + // 99 100 101 102 103 104 105 106 107 108 109 + "RewHonorableKills, RewOrReqMoney, RewMoneyMaxLevel, RewSpell, RewSpellCast, RewMailTemplateId, RewMailDelaySecs, PointMapId, PointX, PointY, PointOpt," + // 110 111 112 113 114 115 116 117 118 119 "DetailsEmote1, DetailsEmote2, DetailsEmote3, DetailsEmote4,IncompleteEmote, CompleteEmote, OfferRewardEmote1, OfferRewardEmote2, OfferRewardEmote3, OfferRewardEmote4," - // 119 120 + // 120 121 "StartScript, CompleteScript" " FROM quest_template"); if(result == NULL) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 25b35a9..9b2fc9d 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -12047,6 +12047,10 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver // Give player extra money if GetRewOrReqMoney > 0 and get ReqMoney if negative ModifyMoney( pQuest->GetRewOrReqMoney() ); + // honor reward + if(pQuest->GetRewHonorableKills()) + RewardHonor(NULL, 0, MaNGOS::Honor::hk_honor_at_level(getLevel(), pQuest->GetRewHonorableKills())); + // title reward if(pQuest->GetCharTitleId()) { diff --git a/src/game/QuestDef.cpp b/src/game/QuestDef.cpp index 4a96d26..06a7ed2 100644 --- a/src/game/QuestDef.cpp +++ b/src/game/QuestDef.cpp @@ -101,28 +101,29 @@ Quest::Quest(Field * questRecord) for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) RewRepValue[i] = questRecord[94+i].GetInt32(); - RewOrReqMoney = questRecord[99].GetInt32(); - RewMoneyMaxLevel = questRecord[100].GetUInt32(); - RewSpell = questRecord[101].GetUInt32(); - RewSpellCast = questRecord[102].GetUInt32(); - RewMailTemplateId = questRecord[103].GetUInt32(); - RewMailDelaySecs = questRecord[104].GetUInt32(); - PointMapId = questRecord[105].GetUInt32(); - PointX = questRecord[106].GetFloat(); - PointY = questRecord[107].GetFloat(); - PointOpt = questRecord[108].GetUInt32(); + RewHonorableKills = questRecord[99].GetUInt32(); + RewOrReqMoney = questRecord[100].GetInt32(); + RewMoneyMaxLevel = questRecord[101].GetUInt32(); + RewSpell = questRecord[102].GetUInt32(); + RewSpellCast = questRecord[103].GetUInt32(); + RewMailTemplateId = questRecord[104].GetUInt32(); + RewMailDelaySecs = questRecord[105].GetUInt32(); + PointMapId = questRecord[106].GetUInt32(); + PointX = questRecord[107].GetFloat(); + PointY = questRecord[108].GetFloat(); + PointOpt = questRecord[109].GetUInt32(); for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - DetailsEmote[i] = questRecord[109+i].GetUInt32(); + DetailsEmote[i] = questRecord[110+i].GetUInt32(); - IncompleteEmote = questRecord[113].GetUInt32(); - CompleteEmote = questRecord[114].GetUInt32(); + IncompleteEmote = questRecord[114].GetUInt32(); + CompleteEmote = questRecord[115].GetUInt32(); for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - OfferRewardEmote[i] = questRecord[115+i].GetInt32(); + OfferRewardEmote[i] = questRecord[116+i].GetInt32(); - QuestStartScript = questRecord[119].GetUInt32(); - QuestCompleteScript = questRecord[120].GetUInt32(); + QuestStartScript = questRecord[120].GetUInt32(); + QuestCompleteScript = questRecord[121].GetUInt32(); QuestFlags |= SpecialFlags << 16; diff --git a/src/game/QuestDef.h b/src/game/QuestDef.h index 7dc55ca..551c3dd 100644 --- a/src/game/QuestDef.h +++ b/src/game/QuestDef.h @@ -198,6 +198,7 @@ class Quest std::string GetRequestItemsText() const { return RequestItemsText; } std::string GetEndText() const { return EndText; } int32 GetRewOrReqMoney() const; + uint32 GetRewHonorableKills() const { return RewHonorableKills; } uint32 GetRewMoneyMaxLevel() const { return RewMoneyMaxLevel; } // use in XP calculation at client uint32 GetRewSpell() const { return RewSpell; } @@ -287,6 +288,7 @@ class Quest std::string OfferRewardText; std::string RequestItemsText; std::string EndText; + uint32 RewHonorableKills; int32 RewOrReqMoney; uint32 RewMoneyMaxLevel; uint32 RewSpell; diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 7f82341..2f29cfc 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -1935,9 +1935,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) return; case 43873: // Headless Horseman Laugh if(caster->GetTypeId() == TYPEID_PLAYER) - { ((Player*)caster)->PlaySound(11965, false); - } return; case 46354: // Blood Elf Illusion if(caster) @@ -2489,16 +2487,12 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real) { // remove other shapeshift before applying a new one if(m_target->m_ShapeShiftFormSpellId) - { m_target->RemoveAurasDueToSpell(m_target->m_ShapeShiftFormSpellId,this); - } m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, form); if(modelid > 0) - { m_target->SetDisplayId(modelid); - } if(PowerType != POWER_MANA) { @@ -2528,17 +2522,13 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real) { m_target->SetPower(POWER_ENERGY,0); if(urand(1,100) <= FurorChance) - { m_target->CastSpell(m_target,17099,true,NULL,this); - } } else { m_target->SetPower(POWER_RAGE,0); if(urand(1,100) <= FurorChance) - { m_target->CastSpell(m_target,17057,true,NULL,this); - } } break; } @@ -2930,9 +2920,7 @@ void Aura::HandleModPossess(bool apply, bool Real) m_target->SetCharmerGUID(0); if(m_target->GetTypeId() == TYPEID_PLAYER) - { ((Player*)m_target)->setFactionForRace(m_target->getRace()); - } else if(m_target->GetTypeId() == TYPEID_UNIT) { CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo(); @@ -3039,9 +3027,7 @@ void Aura::HandleModCharm(bool apply, bool Real) m_target->SetCharmerGUID(0); if(m_target->GetTypeId() == TYPEID_PLAYER) - { ((Player*)m_target)->setFactionForRace(m_target->getRace()); - } else { CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo(); @@ -3604,9 +3590,7 @@ void Aura::HandleModTaunt(bool apply, bool Real) return; if(apply) - { m_target->TauntApply(caster); - } else { // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat @@ -4276,18 +4260,14 @@ void Aura::HandleAuraModBaseResistancePCT(bool apply, bool Real) { //pets only have base armor if(((Creature*)m_target)->isPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)) - { m_target->HandleStatModifier(UNIT_MOD_ARMOR, BASE_PCT, float(m_modifier.m_amount), apply); - } } else { for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++) { if(m_modifier.m_miscvalue & int32(1<HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_PCT, float(m_modifier.m_amount), apply); - } } } } @@ -4365,9 +4345,7 @@ void Aura::HandleModPercentStat(bool apply, bool Real) for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) { if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1) - { m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), BASE_PCT, float(m_modifier.m_amount), apply); - } } } @@ -5282,9 +5260,7 @@ void Aura::HandleAuraEmpathy(bool apply, bool Real) CreatureInfo const * ci = objmgr.GetCreatureTemplate(m_target->GetEntry()); if(ci && ci->type == CREATURE_TYPE_BEAST) - { m_target->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO, apply); - } } void Aura::HandleAuraUntrackable(bool apply, bool Real) -- 2.11.4.GIT