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

Script to strengthen the monster's attacks by 5%

Newone0

Member
Joined
Nov 22, 2021
Messages
59
Reaction score
7
Hi guys,
Like in the title i looking for script to strengthen the monster's attacks(mele+spells) by 5% and script to strengthen the monster's defense(player attack monster 5% less from all spells and mele) by 5%. I know i have to use onHelathChange() but i dont know how.
 
Solution
Works great Thanks!
Do you know ho to make script to strengthen the monster's defense(player attack monster 5% less from all spells and mele)
I can make onHealthChange for player but i need to reduce attack only for a specific monster
Lua:
local storage_attack = 1235 -- value of monster bonus damage, ex. set it to 5 for 5% but if you want to disable it set to -1
local storage_defense = 1236 -- value of monster bonus defense, ex. set it to 5 for 5% but if you want to disable it set to -1

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if creature:isPlayer() and attacker:isMonster() then
        local bonus_damage = attacker:getStorageValue(storage_attack)...
You won't do it in creaturescripts using onHelathChange because you can't give monsters storage value.
You can create a spell for a monster that would turn it into a upgraded version of monster or add a function to source that will strengthen monster.

You can easily pull it into a function in source because boost functions exist in config.lua but for all monsters.

Lua:
-- Monster rates
rateMonsterHealth = 1.0
rateMonsterMana = 1.0
rateMonsterAttack = 1.0
rateMonsterDefense = 1.0
 
You won't do it in creaturescripts using onHelathChange because you can't give monsters storage value.
You can create a spell for a monster that would turn it into a upgraded version of monster or add a function to source that will strengthen monster.

You can easily pull it into a function in source because boost functions exist in config.lua but for all monsters.

Lua:
-- Monster rates
rateMonsterHealth = 1.0
rateMonsterMana = 1.0
rateMonsterAttack = 1.0
rateMonsterDefense = 1.0

U can
U dont have to give monster storage
+ u can give monster storage its possible
 
You won't do it in creaturescripts using onHelathChange because you can't give monsters storage value.
You can create a spell for a monster that would turn it into a upgraded version of monster or add a function to source that will strengthen monster.

You can easily pull it into a function in source because boost functions exist in config.lua but for all monsters.

Lua:
-- Monster rates
rateMonsterHealth = 1.0
rateMonsterMana = 1.0
rateMonsterAttack = 1.0
rateMonsterDefense = 1.0
I can give monster storage and i need to make in script beacouse i want to strengthen the monster few times. Its posibble with onHealthChange() but i dont know what to return to make it 5% more or less
Post automatically merged:

U can
U dont have to give monster storage
+ u can give monster storage its possible
Can you write that script for me? I guess it is simple but I don't know how
 
So, if storages on monster work try this:
Lua:
local storage = 1235 -- value of monster bonus damage, ex. set it to 5 for 5% but if you want to disable it set to -1

function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(cid) and isMonster(attacker) then
        if getCreatureStorage(attacker, storage) > 0 then
            value = value * (1 +  getCreatureStorage(attacker, storage) / 100)
            doTargetCombatHealth(attacker, cid, combat, -value, -value, 0)
            return false
        end
    end
return true
end
 
Last edited:
I can give monster storage and i need to make in script beacouse i want to strengthen the monster few times. Its posibble with onHealthChange() but i dont know what to return to make it 5% more or less
Post automatically merged:


Can you write that script for me? I guess it is simple but I don't know how
Tfs version
 
Tfs version
1.3
Post automatically merged:

So, if storages on monster work try this:
Lua:
local storage = 1235 -- value of monster bonus damage, ex. set it to 5 for 5% but if you want to disable it set to -1

function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(cid) and isMonster(attacker) then
        if getCreatureStorage(attacker, storage) > 0 then
            value = value * (1 +  getCreatureStorage(attacker, storage) / 100)
            doTargetCombatHealth(attacker, cid, combat, -value, -value, 0)
            return false
        end
    end
return true
end
thanks but this is not for my engine version and i donst have function like onChangeStats
 
