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

Solved Lifesteal attack against creatures

Baneczek

うさちゃん
Joined
Nov 13, 2013
Messages
70
Reaction score
4
Location
Pila, Poland
Hi guys. I need some help, again with creaturescript.
I want to make knight healing for a percentage of damage dealt (something like life steal) but also against creatures.

I tested those two
http://otland.net/threads/creaturescript-vampiric-touch-lifesteal-atk.116496/
and
http://otland.net/threads/life-steal-life-drain-for-x-seconds.117595/


Those work perfectly only against players and i want it to work against creatures too.
f.e. if i hit MONSTER for 100 and it heals me for 10.

Tried remaking it, adding
if isMonster(target)... but it doesn't work.

Would be great if someone could help me.

EDIT: It's TFS 0.3.6
 
If it should look like this
Code:
local drainPercent = 30

function onStatsChange(cid, attacker, type, combat, value)
if (type == STATSCHANGE_MANALOSS or type == STATSCHANGE_HEALTHLOSS) then
doCreatureAddHealth(attacker, value * drainPercent / 100)
end
return true
end
This also doesn't work.

EDIT: Or should i add if isMonster(target)?
 
If attacker is the player, then cid should be the monster, for cid to be the monster, it has to be registered in the monster file (or in a lua file where it's registered to a specific monster).
Also readd add the storage, else people always have lifesteal.
 
I want knight to have a 10% of his damage lifesteal every attack he deals.

The script looks like this now, but it doesn't work against monsters/creatures, but only against players.

Code:
function onStatsChange(cid, attacker, type, combat, value)

local drainPercent = 10
local target = getCreatureTarget(cid)

if isMonster(target) then
if (type == STATSCHANGE_MANALOSS or type == STATSCHANGE_HEALTHLOSS) then
doCreatureAddHealth(attacker, value * drainPercent / 100)
end
end
return true
end
[code]
 
try this:

Code:
function onStatsChange(cid, attacker, type, combat, value)
        local drainPercent = 10
       
        if (type == STATSCHANGE_HEALTHLOSS) then
            doCreatureAddHealth(attacker, value * drainPercent / 100)
        end
       
    return true
end
 
When cid is a monster, it has to be registered to that monster. What you could do is add a script with type combat, check for the storage and then register the statschange creaturescript to the target.
 
try this:

Code:
function onStatsChange(cid, attacker, type, combat, value)
        local drainPercent = 10
 
        if (type == STATSCHANGE_HEALTHLOSS) then
            doCreatureAddHealth(attacker, value * drainPercent / 100)
        end
 
    return true
end
It doesn't work too,

When cid is a monster, it has to be registered to that monster. What you could do is add a script with type combat, check for the storage and then register the statschange creaturescript to the target.

So if i want to have the lifesteal on every monster on the server, i have to register it to every monster too?
EDIT: Sorry Limos, but i didn't get second part of what you said. Could you please help me to write the script or just give a little tip ?

EDIT3: Registered an event that you said above and it works perfectly. Thank you Limos.
 
Last edited:
Back
Top