Did you mean like the script where it follow the master when he goes on higher floors or walks too far away?Hello ppl i was wondering if someone had a script for summon reposition into master pos.
The clasic summons tp scripts but working in tfs 1.3
<event type="think" name="SummonThink" script="custom/summon_think.lua" />
summon:registerEvent('SummonThink')
function onThink(creature, interval)
local master = creature:getMaster()
if not master then return true end
local pos = creature:getPosition()
local master_pos = master:getPosition()
if getDistanceBetween(pos, master_pos) > 7 or master_pos.z ~=...
post the script, we dont have a magic ball to see the where is the errorAlready tried those, i dont get errors in console, but the script just wont do anything
Did you mean like the script where it follow the master when he goes on higher floors or walks too far away?Hello ppl i was wondering if someone had a script for summon reposition into master pos.
The clasic summons tp scripts but working in tfs 1.3
<event type="think" name="SummonThink" script="custom/summon_think.lua" />
summon:registerEvent('SummonThink')
function onThink(creature, interval)
local master = creature:getMaster()
if not master then return true end
local pos = creature:getPosition()
local master_pos = master:getPosition()
if getDistanceBetween(pos, master_pos) > 7 or master_pos.z ~= pos.z then
if creature:teleportTo(master_pos) then
pos:sendMagicEffect(CONST_ME_POFF)
end
end
return true
end
YepIll try this after work, are u using tfs 1.3 aswell?
onView attachment 37054Code:spells/scripts/support/summon_creature.lua
local tempo = 120
local function removeMonster(cid)
local monster = Monster(cid)
if monster then
doCreatureSay(monster, "Good Bye!", TALKTYPE_ORANGE_1)
monster:getPosition():sendMagicEffect(CONST_ME_POFF)
monster:remove()
end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:getExhaustion(84309) <= 0 then
local position = player:getPosition()
local monster = Game.createMonster("Barbarian Bloodwalker", position)
if monster then
player:addSummon(monster)
position:sendMagicEffect(CONST_ME_MAGIC_RED)
monster:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
doCreatureSay(monster, "Praise the sun!", TALKTYPE_ORANGE_1)
addEvent(removeMonster, tempo*1000, monster:getId())
player:setExhaustion(84309, tempo)
-- item:remove()
else
player:sendCancelMessage("There is not enough room.")
position:sendMagicEffect(CONST_ME_POFF)
end
else
player:sendCancelMessage('You need to wait to use this item again.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end
return false
end
summon:registerEvent('SummonThink')
function Creature:addSummon(monster)
local summon = Monster(monster)
if not summon then
return false
end
summon:setTarget(nil)
summon:setFollowCreature(nil)
summon:setDropLoot(false)
summon:setSkillLoss(false)
summon:setMaster(self)
summon:registerEvent('SummonThink')
return true
end
Did you mean like the script where it follow the master when he goes on higher floors or walks too far away?
If so when the summon is created you can register a creaturescript event to it like this:
XML:<event type="think" name="SummonThink" script="custom/summon_think.lua" />
Lua:summon:registerEvent('SummonThink')
Lua:function onThink(creature, interval) local master = creature:getMaster() if not master then return true end local pos = creature:getPosition() local master_pos = master:getPosition() if getDistanceBetween(pos, master_pos) > 7 or master_pos.z ~= pos.z then if creature:teleportTo(master_pos) then pos:sendMagicEffect(CONST_ME_POFF) end end return true end
local tile = master:getTile()
local ground = tile:hasFlag(TILESTATE_PROTECTIONZONE) and tile:getGround()
if ground then
return true
end