Ir para conteúdo

[Encerrado] Shield Reclect


Posts Recomendados

poe isso em MODS... arquivo.XML

 

 

<?xml version="1.0" encoding="UTF-8"?>
<mod name="Reflect System" version="0.1" author="Aluccard and edited Cleberadm" contact="" enabled="yes">
		<description>
				Script que funciona para refletir danos para as creatures que o atacar.
		</description>

		<event type="login" name="regReflectDamage" event="script"><![CDATA[
				function onLogin(cid)
						registerCreatureEvent(cid,"ReflectDamage")
						return true
				end
	]]></event>

		<event type="statschange" name="ReflectDamage" event="script"><![CDATA[

local slotPos = {CONST_SLOT_SHIELD}
	
function onStatsChange(cid, attacker, type, combat, value)
		local reflectPercent = 90
	local dmg = value
	local playerPos = getCreaturePosition(cid)
	local attackerPos = getCreaturePosition(attacker)

	for i = 1, #slotPos do
		if getPlayerSlotItem(cid, slotPos[i]).uid > 1 then
			if getItemReflectPercent(getPlayerSlotItem(cid, slotPos[i]).uid) then
				reflectPercent = reflectPercent + getItemReflectPercent(getPlayerSlotItem(cid, slotPos[i]).uid)
			end
		end
	end
		
	if reflectPercent > 0 then
		dmg = math.ceil(-value*((100-reflectPercent)/100))		
		if (dmg < 0) then
			
			doSendAnimatedText(playerPos, -dmg, COLOR_GREEN)
			doSendMagicEffect(playerPos, 30)					
		else
			doSendMagicEffect(playerPos, 10)
		end

		dmg = math.ceil(-value*(reflectPercent/100))
		if (dmg < 0) then
			doCreatureAddHealth(attacker, dmg)
			doSendAnimatedText(attackerPos, -dmg, COLOR_GREEN)
			doSendDistanceShoot(playerPos, attackerPos, CONST_ANI_SUDDENDEATH)
		end
	else
		return true
	end
end]]></event>
</mod>

 

 

 

Em data/lib

 

ReflectLib.lua

 

 

function getItemReflectPercent(itemuid)
local item = {2514, 2520} --- adicione os IDS dos shields aqui.
setItemAttribute(item.uid, "reflectPercent")
doItemSetAttribute(item.uid, "description", "[Reflect: "..percent.."%]")
doItemSetAttribute(item.uid, "reflectPercent", percent)
return getItemAttribute(itemuid, "reflectPercent")
end

 

 

Link para o comentário
Compartilhar em outros sites

Obrigado vou testa já edito aqui :)


[25/08/2013 04:36:35] buffer:onStatsChange
[25/08/2013 04:36:35] Description:
[25/08/2013 04:36:35] (luaDoCreatureAddHealth) Creature not found
[25/08/2013 04:36:35] [Error - CreatureScript Interface]
[25/08/2013 04:36:35] buffer:onStatsChange
[25/08/2013 04:36:35] Description:
[25/08/2013 04:36:35] (luaGetThingPosition) Thing not found
[25/08/2013 04:36:35] [Error - CreatureScript Interface]
[25/08/2013 04:36:35] buffer:onStatsChange
[25/08/2013 04:36:35] Description:
[25/08/2013 04:36:35] (luaDoCreatureAddHealth) Creature not found
[25/08/2013 04:36:36] [Error - CreatureScript Interface]
[25/08/2013 04:36:36] buffer:onStatsChange
[25/08/2013 04:36:36] Description:
[25/08/2013 04:36:36] (luaGetThingPosition) Thing not found
[25/08/2013 04:36:36] [Error - CreatureScript Interface]
[25/08/2013 04:36:36] buffer:onStatsChange
[25/08/2013 04:36:36] Description:
[25/08/2013 04:36:36] (luaDoCreatureAddHealth) Creature not found
[25/08/2013 04:36:37] Osmoze efetuou login.
[25/08/2013 04:36:38] [Error - CreatureScript Interface]
[25/08/2013 04:36:38] buffer:onStatsChange
[25/08/2013 04:36:38] Description:
[25/08/2013 04:36:38] (luaGetThingPosition) Thing not found
Link para o comentário
Compartilhar em outros sites

 

 

<?xml version="1.0" encoding="UTF-8"?>
<mod name="Reflect System" version="0.1" author="Aluccard / edited by Cleberadm" contact="" enabled="yes">
		<description>
				Script que funciona para refletir danos para as creatures que o atacar.
		</description>

		<event type="login" name="regReflectDamage" event="script"><![CDATA[
				function onLogin(cid)
						registerCreatureEvent(cid,"ReflectDamage")
						return true
				end
	]]></event>

		<event type="statschange" name="ReflectDamage" event="script"><![CDATA[

local slotPos = {CONST_SLOT_SHIELD}
	
function onStatsChange(cid, attacker, type, combat, value)
			if isPlayer(attacker) or isMonster(attacker) then
        local reflectPercent = 100
	local dmg = value
	local playerPos = getCreaturePosition(cid)
	local attackerPos = getCreaturePosition(attacker)

	for i = 1, #slotPos do
		if getPlayerSlotItem(cid, slotPos[i]).uid > 1 then
			if getItemReflectPercent(getPlayerSlotItem(cid, slotPos[i]).uid) then
				reflectPercent = reflectPercent + getItemReflectPercent(getPlayerSlotItem(cid, slotPos[i]).uid)
			end
		end
	end
		
	if reflectPercent > 0 then
		dmg = math.ceil(-value*((100-reflectPercent)/100))		
		if (dmg < 0) then
			doCreatureAddHealth(cid, dmg)	
			doSendAnimatedText(playerPos, -dmg, COLOR_RED)
			doSendMagicEffect(playerPos, 0)					
		else
			doSendMagicEffect(playerPos, 3)
		end

		dmg = math.ceil(-value*(reflectPercent/100))
		if (dmg < 0) then
			doCreatureAddHealth(attacker, dmg)
			doSendAnimatedText(attackerPos, -dmg, COLOR_RED)
			doSendDistanceShoot(playerPos, attackerPos, CONST_ANI_SUDDENDEATH)
		end
	else
		return true
	
    end
    end
end]]></event>
</mod>

 

 

Link para o comentário
Compartilhar em outros sites

  • 4 years later...
A questão neste tópico de suporte foi encerrada por falta de respostas. Este tópico está fechado e foi movido para Suporte - Tópicos Sem Resposta.

+ Caso a dúvida não tenha sido resolvida você poderá criar outro tópico solicitando ajuda.
* Lembre-se que é permitido dar UP no tópico a cada 24 horas para assim o destacar e manter movimentado.
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...