dofile('data/actions/actionSystem.lua')
--USE, IsType (Obj1,2948) -> Effect(Obj1,19)
-- sound
USE(
CONDITION(
IsType(ACTIONVAR_OBJ1, 2070)
),
ACTION(
EffectAction(ACTIONVAR_OBJ1, CONST_ME_SOUND_GREEN)
)
)
-- the only condition is the position
-- better than using an action id or unique id on a certain item in that position
USE(
CONDITION(
IsPosition(ACTIONVAR_OBJ1, 234, 420, 6)
),
ACTION(
EffectAction(ACTIONVAR_OBJ1, CONST_ME_FERUMBRAS)
)
)
--bush
local function onUseBush(vars, fromPosition, isHotkey)
local blueberryCount = 3
vars[ACTIONVAR_OBJ1]:transform(2786)
vars[ACTIONVAR_OBJ1]:decay()
for loop = 1, blueberryCount do
Game.createItem(2677, 1, fromPosition)
end
return true
end
USE(
CONDITION(
IsType(ACTIONVAR_OBJ1, 2785)
),
ACTION(
onUseBush
)
)
-- teleports
local upFloorIds = {1386, 3678, 5543}
function onUseTeleport(vars, fromPosition, isHotkey)
if table.contains(upFloorIds, vars[ACTIONVAR_OBJ1ID]) then
fromPosition:moveUpstairs()
else
fromPosition.z = fromPosition.z + 1
end
local player = vars[ACTIONVAR_USER]
if player:isPzLocked() and Tile(fromPosition):hasFlag(TILESTATE_PROTECTIONZONE) then
player:sendCancelMessage(RETURNVALUE_PLAYERISPZLOCKED)
return true
end
player:teleportTo(fromPosition, false)
return true
end
USE(
CONDITION(
IsType(ACTIONVAR_OBJ1, 430)
),
ACTION(
onUseTeleport
)
)
-- doors
function onUseDoor(vars, fromPosition, isHotkey)
local itemId = vars[ACTIONVAR_OBJ1ID]
local player = vars[ACTIONVAR_USER]
local item = vars[ACTIONVAR_OBJ1]
local toPosition = fromPosition
if table.contains(questDoors, itemId) then
if player:getStorageValue(item.actionid) ~= -1 then
item:transform(itemId + 1)
player:teleportTo(toPosition, true)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "The door seems to be sealed against unwanted intruders.")
end
return true
elseif table.contains(levelDoors, itemId) then
if item.actionid > 0 and player:getLevel() >= item.actionid - 1000 then
item:transform(itemId + 1)
player:teleportTo(toPosition, true)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "Only the worthy may pass.")
end
return true
elseif table.contains(keys, itemId) then
if target.actionid > 0 then
if item.actionid == target.actionid and doors[target.itemid] then
target:transform(doors[target.itemid])
return true
end
player:sendTextMessage(MESSAGE_STATUS_SMALL, "The key does not match.")
return true
end
return false
end
if table.contains(horizontalOpenDoors, itemId) or table.contains(verticalOpenDoors, itemId) then
local doorCreature = Tile(toPosition):getTopCreature()
if doorCreature ~= nil then
toPosition.x = toPosition.x + 1
local query = Tile(toPosition):queryAdd(doorCreature, bit.bor(FLAG_IGNOREBLOCKCREATURE, FLAG_PATHFINDING))
if query ~= RETURNVALUE_NOERROR then
toPosition.x = toPosition.x - 1
toPosition.y = toPosition.y + 1
query = Tile(toPosition):queryAdd(doorCreature, bit.bor(FLAG_IGNOREBLOCKCREATURE, FLAG_PATHFINDING))
end
if query ~= RETURNVALUE_NOERROR then
player:sendTextMessage(MESSAGE_STATUS_SMALL, query)
return true
end
doorCreature:teleportTo(toPosition, true)
end
if not table.contains(openSpecialDoors, itemId) then
item:transform(itemId - 1)
end
return true
end
if doors[itemId] then
if item.actionid == 0 then
item:transform(doors[itemId])
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "It is locked.")
end
return true
end
return false
end
for doorItemId, _ in pairs(doors) do
USE(
CONDITION(
IsType(ACTIONVAR_OBJ1, doorItemId)
),
ACTION(
onUseDoor
)
)
end
for _, list in ipairs({horizontalOpenDoors, verticalOpenDoors}) do
for _, doorItemId in ipairs(list) do
USE(
CONDITION(
IsType(ACTIONVAR_OBJ1, doorItemId)
),
ACTION(
onUseDoor
)
)
end
end
-- food
local foods = {
[2362] = {5, "Crunch."}, -- carrot
[2666] = {15, "Munch."}, -- meat
[2667] = {12, "Munch."}, -- fish
[2668] = {10, "Mmmm."}, -- salmon
[2669] = {17, "Munch."}, -- northern pike
[2670] = {4, "Gulp."}, -- shrimp
[2671] = {30, "Chomp."}, -- ham
[2672] = {60, "Chomp."}, -- dragon ham
[2673] = {5, "Yum."}, -- pear
[2674] = {6, "Yum."}, -- red apple
[2675] = {13, "Yum."}, -- orange
[2676] = {8, "Yum."}, -- banana
[2677] = {1, "Yum."}, -- blueberry
[2678] = {18, "Slurp."}, -- coconut
[2679] = {1, "Yum."}, -- cherry
[2680] = {2, "Yum."}, -- strawberry
[2681] = {9, "Yum."}, -- grapes
[2682] = {20, "Yum."}, -- melon
[2683] = {17, "Munch."}, -- pumpkin
[2684] = {5, "Crunch."}, -- carrot
[2685] = {6, "Munch."}, -- tomato
[2686] = {9, "Crunch."}, -- corncob
[2687] = {2, "Crunch."}, -- cookie
[2688] = {2, "Munch."}, -- candy cane
[2689] = {10, "Crunch."}, -- bread
[2690] = {3, "Crunch."}, -- roll
[2691] = {8, "Crunch."}, -- brown bread
[2695] = {6, "Gulp."}, -- egg
[2696] = {9, "Smack."}, -- cheese
[2787] = {9, "Munch."}, -- white mushroom
[2788] = {4, "Munch."}, -- red mushroom
[2789] = {22, "Munch."}, -- brown mushroom
[2790] = {30, "Munch."}, -- orange mushroom
[2791] = {9, "Munch."}, -- wood mushroom
[2792] = {6, "Munch."}, -- dark mushroom
[2793] = {12, "Munch."}, -- some mushrooms
[2794] = {3, "Munch."}, -- some mushrooms
[2795] = {36, "Munch."}, -- fire mushroom
[2796] = {5, "Munch."}, -- green mushroom
[5097] = {4, "Yum."}, -- mango
[6125] = {8, "Gulp."}, -- tortoise egg
[6278] = {10, "Mmmm."}, -- cake
[6279] = {15, "Mmmm."}, -- decorated cake
[6393] = {12, "Mmmm."}, -- valentine's cake
[6394] = {15, "Mmmm."}, -- cream cake
[6501] = {20, "Mmmm."}, -- gingerbread man
[6541] = {6, "Gulp."}, -- coloured egg (yellow)
[6542] = {6, "Gulp."}, -- coloured egg (red)
[6543] = {6, "Gulp."}, -- coloured egg (blue)
[6544] = {6, "Gulp."}, -- coloured egg (green)
[6545] = {6, "Gulp."}, -- coloured egg (purple)
[6569] = {1, "Mmmm."}, -- candy
[6574] = {5, "Mmmm."}, -- bar of chocolate
[7158] = {15, "Munch."}, -- rainbow trout
[7159] = {13, "Munch."}, -- green perch
[7372] = {2, "Yum."}, -- ice cream cone (crispy chocolate chips)
[7373] = {2, "Yum."}, -- ice cream cone (velvet vanilla)
[7374] = {2, "Yum."}, -- ice cream cone (sweet strawberry)
[7375] = {2, "Yum."}, -- ice cream cone (chilly cherry)
[7376] = {2, "Yum."}, -- ice cream cone (mellow melon)
[7377] = {2, "Yum."}, -- ice cream cone (blue-barian)
[7909] = {4, "Crunch."}, -- walnut
[7910] = {4, "Crunch."}, -- peanut
[7963] = {60, "Munch."}, -- marlin
[8112] = {9, "Urgh."}, -- scarab cheese
[8838] = {10, "Gulp."}, -- potato
[8839] = {5, "Yum."}, -- plum
[8840] = {1, "Yum."}, -- raspberry
[8841] = {1, "Urgh."}, -- lemon
[8842] = {7, "Munch."}, -- cucumber
[8843] = {5, "Crunch."}, -- onion
[8844] = {1, "Gulp."}, -- jalapeño pepper
[8845] = {5, "Munch."}, -- beetroot
[8847] = {11, "Yum."}, -- chocolate cake
[9005] = {7, "Slurp."}, -- yummy gummy worm
[9114] = {5, "Crunch."}, -- bulb of garlic
[9996] = {0, "Slurp."}, -- banana chocolate shake
[10454] = {0, "Your head begins to feel better."}, -- headache pill
[11246] = {15, "Yum."}, -- rice ball
[11370] = {3, "Urgh."}, -- terramite eggs
[11429] = {10, "Mmmm."}, -- crocodile steak
[12415] = {20, "Yum."}, -- pineapple
[12416] = {10, "Munch."}, -- aubergine
[12417] = {8, "Crunch."}, -- broccoli
[12418] = {9, "Crunch."}, -- cauliflower
[12637] = {55, "Gulp."}, -- ectoplasmic sushi
[12638] = {18, "Yum."}, -- dragonfruit
[12639] = {2, "Munch."}, -- peas
[13297] = {20, "Crunch."}, -- haunch of boar
[15405] = {55, "Munch."}, -- sandfish
[15487] = {14, "Urgh."}, -- larvae
[15488] = {15, "Munch."}, -- deepling filet
[16014] = {60, "Mmmm."}, -- anniversary cake
[18397] = {33, "Munch."}, -- mushroom pie
[19737] = {10, "Urgh."}, -- insectoid eggs
[20100] = {15, "Smack."}, -- soft cheese
[20101] = {12, "Smack."} -- rat cheese
}
function onUseFood(vars, fromPosition, isHotkey)
local itemId = vars[ACTIONVAR_OBJ1ID]
local player = vars[ACTIONVAR_USER]
local item = vars[ACTIONVAR_OBJ1]
local toPosition = fromPosition
local food = foods[itemId]
if not food then
return false
end
local condition = player:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
if condition and math.floor(condition:getTicks() / 1000 + (food[1] * 12)) >= 1200 then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You are full.")
else
player:feed(food[1] * 12)
player:say(food[2], TALKTYPE_MONSTER_SAY)
item:remove(1)
end
return true
end
for foodItemId, _ in pairs(foods) do
USE(
CONDITION(
IsType(ACTIONVAR_OBJ1, foodItemId)
),
ACTION(
onUseFood
)
)
end
print('Actions reloaded!!!')