• TibiaFace

    Tibiaface | Una comunidad Open Tibia donde encontras : mapas, scripts, Otserver, npc y amigos etc ...

    .
    demo menumenu

    Afiliados



    Votar:

    [Sistema] Boosted Creature [Monster, Exp, Loot, EventCallBack] (TFS 1.X & OTX / TFS 1.4 o 1.5)

    Compartir:

    Ver el tema anterior Ver el tema siguiente Ir abajo  Mensaje (Página 1 de 1.)

    SoyFabi

    SoyFabi
    Miembro
    Miembro
    Saludos, vi que en este foro no existe un post que tenga que ver con Boosted Creature.

    ¿Que es Boosted Creature?
    - Este sistema sirve para potenciar el monster seleccionado, que te otorgan mas exp y loot al matarlo algo como el de Tibia RL.

    [Sistema] Boosted Creature [Monster, Exp, Loot, EventCallBack] (TFS 1.X & OTX / TFS 1.4 o 1.5) Screen55

    [Sistema] Boosted Creature [Monster, Exp, Loot, EventCallBack] (TFS 1.X & OTX / TFS 1.4 o 1.5) Screen56

    Bueno, es facil de instalar con un simple scripts, ya que es un revscripts.

    Nos vamos a:

    data/scripts y creamos un archivo lua y copiamos estos dentro:

    Código:
    if not boostCreature then boostCreature = {} end

    local BoostedCreature = {
     monsters = {"Demon", "Dragon", "Grim Reaper"}, --/ Monsters aleatoriamente que apareceran. (, "Defiler")
     db = true, --/ Si quieres que refleje en la tabla db.
     exp = {20, 45}, --/ Porcentage de Exp. 20/45%.
     loot = {20, 45}, --/ Porcentage de Loot. 20/45%.
     position = Position(1000, 1000, 7), --/ Posicion del Monsters donde estara.
     messages = {
     prefix = "[Boosted Creature] ",
     chosen = "The creature chosen was %s. When killing you receive +%d of experience and +%d of loot.",
     },
    }

    function BoostedCreature:start()
     local rand = math.random
     local monsterRand = BoostedCreature.monsters[rand(#BoostedCreature.monsters)]
     local expRand = rand(BoostedCreature.exp[1], BoostedCreature.exp[2])
     local lootRand = rand(BoostedCreature.loot[1], BoostedCreature.loot[2])
     table.insert(boostCreature, {name = monsterRand:lower(), exp = expRand, loot = lootRand})
     local monster = Game.createMonster(boostCreature[1].name, BoostedCreature.position, false, true)
     monster:setDirection(SOUTH)
    end

    local text = GlobalEvent("Text_Boost")
    function text.onThink(interval)
     -- Change Position --
     local effects = {
     {position = Position(999, 1000, 7), text = "+" .. boostCreature[1].exp .."% Exp", color = math.random(178,180)},
     {position = Position(1001, 1000, 7), text = "+" .. boostCreature[1].loot .."% Loot", color = math.random(178,180)},
     }
     
     for i = 1, #effects do
            local settings = effects[i]
            local spectators = Game.getSpectators(settings.position, false, true, 100, 100, 100, 100)
            if #spectators > 0 then
                if settings.text then
                    for i = 1, #spectators do
                        if settings.say then
                            spectators[i]:say(settings.text, TALKTYPE_MONSTER_SAY, false, spectators[i], settings.position)
                        else
                            Game.sendAnimatedText(settings.text, settings.position, settings.color)
     Game.sendAnimatedText(settings.text, settings.position, settings.color)
                        end
                    end
                end
                if settings.effect then
                    settings.position:sendMagicEffect(settings.effect)
                end
            end
        end

     return true
    end
    text:interval(6000)
    text:register()


    ------- DB -------
    local mb_start = GlobalEvent("MonstersStart")
    function mb_start.onStartup()
     BoostedCreature:start()
     if BoostedCreature.db then
     db.query(string.format("UPDATE `boost_creature` SET `name` = '%s', `exp` = %d, `loot` = %d", firstToUpper(boostCreature[1].name), boostCreature[1].exp, boostCreature[1].loot))
     end
     return true
    end
    mb_start:register()

    ------- GLOBALEVENT -------
    local monstersboost = GlobalEvent("Monsters_Boost")
    function monstersboost.onThink(interval)
     Game.broadcastMessage(BoostedCreature.messages.prefix .. BoostedCreature.messages.chosen:format(firstToUpper(boostCreature[1].name), boostCreature[1].exp, boostCreature[1].loot))
     return true
    end

    monstersboost:interval(10800000)
    monstersboost:register()

    ------- TALKACTION -------
    local boostedmtalk = TalkAction("!boosted","!boostedcreature","!boost")
    function boostedmtalk.onSay(player, words, param)
     local message = "--------[+]----------- [Boost Creature] -----------[+]--------\n\n   Every day a [Monster] is chosen so that they have an extra exp and loot.\n\n--------[+]-----------------------------------[+]--------\n                                               Creature of Today: ".. firstToUpper(boostCreature[1].name) .."\n                                                        Experience: +".. boostCreature[1].exp .."%\n                                                              Loot: +".. boostCreature[1].loot .."%              "
     player:popupFYI(message)
     return false
    end

    boostedmtalk:register()

    ------- CREATUREEVENT / LOGIN -------
    local boostedlogin = CreatureEvent("Boosted_Login")
    function boostedlogin.onLogin(player)
     addEvent(function()
     local message = "Today daily creature are: \n[" .. boostCreature[1].name .. "]\nBonus Exp Rate: " .. boostCreature[1].exp .."%.\n Extra Loot Rate: " .. boostCreature[1].loot .."%."
     player:sendTextMessage(MESSAGE_INFO_DESCR, message)
     end, 2000)
     return true
    end

    boostedlogin:register()

    -- EventCallBack / onGainExperience --

    local ec = EventCallback
    ec.onGainExperience = function(self, source, exp, rawExp)
     -- Boost Creature
     local extraXp = 0
     if (source:getName():lower() == boostCreature[1].name) then
     local extraPercent = boostCreature[1].exp
     extraXp = exp * extraPercent / 100
     self:sendTextMessage(MESSAGE_STATUS_DEFAULT, "[Boosted Creature] You won +".. extraXp .." of experience bonus for kill a ".. source:getName()..".")
     addEvent(function()Game.sendAnimatedText("+".. extraXp .." exp", self:getPosition(), 102) end, 250)
     self:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
     end
     
     return exp + extraXp
    end

    ec:register()

    En el caso que tu servidor no tenga EventCallBack, ya que te saltara un error como "local ec".

    Entonces borre este codigo:
    Código:
    -- EventCallBack / onGainExperience --

    local ec = EventCallback
    ec.onGainExperience = function(self, source, exp, rawExp)
     -- Boost Creature
     local extraXp = 0
     if (source:getName():lower() == boostCreature[1].name) then
     local extraPercent = boostCreature[1].exp
     extraXp = exp * extraPercent / 100
     self:sendTextMessage(MESSAGE_STATUS_DEFAULT, "[Boosted Creature] You won +".. extraXp .." of experience bonus for kill a ".. source:getName()..".")
     addEvent(function()Game.sendAnimatedText("+".. extraXp .." exp", self:getPosition(), 102) end, 250)
     self:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
     end
     
     return exp + extraXp
    end

    ec:register()

    Vaya a:
    data/events/player.lua

    Buscaremos esta linea:
    Código:
    function Player:onGainExperience(source, exp, rawExp)

    Debajo colocaremos esta linea:
    Código:
    -- Boost Creature
     local extraXp = 0
     if (source:getName():lower() == boostCreature[1].name) then
     local extraPercent = boostCreature[1].exp
     extraXp = exp * extraPercent / 100
     self:sendTextMessage(MESSAGE_STATUS_DEFAULT, "[Boosted Creature] You won +".. extraXp .." of experience bonus for kill a ".. source:getName()..".")
     addEvent(function()Game.sendAnimatedText("+".. extraXp .." exp", self:getPosition(), 102) end, 250)
     end

    Terminando con:
    Código:
    return exp + extraXp
    end


    Por lo que quedaria asi:
    Código:
    function Player:onGainExperience(source, exp, rawExp)
     if not source or source:isPlayer() then
     return exp
     end
     
     -- Apply experience stage multiplier
     exp = exp * Game.getExperienceStage(self:getLevel())

     -- Stamina modifier
     if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
     useStamina(self)

     local staminaMinutes = self:getStamina()
     if staminaMinutes > 2400 and self:isPremium() then
     exp = exp * 1.5
     elseif staminaMinutes <= 840 then
     exp = exp * 0.5
     end
     end
     
     -- Soul regeneration
     local vocation = self:getVocation()
     if self:getSoul() < vocation:getMaxSoul() and exp >= self:getLevel() then
     soulCondition:setParameter(CONDITION_PARAM_SOULTICKS, vocation:getSoulGainTicks() * 1000)
     self:addCondition(soulCondition)
     end
     
     -- Boost Creature
     local extraXp = 0
     if (source:getName():lower() == boostCreature[1].name) then
     local extraPercent = boostCreature[1].exp
     extraXp = exp * extraPercent / 100
     self:sendTextMessage(MESSAGE_STATUS_DEFAULT, "[Boosted Creature] You won +".. extraXp .." of experience bonus for kill a ".. source:getName()..".")
     addEvent(function()Game.sendAnimatedText("+".. extraXp .." exp", self:getPosition(), 102) end, 250)
     end
     return exp + extraXp
    end

    Agregar en cualquier parte de:
    global.lua
    Código:
    -- Boosted Creature Table --
    function firstToUpper(str)
        return (str:gsub("^%l", string.upper))
    end

    Pata termiinar nos vamos a:
    data/events/scripts/monster

    Debajo de esta linea:
    Código:
    onDropLoot = function(self, corpse)

    Colocamos esto:
    Código:
    -- Boost Creature
     local percent = 0
     if (mType:getName():lower() == boostCreature[1].name) then
     percent = (boostCreature[1].loot / 100)
     end

    Cualquier duda o error, no olvide mencionarlo en este mismo post.
    Suerte!



    Última edición por SoyFabi el Mar Feb 28, 2023 11:46 am, editado 3 veces

    3 participantes

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    gracias por el paorte +1 (y)



    [Sistema] Boosted Creature [Monster, Exp, Loot, EventCallBack] (TFS 1.X & OTX / TFS 1.4 o 1.5) YNU5B25
    3 participantes
    http://www.tibiaface.com

    akane

    akane
    Miembro
    Miembro
    muy bueno, necesitaba uno para mi tfs

    3 participantes

    SoyFabi

    SoyFabi
    Miembro
    Miembro
    akane escribió:muy bueno, necesitaba uno para mi tfs

    Funciona perfectamente tambien para los OTX.

    3 participantes

    Contenido patrocinado


    3 participantes

    Ver el tema anterior Ver el tema siguiente Volver arriba  Mensaje (Página 1 de 1.)

    Permisos de este foro:
    No puedes responder a temas en este foro.

     

    BienvenidosTibiaFace es una comunidad de Open Tibia. Para participar debes estar registrado (click para Regístrate).