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

Vocations balance tfs 1.5 7.72

dewral

Veteran OT User
Joined
Dec 4, 2019
Messages
343
Solutions
10
Reaction score
351
Hello i have this script from some time ago but now have some issues with with getting this worked
Lua:
local pvpvocs = {
    [1] = {
        pvp = {weapon = 40.2, spells = 45.0, defense = 1.0},
        pve = {weapon = 40.2, spells = 45.0, defense = 50.0},
        healing = 50.0
    },
    [2] = {
        pvp = {weapon = 1.2, spells = 1.3, defense = 1.2},
        pve = {weapon = 1.2, spells = 1.3, defense = 1.2},
        healing = 1.8
    },
    [3] = {
        pvp = {weapon = 1.8, spells = 1.2, defense = 1.2},
        pve = {weapon = 1.8, spells = 1.2, defense = 1.2},
        healing = 1.4
    },
    [4] = {
        pvp = {weapon = 1.2, spells = 1.0, defense = 1.6},
        pve = {weapon = 0.8, spells = 1.0, defense = 1.6},
        healing = 1.1
    },
    [5] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [6] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [7] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [8] = {
        pvp = {weapon = 1.3, spells = 1.1, defense = 1.7},
        pve = {weapon = 0.7, spells = 1.1, defense = 1.7},
        healing = 1.1
    },
}
 
function onHealthChange(creature, attacker, primaryType, primaryDamage, origin)    
   
    if attacker:isMonster() then attacker:registerEvent("vocations") end
       
    if attacker and attacker:isPlayer() then  
        local base = attacker:getVocation():getId()
   
        if primaryType == COMBAT_HEALING then      
            primaryDamage = primaryDamage * pvpvocs[base].healing  
        elseif creature:isPlayer() then          
            local form = pvpvocs[base].pvp
            if origin == ORIGIN_SPELLS then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED then
                primaryDamage = primaryDamage * form.weapon      
            end      
        elseif creature:isMonster() then
            local form = pvpvocs[base].pve
            if origin == ORIGIN_SPELLS then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED then
                primaryDamage = primaryDamage * form.weapon      
            end              
        end
    elseif creature and creature:isPlayer() then
        local base = creature:getVocation():getId()
   
        if primaryType == COMBAT_HEALING then      
            primaryDamage = primaryDamage * pvpvocs[base].healing
        elseif attacker:isPlayer() then          
            local form = pvpvocs[base].pvp
            if origin == ORIGIN_SPELLS then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED then
                primaryDamage = primaryDamage * form.weapon      
            end              
        elseif attacker:isMonster() then
            local form = pvpvocs[base].pve
            if origin == ORIGIN_SPELLS then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED then
                primaryDamage = primaryDamage * form.weapon      
            end                      
        end  
    end
   
return primaryType, primaryDamage, origin
end

I already registered it in events like this :
Lua:
function Creature:onTargetCombat(target)
    if hasEventCallback(EVENT_CALLBACK_ONTARGETCOMBAT) then
        return EventCallback(EVENT_CALLBACK_ONTARGETCOMBAT, self, target)
    else
target:registerEvent("Vocations")
self:registerEvent("Vocations")
        return RETURNVALUE_NOERROR
    end
end

But it's not working and when im using this one it's only changing the melee damage and healing but i have to register it to every monsters.
Spells are not working in both scripts so i don't really know what im doing wrong here xD

