RevScript Teleport onKill Boss/Monster

Alex

Miembro del equipo
Webdesigner
LV
58
 
Awards
38
Hola a todos,

Aquí encontrareis el RevScript que hace aparecer un Teleport al matar un Boss/Monstruo,
Tengan en cuenta que si por ejemplo cogen un monstruo que existe demasiado, por ejemplo el Demon, el teleport aparecerá en donde habrán las coordenadas, y no en varios sitios determinados.

Es mejor utilizar el Script para un Boss, existente o Customizado, si bien es un monster aconsejo de customizarlo en una area determinada.

Para empezar este RevScript se pondra en data/scripts/creaturescripts
Crearemos el fichero teleportonkill.lua:

Código:
local tpkillboss = CreatureEvent("tpkillboss")
local enemyNames = {
    [1] = "NOMBRE_BOSS"
}

local function removeTeleport(position)
    local spawnedTeleport = Tile(position):getItemById(17868)
    if spawnedTeleport then
        spawnedTeleport:remove()
        position:sendMagicEffect(CONST_ME_POFF)
    end
 
    return true
end

local function formatString(s)
    s = string.gsub(s, "[%d%p%c%s]", "")
    s = s:lower()
 
    return s
end

function tpkillboss.onKill(creature, target)
    if not target or not target:isMonster() then
        return true
    end
 
    local f = false
    local t = formatString(target:getName())
    for _, v in ipairs(enemyNames) do
        if t == formatString(v) then
            f = true
        end
    end
 
    if not f then
        return true
    end

    local teleportSpawn = Position(34709, 32022, 11) -- Position for teleport to spawn
    removeTeleport(teleportSpawn)
    teleportSpawn:sendMagicEffect(CONST_ME_TELEPORT)
 
    local item = Game.createItem(17868, 1, teleportSpawn)
    if item:isTeleport() then
        local teleportTo = Position(34727, 32023, 11) -- Teleport destination
        item:setDestination(teleportTo)
    end

    target:say('Take the teleport before they disappear!', TALKTYPE_MONSTER_SAY, 0, 0, teleportSpawn)
    addEvent(removeTeleport, 200000, teleportSpawn)
 
    return true
end
tpkillboss:register()

Veremos que al principio del RevScript el nombre del boss " NOMBRE_BOSS " aqui pondran el nombre de su boss, si tiene un espacio pues sera con espacio ejemplo: "Goshnar Megalomania".

Al principio, medio y final del RevScript veremos la palabra "tpkillboss" esto sera lo que determinara el Script, si porqué hay que registrar la función en el login.lua, pero también si desean utilizar varias veces este Script deberán cada vez cambiar este nombre "tpkillboss" es decir por ejemplo el primer script traerá este nombre dentro pués el segundo le pondréis por ejemplo "tpkillbosssecond" , le hemos añadido "second" para diferenciarlo.

Position for Teleport to Spawn significa la position en donde aparecerá el teleport.
Teleport Destination significa en donde sera transportado el jugador.
addEvent(removeTeleport, 200000, teleportSpawn): Significael tiempo que durara el Teleport.

Registrar el RevScript:

Entraremos en data/scripts/creaturescripts/other y abriremos el fichero login.lua

En la parte donde dice:
Código:
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Welcome to " .. SERVER_NAME .. " Server.!")

Justo encima le añadiremos:
Código:
player:registerEvent("tpkillboss")

Quedaría entonces:
Código:
player:registerEvent("tpkillboss")
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Welcome to " .. SERVER_NAME .. " Server.!")
 
Última edición:
Arriba