beliar34
Member
- Joined
- Feb 28, 2012
- Messages
- 307
- Solutions
- 7
- Reaction score
- 11
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Shield" author="C" enabled="yes">
<config name="shield_setup">
<![CDATA[
storage = 212123
vocations = {7,8,9,10,11,12,72,82,83,84,85,86,87,102,103,104,105,106,107,18,19,20,21,22,23,78,28,29,30,31,32,33,76,34,35,36,37,38,39,79,52,53,54,55,56,57,58,59}
spentMana = 1
time = 10 -- in minutes
condition = createConditionObject(CONDITION_INFIGHT)
setConditionParam(condition, CONDITION_PARAM_TICKS, time*60*1000)
function doFinish(cid)
if isPlayer(cid) and getPlayerStorageValue(cid,storage) > 0 then
return doPlayerSetStorageValue(cid, storage, 0)
end
end
function doWaste(cid)
if isPlayer(cid) then
if getPlayerStorageValue(cid,storage) > 0 then
if getCreatureMana(cid) >= spentMana then
doCreatureAddMana(cid, -spentMana)
doSendMagicEffect(getThingPos(cid), 93)
addEvent(doWaste, 1000, cid)
else
doPlayerSetStorageValue(cid, storage, 0)
doPlayerSendCancel(cid, 'Your shield has worn out.')
end
end
end
end
]]>
</config>
<event type="login" name="shield2" event="script">
<![CDATA[
domodlib('shield_setup')
function onLogin(cid)
registerCreatureEvent(cid, "shield3")
doPlayerSetStorageValue(cid, storage, 0)
return true
end
]]>
</event>
<event type="statschange" name="shield3" event="script">
<![CDATA[
domodlib('shield_setup')
function onStatsChange(cid, attacker, type, combat, value)
if isPlayer(cid) and getPlayerStorageValue(cid, storage) > 0 then
if isInArray(vocations, getPlayerVocation(cid)) and combat ~= COMBAT_HEALING and isCreature(attacker) then
if value >= getCreatureHealth(cid) then
doSendAnimatedText(getThingPos(cid), TEXTCOLOR_DARKORANGE, 'BREAK')
doPlayerSendTextMessage(cid,27,"Your shield was broken.")
setPlayerStorageValue(cid, storage, 0)
return false
else
doPlayerSendTextMessage(cid,27, "Shield : absorbed "..value.." hit points.")
return false
end
end
end
return true
end
]]>
</event>
<instant name="Absorb Shield" words="absorb shield" lvl="5" mana="0" soul="0" exhaustion="500" event="script">
<text>
<![CDATA[
domodlib('shield_setup')
function onCastSpell(cid, var)
if exhaustion.get(cid, 230) then
doPlayerSendCancel(cid, 'Slow down.')
return true
end
exhaustion.set(cid, 230, 55)
if getPlayerStorageValue(cid, storage) > 0 then
doPlayerSendCancel(cid,'Your shield is still active.')
return false
end
doAddCondition(cid, condition)
doPlayerSetStorageValue(cid, storage, 1)
addEvent(doWaste, 1000, cid)
addEvent(doFinish, time*60*1000, cid)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
doPlayerSendCancel(cid,'You have just enabled shield for "..time.." minutes.')
return true
end
]]>
</text>
<vocation id="7;8;9;10;11;12;72;82;83;84;85;86;87;102;103;104;105;106;107;18;19;20;21;22;23;78;28;29;30;31;32;33;76;34;35;36;37;38;39;79;52;53;54;55;56;57;58;59"/>
</instant>
</mod>
This code works in that way : give player barrier and got it till somebody (player or monster) hit him IN ONE HIT by his max health and then barrier is destroyed.
How i want to this code work : i want to add barrier based on max health But barrier is destroyed when player recieve a damage from diffrent sources equal to his max health
Quick sample:
how i want this script to work:
Player 10000 Health turn on barrier
Player X hits him by 2000
Player Z hits him by 5000
Player C hits hym by 2000
Player Z hits him by 1000
Barrier is destroyed
How this script works:
Player 10000 Health turn on barrier
Player X hits him by 2000
Player Z hits him by 5000
Player C hits hym by 2000
Player Z hits him by 1000
Barrier is still there
Player X hits him by 2000
Player Z hits him by 5000
Player C hits hym by 2000
Player Z hits him by 1000
barrier is still there
Player G hits him by 10000 or more
Barrier is destroyed