ralke
(҂ ͠❛ ෴ ͡❛)ᕤ
Hi again! I'm using TFS 1.x and i'm facing an issue with Wrath of the Emperor, where sometimes, if the boss got killed it spawns the next "form" of the boss duplicated. The last boss from Wrath of emperor is known because it changes his form as soon you kill one of their phases. This is how I have my .lua files:
Trying to understand what happened here, I wonder if would be better to have something such as this:
Also been struggling with the teleport room lever. It behaves kinda weird, I added some checks to make it more accurate (changed a few storages).
This is the whole part of the quest i'm pointing to:
And this is the lever I have:
And here's the most updated script from the quest where I took the script.
Thanks in advance!
Regards
Lua:
local bossForms = {
['esencia del dios serpiente'] = {
text = 'NO ES TAN FACIL, MORTALES! SIENTAN EL PODER DEL DIOS!',
newForm = 'serpentosa'
},
['serpentosa'] = {
text = 'NOOO! AHORA USTEDES HEREJES ENFRENTARAN MI IRA DIVINA!',
newForm = 'lagarto aberrante'
},
['lagarto aberrante'] = {
text = 'USTEDES... PAGARAN... CON LA ETERNIDAD... DEL DOLOR!',
newForm = 'zalamon mutado'
}
}
function onKill(player, target)
local targetMonster = target:getMonster()
if not targetMonster then
return true
end
if targetMonster:getName():lower() == 'zalamon mutado' then
Game.setStorageValue(PlayerStorageKeys.WrathoftheEmperor.Mission11, -1)
return true
end
local bossConfig = bossForms[targetMonster:getName():lower()]
if not bossConfig then
return true
end
Game.createMonster(bossConfig.newForm, targetMonster:getPosition(), false, true)
player:say(bossConfig.text, TALKTYPE_MONSTER_SAY)
return true
end
Trying to understand what happened here, I wonder if would be better to have something such as this:
Lua:
local creatureevent = CreatureEvent("FormOne")
function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
if math.random(100) < 10 then
Game.createMonster("Bossname", creature:getPosition())
creature:say("Next form.", TALKTYPE_MONSTER_SAY)
end
return true
end
Also been struggling with the teleport room lever. It behaves kinda weird, I added some checks to make it more accurate (changed a few storages).
This is the whole part of the quest i'm pointing to:
And this is the lever I have:
Lua:
local config = {
firstboss = "Esencia Del Dios Serpiente",
bossPosition = Position(1069, 633, 15),
trap = "Tiraplaga",
trapPositions = {
Position(1059, 629, 15),
Position(1068, 629, 15),
Position(1059, 636, 15),
Position(1068, 636, 15)
},
startAreaPosition = Position(1061, 630, 14),
arenaPosition = Position(1063, 632, 15)
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
--- Check if there's players inside'
local playersInside = Game.getSpectators(config.arenaPosition, true, false, 10, 10, 10, 10)
if #playersInside > 0 then
player:sendTextMessage(MESSAGE_STATUS_SMALL, 'La arena esta ocupada.')
return true
end
--- Check if player already killed Zalamon, so he/she don't help killing it twice
if Game.getStorageValue(PlayerStorageKeys.WrathoftheEmperor.Mission11) >= 2 then
player:sendTextMessage(MESSAGE_STATUS_SMALL, 'Un jugador que intenta entrar ya uso su cetro en el cuerpo sin vida de Zalamon.')
return true
end
--- Set storage of player "is inside"
Game.setStorageValue(PlayerStorageKeys.WrathoftheEmperor.Mission11, 1)
--- Clean items in area
Game.cleanAreaZalamon(Position(1055, 625, 15), Position(1071, 641, 15))
--- Check if there's monsters inside boss area and delete them all if the lever is being pulled
local monsters = Game.getSpectators(config.arenaPosition, false, false, 10, 10, 10, 10)
local spectator
for i = 1, #monsters do
spectator = monsters[i]
if spectator:isMonster() then
spectator:remove()
end
end
--- Teleport players from starting position to arena position
local spectators = Game.getSpectators(config.startAreaPosition, false, true, 0, 5, 0, 5)
for i = 1, #spectators do
spectator = spectators[i]
spectator:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
spectator:teleportTo(config.arenaPosition)
config.arenaPosition:sendMagicEffect(CONST_ME_TELEPORT)
end
for i = 1, #config.trapPositions do
Game.createMonster(config.trap, config.trapPositions[i])
end
Game.createMonster(config.firstboss, config.bossPosition)
item:transform(item.itemid == 1945 and 1946 or 1945)
return true
end
And here's the most updated script from the quest where I took the script.
orts2/data/scripts/quests/missions/wrath_of_the_emperor.lua at main · EPuncker/orts2
ORTS datapack working on latest TFS. Contribute to EPuncker/orts2 development by creating an account on GitHub.
github.com
Thanks in advance!
Regards