Lua:
local pvpvocs = {
    [1] = {
        pvp = {weapon = 40.2, spells = 45.0, defense = 1.0},
        pve = {weapon = 40.2, spells = 45.0, defense = 50.0},
        healing = 50.0
    },
    [2] = {
        pvp = {weapon = 1.2, spells = 1.3, defense = 1.2},
        pve = {weapon = 1.2, spells = 1.3, defense = 1.2},
        healing = 1.8
    },
    [3] = {
        pvp = {weapon = 1.8, spells = 1.2, defense = 1.2},
        pve = {weapon = 1.8, spells = 1.2, defense = 1.2},
        healing = 1.4
    },
    [4] = {
        pvp = {weapon = 1.2, spells = 1.0, defense = 1.6},
        pve = {weapon = 0.8, spells = 1.0, defense = 1.6},
        healing = 1.1
    },
    [5] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [6] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [7] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [8] = {
        pvp = {weapon = 1.3, spells = 1.1, defense = 1.7},
        pve = {weapon = 0.7, spells = 1.1, defense = 1.7},
        healing = 1.1
    },
}
 
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)    
   
    if attacker and attacker:isPlayer() then  
        local base = attacker:getVocation():getId()
   
        if primaryType == COMBAT_HEALING then      
            primaryDamage = primaryDamage * pvpvocs[base].healing  
        elseif creature:isPlayer() then          
            local form = pvpvocs[base].pvp
            if origin == ORIGIN_SPELLS then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED then
                primaryDamage = primaryDamage * form.weapon      
            end      
        elseif creature:isMonster() then
            local form = pvpvocs[base].pve
            if origin == ORIGIN_SPELLS then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED then
                primaryDamage = primaryDamage * form.weapon      
            end              
        end
    elseif creature and creature:isPlayer() then
        local base = creature:getVocation():getId()
   
        if primaryType == COMBAT_HEALING then      
            primaryDamage = primaryDamage * pvpvocs[base].healing
        elseif attacker:isPlayer() then          
            local form = pvpvocs[base].pvp
            if origin == ORIGIN_SPELLS then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED then
                primaryDamage = primaryDamage * form.weapon      
            end              
        elseif attacker:isMonster() then
            local form = pvpvocs[base].pve
            if origin == ORIGIN_SPELLS then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED then
                primaryDamage = primaryDamage * form.weapon      
            end                      
        end  
    end
   
return primaryDamage, primaryType, secondaryDamage, secondaryType, origin  
end
 
Last edited:
Managed to get it working to all monsters but still without spell damage :/
Should it be it added on areacombat like this?

Lua:
function Creature:onAreaCombat(tile, isAggressive)
    if hasEventCallback(EVENT_CALLBACK_ONAREACOMBAT) then
        return EventCallback(EVENT_CALLBACK_ONAREACOMBAT, self, tile, isAggressive)
    else
self:registerEvent("Vocations")
        return RETURNVALUE_NOERROR
    end
end

I tried to register it as target:registerEvent("Vocations") but getting an error
hh4vou4.png
 
Registering onHealthChange globally..

for players use
-> onLogin event

for monsters use
-> onSpawn event
 
I did as @Xikini said but that's not solving this for spells.
I think there is something wrong with the code.
And there is actually 0 errors in console :/

I used this for increasing the damage with items and it worked wel :/

Lua:
-- HealthChange damage increase event

local eventHpChange = CreatureEvent("DamageIncreaseHP")
eventHpChange:type("healthChange")

function eventHpChange.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker and attacker:isPlayer() then -- only buff players
        if primaryType and secondaryType ~= COMBAT_HEALING then -- does not equal healing "damage"
            local damage = attacker:getStorageValue(STORAGE) -- storage value
            if damage >= 1 then
                local newPrimaryDmg = math.ceil(primaryDamage + (primaryDamage * (damage / 100)))
                local newSecondaryDmg = math.ceil(secondaryDamage + (secondaryDamage * (damage / 100)))
                return newPrimaryDmg, primaryType, newSecondaryDmg, secondaryType, origin
            end
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end

eventHpChange:register()

-- ManaChange damage increase event
local eventMpChange = CreatureEvent("DamageIncreaseMP")
eventMpChange:type("manaChange")

function eventMpChange.onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker and attacker:isPlayer() then -- only buff players
        if primaryType and secondaryType ~= COMBAT_HEALING then -- does not equal healing "damage"
            local damage = attacker:getStorageValue(STORAGE) -- storage value
            if damage >= 1 then
                local newPrimaryDmg = math.ceil(primaryDamage + (primaryDamage * (damage / 100)))
                local newSecondaryDmg = math.ceil(secondaryDamage + (secondaryDamage * (damage / 100)))
                return newPrimaryDmg, primaryType, newSecondaryDmg, secondaryType, origin
            end
        end
    end
