local drunk = Condition(CONDITION_DRUNK)
drunk:setParameter(CONDITION_PARAM_TICKS, 60000)
local poison = Condition(CONDITION_POISON)
poison:setParameter(CONDITION_PARAM_DELAYED, true)
poison:setParameter(CONDITION_PARAM_MINVALUE, -50)
poison:setParameter(CONDITION_PARAM_MAXVALUE, -120)
poison:setParameter(CONDITION_PARAM_STARTVALUE, -5)
poison:setParameter(CONDITION_PARAM_TICKINTERVAL, 4000)
poison:setParameter(CONDITION_PARAM_FORCEUPDATE, true)
local fluidMessage = {
[13076] = "Aah...",
[13077] = "Urgh!",
[13072] = "Mmmh.",
[13078] = "Aaaah...",
[13079] = "Aaaah...",
[13068] = "Urgh!",
[13080] = "Urgh!",
[13074] = "Aah...",
[13082] = "Urgh!",
[13085] = "Aah...",
[13087] = "Aaaah..."
}
local fluidPool = 2016
local emptyContainer = 13069
local fluids = {
[1] = 13075, -- FLUID_WATER,
[2] = 13079, -- FLUID_LIFE,
[3] = 13076, -- FLUID_BEER,
[4] = 13077, -- FLUID_SLIME,
[5] = 13072, -- FLUID_LEMONADE,
[6] = 13073, -- FLUID_MILK,
[7] = 13078, -- FLUID_MANA,
[10] = 13070, -- FLUID_BLOOD,
[11] = 13068, -- FLUID_OIL,
[13] = 13080, -- FLUID_URINE,
[14] = 13081, -- FLUID_COCONUTMILK,
[15] = 13074, -- FLUID_WINE,
[19] = 13082, -- FLUID_MUD,
[21] = 13083, -- FLUID_FRUITJUICE,
[26] = 13084, -- FLUID_LAVA,
[27] = 13085, -- FLUID_RUM,
[28] = 13071, -- FLUID_SWAMP,
[35] = 13086, -- FLUID_TEA,
[43] = 13087, -- FLUID_MEAD
}
local fluidContainers = {
[13075] = 1, -- FLUID_WATER,
[13079] = 2, -- FLUID_LIFE,
[13076] = 3, -- FLUID_BEER,
[13077] = 4, -- FLUID_SLIME,
[13072] = 5, -- FLUID_LEMONADE,
[13073] = 6, -- FLUID_MILK,
[13078] = 7, -- FLUID_MANA,
[13070] = 10, -- FLUID_BLOOD,
[13068] = 11, -- FLUID_OIL,
[13080] = 13, -- FLUID_URINE,
[13081] = 14, -- FLUID_COCONUTMILK,
[13074] = 15, -- FLUID_WINE,
[13082] = 19, -- FLUID_MUD,
[13083] = 21, -- FLUID_FRUITJUICE,
[13084] = 26, -- FLUID_LAVA,
[13085] = 27, -- FLUID_RUM,
[13071] = 28, -- FLUID_SWAMP,
[13086] = 35, -- FLUID_TEA,
[13087] = 43 -- FLUID_MEAD
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if target and target:isCreature() then
print("Creature was targeted.")
if player == target then
print("Self targeted.")
if table.contains({13076, 13074, 13087}, item:getId()) then
player:addCondition(drunk)
elseif table.contains({13077, 13071}, item:getId()) then
player:addCondition(poison)
elseif item:getId() == 13078 then
player:addMana(math.random(50, 150))
fromPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
elseif item:getId() == 13079 then
player:addHealth(60)
fromPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
player:say(fluidMessage[item:getId()] or "Gulp.", TALKTYPE_MONSTER_SAY)
item:transform(emptyContainer)
return true
end
print("A creature other then self was targeted. Target is now top-most item under player.")
local tile = Tile(toPosition)
if tile then
target = tile:getTopDownItem()
if not target then
target = tile:getGround()
end
end
end
if target and target:isItem() then
print("Target is Item.")
-- POI Gravestone
local targetActionId = target:getActionId()
if targetActionId == 2023 then
local standPosition = Position(toPosition.x, toPosition.y + 1, toPosition.z)
if player:getPosition() ~= standPosition then
return false
end
local creatures = Tile(standPosition):getCreatures()
for i = 1, #creatures do
local _player = Player(creatures[i])
if _player then
_player:teleportTo(Position(toPosition.x, toPosition.y, toPosition.z + 1))
_player:say('Muahahahaha..', TALKTYPE_MONSTER_SAY, false, _player)
end
end
fromPosition:sendMagicEffect(CONST_ME_DRAWBLOOD)
toPosition:sendMagicEffect(CONST_ME_MORTAREA)
item:transform(emptyContainer)
return true
end
-- empty vial
if item:getId() == emptyContainer then
local itemType = ItemType(target:getId())
if itemType:isCorpse() then
local fluidSource = itemType:getFluidSource()
if fluidSource == 2 then
item:transform(13070) -- blood
elseif fluidSource == 4 then
item:transform(13077) -- slime
end
return true
end
if target:getId() == fluidPool then
item:transform(fluids[target.type])
target:remove()
return true
end
return true
end
-- full vials
if item:getId() ~= emptyContainer then
if target:getId() == emptyContainer then
target:transform(fluids[fluidContainers[item:getId()]])
item:transform(emptyContainer)
return true
end
Game.createItem(fluidPool, fluidContainers[item:getId()], (toPosition.x == CONTAINER_POSITION and player:getPosition() or toPosition)):decay()
item:transform(emptyContainer)
return true
end
print("No function currently scripted for this action.")
return true
end
print("Target was not an item or a creature. Empty tile?")
print("No function currently scripted for this action.")
return true
end