增加死亡骑士跳过初始区域模块

This commit is contained in:
尚美 2025-09-08 20:35:32 +08:00
parent 52d4caf9c5
commit 3edd97c433
2 changed files with 202 additions and 0 deletions

View File

@ -0,0 +1,196 @@
#include "AccountMgr.h"
#include "ScriptMgr.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
#include "Config.h"
#include "Common.h"
#include "Chat.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "SharedDefines.h"
#include "World.h"
#include "WorldSession.h"
#include "mod_Switch/Switch.h" // 通用配置
constexpr auto YESSKIPDK = 1;
void Azerothcore_skip_deathknight_HandleSkip(Player* player)
{
// 不确定死亡骑士应该从哪里获得这个物品,暂时保留为手动添加
player->AddItem(6948, true); //Hearthstone
//
/// <summary>
/// 这个数组包含了死亡骑士新手区的所有重要任务ID。
/// 当玩家选择跳过新手区时,系统会自动完成这些任务,确保死亡骑士获得应有的奖励,这些任务通常会给予:
/// -> 天赋点数
/// -> 重要的任务物品
/// -> 技能和法术
/// -> 经验值
/// </summary>
int STARTER_QUESTS[33] = { 12593, 12619, 12842, 12848, 12636, 12641, 12657, 12678, 12679, 12680, 12687, 12698, 12701, 12706, 12716, 12719, 12720, 12722, 12724, 12725, 12727, 12733, -1, 12751, 12754, 12755, 12756, 12757, 12779, 12801, 13165, 13166 };
/// <summary>
/// 根据玩家的种族分配特定的任务ID。 在魔兽世界中,不同种族的死亡骑士在新手区会有一些种族特定的任务,比如:
/// -> 牛头人死亡骑士有牛头人相关的剧情任务;
/// -> 人类死亡骑士有人类相关的剧情任务。
/// </summary>
int specialSurpriseQuestId = -1;
switch (player->getRace())
{
case RACE_TAUREN:
specialSurpriseQuestId = 12739;
break;
case RACE_HUMAN:
specialSurpriseQuestId = 12742;
break;
case RACE_NIGHTELF:
specialSurpriseQuestId = 12743;
break;
case RACE_DWARF:
specialSurpriseQuestId = 12744;
break;
case RACE_GNOME:
specialSurpriseQuestId = 12745;
break;
case RACE_DRAENEI:
specialSurpriseQuestId = 12746;
break;
case RACE_BLOODELF:
specialSurpriseQuestId = 12747;
break;
case RACE_ORC:
specialSurpriseQuestId = 12748;
break;
case RACE_TROLL:
specialSurpriseQuestId = 12749;
break;
case RACE_UNDEAD_PLAYER:
specialSurpriseQuestId = 12750;
break;
}
// 填入根据种族确定的特殊任务ID
STARTER_QUESTS[22] = specialSurpriseQuestId;
// 根据玩家阵营(联盟/部落填入不同的任务ID
STARTER_QUESTS[32] = player->GetTeamId() == TEAM_ALLIANCE ? 13188 : 13189; // 联盟玩家获得任务13188 部落玩家获得任务13189
for (int questId : STARTER_QUESTS)
{
if (player->GetQuestStatus(questId) == QUEST_STATUS_NONE)
{
player->AddQuest(sObjectMgr->GetQuestTemplate(questId), nullptr);
player->RewardQuest(sObjectMgr->GetQuestTemplate(questId), 0, player, false);
}
}
// 这些是任务12679的备选奖励物品默认选择物品39320作为奖励
player->AddItem(38664, true); // 天谴使者的邪恶披风
player->AddItem(39322, true); // 北风披风
// 这些是任务12801的备选奖励物品默认选择物品38633作为奖励
player->AddItem(38632, true);// 黑锋大剑
int DKL = sSwitch->GetValueByIndex(ST_SKIP_DK_START_LEVEL, 1); // 默认58级
if (DKL == 0) DKL = 58; // 如果配置为空,使用默认值
if (player->GetLevel() <= DKL)
{
// GiveLevel比SetLevel更彻底地更新角色属性
player->GiveLevel(DKL);
}
// 不需要保存所有玩家,只需保存当前玩家
player->SaveToDB(false, false);
WorldLocation Aloc = WorldLocation(0, -8866.55f, 671.39f, 97.90f, 5.27f); // 暴风城
WorldLocation Hloc = WorldLocation(1, 1637.62f, -4440.22f, 15.78f, 2.42f);// 奥格瑞玛
if (player->GetTeamId() == TEAM_ALLIANCE)
{
player->TeleportTo(0, -8833.37f, 628.62f, 94.00f, 1.06f);// 暴风城
player->SetHomebind(Aloc, 1637); // 暴风城绑定位置
}
else
{
player->TeleportTo(1, 1569.59f, -4397.63f, 7.70f, 0.54f); // 奥格瑞玛
player->SetHomebind(Hloc, 1653); // 奥格瑞玛绑定位置
}
}
class AzerothCore_skip_deathknight_announce : public PlayerScript
{
public:
AzerothCore_skip_deathknight_announce() : PlayerScript("AzerothCore_skip_deathknight_announce") { }
void OnLogin(Player* Player)
{
if (sSwitch->GetOnOff(ST_SKIP_DK_ANNOUNCE) && (sSwitch->GetOnOff(ST_SKIP_DK_ENABLE) || sSwitch->GetOnOff(ST_SKIP_DK_OPTIONAL)))
{
ChatHandler(Player->GetSession()).SendSysMessage("本服务器启用了 |cff4CFF00死亡骑士跳过新手区 |r功能。");
}
}
};
class AzerothCore_skip_deathknight : public PlayerScript
{
public:
AzerothCore_skip_deathknight() : PlayerScript("AzerothCore_skip_deathknight") { }
void OnFirstLogin(Player* player)
{
if (player->GetAreaId() == 4342) // 死亡骑士出生区域
{
// 这些改动使得用户在配置文件中的错误不会导致程序运行两次
if ((sSwitch->GetOnOff(ST_SKIP_DK_ENABLE) && player->GetSession()->GetSecurity() == SEC_PLAYER) || (sSwitch->GetOnOff(ST_SKIP_DK_GM_ENABLE) && player->GetSession()->GetSecurity() >= SEC_MODERATOR))
{
Azerothcore_skip_deathknight_HandleSkip(player);
}
}
}
};
class Azerothcore_optional_deathknight_skip : public CreatureScript
{
public:
Azerothcore_optional_deathknight_skip() : CreatureScript("npc_ac_skip_lich") { }
bool OnGossipHello(Player* player, Creature* creature) override
{
if (creature->IsQuestGiver())
{
player->PrepareQuestMenu(creature->GetGUID());
}
if (sSwitch->GetOnOff(ST_SKIP_DK_OPTIONAL))
{
AddGossipItemFor(player, GOSSIP_ICON_INTERACT_1, "我想跳過死亡騎士新手任務線。", GOSSIP_SENDER_MAIN, YESSKIPDK, "确定要跳过新手区吗?", 0, false);
}
player->TalkedToCreature(creature->GetEntry(), creature->GetGUID());
SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID());
return true;
}
bool OnGossipSelect(Player* player, Creature* /*creature*/, uint32 /*menuId*/, uint32 gossipListId) override
{
switch (gossipListId)
{
case YESSKIPDK:
Azerothcore_skip_deathknight_HandleSkip(player);
CloseGossipMenuFor(player);
break;
}
return true;
}
};
void AddSkipDKScripts()
{
new AzerothCore_skip_deathknight_announce;
new AzerothCore_skip_deathknight;
new Azerothcore_optional_deathknight_skip;
}

View File

@ -0,0 +1,6 @@
void AddSkipDKScripts();
void Addmod_skip_dk_starting_areaScripts()
{
AddSkipDKScripts();
}