• 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!

RevScripts onDeath script Check

peteralto

Member
Joined
Nov 1, 2020
Messages
95
Solutions
1
Reaction score
19
I'm trying to get the script to check the death of the Orshabaal creature, and if it is killed, an item would be removed from a specific tile, the Apocalypse creature would be removed from the tilePosition2 position and would be created in the newPosition position.

There are no errors in the console and nothing happens after Orshabaal dies. TFS 1.3+

Lua:
local LastFightDeath = CreatureEvent("LastFightDeath")

function LastFightDeath.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified)

    if creature:getName():lower() == "Orshabaal" then
        local removeitem = Position(31520, 30251, 7)
        local tilePosition2 = Position(31845, 30591, 7)
        local newPosition = Position(31837, 30591, 7)
        local itemId1 = 19050
        local monsterName = "Apocalypse"


        local tile = Tile(removeitem)
        if tile then
            local item1 = tile:getItemById(itemId1)
            if item1 then
                item1:remove()
            end
        end


        local tile2 = Tile(tilePosition2)
        if tile2 then
            local monster = tile2:getTopCreature()
            if monster and monster:getName():lower() == monsterName:lower() then
                monster:remove()
                Game.createMonster(monsterName, newPosition)
            end
        end
    end
    return true
end

LastFightDeath:register()
 
You are comparing a lowered string to a string that contains an upper case character...
Lua:
if creature:getName():lower() == "Orshabaal" then

Also double check that the Orshabaal monster has the LastFightDeath event registered in either it's XML file or via the Creature::registerEvent() method (if spawned by another script...)

Lua:
local deathMonsterName = "Orshabaal"
local itemId = 19050
local itemPosition = Position(31520, 30251, 7)
local spawnMonsterName = "Apocalypse"
local spawnCreatureFrom = Position(31845, 30591, 7)
local spawnCreatureTo = Position(31837, 30591, 7)

local LastFightDeath = CreatureEvent("LastFightDeath")
function LastFightDeath.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified)

    if creature:getName():lower() ~= deathMonsterName:lower() then
        return true
    end
 
    local tile = Tile(itemPosition)
    if tile then
        local item = tile:getItemById(itemId)
        if item then
            item:remove()
        end
    end

    tile = Tile(spawnCreatureFrom)
    if tile then
        local monster = tile:getTopCreature()
        if monster and monster:getName():lower() == spawnMonsterName:lower() then
            monster:remove()
            Game.createMonster(spawnMonsterName, spawnCreatureTo)
        end
    end
 
    return true
end
LastFightDeath:register()
 
Last edited:
Back
Top