Tag is MoveEvent because thats the mainpart of this function
Activate waypoint by stepping on SQM with ActionID.
Opens waypoint window when stepping on activated waypoint
Can config that you require other storagevalues before you can activate, example needs to complete a quest before you can activate certain waypoints.
movements/movements.xml
XML:
<movevent event="StepIn" fromaid="1000" toaid="1004" script="waypoints.lua" />
movements/scripts/waypoints.lua
Lua:
function onStepIn(creature, item, position, fromPosition)
local waypoint = nil
for i=1,#waypoints do
if item.actionid == waypoints[i].actionId then
waypoint = waypoints[i]
end
end
if creature:getStorageValue(999) == 1 then
creature:setStorageValue(999,0)
return true
end
if waypoint then
if waypoint.requireQuest.Check then
if creature:getStorageValue(waypoint.requireQuest.storage) < waypoint.requireQuest.value then
creature:teleportTo(fromPosition)
creature:say("You have not completed the prerequisite quest to unlock waypoint to ".. waypoint.name ..".", TALKTYPE_MONSTER_SAY)
return false
end
end
if creature:getStorageValue(waypoint.storage) ~= 1 then
creature:setStorageValue(waypoint.storage,1)
creature:say("You have unlocked waypoint to ".. waypoint.name ..".", TALKTYPE_MONSTER_SAY)
return true
end
creature:registerEvent("Waypoints")
local window = ModalWindow(3000, "Waypoints", "Waypoint: " .. waypoint.name .. "\n")
for i=1,#waypoints do
if creature:getStorageValue(waypoints[i].storage) == 1 then
if waypoints[i].actionId ~= item.actionid then
window:addChoice(i, waypoints[i].name)
end
end
end
window:addButton(105,"Select")
window:addButton(103,"Cancel")
window:setDefaultEnterButton(105)
window:setDefaultEscapeButton(103)
window:sendToPlayer(creature)
return true
end
return true
end
creaturescripts/creaturescripts.xml
XML:
<event type="ModalWindow" name="Waypoints" script="waypoints.lua" />
creaturescripts/scripts/waypoints.lua
Lua:
function onModalWindow(player, modalWindowId, buttonId, choiceId)
if modalWindowId == 3000 then
if buttonId == 105 then
player:unregisterEvent("Waypoints")
player:setStorageValue(999,1)
player:teleportTo(waypoints[choiceId].position)
player:getPosition():sendMagicEffect(15)
return true
end
end
end
lib/core/core.lua
Lua:
dofile('data/lib/core/waypoints.lua')
lib/core/waypoints.lua
Lua:
waypoints = {
[1] = {
name = "Ahola Forest",
actionId = 1000,
storage = "3500",
position = Position(977, 1064, 7),
requireQuest = {check = false, storage = 5000, value = 5000},
},
[2] = {
name = "Dragon Nest",
actionId = 1001,
storage = "3501",
position = Position(970, 1060, 7),
requireQuest = {check = false, storage = 5000, value = 5000},
},
[3] = {
name = "Cyclops Mountain",
actionId = 1002,
storage = "3502",
position = Position(968, 1065, 7),
requireQuest = {check = false, storage = 5000, value = 5000},
},
[4] = {
name = "Hell Gate",
actionId = 1003,
storage = "3503",
position = Position(983, 1060, 7),
requireQuest = {check = false, storage = 5000, value = 5000},
},
[5] = {
name = "Demona",
actionId = 1004,
storage = "3504",
position = Position(982, 1069, 7),
requireQuest = {check = false, storage = 5000, value = 5000},
}
}