Hook seems to work, removing TRAVEL FORM check to test
This commit is contained in:
parent
41c6d4d7f4
commit
845a2e217f
@ -1,8 +1,66 @@
|
|||||||
#include "ScriptMgr.h"
|
#include "ScriptMgr.h"
|
||||||
|
#include "Config.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "Unit.h"
|
#include "Unit.h"
|
||||||
|
#include "Item.h"
|
||||||
#include "SharedDefines.h"
|
#include "SharedDefines.h"
|
||||||
#include "WorldSession.h"
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
bool sEnabled = true;
|
||||||
|
uint32 sRequiredItemId = 0;
|
||||||
|
uint32 sRequiredEquipId = 0;
|
||||||
|
uint32 sRequiredSpellId = 0;
|
||||||
|
uint32 sMinLevel = 60;
|
||||||
|
|
||||||
|
bool HasEquippedItem(Player* player, uint32 entry)
|
||||||
|
{
|
||||||
|
if (!player)
|
||||||
|
return false;
|
||||||
|
if (!entry)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
|
||||||
|
{
|
||||||
|
if (Item* it = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
|
||||||
|
if (it->GetEntry() == entry)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RequirementsMet(Player* player)
|
||||||
|
{
|
||||||
|
if (!player)
|
||||||
|
return false;
|
||||||
|
if (!sEnabled)
|
||||||
|
return false;
|
||||||
|
if (player->GetLevel() < sMinLevel)
|
||||||
|
return false;
|
||||||
|
if (sRequiredItemId && !player->HasItemCount(sRequiredItemId, 1, false))
|
||||||
|
return false;
|
||||||
|
if (sRequiredEquipId && !HasEquippedItem(player, sRequiredEquipId))
|
||||||
|
return false;
|
||||||
|
if (sRequiredSpellId && !player->HasSpell(sRequiredSpellId))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SwiftTravelForm_WorldScript : public WorldScript
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SwiftTravelForm_WorldScript() : WorldScript("SwiftTravelForm_WorldScript") {}
|
||||||
|
|
||||||
|
void OnAfterConfigLoad(bool) override
|
||||||
|
{
|
||||||
|
sEnabled = sConfigMgr->GetOption<bool>("SwiftTravelForm.Enable", true);
|
||||||
|
sRequiredItemId = sConfigMgr->GetOption<uint32>("SwiftTravelForm.RequiredItem", 0u);
|
||||||
|
sRequiredEquipId = sConfigMgr->GetOption<uint32>("SwiftTravelForm.RequiredEquipment", 0u);
|
||||||
|
sRequiredSpellId = sConfigMgr->GetOption<uint32>("SwiftTravelForm.RequiredSpell", 0u);
|
||||||
|
sMinLevel = sConfigMgr->GetOption<uint32>("SwiftTravelForm.MinLevel", 60u);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class SwiftTravelForm_UnitScript : public UnitScript
|
class SwiftTravelForm_UnitScript : public UnitScript
|
||||||
{
|
{
|
||||||
@ -14,18 +72,24 @@ public:
|
|||||||
|
|
||||||
void OnUnitSetShapeshiftForm(Unit* unit, uint8 form) override
|
void OnUnitSetShapeshiftForm(Unit* unit, uint8 form) override
|
||||||
{
|
{
|
||||||
|
// if (!sEnabled)
|
||||||
|
// return;
|
||||||
if (!unit || unit->GetTypeId() != TYPEID_PLAYER)
|
if (!unit || unit->GetTypeId() != TYPEID_PLAYER)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player* player = unit->ToPlayer();
|
Player* player = unit->ToPlayer();
|
||||||
if (!player)
|
if (!player)
|
||||||
return;
|
return;
|
||||||
|
// if (!RequirementsMet(player))
|
||||||
|
// return;
|
||||||
|
|
||||||
player->GetSession()->SendAreaTriggerMessage("Shapeshift form changed.");
|
// if (form == FORM_TRAVEL)
|
||||||
|
player->SetSpeed(MOVE_RUN, 2.0f, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void AddSC_swift_travel_form()
|
void AddSC_swift_travel_form()
|
||||||
{
|
{
|
||||||
|
new SwiftTravelForm_WorldScript();
|
||||||
new SwiftTravelForm_UnitScript();
|
new SwiftTravelForm_UnitScript();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user