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

[TFS 1.4] - Faster skill training with certain weapons! (on certain mobs!)

Tofame

Intermediate OT User
Joined
Aug 17, 2021
Messages
125
Solutions
4
Reaction score
101
Location
Poland
Yo,
The anime OT that existed 10 years ago had interesting system in which you had training weapons that allowed you to get more skill tries than usually and I just wanted to bring it to modern tfs (old version should work on any tfs 1.x, new one requires revscript system so its 1.3-1.5)
example behavior: club weapons give few skill_club tries as usual.
club weapon with certain id will be giving few skill_club tries + additional skill_club tries (configured in the script).

preview:

Installing:
Thanks to Xikini kindness we now have revscript version that requires only uploading file to data/scripts and that's all to do!

data/scripts/skillTries.lua
Lua:
local configBands = {
    [26433] = { -- item id that increases skill tries
        bonusTry = 8, -- how much it increases tries by
        xeffect = 40 -- what effect to send on creature
    },
    [26435] = {
        bonusTry = 4,
        xeffect = 40
    },
    [26436] = {
        bonusTry = 106,
        xeffect = 40
    },
    [26437] = {
        bonusTry = 50,
        xeffect = 40
    }
}


local ec = EventCallback

ec.onGainSkillTries = function(self, skill, tries)
    local target = self:getTarget()
    local whatBand = 0
    -- if you want to enable only for certain monster than change line below for:
    -- if target and target:getName() == "Train" then
    if target then
        if self:getSlotItem(CONST_SLOT_LEFT):getId() then
            whatBand = configBands[self:getSlotItem(CONST_SLOT_LEFT):getId()]
            if not whatBand then
                return tries
            end
            tries = tries + whatBand.bonusTry -- increased tries by config
            target:getPosition():sendMagicEffect(whatBand.xeffect)
            self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Using training weapon. Skilling is increased!")
        end
    end
    return tries
end

ec:register(1) -- 1 is indicating execution order of scripts.

data\creaturescripts\skillTries.lua
(local bands is basically configuration where you configure everything)
Lua:
-- specific weapons giving more skill tries than usually.
-- (while attacking some monsters like "Train". Depends to whom you added this event to..)
--[[
    (SKILL_FIST)  |  (SKILL_CLUB) |  (SKILL_SWORD)
    (SKILL_AXE)   (SKILL_DISTANCE)  (SKILL_SHIELD)
    (SKILL_FISHING)  (SKILL_MAGLEVEL)  (SKILL_LEVEL)
 
    (CONST_SLOT_HEAD)    
    (CONST_SLOT_NECKLACE)
    (CONST_SLOT_BACKPACK)
    (CONST_SLOT_ARMOR)
    (CONST_SLOT_RIGHT)
    (CONST_SLOT_LEFT)
    (CONST_SLOT_LEGS)
    (CONST_SLOT_FEET)
    (CONST_SLOT_RING)
    (CONST_SLOT_AMMO)
]]--
local bands = {
    [26433] = { -- item id
        tries = 10, -- bonus skill tries
        skillz = SKILL_CLUB, -- look commented area above for more
        xeffect = 40 -- what effect to send on attacked creature
    },
    [26435] = { -- Wooden band
        tries = 10,
        skillz = SKILL_FISHING,
        xeffect = 40
    },
    [26436] = { -- Critical Band
        tries = 10,
        skillz = SKILL_CLUB,
        xeffect = 40
    },
    [26437] = { -- Attack Speed Band
        tries = 10,
        skillz = SKILL_FIST,
        xeffect = 40
    }
}

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
local whatBand = 0

    if creature:isMonster() and attacker:isPlayer() then
        if attacker:getSlotItem(CONST_SLOT_LEFT) then
            whatBand = bands[attacker:getSlotItem(CONST_SLOT_LEFT):getId()]
            if not whatBand then
                return primaryDamage, primaryType, secondaryDamage, secondaryType
            end
            creature:getPosition():sendMagicEffect(whatBand.xeffect)
            attacker:addSkillTries(whatBand.skillz, whatBand.tries)
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

