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

Elements Resistence:

Derlexy

Intermediate OT User
Joined
Jun 29, 2011
Messages
219
Reaction score
101
Sup guys...
Did someone knows some system/script that makes possible to add an specific element resistence to an vocation?
 
To a vocation? no. but it could be done quite easily. I did make a system for elemental resistance, I could make a slight modification to make it permanent and limited to a vocation.
 
This should be about everything you need.

creaturescripts.xml
Code:
<event type="healthchange" name="vocResist" script="vocResist.lua" />

creaturescripts/scripts/vocResist.lua
Code:
local res = {
    {101, COMBAT_FIREDAMAGE}, {102, COMBAT_EARTHDAMAGE}, {103, COMBAT_ENERGYDAMAGE}, {104, COMBAT_ICEDAMAGE}, {105, COMBAT_HOLYDAMAGE}, {106, COMBAT_DEATHDAMAGE}, {107, COMBAT_PHYSICALDAMAGE}, {108, COMBAT_PHYSICALDAMAGE},
}

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if creature:isPlayer() then
        if primaryType == COMBAT_HEALING then
            return primaryDamage, primaryType, secondaryDamage, secondaryType
        end
        for i = 1, 8 do
            if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, res[i][1]) then
                if primaryType == res[i][2] or i == 8 then
                    primaryDamage = (primaryDamage - (primaryDamage * (creature:getStorageValue(5) / 100)))
                end
                if secondaryType == res[i][2] or i == 8 then
                    secondaryDamage = (secondaryDamage - (secondaryDamage * (creature:getStorageValue(5) / 100)))
                end
            end
        end
    if primaryDamage == 0 and secondaryDamage == 0 and creature:isPlayer() then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

creaturescripts/scripts/login.lua
at the very top above
Code:
function onLogin(player)
put
Code:
--[[
config:
101 = fire
102 = earth
103 = energy
104 = ice
105 = holy
106 = death
107 = physical
108 = all
]]--
local vocResists = {
    [1] = {101, 5}, --sorcerer, resist fire, 5%
    [2] = {102, 5}, --druid, resist earth, 5%
    [3] = {105, 10}, --paladin, resist holy, 10%
    [4] = {107, 6}, --knight, resist physical, 6%
}
at the bottom with other registers
Code:
player:registerEvent("vocResist")

somewhere else in login.lua, add this:
Code:
--VocResist
    local voc = player:getVocation()
    local v = vocResists[voc][2]
    local r = vocResists[voc][1]
    local resist = Condition(CONDITION_ATTRIBUTES)
    resist:setParameter(CONDITION_PARAM_SUBID, r)
    resist:setParameter(CONDITION_PARAM_TICKS, -1)
    player:addCondition(resist)
    player:setStorageValue(5, v)
 
Dude:
f4062c87adfeda85d49988c4d884bb26.png
 
Back
Top