return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end

eventMpChange:register()
Post automatically merged:

Well when i change COMBAT_HEALING to any combat damage it's working so it's like not taking the value from pvpvocs
it something wrong with this guys?

Lua:
            if origin == ORIGIN_SPELLS then
                primaryDamage = primaryDamage * form.spells

It's possible to make it like this

Lua:
        if primaryType == COMBAT_PHYSICALDAMAGE then       
            primaryDamage = primaryDamage * pvpvocs[base].spells

Lua:
local pvpvocs = {
    [1] = {
        pvp = {weapon = 40.0, spells = 45.0, defense = 1.0},
        pve = {weapon = 40.0, spells = 45.0, defense = 1.0},
        spells = 45.0,
        healing = 23.0
    },

But that works equally for players and monsters and i have to register every type of damage :/
Post automatically merged:

Solved
 
Last edited:
I just discovered a problem with this script when i use it my fire fields etc don't do dmg
when i step in i got error -
TVsacaY.png

With this one :

Lua:
local pvpvocs = {
    [0] = {
        pvp = {weapon = 45.0, spells = 45.3, defense = 45.0},
        pve = {weapon = 45.0, spells = 45.3, defense = 45.0},
        healing = 1.2
    },
    [1] = {
        pvp = {weapon = 0.2, spells = 5.0, defense = 1.0},
        pve = {weapon = 0.2, spells = 4.0, defense = 1.0},
        healing = 1.2
    },
    [2] = {
        pvp = {weapon = 0.2, spells = 4.4, defense = 1.0},
        pve = {weapon = 0.2, spells = 3.8, defense = 1.0},
        healing = 1.6
    },
    [3] = {
        pvp = {weapon = 1.5, spells = 2.3, defense = 1.0},
        pve = {weapon = 1.5, spells = 2.0, defense = 1.0},
        healing = 1.1
    },
    [4] = {
        pvp = {weapon = 1.9, spells = 1.8, defense = 1.0},
        pve = {weapon = 2.0, spells = 1.4, defense = 1.0},
        healing = 1.3
    },
    [5] = {
        pvp = {weapon = 0.4, spells = 5.2, defense = 1.0},
        pve = {weapon = 0.4, spells = 4.2, defense = 1.0},
        healing = 1.5
    },
    [6] = {
        pvp = {weapon = 0.6, spells = 4.6, defense = 1.0},
        pve = {weapon = 0.8, spells = 4.0, defense = 1.0},
        healing = 1.8
    },
    [7] = {
        pvp = {weapon = 1.7, spells = 2.5, defense = 1.0},
        pve = {weapon = 1.8, spells = 2.2, defense = 1.0},
        healing = 1.3
    },
    [8] = {
        pvp = {weapon = 2.4, spells = 1.9, defense = 1.0},
        pve = {weapon = 2.4, spells = 1.5, defense = 1.0},
        healing = 1.2
    },   
}
 
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)     
    
    if attacker and attacker:isPlayer() then   
        local base = attacker:getVocation():getId()
    
        if primaryType == COMBAT_HEALING then       
            primaryDamage = primaryDamage * pvpvocs[base].healing   
        elseif creature:isPlayer() then           
            local form = pvpvocs[base].pvp
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon           
            end       
        elseif creature:isMonster() then
            local form = pvpvocs[base].pve
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon   
            end               
        end
    elseif creature and creature:isPlayer() then
        local base = creature:getVocation():getId()
    
        if primaryType == COMBAT_HEALING then       
            primaryDamage = primaryDamage * pvpvocs[base].healing
        elseif attacker:isPlayer() then           
            local form = pvpvocs[base].pvp
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_CONDITION then
                primaryDamage = primaryDamage * form.defense
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon           
            end               
        elseif attacker:isMonster() then
            local form = pvpvocs[base].pve
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon           
            end                       
        end   
    end
    
return primaryDamage, primaryType, secondaryDamage, secondaryType, origin   
end

If someone can help i appreciate that :D
 
