Initial Upload
This commit is contained in:
commit
4928c25e01
42
conf/mod-swift-travel-form.conf.dist
Normal file
42
conf/mod-swift-travel-form.conf.dist
Normal file
@ -0,0 +1,42 @@
|
||||
########################################
|
||||
# Swift Travel Form Config
|
||||
########################################
|
||||
#
|
||||
# SwiftTravelForm.Enable
|
||||
# Description: Enable the module
|
||||
# Default: 1 - Enabled
|
||||
# 0 - Disabled
|
||||
#
|
||||
|
||||
SwiftTravelForm.Enable = 1
|
||||
#
|
||||
# SwiftTravelForm.RequiredItem
|
||||
# Description: Allows setting an item required in bags to activate Swift Travel Form.
|
||||
# Default: 0 - No Item Required
|
||||
# xxxxx - Specify the item ID
|
||||
#
|
||||
|
||||
SwiftTravelForm.RequiredItem = 0
|
||||
#
|
||||
# SwiftTravelForm.RequiredEquipment
|
||||
# Description: Allows setting a piece of gear, equipped, to be required for activating Swift Travel Form
|
||||
# Default: 0 - No Gear Required
|
||||
# xxxxx - Specify the item ID of the piece of equipment
|
||||
#
|
||||
|
||||
SwiftTravelForm.RequiredEquipment = 0
|
||||
#
|
||||
# SwiftTravelForm.RequiredSpell
|
||||
# Description: Allows setting a SpellID of a learned spell required to activate Swift Travel Form.
|
||||
# Default: 0 - No Spell Required
|
||||
# xxxxx - Specify the SpellID
|
||||
#
|
||||
|
||||
SwiftTravelForm.RequiredSpell = 0
|
||||
#
|
||||
# SwiftTravelForm.MinLevel
|
||||
# Description: Sets the minimum level required to activate Swift Travel Form
|
||||
# Default: 60
|
||||
#
|
||||
#
|
||||
SwiftTravelForm.MinLevel = 60
|
||||
6
src/loader.cpp
Normal file
6
src/loader.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
void AddSC_swift_travel_form();
|
||||
|
||||
void Addmod_swift_travelformScripts()
|
||||
{
|
||||
AddSC_swift_travel_form();
|
||||
}
|
||||
90
src/mod_swift_travel_form.cpp
Normal file
90
src/mod_swift_travel_form.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
#include "ScriptMgr.h"
|
||||
#include "Config.h"
|
||||
#include "Player.h"
|
||||
#include "Unit.h"
|
||||
#include "Item.h"
|
||||
#include "UnitDefines.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
|
||||
{
|
||||
public:
|
||||
SwiftTravelForm_UnitScript() : UnitScript("SwiftTravelForm_UnitScript") {}
|
||||
|
||||
void OnUnitSetShapeshiftForm(Unit* unit, ShapeshiftForm form) override
|
||||
{
|
||||
if (!sEnabled)
|
||||
return;
|
||||
if (!unit || unit->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
Player* player = unit->ToPlayer();
|
||||
if (!RequirementsMet(player))
|
||||
return;
|
||||
|
||||
if (form == FORM_TRAVEL)
|
||||
player->SetSpeed(MOVE_RUN, 2.0f, true);
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_swift_travel_form()
|
||||
{
|
||||
new SwiftTravelForm_WorldScript();
|
||||
new SwiftTravelForm_UnitScript();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user