No Damage

Activity

Member
Joined
Apr 7, 2016
Messages
179
Reaction score
21
Hey there,
Is it possible to make a spell that makes the player doesn't receive any damage for some seconds?

I am just wondering if is it possible without source edit, i need it with LUA.

Using tfs 0.4
thanks in advance
 

heba

Veteran OT User
Joined
Aug 5, 2011
Messages
1,346
Reaction score
167
in creaturescripts
Code:
function onStatsChange(cid, attacker, type, combat, value)
   if exhaustion.check(cid, 40902) then
     return false
   end
   return true
end
creaturescript.xml
Code:
<event type="statschange" name="BlockEffect" event="script" value="blockeffectspell.lua"/>
in login.lua add
Code:
registerCreatureEvent(cid, "BlockEffect")
spells
Code:
local c = {
   storage = 40902,
   time = 4
}
local cfg = {
fromPosition = {x = 32346, y = 32347, z = 13}, -- top left cornor of the playground
     toPosition = {x = 32445, y = 32431, z = 13}, -- bottom right cornor of the playground
     }
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)


local function doBlockEffect(cid)
doSendAnimatedText(getPlayerPosition(cid), "Immune!", COLOR_GREY)
     return doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
end

function onCastSpell(cid, var)
if isInRange(getPlayerPosition(cid), cfg.fromPosition, cfg.toPosition) then
     return doPlayerSendCancel(cid, "You can't use this spell in event.")
end
     local target = getTopCreature(variantToPosition(var)).uid
     if not isPlayer(target) then
         doPlayerSendCancel(cid, "Target has to be a player.")
         doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
         return false
     end
     if exhaustion.check(target, c.storage) then
         local n = target == cid and "You are" or getPlayerName(target).." is"
         doPlayerSendCancel(cid, n.." already blocking attacks.")
         doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
         return false
     end
     exhaustion.set(target, c.storage, c.time)
     doSendAnimatedText(getPlayerPosition(cid), "Immune!", COLOR_YELLOW)
     doCombat(cid, combat, var)
     for x = 1, c.time do
         addEvent(doBlockEffect, x * 1000, target)
     end
     return true
end
Code:
    <instant name="protect me"  words="Bonte" lvl="350" mana="200" prem="1" aggressive="0" blocktype="solid" soul="20" event="script" value="blockdamgspell.lua">
        <vocation id="12"/>
        <vocation id="10"/>
        <vocation id="9"/>
        <vocation id="11"/>
         </instant>
 
OP
Activity

Activity

Member
Joined
Apr 7, 2016
Messages
179
Reaction score
21
in creaturescripts
Code:
function onStatsChange(cid, attacker, type, combat, value)
   if exhaustion.check(cid, 40902) then
     return false
   end
   return true
end
creaturescript.xml
Code:
<event type="statschange" name="BlockEffect" event="script" value="blockeffectspell.lua"/>
in login.lua add
Code:
registerCreatureEvent(cid, "BlockEffect")
spells
Code:
local c = {
   storage = 40902,
   time = 4
}
local cfg = {
fromPosition = {x = 32346, y = 32347, z = 13}, -- top left cornor of the playground
     toPosition = {x = 32445, y = 32431, z = 13}, -- bottom right cornor of the playground
     }
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)


local function doBlockEffect(cid)
doSendAnimatedText(getPlayerPosition(cid), "Immune!", COLOR_GREY)
     return doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
end

function onCastSpell(cid, var)
if isInRange(getPlayerPosition(cid), cfg.fromPosition, cfg.toPosition) then
     return doPlayerSendCancel(cid, "You can't use this spell in event.")
end
     local target = getTopCreature(variantToPosition(var)).uid
     if not isPlayer(target) then
         doPlayerSendCancel(cid, "Target has to be a player.")
         doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
         return false
     end
     if exhaustion.check(target, c.storage) then
         local n = target == cid and "You are" or getPlayerName(target).." is"
         doPlayerSendCancel(cid, n.." already blocking attacks.")
         doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
         return false
     end
     exhaustion.set(target, c.storage, c.time)
     doSendAnimatedText(getPlayerPosition(cid), "Immune!", COLOR_YELLOW)
     doCombat(cid, combat, var)
     for x = 1, c.time do
         addEvent(doBlockEffect, x * 1000, target)
     end
     return true
end
Code:
    <instant name="protect me"  words="Bonte" lvl="350" mana="200" prem="1" aggressive="0" blocktype="solid" soul="20" event="script" value="blockdamgspell.lua">
        <vocation id="12"/>
        <vocation id="10"/>
        <vocation id="9"/>
        <vocation id="11"/>
         </instant>
Working perfectly but when i am using it, i can't use spells or potions :< is there a way to make it work with healing?
 

Xikini

I whore myself out for likes
Joined
Nov 17, 2010
Messages
3,925
Reaction score
2,048
Top