I just discovered a problem with this script when i use it my fire fields etc don't do dmg
when i step in i got error -
TVsacaY.png

With this one :

Lua:
local pvpvocs = {
    [0] = {
        pvp = {weapon = 45.0, spells = 45.3, defense = 45.0},
        pve = {weapon = 45.0, spells = 45.3, defense = 45.0},
        healing = 1.2
    },
    [1] = {
        pvp = {weapon = 0.2, spells = 5.0, defense = 1.0},
        pve = {weapon = 0.2, spells = 4.0, defense = 1.0},
        healing = 1.2
    },
    [2] = {
        pvp = {weapon = 0.2, spells = 4.4, defense = 1.0},
        pve = {weapon = 0.2, spells = 3.8, defense = 1.0},
        healing = 1.6
    },
    [3] = {
        pvp = {weapon = 1.5, spells = 2.3, defense = 1.0},
        pve = {weapon = 1.5, spells = 2.0, defense = 1.0},
        healing = 1.1
    },
    [4] = {
        pvp = {weapon = 1.9, spells = 1.8, defense = 1.0},
        pve = {weapon = 2.0, spells = 1.4, defense = 1.0},
        healing = 1.3
    },
    [5] = {
        pvp = {weapon = 0.4, spells = 5.2, defense = 1.0},
        pve = {weapon = 0.4, spells = 4.2, defense = 1.0},
        healing = 1.5
    },
    [6] = {
        pvp = {weapon = 0.6, spells = 4.6, defense = 1.0},
        pve = {weapon = 0.8, spells = 4.0, defense = 1.0},
        healing = 1.8
    },
    [7] = {
        pvp = {weapon = 1.7, spells = 2.5, defense = 1.0},
        pve = {weapon = 1.8, spells = 2.2, defense = 1.0},
        healing = 1.3
    },
    [8] = {
        pvp = {weapon = 2.4, spells = 1.9, defense = 1.0},
        pve = {weapon = 2.4, spells = 1.5, defense = 1.0},
        healing = 1.2
    },  
}
 
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)    
   
    if attacker and attacker:isPlayer() then  
        local base = attacker:getVocation():getId()
   
        if primaryType == COMBAT_HEALING then      
            primaryDamage = primaryDamage * pvpvocs[base].healing  
        elseif creature:isPlayer() then          
            local form = pvpvocs[base].pvp
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon          
            end      
        elseif creature:isMonster() then
            local form = pvpvocs[base].pve
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon  
            end              
        end
    elseif creature and creature:isPlayer() then
        local base = creature:getVocation():getId()
   
        if primaryType == COMBAT_HEALING then      
            primaryDamage = primaryDamage * pvpvocs[base].healing
        elseif attacker:isPlayer() then          
            local form = pvpvocs[base].pvp
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_CONDITION then
                primaryDamage = primaryDamage * form.defense
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon          
            end              
        elseif attacker:isMonster() then
            local form = pvpvocs[base].pve
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon          
            end                      
        end  
    end
   
return primaryDamage, primaryType, secondaryDamage, secondaryType, origin  
end

If someone can help i appreciate that :D
wher did you take these scripts fom' i want to balance vocation in my server im using the same distribution as you, maybe i can implement it
 
I bought it from @Animera some time ago :D
Here you have the full code with working fire fields :

Lua:
local pvpvocs = {
    [0] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [1] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [2] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [3] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [4] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [5] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [6] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [7] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [8] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    }, 
}
 
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)   
  
    if attacker and attacker:isPlayer() then 
        local base = attacker:getVocation():getId()
  
        if primaryType == COMBAT_HEALING then     
            primaryDamage = primaryDamage * pvpvocs[base].healing 
        elseif creature:isPlayer() then         
            local form = pvpvocs[base].pvp
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon         
            end     
        elseif creature:isMonster() then
            local form = pvpvocs[base].pve
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon 
            end             
        end
    elseif creature and creature:isPlayer() then
        local base = creature:getVocation():getId()
  
        if primaryType == COMBAT_HEALING then     
            primaryDamage = primaryDamage * pvpvocs[base].healing
        elseif attacker and attacker:isPlayer() then             
            local form = pvpvocs[base].pvp
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_CONDITION then
                primaryDamage = primaryDamage * form.defense
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon         
            end             
        elseif attacker and attacker:isMonster() then
            local form = pvpvocs[base].pve
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon         
            end                     
        end 
    end
  
