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

CreatureEvent [TFS 1.X] Upgrade Weapon When X count Monster Killed

S

Shadow_

Guest
don't forget to register it in login.lua and creaturescripts.xml if you don't know how don't use it.
this script will upgrade the weapon you add in its lua script these lines to another weapon after killing specific count of monsters.
to use in quests log you can do it like this :
XML:
    <quest name="Grimfrost Upgrading" startstorageid="73913" startstoragevalue="3">
        <mission name="Magical Energy Consuming" storageid="73913" startvalue="3" endvalue="5">
            <missionstate id="3" description="You need to consume 50 terrorsleep energy in order to upgrade your weapon, the only way to consume their energy is to kill them." />
            <missionstate id="4" description="Your weapon is ready to be upgraded successfully! By using your weapon one more time it will be upgraded automatically." />
            <missionstate id="5" description="Your weapon is already upgraded" />
        </mission>
    </quest>
Lua:
local config = {
     ['terrorsleep'] = {amount = 50, storage = 89273, startstorage = 73913},
}
function onKill(player, target)
     local monster = config[target:getName():lower()]
     if target:isPlayer() or not monster or target:getMaster() then
         return true
     end
        local stor = player:getStorageValue(monster.storage) + 1
        if stor < monster.amount and player:getStorageValue(monster.startstorage) == 3 then
        player:setStorageValue(monster.storage, stor)
           player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, '[GrimFrost Upgrade]: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.')
         end
     if (stor +1) == monster.amount then
         player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations, you have killed '..(stor +1)..' '..target:getName()..'s and completed the '..target:getName()..'s mission.')
         player:setStorageValue(monster.storage, stor +1)
         player:setStorageValue(monster.startstorage, 4)
     end
     return true
end

in your weapon file (weapons/scripts) you should add this
Lua:
    player = Player(cid)
    if player:getStorageValue(73913) < 3 then
        player:setStorageValue(73913, 3)
    end
    if player:getStorageValue(73913) == 4 then
        if player:removeItem(22415, 1) then
        player:addItem(26449, 1)
        player:setStorageValue(73913, 5)
        player:setStorageValue(89273, 51) -- if in onKill function you made the monster die for 100 times set this to 101 instead of 51 you should get it.
        player:say(TALKTYPE_MONSTER_SAY, "GRIMFROST")
        player:getPosition():SendMagicEffect(40)
        end
    end
 
Hey @Shadow_ may i ask why am getting this error in console when i dont have a weapon equipped?

"
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/weaponupgrade.lua:eek:nKill
data/creaturescripts/scripts/weaponupgrade.lua:16: attempt to index local 'weapon' (a nil value)
stack traceback:
[C]: in function '__index'
data/creaturescripts/scripts/weaponupgrade.lua:16: in function <data/creaturescripts/scripts/weaponupgrade.lua:7>
"

Otherwise the script runs very good without any issues, its just that i might have a vocation that uses no weapon slot and wondering if there is any solution :)

Thx!
 
Last edited:
Just a question, as I was considering doing something like this myself, but would this not count for a whole party of say 3 players, all killing the same demon?
 
Just a question, as I was considering doing something like this myself, but would this not count for a whole party of say 3 players, all killing the same demon?
onKill just work for last hit for party must use onDeath and take the damageMap.
 
So you are certain two different players can't kill something together and both get increased storage values for it? I could have sworn that someone once said a system like this would have to use OnDeath instead, to make sure it gets the correct person and not multiples.


I just want to be certain before I get too far in the one I am trying to make, you have tested for such a situation before?
 
So you are certain two different players can't kill something together and both get increased storage values for it? I could have sworn that someone once said a system like this would have to use OnDeath instead, to make sure it gets the correct person and not multiples.


I just want to be certain before I get too far in the one I am trying to make, you have tested for such a situation before?
as he told you it detects the last hit if you want to use onDeath you always can, won't be there much difference if there will
 
Back
Top