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

Is it possible?

himer23

New Member
Joined
Jan 6, 2016
Messages
1
Reaction score
0
Is it possible to write a spell that would grant an invincibility for a short period of time?
 
The one for my other system isn't quite what you need so I wrote up a new one. Should work. It will last 60 seconds, configurable by changing 60000 in the spell script to another number.

creaturescripts/creaturescripts.xml
Code:
<event type="healthchange" name="Invincible" script="invincible.lua"/>
<event type="manachange" name="Invincible" script="invincible.lua"/>
creaturescripts/scripts/invincible.lua
Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if primaryType == COMBAT_HEALING then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, 300) then
        primaryDamage = 0
        secondaryDamage = 0
    end
    if primaryDamage == 0 and secondaryDamage == 0 and creature:isPlayer() and not creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, 20) then
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

function onManaChange(creature, attacker, manaChange, origin)
    if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, 300) then
        manaChange = 0
    end
    return manaChange
end

creaturescripts/scripts/login.lua
Code:
player:registerEvent("Invincible")

spells/scripts/invincible.lua
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

local condition = Condition(CONDITION_ATTRIBUTES)
condition:setParameter(CONDITION_PARAM_TICKS, 60000)
condition:setParameter(CONDITION_PARAM_SUBID, 300)
combat:setCondition(condition)

function onCastSpell(creature, var)
    return combat:execute(creature, var)
end
 
Back
Top