Um mano gringo aí pediu algo do tipo, e eu precisava me familiarizar melhor com a orientação a objetos usada em Lua do TFS 1.3, então fiz esse action, onde o player que possui um scroll pode fazer um portal para seu templo, que é usado dando USE mesmo, e sua party inteira pode ir junto para seus respectivos templos se não estiverem pz locked ou com battle, e caso o player não esteja em uma party, apenas o mesmo pode entrar no portal.
Tags XML:
<action actionid="43443" script="townportalsystem.lua"/>
<action itemid="SCROLLID HERE" script="townportalsystem.lua"/>
Arquivo townportalsystem.lua em data/actions/scripts/:
-- Town Portal Scroll System based in Dota 2
-- by Nazo
local config = {
portalId = 1231, -- change to portal item id
portalTime = 30, -- portal duration in seconds
scrollId = 1232, -- change to scroll item id
effect = CONST_ME_POFF -- effect id or CONST that appears at the end of time
}
local function removePortal(portal)
if(portal)
portal:remove()
portal:getPosition():sendMagicEffect(config.effect)
else
print("A bug has deleted the portal")
end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if(item:getId()==config.scrollId) then
portal = Game.createItem(config.portalId, 1, player:getPosition())
if(player:getParty()) then
portal:setCustomAttribute("party", player:getParty())
else
portal:setCustomAttribute("owner", player:getName())
end
portal:setAction(43443)
addEvent(removePortal, config.portalTime * 1000, portal)
item:remove()
else
if(not player:isPzLocked() and not player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)) then
if(item:getCustomAttribute("party")) then
if(player:getParty()==item:getCustomAttribute("party")) then
player:teleportTo(player:getTown():getTemplePosition(), true)
else
player:popupFYI("You do not participate in the portal creator's party.")
end
elseif(item:getCustomAttribute("name") and player:getName() == item:getCustomAttribute("name")) then
player:teleportTo(player:getTown():getTemplePosition(), true)
else
player:popupFYI("You isn't the owner.")
end
else
player:popupFYI("You are PZ locked or in battle.")
end
end
return true
end
Obs: fiz e testei apenas no TFS 1.3.
Obs²: se desejar trocar a action, lembre-se de mudar no código também, procurando por "setAction".