1.3
Post automatically merged:


thanks but this is not for my engine version and i donst have function like onChangeStats
Lua:
local storage = 1235 -- value of monster bonus damage, ex. set it to 5 for 5% but if you want to disable it set to -1

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if creature:isPlayer() and attacker:isMonster() then
        local bonus_damage = attacker:getStorageValue(storage)
        if bonus_damage > 0 then
            multip = 1 + (bonus_damage / 100)
            return primaryDamage * multip, primaryType, secondaryDamage, secondaryType
        end
    end
 
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if creature:isPlayer() and attacker:isMonster() then
        local bonus_damage = attacker:getStorageValue(storage)
        if bonus_damage > 0 then
            multip = 1 + (bonus_damage / 100)
            return primaryDamage * multip, primaryType, secondaryDamage, secondaryType
        end
    end
 
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
 
Lua:
local storage = 1235 -- value of monster bonus damage, ex. set it to 5 for 5% but if you want to disable it set to -1

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if creature:isPlayer() and attacker:isMonster() then
        local bonus_damage = attacker:getStorageValue(storage)
        if bonus_damage > 0 then
            multip = 1 + (bonus_damage / 100)
            return primaryDamage * multip, primaryType, secondaryDamage, secondaryType
        end
    end
 
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if creature:isPlayer() and attacker:isMonster() then
        local bonus_damage = attacker:getStorageValue(storage)
        if bonus_damage > 0 then
            multip = 1 + (bonus_damage / 100)
            return primaryDamage * multip, primaryType, secondaryDamage, secondaryType
        end
    end
 
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Works great Thanks!
Do you know ho to make script to strengthen the monster's defense(player attack monster 5% less from all spells and mele)
I can make onHealthChange for player but i need to reduce attack only for a specific monster
 
Last edited:
Works great Thanks!
Do you know ho to make script to strengthen the monster's defense(player attack monster 5% less from all spells and mele)
I can make onHealthChange for player but i need to reduce attack only for a specific monster
Lua:
local storage_attack = 1235 -- value of monster bonus damage, ex. set it to 5 for 5% but if you want to disable it set to -1
local storage_defense = 1236 -- value of monster bonus defense, ex. set it to 5 for 5% but if you want to disable it set to -1

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if creature:isPlayer() and attacker:isMonster() then
        local bonus_damage = attacker:getStorageValue(storage_attack)
        if bonus_damage > 0 then
            multip = 1 + (bonus_damage / 100)
            return primaryDamage * multip, primaryType, secondaryDamage, secondaryType
        end
    end
    if creature:isMonster() and attacker:isPlayer() then
        local bonus_defense = creature:getStorageValue(storage_defense)
        if bonus_defense > 0 then
            multip = math.max(0, 1 - (bonus_defense / 100))
            return primaryDamage * multip, primaryType, secondaryDamage * multip, secondaryType
        end
    end
 
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if creature:isPlayer() and attacker:isMonster() then
        local bonus_damage = attacker:getStorageValue(storage_attack)
        if bonus_damage > 0 then
            multip = 1 + (bonus_damage / 100)
            return primaryDamage * multip, primaryType, secondaryDamage, secondaryType
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
 
Solution
Lua:
local storage = 1235 -- value of monster bonus damage, ex. set it to 5 for 5% but if you want to disable it set to -1

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if creature:isPlayer() and attacker:isMonster() then
        local bonus_damage = attacker:getStorageValue(storage)
        if bonus_damage > 0 then
            multip = 1 + (bonus_damage / 100)
            return primaryDamage * multip, primaryType, secondaryDamage, secondaryType
        end
    end
 
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if creature:isPlayer() and attacker:isMonster() then
        local bonus_damage = attacker:getStorageValue(storage)
        if bonus_damage > 0 then
            multip = 1 + (bonus_damage / 100)
            return primaryDamage * multip, primaryType, secondaryDamage, secondaryType
        end
    end
 
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
there for tfs 0.4?
 
Back
Top