Guiaki
Member
- Joined
- Jan 3, 2011
- Messages
- 137
- Reaction score
- 8
okay, darkhaos gave me the lets say initial part of the code, I changed it all and okay, i'll show you everthing:
First thing, the cid / attacker manual
Okay, first thing as you can see when a monster attack a player or a player attack a monster cid and attacker are both the same, so if a monster attack a player the action that it will receive wil be the same one as the player attacking a monster, so i needed a function or something that will only do the action if the player are the one attacking, or in other words the monster is the one who is loosing hp.
Second thing, on the code, when its called:
all the things will be only resulting in the monster, if you do like a
You will see that even if the player attacks or the monster attacks, it will be always the monster attack value, never the player one, so this needs to take only the damage done by the player.
third thing: MOST IMPORTANT:
when you do like:
or
it will do the new damage, but since you are doing a new damage, it automaticly enters in the onStatsChange again, and do a new damage with your new damage, like I did 50 damage to a player and I have 5 resets, it will be done 100 damage, and by that damage it will do a new one that will make it go to 200, after that 400, then 800, etc..
so what i mean: if you attack once, and hit 50, you will kill the target because it goes into a infinite loop inside the script.
can someone help me with all these things?
Code:
function onStatsChange(cid, attacker, type, combat, value)
if isPlayer(attacker) then
if type == STATSCHANGE_HEALTHLOSS then
if combat == COMBAT_PHYSICALDAMAGE then
local reset = getReset(attacker)
local value = (value + value*(reset/5))
end
end
end
if isMonster(attacker) and isPlayer(cid) then
if type == STATSCHANGE_HEALTHLOSS then
if combat == COMBAT_PHYSICALDAMAGE then
local reset = getReset(cid)
local value = (value + value*(reset/5))
end
end
end
return true
end
First thing, the cid / attacker manual
Code:
Player1 x Player2 =
Player1 = attacker
Player2 = cid
Player1 x Monster1 =
Player1 = cid
Monster1 = attacker
Monster1 x Player1 =
Player1 = cid
Monster1 = attacker
Okay, first thing as you can see when a monster attack a player or a player attack a monster cid and attacker are both the same, so if a monster attack a player the action that it will receive wil be the same one as the player attacking a monster, so i needed a function or something that will only do the action if the player are the one attacking, or in other words the monster is the one who is loosing hp.
Second thing, on the code, when its called:
Code:
if isMonster(attacker) and isPlayer(cid) then
if type == STATSCHANGE_HEALTHLOSS then
if combat == COMBAT_PHYSICALDAMAGE then
local reset = getReset(cid)
local value = (value + value*(reset/5))
end
end
end
all the things will be only resulting in the monster, if you do like a
Code:
doCreatureSay(cid, "damage initial "..value.." hitpoints")
local value = (value + value*(reset/5))
doCreatureSay(cid, "damage final "..value.." hitpoints")
You will see that even if the player attacks or the monster attacks, it will be always the monster attack value, never the player one, so this needs to take only the damage done by the player.
third thing: MOST IMPORTANT:
when you do like:
Code:
doTargetCombatHealth(attacker, cid, combat, -value, -value, CONST_ME_DRAWBLOOD)
or
Code:
doCreatureAddHealth(cid, -value)
it will do the new damage, but since you are doing a new damage, it automaticly enters in the onStatsChange again, and do a new damage with your new damage, like I did 50 damage to a player and I have 5 resets, it will be done 100 damage, and by that damage it will do a new one that will make it go to 200, after that 400, then 800, etc..
so what i mean: if you attack once, and hit 50, you will kill the target because it goes into a infinite loop inside the script.
can someone help me with all these things?