• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Transform item if a monster in range

Dercas

Active Member
Joined
Nov 15, 2008
Messages
88
Reaction score
29
Hi all,

I've been trying to make a script that would transform an item if there's a monster within the X / Y range of it.

I.e. if I have an item with ID 1234 lying on the ground or equipped (no matter in which slot) or it's in the backpack and there's a rat within 30/30 area it transforms into ID 1235.
If rat dies or moves away it truns back to 1234.

Please help! been trying the last few hours to make it.
 
do onStepIn if its within the area i guess?

Lua:
function onStepIn(cid, item, pos)

    return true
end

function onStepOut(cid, item, pos)
local outfit2 = getCreatureOutfit(cid)

if (outfit2.lookType == 77) then

doSendMagicEffect(pos, 15)
end

if (outfit2.lookType == 150 ) then
doSendMagicEffect(pos, 15)
        end
        
if getPlayerStorageValue(cid, 100100900) > 0 then
local out = getCreatureOutfit(cid)
        doCreatureChangeOutfit (cid, {lookType = out.lookType, lookHead = math.random(132) , lookBody = math.random(132), lookLegs = math.random(132), lookFeet = math.random(132), lookAddons = out.lookAddons } )
        end



        return true
end

this was changing players outfit on each step
 
Thanks for the response! but I don't think i know how to use onstepin to transform, for example, leather boots that lies on the ground (or on player's house) to soft boots if rat appear within 30x30 range of it
 
the question is why would you wand such option but one way would be to do <movements itemid="floortile e.g street cobblestone" function="onStepIn" script="a.lua"/>

then write the scrpit that will query tiles around the center of the tile and search for

tile:getItemById(itemId[, subType = -1])

you can use for loop to iterate over the fromPosition or toPosition

if creaturee name rat then

you query the for loop of all tiles from center tile via -x -y +x +y

(here is arena part of mine that removes creatures)

or i = 32117, 32181 do
for j = 32128, 32192 do
local tile = Tile(Position(i, j, 5))
if tile then
local creatures = tile:getCreatures()

this logic would check all tiles within xyz but you can change the numbers to fromPositon.x-5, fromPosition.y-5
.j fromPosition.x+5, fromPosition.y+5
and transofrm all items of id preferably from table to to table :p
 
the question is why would you wand such option but one way would be to do <movements itemid="floortile e.g street cobblestone" function="onStepIn" script="a.lua"/>

then write the scrpit that will query tiles around the center of the tile and search for

tile:getItemById(itemId[, subType = -1])

you can use for loop to iterate over the fromPosition or toPosition

if creaturee name rat then

you query the for loop of all tiles from center tile via -x -y +x +y

(here is arena part of mine that removes creatures)

or i = 32117, 32181 do
for j = 32128, 32192 do
local tile = Tile(Position(i, j, 5))
if tile then
local creatures = tile:getCreatures()

this logic would check all tiles within xyz but you can change the numbers to fromPositon.x-5, fromPosition.y-5
.j fromPosition.x+5, fromPosition.y+5
and transofrm all items of id preferably from table to to table :p

this would be assigned with the particular x y position

I'm refering to situation a player have an item in carlin, enter the underground, spot a rat and then the item carried transform, while other player is having the same item in thais and the item behaves the same & at the same time third player just throw the item on the ground in the ankh and a rat approched so the item transformed.
So, more like item-related script rather than particular position

@edit
thanks once again for your help! Fingers crossed we manage to make it :D
 
Back
Top