• 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

Shadow_

Veteran OT User
Joined
Jun 2, 2018
Messages
923
Solutions
30
Reaction score
340
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
 

Musaab

NoxOts
Premium User
Joined
May 13, 2010
Messages
177
Reaction score
74
Location
Sweden
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:

Codinablack

Dreamer
Content Editor
Premium User
Joined
Dec 26, 2013
Messages
1,383
Solutions
7
Reaction score
507
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?
 

Acubens

Old Penguin
Joined
May 6, 2008
Messages
1,117
Solutions
7
Reaction score
118
Location
YurOTS Land
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.
 

Codinablack

Dreamer
Content Editor
Premium User
Joined
Dec 26, 2013
Messages
1,383
Solutions
7
Reaction score
507
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?
 
OP
Shadow_

Shadow_

Veteran OT User
Joined
Jun 2, 2018
Messages
923
Solutions
30
Reaction score
340
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
 
Top