1
[CreatureEvents] Vocations al atakar recupera vida Miér Abr 27, 2016 3:00 pm
[Admin] God Maya
![[Admin] God Maya](https://2img.net/u/2712/30/40/04/avatars/1-92.jpg)
Administrador

Hola usuarios de tibiaface
Este script trabaja con el skill de weapon mientras mejor es el atake mas cura claro esta que solo una vocacion tiene esta habilidad.
![[CreatureEvents] Vocations al atakar recupera vida JOIAXCm](https://i.imgur.com/JOIAXCm.gif)
nos vamos a:
copiamos cualquier archivo y renombramos por vocLifeDrain.lua y pegamos esto dentro:
config:
local lifeStealvocation = {6} -- {vocation} or {vocation, promotion}
local lifeStealPercents = 50 -- Porcentaje de vida adquirida.
en la misma carpeta buscamos Login.lua y registramos:
ahora novamos a:
y agregamos estas tag:
y listo.
bueno tambien hay de otra forma que al ejecutar una spells se active esete script tendrias que cambiar el scriptt de vocLifeDrain.lua por este:
y crear un spells aqui les dejo la spells:
creditos: Belerofonte
Este script trabaja con el skill de weapon mientras mejor es el atake mas cura claro esta que solo una vocacion tiene esta habilidad.
![[CreatureEvents] Vocations al atakar recupera vida JOIAXCm](https://i.imgur.com/JOIAXCm.gif)
nos vamos a:
Data/Creaturescripts/scripts |
copiamos cualquier archivo y renombramos por vocLifeDrain.lua y pegamos esto dentro:
- Código:
function onAttack(cid, target)
if isPlayer(cid) and isCreature(target) then
registerCreatureEvent(target, "vocLifeDrain")
end
return true
end
local lifeStealvocation = {6} -- {vocation} or {vocation, promotion}
local lifeStealPercents = 50 -- Porcentaje de vida adquirida.
function onStatsChange(cid, attacker, type, combat, value)
local healing = math.ceil(value * lifeStealPercents / 100)
if isPlayer(attacker) and combat == COMBAT_PHYSICALDAMAGE then
if getPlayerWeapon(attacker).itemid > 0 and isInArray({WEAPON_SWORD, WEAPON_CLUB, WEAPON_AXE}, getItemInfo(getPlayerWeapon(attacker).itemid).weaponType) then
if isInArray(lifeStealvocation, getPlayerVocation(attacker)) then
if getCreatureHealth(attacker) < getCreatureMaxHealth(attacker) then
if (value + getCreatureHealth(attacker)) > getCreatureMaxHealth(attacker) then
healing = getCreatureMaxHealth(attacker) - getCreatureHealth(attacker)
end
doCreatureAddHealth(attacker, healing)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
doSendMagicEffect(getPlayerPosition(attacker), CONST_ME_MAGIC_RED)
doSendAnimatedText(getPlayerPosition(attacker), "+" .. healing .. " HP", TEXTCOLOR_GREEN)
doPlayerSendTextMessage(attacker, MESSAGE_STATUS_DEFAULT, "You stole " .. healing .. " health from " .. getCreatureName(cid) .. ".")
end
end
end
end
return true
end
config:
local lifeStealvocation = {6} -- {vocation} or {vocation, promotion}
local lifeStealPercents = 50 -- Porcentaje de vida adquirida.
en la misma carpeta buscamos Login.lua y registramos:
- Código:
registerCreatureEvent(cid, "RegVocLifeDrain")
ahora novamos a:
Data/creaturescripts/creaturescripts.xml |
y agregamos estas tag:
- Código:
<event type="attack" name="RegVocLifeDrain" event="script" value="vocLifeDrain.lua"/>
<event type="statschange" name="vocLifeDrain" event="script" value="vocLifeDrain.lua"/>
y listo.
bueno tambien hay de otra forma que al ejecutar una spells se active esete script tendrias que cambiar el scriptt de vocLifeDrain.lua por este:
- Código:
function onAttack(cid, target)
if isPlayer(cid) and isCreature(target) then
registerCreatureEvent(target, "vocLifeDrain")
end
return true
end
local key = 398728 -- Mismo storage Key que en el spell.
local lifeStealvocation = {6} -- {"vocation"} or {"vocation", "promotion"}
local lifeStealPercents = 50 -- Porcentaje de vida adquirida.
function onStatsChange(cid, attacker, type, combat, value)
local healing = math.ceil(value * lifeStealPercents / 100)
if isPlayer(attacker) and combat == COMBAT_PHYSICALDAMAGE then
if getPlayerWeapon(attacker).itemid > 0 and isInArray({WEAPON_SWORD, WEAPON_CLUB, WEAPON_AXE}, getItemInfo(getPlayerWeapon(attacker).itemid).weaponType) then
if isInArray(lifeStealvocation, getPlayerVocation(attacker)) then
if exhaustion.get(attacker, key) ~= false then
if getCreatureHealth(attacker) < getCreatureMaxHealth(attacker) then
if (value + getCreatureHealth(attacker)) > getCreatureMaxHealth(attacker) then
healing = getCreatureMaxHealth(attacker) - getCreatureHealth(attacker)
end
doCreatureAddHealth(attacker, healing)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
doSendMagicEffect(getPlayerPosition(attacker), CONST_ME_MAGIC_RED)
doSendAnimatedText(getPlayerPosition(attacker), "+" .. healing .. " HP", TEXTCOLOR_GREEN)
doPlayerSendTextMessage(attacker, MESSAGE_STATUS_DEFAULT, "You stole " .. healing .. " health from " .. getCreatureName(cid) .. ".")
end
end
end
end
end
return true
end
y crear un spells aqui les dejo la spells:
- Código:
local key, sec = 398728, 10 -- Mismo storage Key que en vocLifeDrain, Segundos que durará.
function onTargetTile(cid, pos)
if isPlayer(cid) then
if exhaustion.get(cid, key) == false then
exhaustion.set(cid, key, sec)
else
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return
end
end
end
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end
creditos: Belerofonte

![[CreatureEvents] Vocations al atakar recupera vida YNU5B25](https://i.imgur.com/yNU5B25.png)