commit 4928c25e01424faed89c7d0b9d0baf7622288567 Author: Flerp Date: Thu Nov 13 17:46:30 2025 -0800 Initial Upload diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/conf/mod-swift-travel-form.conf.dist b/conf/mod-swift-travel-form.conf.dist new file mode 100644 index 0000000..18479ff --- /dev/null +++ b/conf/mod-swift-travel-form.conf.dist @@ -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 diff --git a/src/loader.cpp b/src/loader.cpp new file mode 100644 index 0000000..71abe1d --- /dev/null +++ b/src/loader.cpp @@ -0,0 +1,6 @@ +void AddSC_swift_travel_form(); + +void Addmod_swift_travelformScripts() +{ + AddSC_swift_travel_form(); +} diff --git a/src/mod_swift_travel_form.cpp b/src/mod_swift_travel_form.cpp new file mode 100644 index 0000000..6c249a8 --- /dev/null +++ b/src/mod_swift_travel_form.cpp @@ -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("SwiftTravelForm.Enable", true); + sRequiredItemId = sConfigMgr->GetOption("SwiftTravelForm.RequiredItem", 0u); + sRequiredEquipId = sConfigMgr->GetOption("SwiftTravelForm.RequiredEquipment", 0u); + sRequiredSpellId = sConfigMgr->GetOption("SwiftTravelForm.RequiredSpell", 0u); + sMinLevel = sConfigMgr->GetOption("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(); +}