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

How to redirecting damge

Elgenady

Veteran OT User
Joined
Aug 5, 2011
Messages
1,638
Solutions
35
Reaction score
352
i'm working in spell for knight.
this spell help knight to protection other players for 4 seconds but i want when knight protection players the damge redirecting to knight.

part for protection other player is {done}

I want help in redirecting damge to knight

I'm use 0.4
 
Last edited:
i'm working in spell for knight.
this spell help knight to protection other players for 4 seconds but i want when knight protection players the damge redirecting to knight.

party for protection other player is {done}

I want help in redirecting damge to knight

I'm use 0.4
Can we see the script so we can make the changes?
 
i dunno what have you done but i guess you added a storage to knight

you have to use a creaturescript onStatsChange
Code:
onStatsChange(cid, attacker, type, combat, value)

check if player is on a party
get the damage
iterate through party members and check if someone has that storage
if you find someone remove the damage to him/her
check the damage there and remove it to knight
return false

Code:
local STORAGE = 39421 --storage to check if a player has the protection enabled

function onStatsChange(cid, attacker, type, combat, value)
    if type == STATSCHANGE_HEALTHLOSS then
        if (getPlayerParty(cid)) then
            local members = getPartyMembers(cid)
            for _,player in pairs(members) do
                if (getCreatureStorage(player, STORAGE) > 0) then
                    --remove health to that player
                    return false
                end
            end

        end

    end

    return true
end

not finished, not tested
i suggest you migrate to a recent tfs btw
 
my spell work like this

knight can protect player from damge for 4 sec i want damge redirecting to knight

in my spell: knight can give player storage and this storage protect from damge that all i did in my spell
 
my spell work like this

knight can protect player from damge for 4 sec i want damge redirecting to knight

in my spell: knight can give player storage and this storage protect from damge that all i did in my spell
Why not just produce the script?
You are asking for help but are not providing a script which shows what you've done so far.
 
Why not just produce the script?
You are asking for help but are not providing a script which shows what you've done so far.
its easy script sorry
Code:
local c = {
   storage = 48503,
   time = 5
}

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)

function onCastSpell(cid, var)
     local target, pPos = getCreatureTarget(cid), getCreaturePosition(cid)
     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)
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "From now "..getCreatureName(target).." protected from you for 4 seconds.")
     doCombat(cid, combat, var)
     return true
end
 
its easy script sorry
Code:
local c = {
   storage = 48503,
   time = 5
}

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)

function onCastSpell(cid, var)
     local target, pPos = getCreatureTarget(cid), getCreaturePosition(cid)
     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)
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "From now "..getCreatureName(target).." protected from you for 4 seconds.")
     doCombat(cid, combat, var)
     return true
end
This script does not do anything but cast special effects and set an exhaust to the target.

If you exhaust a creature then they can't cast spells, that is not exactly protecting them from damage.
 
This script does not do anything but cast special effects and set an exhaust to the target.

If you exhaust a creature then they can't cast spells, that is not exactly protecting them from damage.

im use this storage to block damge onStatsChange lol
 
This script does not do anything but cast special effects and set an exhaust to the target.

If you exhaust a creature then they can't cast spells, that is not exactly protecting them from damage.

im use this storage to block damge onStatsChange lol
 
almost everything is possible in .lua, if you cant do it you most likely lack knowledge :)
I disagree, the amount of things that are possible with lua is not even 50% (tfs wise ofc) of what you can do if you know C++, with C++ you can edit both the source and edit OTClient and then the imagination is the limit :)

Back to the topic, yes its possible with lua only.
 
I disagree, the amount of things that are possible with lua is not even 50% (tfs wise ofc) of what you can do if you know C++, with C++ you can edit both the source and edit OTClient and then the imagination is the limit :)

Back to the topic, yes its possible with lua only.


totally agree with you
 
Back
Top