return primaryDamage, primaryType, secondaryDamage, secondaryType, origin 
end
If you wanna use that you have to register it on login.lua
Lua:
    player:registerEvent("Vocations")

Register it for target
Lua:
function Creature:onTargetCombat(target)
    if hasEventCallback(EVENT_CALLBACK_ONTARGETCOMBAT) then
        return EventCallback(EVENT_CALLBACK_ONTARGETCOMBAT, self, target)
    else
target:registerEvent("Vocations")
        return RETURNVALUE_NOERROR
    end
end

Lua:
function Monster:onSpawn(position, startup, artificial)
    if hasEventCallback(EVENT_CALLBACK_ONSPAWN) then
        return EventCallback(EVENT_CALLBACK_ONSPAWN, self, position, startup, artificial)
    else
self:registerEvent("Vocations")
        return true
    end
end

And make sure that in events.xml you have
Lua:
    <event class="Monster" method="onSpawn" enabled="1" />
Lua:
    <event class="Creature" method="onTargetCombat" enabled="1" />
 
I bought it from @Animera some time ago :D
Here you have the full code with working fire fields :

Lua:
local pvpvocs = {
    [0] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [1] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [2] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [3] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [4] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [5] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [6] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [7] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
    [8] = {
        pvp = {weapon = 1.0, spells = 1.0, defense = 1.0},
        pve = {weapon = 1.0, spells = 1.0, defense = 1.0},
        healing = 1.0
    },
}
 
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)  
 
    if attacker and attacker:isPlayer() then
        local base = attacker:getVocation():getId()
 
        if primaryType == COMBAT_HEALING then    
            primaryDamage = primaryDamage * pvpvocs[base].healing
        elseif creature:isPlayer() then        
            local form = pvpvocs[base].pvp
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon        
            end    
        elseif creature:isMonster() then
            local form = pvpvocs[base].pve
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon
            end            
        end
    elseif creature and creature:isPlayer() then
        local base = creature:getVocation():getId()
 
        if primaryType == COMBAT_HEALING then    
            primaryDamage = primaryDamage * pvpvocs[base].healing
        elseif attacker and attacker:isPlayer() then            
            local form = pvpvocs[base].pvp
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_CONDITION then
                primaryDamage = primaryDamage * form.defense
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon        
            end            
        elseif attacker and attacker:isMonster() then
            local form = pvpvocs[base].pve
            if origin == ORIGIN_SPELL then
                primaryDamage = primaryDamage * form.spells
            elseif origin == ORIGIN_MELEE or origin == ORIGIN_CONDITION or origin == ORIGIN_RANGED or origin == ORIGIN_WAND then
                primaryDamage = primaryDamage * form.weapon        
            end                    
        end
    end
 
return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end
If you wanna use that you have to register it on login.lua
Lua:
    player:registerEvent("Vocations")

Register it for target
Lua:
function Creature:onTargetCombat(target)
    if hasEventCallback(EVENT_CALLBACK_ONTARGETCOMBAT) then
        return EventCallback(EVENT_CALLBACK_ONTARGETCOMBAT, self, target)
    else
target:registerEvent("Vocations")
        return RETURNVALUE_NOERROR
    end
end

Lua:
function Monster:onSpawn(position, startup, artificial)
    if hasEventCallback(EVENT_CALLBACK_ONSPAWN) then
        return EventCallback(EVENT_CALLBACK_ONSPAWN, self, position, startup, artificial)
    else
self:registerEvent("Vocations")
        return true
    end
end

And make sure that in events.xml you have
Lua:
    <event class="Monster" method="onSpawn" enabled="1" />
Lua:
    <event class="Creature" method="onTargetCombat" enabled="1" />
Thank you
 
Back
Top