Advertisement
LuckOake

Vampire System

Nov 14th, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.28 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <mod name="Vampire System" version="1.0" author="LuckOake" contact="none" enabled="yes">
  3. ------------------------------------------------------------------------------------
  4. <config name="vamp"><![CDATA[
  5. vampwait = 13277
  6. vampstor = 13278
  7. vamplevel = 13279
  8. vamptime = 13280
  9. exha = 10 -- Segundos de exhaustion até poder morder alguém novamente
  10. chance = 10 -- Porcentagem de chance de alguém virar vampiro ao ser mordido
  11. hp = 100 -- Quanto de HP a criatura perderá ao ser mordida
  12. vamphours = 24 -- De quantas em quantas horas a criatura evoluirá de nível de vampirismo caso não se alimente
  13. vampmax = 4 -- Level máximo de vampirismo e level necessário para se transformar num Vampire Lord
  14. vamplordout = 287 -- Outfit do Vampire Lord
  15. weak = 90 -- Porcentagem extra de dano de holy que um vampiro receberá
  16. strenght = 50 -- Porcentagem de resistência do elemento death que um vampiro possui
  17.  
  18. function isSummon(sid)
  19.     for i, pid in ipairs(getPlayersOnline()) do
  20.         for c, cid in pairs(getCreatureSummons(pid)) do
  21.             if (cid == sid) then
  22.                 return true
  23.             end
  24.         end
  25.     end
  26.     return false
  27. end
  28.  
  29. function turnIntoVampire(cid)
  30.     return setPlayerStorageValue(cid, vampstor, 1) and setVampireLevel(cid, 1)
  31. end
  32.  
  33. function turnIntoVampireLord(cid)
  34.     setPlayerStorageValue(cid, vampstor, 2)
  35.     doSetCreatureOutfit(cid, {lookType = vamplordout}, -1)
  36. end
  37.  
  38. function cureVampirism(cid)
  39.     if hasCondition(cid, CONDITION_OUTFIT) then
  40.         doRemoveCondition(cid, CONDITION_OUTFIT)
  41.     end
  42.     return setPlayerStorageValue(cid, vampstor, -1) and setVampireLevel(cid, 0)
  43. end
  44.  
  45. function isVampire(cid)
  46.     return getPlayerStorageValue(cid, vampstor) == 1 and true or false
  47. end
  48.  
  49. function isVampireLord(cid)
  50.     return getPlayerStorageValue(cid, vampstor) == 2 and true or false
  51. end
  52.  
  53. function setVampireLevel(cid, level)
  54.     return setPlayerStorageValue(cid, vamplevel, level)
  55. end
  56.  
  57. function getVampireLevel(cid)
  58.     return getPlayerStorageValue(cid, vamplevel)
  59. end
  60. ]]></config>
  61. ------------------------------------------------------------------------------------
  62. <event type="look" name="VampLook" event="script"><![CDATA[
  63. function onLook(cid, thing, position, lookDistance)
  64. domodlib('vamp')
  65.     if not isCreature(thing.uid) then return true
  66.     elseif isPlayer(thing.uid) and thing.uid ~= cid and isVampire(thing.uid) or isVampireLord(thing.uid) then
  67.         doPlayerSetSpecialDescription(thing.uid, ". Vampire Level "..getVampireLevel(thing.uid).."") return true
  68.     elseif thing.uid == cid and isVampire(cid) or isVampireLord(thing.uid) then
  69.         doPlayerSetSpecialDescription(cid, ". Vampire Level "..getVampireLevel(cid).."") return true
  70.     end
  71. return true
  72. end
  73. ]]></event>
  74. ------------------------------------------------------------------------------------
  75. <event type="login" name="VampRegister" event="script"><![CDATA[
  76. function onLogin(cid)
  77. domodlib('vamp')
  78.         registerCreatureEvent(cid, "VampLook")
  79.         registerCreatureEvent(cid, "VampThink")
  80.         registerCreatureEvent(cid, "VampDmg")
  81.     if isVampireLord(cid) then
  82.         doSetCreatureOutfit(cid, {lookType = vamplordout}, -1)
  83.     end
  84. return true
  85. end
  86. ]]></event>
  87. ------------------------------------------------------------------------------------
  88. <event type="combat" name="VampAttack" event="script"><![CDATA[
  89. function onCombat(cid, target)
  90. domodlib('vamp')
  91.     if isPlayer(target) and not isVampire(target) and not isVampireLord(target) and math.random(1, 100) <= chance then
  92.         turnIntoVampire(target)
  93.         doPlayerSendTextMessage(target, MESSAGE_STATUS_CONSOLE_ORANGE, "You contracted vampirism.")
  94.         exhaustion.set(target, vamptime, vamphours*3600)
  95.         doCreatureAddHealth(target, -hp)
  96.         doCreatureAddHealth(cid, hp)
  97.         doSendMagicEffect(getCreaturePos(target), 13)
  98.         doSendMagicEffect(getCreaturePos(cid), 2)
  99.     end
  100. return true
  101. end
  102. ]]></event>
  103. ------------------------------------------------------------------------------------
  104. <talkaction words="bite" event="buffer"><![CDATA[
  105. domodlib('vamp')
  106.     local r = math.random(1, 100)
  107.     local target = getCreatureTarget(cid)
  108.     if not isVampire(cid) and not isVampireLord(cid) then
  109.         doPlayerSendCancel(cid, "You are not a vampire.") return true
  110.     elseif getCreatureTarget(cid) < 1 then
  111.         doPlayerSendCancel(cid, "You must have a target.") return true
  112.     elseif exhaustion.check(cid, vampwait) then
  113.         doPlayerSendCancel(cid, "Wait "..exhaustion.get(cid, vampwait).." seconds to bite someone again.") return true
  114.     elseif getDistanceBetween(getCreaturePos(cid), getCreaturePos(target)) > 1 then
  115.         doPlayerSendCancel(cid, "Get close to your target.") return true
  116.     elseif isSummon(target) then
  117.         doPlayerSendCancel(cid, "Sorry, but you can't bite a summon.") return true
  118.     elseif isVampire(target) or isVampireLord(target) then
  119.         doPlayerSendCancel(cid, "Sorry, but this creature is already a vampire.") return true
  120.     end
  121.    
  122.     if isPlayer(target) and r <= chance then
  123.         turnIntoVampire(target)
  124.         doPlayerSendTextMessage(target, MESSAGE_STATUS_CONSOLE_ORANGE, ""..getCreatureName(cid).." turned you into a vampire.")
  125.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You turned "..getCreatureName(target).." into a vampire.")
  126.         exhaustion.set(target, vamptime, vamphours*3600)
  127.     elseif isMonster(target) and r <= chance and (getMonsterInfo(getCreatureName(target)).convinceable) then
  128.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You turned "..getCreatureName(target).." into a vampire and now it's your thrall.")
  129.         doConvinceCreature(cid, target)
  130.     end
  131.         doSendAnimatedText(getCreaturePos(target), "-"..hp, TEXTCOLOR_RED)
  132.         doCreatureAddHealth(target, -hp)
  133.         doCreatureAddHealth(cid, hp)
  134.     if not isVampireLord(cid) then
  135.         setVampireLevel(cid, 1)
  136.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your vampirism level regressed to 1.")
  137.         exhaustion.set(cid, vamptime, vamphours*3600)
  138.     end
  139.         doSendMagicEffect(getCreaturePos(target), 13)
  140.         doSendMagicEffect(getCreaturePos(cid), 2)
  141.         exhaustion.set(cid, vampwait, exha)
  142. return true
  143. ]]></talkaction>
  144. ------------------------------------------------------------------------------------
  145. <event type="think" name="VampThink" event="script"><![CDATA[
  146. function onThink(cid)
  147. domodlib('vamp')
  148.     if isVampire(cid) and not exhaustion.check(cid, vamptime) and getVampireLevel(cid) < 4 then
  149.         exhaustion.set(cid, vamptime, vamphours*3600)
  150.         setVampireLevel(cid, getVampireLevel(cid)+1)
  151.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your vampirism evolved to level "..getVampireLevel(cid).." because you didn't feed.")
  152.     end
  153. return true
  154. end
  155. ]]></event>
  156. ------------------------------------------------------------------------------------
  157. <talkaction words="vampire lord" filter="word-spaced" event="buffer"><![CDATA[
  158. domodlib('vamp')
  159.     if not isVampire(cid) then
  160.         doPlayerSendCancel(cid, "You are not a vampire.") return true
  161.     elseif getVampireLevel(cid) < vampmax then
  162.         doPlayerSendCancel(cid, "You must be a vampire level "..vampmax.." to transform into a Vampire Lord.") return true
  163.     elseif isVampireLord(cid) then
  164.         doPlayerSendCancel(cid, "You are already a Vampire Lord.") return true
  165.     end
  166.    
  167.         doSendMagicEffect(getCreaturePos(cid), 40)
  168.         turnIntoVampireLord(cid)
  169.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You are now a Vampire Lord!")
  170. return true
  171. ]]></talkaction>
  172. ------------------------------------------------------------------------------------
  173. <action itemid="6311" event="script"><![CDATA[
  174. domodlib('vamp')
  175.     if itemEx.uid ~= cid then
  176.         doPlayerSendCancel(cid, "You may only use this potion on yourself.") return true
  177.     elseif not isVampire(cid) and not isVampireLord(cid) then
  178.         doPlayerSendCancel(cid, "You aren't a vampire.") return true
  179.     end
  180.        
  181.         doSendMagicEffect(getCreaturePos(cid), 12)
  182.         cureVampirism(cid)
  183.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your vampirism was cured.")
  184.         doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER)
  185.         doRemoveItem(item.uid, 1)
  186. return true
  187. ]]></action>
  188. ------------------------------------------------------------------------------------
  189. <event type="statschange" name="VampDmg" event="script"><![CDATA[      
  190. function onStatsChange(cid, attacker, type, combat, value)
  191. domodlib('vamp')
  192.     ndmg = math.ceil(value*(weak/100)+(getVampireLevel(cid)*20))
  193.     pdmg = math.ceil(value*(strenght/100)+(getVampireLevel(cid)*20))
  194.     if type == STATSCHANGE_HEALTHLOSS and isVampire(cid) or isVampireLord(cid) then
  195.         if combat == COMBAT_HOLYDAMAGE then
  196.             doCreatureAddHealth(cid, -ndmg)
  197.             doSendAnimatedText(getCreaturePos(cid), "-"..ndmg, TEXTCOLOR_YELLOW)
  198.         elseif combat == COMBAT_DEATHDAMAGE then
  199.             doCreatureAddHealth(cid, pdmg)
  200.         end
  201.     end
  202. return true
  203. end
  204. ]]></event>
  205. ------------------------------------------------------------------------------------
  206. <action itemid="6312" event="script"><![CDATA[
  207. domodlib('vamp')
  208.     if itemEx.uid ~= cid then
  209.         doPlayerSendCancel(cid, "You may only use this potion on yourself.") return true
  210.     elseif not isVampire(cid) and not isVampireLord(cid) then
  211.         doPlayerSendCancel(cid, "You aren't a vampire.") return true
  212.     end
  213.        
  214.         setVampireLevel(cid, 1)
  215.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your vampirism level regressed to 1.")
  216.         doSendMagicEffect(getCreaturePos(cid), 13)
  217.         exhaustion.set(cid, vamptime, vamphours*3600)
  218.         doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER)
  219.         doRemoveItem(item.uid, 1)
  220. return true
  221. ]]></action>
  222. </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement