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

Lua vocations weapons bonus damage tfs 1.4.2

wafuboe

Member
Joined
Dec 24, 2010
Messages
881
Solutions
2
Reaction score
22
Hello,

Im requesting sorting of a passive for custom vocations using their weapons.

Ex. Berserker and promoted Voc., while equipped a 2h weapon their damage increase 10% (on hit)
Ex Spearman and promoted Voc, while equipped a Spear, chance 5% to cause bleeding 10 ticks for the amount (level/distanceskill * 25)

I am currently using tfs 1.4.2

Thank you!
 
I gave it a try, Not best written but should work.
Lua:
local chance = math.random(0, 100)
local chancePercent = 5

local healthDamageBonus = CreatureEvent("healthDamageBonus")

function healthDamageBonus.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker and attacker:isPlayer() then
        local berserkerWeapon = attacker:getSlotItem(CONST_SLOT_LEFT):getId() == 2400
        local base = attacker:getVocation():getId()
        if creature:isMonster() or creature:isPlayer() then
            if origin == ORIGIN_MELEE then
                if base == 4 and berserkerWeapon then
                    primaryDamage = primaryDamage * 1.1
                end
            elseif origin == ORIGIN_RANGED then
                local spearmanWeapon = attacker:getSlotItem(CONST_SLOT_LEFT):getId() == 2389
                local playerLevel = attacker:getLevel()
                local playerDistance = attacker:getSkillLevel(SKILL_DISTANCE)
                local condition = Condition(CONDITION_BLEEDING)
                condition:setParameter(CONDITION_PARAM_DELAYED, 1)
                condition:addDamage(10, 1000, -(playerLevel / playerDistance) * 25)
                if base == 3 and spearmanWeapon then
                    if chance <= chancePercent then
                        primaryDamage = primaryDamage
                        creature:addCondition(condition)
                    end
                end
            end
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end

healthDamageBonus:register()

local manaDamageBonus = CreatureEvent("manaDamageBonus")

function manaDamageBonus.onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker and attacker:isPlayer() then
        local berserkerWeapon = attacker:getSlotItem(CONST_SLOT_LEFT):getId() == 2400
        local base = attacker:getVocation():getId()
        if creature:isPlayer() then
            if origin == ORIGIN_MELEE then
                if base == 4 and berserkerWeapon then
                    primaryDamage = primaryDamage * 1.1
                end
            elseif origin == ORIGIN_RANGED then
                local spearmanWeapon = attacker:getSlotItem(CONST_SLOT_LEFT):getId() == 2389
                local playerLevel = attacker:getLevel()
                local playerDistance = attacker:getSkillLevel(SKILL_DISTANCE)
                local condition = Condition(CONDITION_BLEEDING)
                condition:setParameter(CONDITION_PARAM_DELAYED, 1)
                condition:addDamage(10, ((playerLevel / playerDistance) * 25), -1)
                if base == 3 and spearmanWeapon then
                    if chance <= chancePercent then
                        primaryDamage = primaryDamage
                        creature:addCondition(condition)
                    end
                end
            end
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end

manaDamageBonus:register()

local creatureEvent = CreatureEvent("loginBonus")

function creatureEvent.onLogin(player)
    player:registerEvent("healthDamageBonus")
    player:registerEvent("manaDamageBonus")
    return true
end

creatureEvent:register()

local ec = EventCallback

function ec.onSpawn(monster, position, startup, artificial)
    monster:registerEvent("healthDamageBonus")
    return true
end

ec:register(-666)
You'll have to change berserkerWeapon to your Berserker weapon id and spearmanWeapon to your Spearman weapon id.
You'll also have to change base == 4 to Berserker vocation id and base == 3 to Spearman vocation id.
Note: I assumed that Berserker is based on Knight so I used origin == ORIGIN_MELEE and I assumed that Spearman is based on Paladin so I used origin == ORIGIN_RANGED, You can change them.
 
Last edited:
Back
Top