local discovery = MoveEvent()
function discovery.onStepIn(player, item, position, fromPosition)
if not player:isPlayer() then
return true -- If it's not a player, do nothing
end
local discoveries = {
{aid = 23001, name = "Rook Temple", experience = 50},
{aid = 23002, name = "Rook Shop Tower", experience = 25},
{aid = 23003, name = "Weapon Dealer Shop", experience = 25},
{aid = 23004, name = "Woodlow", experience = 100},
{aid = 23005, name = "Elary", experience = 100},
{aid = 23006, name = "Smallville", experience = 250},
{aid = 23007, name = "Emerald Town", experience = 100},
{aid = 23008, name = "Caver Town", experience = 500},
{aid = 23009, name = "Toros Town", experience = 1000},
}
-- Reward milestones
local rewards = {
[10] = {
experience = 500,
items = {{id = 2160, count = 5}}, -- 5 crystal coins
outfit = {lookType = 128, addon = nil}, -- Only outfit, no addon
},
[15] = {
experience = 1000,
items = {{id = 2160, count = 10}}, -- 10 crystal coins
outfit = {lookType = 129, addon = 1}, -- Outfit with first addon
},
[20] = {
experience = 2000,
items = {{id = 2152, count = 100}}, -- 100 platinum coins
outfit = {lookType = 130, addon = 2}, -- Outfit with second addon
},
}
local globalStorageKey = 23000 -- Key to store total discoveries count
for _, discovery in pairs(discoveries) do
if item.actionid == discovery.aid then
local storageValue = player:getStorageValue(discovery.aid)
if storageValue == -1 then
-- Mark the discovery as found
player:setStorageValue(discovery.aid, 1)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have discovered " .. discovery.name .. ".")
player:addExperience(discovery.experience, true)
-- Increase the count of total discoveries
local totalDiscoveries = player:getStorageValue(globalStorageKey) or 0
totalDiscoveries = totalDiscoveries + 1
player:setStorageValue(globalStorageKey, totalDiscoveries)
-- Check for rewards at specific milestones
local reward = rewards[totalDiscoveries]
if reward then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Congratulations! You have discovered " .. totalDiscoveries .. " places and earned a reward.")
-- Add experience
if reward.experience then
player:addExperience(reward.experience, true)
end
-- Add items
if reward.items then
for _, item in ipairs(reward.items) do
player:addItem(item.id, item.count)
end
end
-- Add outfit and/or addons
if reward.outfit then
local lookType = reward.outfit.lookType
local addon = reward.outfit.addon
if addon then
if addon == 1 or addon == 2 then
player:addOutfitAddon(lookType, addon)
elseif addon == 3 then
player:addOutfitAddon(lookType, 1)
player:addOutfitAddon(lookType, 2)
end
else
-- No addon specified, just give the outfit
player:addOutfit(lookType)
end
end
end
end
break
end
end
return true
end
-- Register the discovery events
local discoveryAids = {23001, 23002, 23003, 23004, 23005, 23006, 23007, 23008, 23009}
for _, aid in ipairs(discoveryAids) do
discovery:aid(aid)
end
discovery:type("stepin")
discovery:register()