Hello,
I am using this script (creature script) for critical hit on monsters and players.
but i found something weird.
when i hit a monster with
a weapon its basic dmg is 100
a monster with
a critical dmg amount is 100% extra
the damage to this monster should be 50 if no critical and 100 if critical.
but i found all damages to this monster = 50 even if it is critical.
i don't know what is the problem.
any help?
TFS 0.4
Monster file
Script file
I am using this script (creature script) for critical hit on monsters and players.
but i found something weird.
when i hit a monster with
a weapon its basic dmg is 100
a monster with
Code:
<element holyPercent="50"/>
the damage to this monster should be 50 if no critical and 100 if critical.
but i found all damages to this monster = 50 even if it is critical.
i don't know what is the problem.
any help?
TFS 0.4
Monster file
XML:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Training Monk" species="human" tp="1" nameDescription="a training monk" race="blood" experience="200" speed="0" manacost="600">
<health now="1000000" max="1000000"/>
<look type="57" head="20" body="30" legs="40" feet="50" corpse="3128"/>
<targetchange interval="60000" chance="0"/>
<strategy attack="100" defense="0"/>
<flags>
<flag summonable="0"/>
<flag attackable="1"/>
<flag hostile="1"/>
<flag illusionable="1"/>
<flag convinceable="1"/>
<flag pushable="0"/>
<flag canpushitems="1"/>
<flag staticattack="50"/>
<flag lightlevel="0"/>
<flag lightcolor="0"/>
<flag targetdistance="1"/>
<flag runonhealth="0"/>
</flags>
<elements>
<element holyPercent="50"/>
</elements>
<script>
<event name="Critical"/>
</script>
<attacks>
<attack name="Heal Friend" interval="6000" chance="60" min="600" max="1000"/>
<attack name="melee" interval="2000" min="-0" max="-1"/>
</attacks>
<defenses armor="30" defense="31">
<defense name="healing" interval="1500" chance="100" min="1000000" max="1000000">
<attribute key="areaEffect" value="blueshimmer"/>
</defense>
</defenses>
<immunities>
<immunity physical="0"/>
<immunity energy="0"/>
<immunity fire="0"/>
<immunity poison="0"/>
<immunity lifedrain="0"/>
<immunity paralyze="0"/>
<immunity outfit="0"/>
<immunity drunk="0"/>
<immunity invisible="1"/>
</immunities>
<voices interval="2000" chance="5">
<voice sentence="i'm healing you"/>
<voice sentence="Are you so weak?"/>
<voice sentence="i dont want to kill you you are to easy"/>
</voices>
<loot>
</loot>
</monster>
Script file
Lua:
local creature_table = {}
local lvlcrit = 16221 -- storage (the same like givecritical.lua script)
local chance = 10 -- critical chance = 10%
function onStatsChange(cid, attacker, type, combat, value)
if not isPlayer(attacker) then
return true
elseif cid == attacker then
return true
end
if not creature_table[cid] then
creature_table[cid] = false
elseif creature_table[cid] == true then
creature_table[cid] = false
return true
end
if getPlayerStorageValue(attacker, lvlcrit) < 1 then
return true
end
if (math.random(0, 100) <= chance) then
if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS then
creature_table[cid] = true
local multiplier = (getPlayerStorageValue(attacker, lvlcrit) / 100) + 1
local new_value = math.ceil(value * multiplier)
local new_value2 = math.ceil(2 * value * multiplier)
--doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_ORANGE, "Critical Hit: "..math.floor((new_value/1)))
if isPlayer(cid) then
doTargetCombatHealth(attacker, cid, combat, -new_value2, -new_value2, 255)
end
if isMonster(cid) then
doTargetCombatHealth(attacker, cid, combat, -new_value, -new_value, 255)
end
doSendAnimatedText(getCreaturePos(attacker), "CRITICAL!", 138)
return false
end
end
return true
end