creaturescripts.xml
XML:
<event type="healthchange" name="skillTries" script="skillTries.lua"/>

Add to the monster that you want to script work with this part
data\monster\monsters\YourMonsterName.xml:
XML:
<script>
        <event name="skillTries"/>
</script>


Notes:
  • NOTE FOR OLD VERSION: If you have for example weaponType = "club" and in script this weapon adds different skill tries than club then you are getting those bonus skill tries to your skill + few skill_tries to club. If you want fist tries + bonus fist tries (script) then you don't put weaponType at all in items.xml
  • NOTE FOR OLD VERSION: The script will work only with monsters that have part above copied.
  • I got huge help with error fixing in this script on otacademy for what im grateful ;3
  • Huge help from Xikini here too
  • Revscript (new version) bonus tries are now given based on weaponType from items.xml as usual. No longer config for setting which skill to add tries to.
edit: slight changes to be more clear and preview added
edit: admin add please [1.4] in title, I forgot and there are no options for editing it :(
 
Last edited:
Instead of relying on a monster to be blood hit (onHealthChange), it would be more accurate to use onGainSkillTries.

Cool idea nonetheless.
Thanks for bringing it back to life.
 
Instead of relying on a monster to be blood hit (onHealthChange), it would be more accurate to use onGainSkillTries.

Cool idea nonetheless.
Thanks for bringing it back to life.
thanks for info, I didn't know that lol :D Looking on that it indeed is better. Though, I think onHealthChange is a bit more flexible - allows for sending effect on creature (like I did in original script) and you can limit it to monsters. onGainSkillTries I think will depend on player and thus set the script working for all the monster unless I'm understanding it wrongly.

I edited it for version with onGainSkillTries:
Lua:
-- specific weapons giving more skill tries than usually.
-- (while attacking some monsters like "Train". Depends to whom you added this event to..)
--[[
    (SKILL_FIST)  |  (SKILL_CLUB) |  (SKILL_SWORD)
    (SKILL_AXE)   (SKILL_DISTANCE)  (SKILL_SHIELD)
    (SKILL_FISHING)  (SKILL_MAGLEVEL)  (SKILL_LEVEL)
 
    (CONST_SLOT_HEAD)         
    (CONST_SLOT_NECKLACE)
    (CONST_SLOT_BACKPACK)
    (CONST_SLOT_ARMOR)
    (CONST_SLOT_RIGHT)
    (CONST_SLOT_LEFT)
    (CONST_SLOT_LEGS)
    (CONST_SLOT_FEET)
    (CONST_SLOT_RING)
    (CONST_SLOT_AMMO)
]]--
local bands = {
    [26433] = { -- item id
        tries = 10, -- bonus skill tries
        skillz = SKILL_CLUB -- look commented area above for more
    },
    [26435] = { -- Wooden band
        tries = 10,
        skillz = SKILL_FISHING
    },
    [26436] = { -- Critical Band
        tries = 10,
        skillz = SKILL_CLUB
    },
    [26437] = { -- Attack Speed Band
        tries = 10,
        skillz = SKILL_FIST
    }
}

function onGainSkillTries(skill, tries)
local whatBand = 0
    if player:getSlotItem(CONST_SLOT_LEFT) then
        whatBand = bands[player:getSlotItem(CONST_SLOT_LEFT):getId()]
        if not whatBand then
            return
        end
        player:addSkillTries(whatBand.skillz, whatBand.tries)
    end
    return
end

I can't test it though, because I don't know what to write in creaturescripts.xml
Code:
<event type="what should be here?" name="skillTries2" script="skillTriesv2.lua"/>
 
Last edited:
thanks for info, I didn't know that lol :D Looking on that it indeed is better. Though, I think onHealthChange is a bit more flexible - allows for sending effect on creature (like I did in original script) and you can limit it to monsters. onGainSkillTries I think will depend on player and thus set the script working for all the monster unless I'm understanding it wrongly.

I edited it for version with onGainSkillTries:
Lua:
-- specific weapons giving more skill tries than usually.
-- (while attacking some monsters like "Train". Depends to whom you added this event to..)
--[[
    (SKILL_FIST)  |  (SKILL_CLUB) |  (SKILL_SWORD)
    (SKILL_AXE)   (SKILL_DISTANCE)  (SKILL_SHIELD)
    (SKILL_FISHING)  (SKILL_MAGLEVEL)  (SKILL_LEVEL)
 
    (CONST_SLOT_HEAD)       
    (CONST_SLOT_NECKLACE)
    (CONST_SLOT_BACKPACK)
    (CONST_SLOT_ARMOR)
    (CONST_SLOT_RIGHT)
    (CONST_SLOT_LEFT)
    (CONST_SLOT_LEGS)
    (CONST_SLOT_FEET)
    (CONST_SLOT_RING)
    (CONST_SLOT_AMMO)
]]--
local bands = {
    [26433] = { -- item id
        tries = 10, -- bonus skill tries
        skillz = SKILL_CLUB -- look commented area above for more
    },
    [26435] = { -- Wooden band
        tries = 10,
        skillz = SKILL_FISHING
    },
    [26436] = { -- Critical Band
        tries = 10,
        skillz = SKILL_CLUB
    },
    [26437] = { -- Attack Speed Band
        tries = 10,
        skillz = SKILL_FIST
    }
}

function onGainSkillTries(skill, tries)
local whatBand = 0
    if player:getSlotItem(CONST_SLOT_LEFT) then
        whatBand = bands[player:getSlotItem(CONST_SLOT_LEFT):getId()]
        if not whatBand then
            return
        end
        player:addSkillTries(whatBand.skillz, whatBand.tries)
    end
    return
end

I can't test it though, because I don't know what to write in creaturescripts.xml
Code:
<event type="what should be here?" name="skillTries2" script="skillTriesv2.lua"/>
I'm not sure how to do it via standard creaturescripts.. but if you use data/scripts the revscript system, you could do this
Lua:
local ec = EventCallback

ec.onGainSkillTries = function(self, skill, tries)
    --code here
    return tries
end

ec:register(1) -- 1 is indicating execution order of scripts.

As for not being able to use monsters, you could do this..
(Although doesn't work for magic / spells really), since you wouldn't have a specific target.. 🤷‍♂️
But then again in your original post, if someone put like 5 different dot's (fire, poison, electric.. et cetera)
They would gain massive skill points really quickly xD

anyway
Lua:
local target = self:getTarget()   
if target and target:getName() == "Trainer" then
    if skill == whatever_skill then
        tries = math.ceil(tries * 1.5)
        tries = tries + 10
    end
else
    -- no target.. so check for magic usage? or don't do anything
end
 
I'm not sure how to do it via standard creaturescripts.. but if you use data/scripts the revscript system, you could do this
Lua:
local ec = EventCallback

ec.onGainSkillTries = function(self, skill, tries)
    --code here
    return tries
end

ec:register(1) -- 1 is indicating execution order of scripts.

As for not being able to use monsters, you could do this..
(Although doesn't work for magic / spells really), since you wouldn't have a specific target.. 🤷‍♂️
But then again in your original post, if someone put like 5 different dot's (fire, poison, electric.. et cetera)
They would gain massive skill points really quickly xD

anyway
Lua:
local target = self:getTarget()  
if target and target:getName() == "Trainer" then
    if skill == whatever_skill then
        tries = math.ceil(tries * 1.5)
        tries = tries + 10
    end
else
    -- no target.. so check for magic usage? or don't do anything
end
Thanks for all your explanations. I just finished converting it to revscript and will update the main post now.
 
I can't edit so there is fix that I didn't notice at first: (in revscript version)
line 29
Lua:
if self:getSlotItem(CONST_SLOT_LEFT):getId() then
change to:
Lua:
if self:getSlotItem(CONST_SLOT_LEFT) then
Otherwise, it sends errors to console if you dont have weapon equipped at all.
 
Back
Top