Ir para conteúdo

Sistema De Reflect Damage.


Posts Recomendados

Bem, o script funciona de uma forma. Voce adiciona um item a uma pessoa, e adiciona uma porcentagem de reflexão e o numero de vezes qeu vai refletir. Só reflete dano fisico.

 

Video:

 

Voce pode adicionar em colares, armaduras, botas, escudos e ate mesmo armas.

 

 

Instalando:

 

Vá na pasta data/lib e crie um arquivo chamado de ReflectLib.lua e adicione isso dentro:

function isHandedWeapon(itemuid)
   local typee = getItemWeaponType(itemuid) or 0
   if typee >= 1 and typee <= 6 then
       return CONST_SLOT_RIGHT
   end
   return -1
end

function getItemType(itemid)
   local slottypes = {"head", "body", "legs", "feet", "ring", "necklace"}
   local consts = {
   ["head"] = CONST_SLOT_HEAD,
   ["armor"] = CONST_SLOT_ARMOR,
   ["legs"] = CONST_SLOT_LEGS,
   ["feet"] = CONST_SLOT_FEET,
   ["ring"] = CONST_SLOT_RING,
   ["necklace"] = CONST_SLOT_NECKLACE
   } 
   local arq = io.open("data/items/items.xml", "r"):read("*all")
   local attributes = arq:match('<item id="' .. itemid .. '".+name="' .. getItemNameById(itemid) ..'">(.-)</item>')
   local slot = ""
   for i,x in pairs(slottypes) do
       if attributes:find(x) then
               slot = x
                   break
           end
   end
   if slot == "body" then
       slot = "armor"
   end
return consts[slot]
end

function addReflectCharges(item, charges, reflectpercent)
   if charges ~= "inf" then
       charges = charges+1
       doItemSetAttribute(item, "mcharges", charges)
       doItemSetAttribute(item, "charges", charges)
       doItemSetAttribute(item, "name", getItemNameById(getThing(item).itemid) .. " that is brand-new")
   else
       doItemSetAttribute(item, "charges", -1)
       doItemSetAttribute(item, "mcharges", "inf")
   end
   doItemSetAttribute(item, "reflect", reflectpercent)
   doItemSetAttribute(item, "description", "That item reflects " .. reflectpercent .. " percent of physical damage.")
end

function renewCharges(item)
   if getItemAttribute(item, "charges") and getItemAttribute(item, "mcharges") ~= "inf" then
       doItemSetAttribute(item, "charges", getItemAttribute(item, "mcharges"))
       doItemSetAttribute(item, "name", getItemNameById(getThing(item).itemid) .. " that is brand-new")
   end
end

 

Agora vá em data/creaturescripts/scripts e adicione o script reflectDamage.lua com esse script:

function onStatsChange(cid, attacker, type, combat, value)
   local slots = {CONST_SLOT_HEAD, CONST_SLOT_NECKLACE, CONST_SLOT_ARMOR, CONST_SLOT_RIGHT, CONST_SLOT_LEFT, CONST_SLOT_LEGS, CONST_SLOT_FEET, CONST_SLOT_RING}
   local reflectpercent = 0
   local itens = {}
   for i = 1, #slots do
       if getPlayerSlotItem(cid, slots[i]).uid > 1 and (getItemType(getPlayerSlotItem(cid, slots[i]).itemid) == slots[i] or isInArray({CONST_SLOT_RIGHT, CONST_SLOT_LEFT}, isHandedWeapon(getPlayerSlotItem(cid, slots[i]).uid))) and getItemAttribute(getPlayerSlotItem(cid, slots[i]).uid, "mcharges") and (getItemAttribute(getPlayerSlotItem(cid, slots[i]).uid, "charges") > 1 or getItemAttribute(getPlayerSlotItem(cid, slots[i]).uid, "mcharges") == "inf") then
           reflectpercent = reflectpercent+getItemAttribute(getPlayerSlotItem(cid, slots[i]).uid, "reflect")
           table.insert(itens, getPlayerSlotItem(cid, slots[i]))
       end
   end
   if combat == 1 and reflectpercent > 0 then
       if math.ceil(-value*((100-reflectpercent)/100)) < 0 then
           doCreatureAddHealth(cid,  math.ceil(-value*((100-reflectpercent)/100)))
           doSendAnimatedText(getCreaturePosition(cid), math.ceil(value*((100-reflectpercent)/100)), COLOR_RED)
           local a = doCreateItem(2019, 2, getCreaturePosition(cid))
           doSendMagicEffect(getCreaturePosition(cid), 0)
           doDecayItem(a)
       else
           doSendMagicEffect(getCreaturePosition(cid), 3)
       end
       if math.ceil(-value*(reflectpercent/100)) < 0 then
           doCreatureAddHealth(attacker, math.ceil(-value*(reflectpercent/100)))
           doSendAnimatedText(getCreaturePosition(attacker), math.ceil(value*(reflectpercent/100)), COLOR_GREY)
           local a = doCreateItem(2019, 2, getCreaturePosition(attacker))
           doSendMagicEffect(getCreaturePosition(attacker), 9)
           doDecayItem(a)
       end
       for i,x in pairs(itens) do
           if getItemAttribute(x.uid, "mcharges") ~= "inf" then
               doItemSetAttribute(x.uid, "charges", getItemAttribute(x.uid, "charges")-1)
               doItemSetAttribute(x.uid, "name", getItemNameById(x.itemid) .. " that has " .. getItemAttribute(x.uid, "charges")-1 .. " charge" .. (getItemAttribute(x.uid, "charges")-1 > 1 and "s" or "") .. " left")
           end
       end
   else
   return TRUE
   end
end

 

Agora na mesma pasta, procure por login.lua, e antes do ultimo return true, adicione essa linha:

registerCreatureEvent(cid, "ReflectDamage")

 

Agora vá em creaturescripts.xml e adicione esta tag:

<event type="statschange" name="ReflectDamage" event="script" value="reflectDamage.lua"/>

 

Pronto, o script esta pronto para uso.

 

O script segue com tais funçoes para voce usar em outros scripts:

 

addReflectCharges(item, charges, reflectpercent)

  • Função: Ela é o coraçao do script, sem ela voce nao faz nada, voce usa ela pra adicionar cargas a um item qualquer, des de que seja equipavel.

  • item - O uid do item que vai ser adicionado as cargas.
  • charges - Numero de cargas, caso voce use "inf", assim mesmo com as aspas, o item tera infinitas cargas.
  • reflectpercent - Porcentagem de reflexão que o item vai ter.

renewCharges(item)

  • Função: Recarregar as cargas de um item.

  • item - O uid do item que vai ser recarregado.

 

O script usado para adicionar o colar foi uma talkaction assim:

function onSay(cid, words, param)
   local item = doPlayerAddItem(cid, 2125)
   addReflectCharges(item, 40, 75)
return TRUE
end

Editado por MatheusMkalo
Link para o comentário
Compartilhar em outros sites

 [18/08/2011 14:33:28] [Error - CreatureScript Interface] 
[18/08/2011 14:33:28] data/creaturescripts/scripts/reflectDamage.lua:onStatsChange
[18/08/2011 14:33:28] Description: 
[18/08/2011 14:33:28] data/lib/reflectlib.lua:23: attempt to index local 'attributes' (a nil value)
[18/08/2011 14:33:28] stack traceback:
[18/08/2011 14:33:28] 	data/lib/reflectlib.lua:23: in function 'getItemType'
[18/08/2011 14:33:28] 	data/creaturescripts/scripts/reflectDamage.lua:6: in function <data/creaturescripts/scripts/reflectDamage.lua:1> 

Link para o comentário
Compartilhar em outros sites

ah então posta isso no tutorial que tem muita gente que nao sabe fazer isso ( inclusive eu ).

 

olha aki:

 

 <item id="2125" article="a" name="crystal necklace">
       <attribute key="weight" value="490" />
       <attribute key="slotType" value="necklace" />
   </item>

 

o que eu edito aki pra funcionar ?

 

desde já agradeço

Editado por LipeFioravanti
Link para o comentário
Compartilhar em outros sites

Lol esta correto, como voce fez dar esse erro?

oO

 

ué cara fiz o que vc pediu

 

data -> lib -> ReflectLib.lua

 

function isHandedWeapon(itemuid)
   local typee = getItemWeaponType(itemuid) or 0
   if typee >= 1 and typee <= 6 then
       return CONST_SLOT_RIGHT
   end
   return -1
end

function getItemType(itemid)
   local slottypes = {"head", "body", "legs", "feet", "ring", "necklace"}
   local consts = {
   ["head"] = CONST_SLOT_HEAD,
   ["armor"] = CONST_SLOT_ARMOR,
   ["legs"] = CONST_SLOT_LEGS,
   ["feet"] = CONST_SLOT_FEET,
   ["ring"] = CONST_SLOT_RING,
   ["necklace"] = CONST_SLOT_NECKLACE
   } 
   local arq = io.open("data/items/items.xml", "r"):read("*all")
   local attributes = arq:match('<item id="' .. itemid .. '".+name="' .. getItemNameById(itemid) ..'">(.-)</item>')
   local slot = ""
   for i,x in pairs(slottypes) do
       if attributes:find(x) then
               slot = x
                   break
           end
   end
   if slot == "body" then
       slot = "armor"
   end
return consts[slot]
end

function addReflectCharges(item, charges, reflectpercent)
   if charges ~= "inf" then
       charges = charges+1
       doItemSetAttribute(item, "mcharges", charges)
       doItemSetAttribute(item, "charges", charges)
       doItemSetAttribute(item, "name", getItemNameById(getThing(item).itemid) .. " that is brand-new")
   else
       doItemSetAttribute(item, "charges", -1)
       doItemSetAttribute(item, "mcharges", "inf")
   end
   doItemSetAttribute(item, "reflect", reflectpercent)
   doItemSetAttribute(item, "description", "That item reflects " .. reflectpercent .. " percent of physical damage.")
end

function renewCharges(item)
   if getItemAttribute(item, "charges") and getItemAttribute(item, "mcharges") ~= "inf" then
       doItemSetAttribute(item, "charges", getItemAttribute(item, "mcharges"))
       doItemSetAttribute(item, "name", getItemNameById(getThing(item).itemid) .. " that is brand-new")
   end
end

 

data -> creaturescripts -> scripts -> reflectDamage.lua

 

 function onStatsChange(cid, attacker, type, combat, value)
   local slots = {CONST_SLOT_HEAD, CONST_SLOT_NECKLACE, CONST_SLOT_ARMOR, CONST_SLOT_RIGHT, CONST_SLOT_LEFT, CONST_SLOT_LEGS, CONST_SLOT_FEET, CONST_SLOT_RING}
   local reflectpercent = 0
   local itens = {}
   for i = 1, #slots do
       if getPlayerSlotItem(cid, slots[i]).uid > 1 and (getItemType(getPlayerSlotItem(cid, slots[i]).itemid) == slots[i] or isInArray({CONST_SLOT_RIGHT, CONST_SLOT_LEFT}, isHandedWeapon(getPlayerSlotItem(cid, slots[i]).uid))) and getItemAttribute(getPlayerSlotItem(cid, slots[i]).uid, "mcharges") and (getItemAttribute(getPlayerSlotItem(cid, slots[i]).uid, "charges") > 1 or getItemAttribute(getPlayerSlotItem(cid, slots[i]).uid, "mcharges") == "inf") then
           reflectpercent = reflectpercent+getItemAttribute(getPlayerSlotItem(cid, slots[i]).uid, "reflect")
           table.insert(itens, getPlayerSlotItem(cid, slots[i]))
       end
   end
   if combat == 1 and reflectpercent > 0 then
       if math.ceil(-value*((100-reflectpercent)/100)) < 0 then
           doCreatureAddHealth(cid,  math.ceil(-value*((100-reflectpercent)/100)))
           doSendAnimatedText(getCreaturePosition(cid), math.ceil(value*((100-reflectpercent)/100)), COLOR_RED)
           local a = doCreateItem(2019, 2, getCreaturePosition(cid))
           doSendMagicEffect(getCreaturePosition(cid), 0)
           doDecayItem(a)
       else
           doSendMagicEffect(getCreaturePosition(cid), 3)
       end
       if math.ceil(-value*(reflectpercent/100)) < 0 then
           doCreatureAddHealth(attacker, math.ceil(-value*(reflectpercent/100)))
           doSendAnimatedText(getCreaturePosition(attacker), math.ceil(value*(reflectpercent/100)), COLOR_GREY)
           local a = doCreateItem(2019, 2, getCreaturePosition(attacker))
           doSendMagicEffect(getCreaturePosition(attacker), 9)
           doDecayItem(a)
       end
       for i,x in pairs(itens) do
           if getItemAttribute(x.uid, "mcharges") ~= "inf" then
               doItemSetAttribute(x.uid, "charges", getItemAttribute(x.uid, "charges")-1)
               doItemSetAttribute(x.uid, "name", getItemNameById(x.itemid) .. " that has " .. getItemAttribute(x.uid, "charges")-1 .. " charge" .. (getItemAttribute(x.uid, "charges")-1 > 1 and "s" or "") .. " left")
           end
       end
   else
   return TRUE
   end
end 

 

data -> creaturescripts -> scripts -> login.lua

 

 local config = {
loginMessage = getConfigValue('loginMessage')
}

function onLogin(cid)
local loss = getConfigValue('deathLostPercent')
if(loss ~= nil) then
	doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
end

local accountManager = getPlayerAccountManager(cid)
if(accountManager == MANAGER_NONE) then
	local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
	if(lastLogin > 0) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
		str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
	else
		str = str .. " Please choose your outfit."
		doPlayerSendOutfitWindow(cid)
	end

	doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
elseif(accountManager == MANAGER_NAMELOCK) then
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
elseif(accountManager == MANAGER_ACCOUNT) then
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
else
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
end

if(not isPlayerGhost(cid)) then
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
end

registerCreatureEvent(cid, "Mail")
registerCreatureEvent(cid, "GuildMotd")

registerCreatureEvent(cid, "killer")
registerCreatureEvent(cid, "Idle")

registerCreatureEvent(cid, "attackguild")	
registerCreatureEvent(cid, "advance")
registerCreatureEvent(cid, "FimVip")
registerCreatureEvent(cid, "SkullCheck")
registerCreatureEvent(cid, "ReportBug")

registerCreatureEvent(cid, VipReceive)
registerCreatureEvent(cid, "PlayerKill")
   if (InitArenaScript ~= 0) then
   InitArenaScript = 1
   -- make arena rooms free
       for i = 42300, 42309 do
           setGlobalStorageValue(i, 0)
           setGlobalStorageValue(i+100, 0)
       end
   end
   -- if he did not make full arena 1 he must start from zero
   if getPlayerStorageValue(cid, 42309) < 1 then
       for i = 42300, 42309 do
           setPlayerStorageValue(cid, i, 0)
       end
   end
   -- if he did not make full arena 2 he must start from zero
   if getPlayerStorageValue(cid, 42319) < 1 then
       for i = 42310, 42319 do
           setPlayerStorageValue(cid, i, 0)
       end
   end
   -- if he did not make full arena 3 he must start from zero
   if getPlayerStorageValue(cid, 42329) < 1 then
       for i = 42320, 42329 do
           setPlayerStorageValue(cid, i, 0)
       end
   end
   if getPlayerStorageValue(cid, 42355) == -1 then
       setPlayerStorageValue(cid, 42355, 0) -- did not arena level
   end
   setPlayerStorageValue(cid, 42350, 0) -- time to kick 0
   setPlayerStorageValue(cid, 42352, 0) -- is not in arena  
fly.login(cid)
registerCreatureEvent(cid, "onPrepareDeath")
registerCreatureEvent(cid, "task_count")
registerCreatureEvent(cid, "onPrepareDeathinifi")
registerCreatureEvent(cid, "ReflectDamage")
return true
end 

 

creaturescripts.xml ->

 

 <?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
<event type="login" name="PlayerLogin" event="script" value="login.lua"/>

<event type="joinchannel" name="GuildMotd" event="script" value="guildmotd.lua"/>
<event type="receivemail" name="Mail" event="script" value="mail.lua"/>
<event type="reportbug" name="SaveReportBug" script="reportbug.lua"/>

<event type="think" name="Idle" event="script" value="idle.lua"/>
<event type="think" name="SkullCheck" event="script" value="skullcheck.lua"/>
<event type="death" name="PlayerDeath" event="script" value="playerdeath.lua"/>
<event type="login" name="FirstItems" event="script" value="firstitems.lua"/>


<event type="PrepareDeath" name="pvparena" script="pvparena.lua"/>
<event type="attack" name="attackguild" script="attackguild.lua"/>
       <event type="logout" name="Playerlogout" event="script" value="logout.lua"/>
       <event type="logout" name="FimVip" event="script" value="vipname.lua"/>
       <event type="statschange" name="ReflectSpellKnight" event="script" value="spells/reflectknight.lua"/>
       <event type="statschange" name="ReflectSpellPally" event="script" value="spells/reflectpally.lua"/>
       <event type="statschange" name="ReflectSpellMage" event="script" value="spells/reflectmage.lua"/>
       <event type="kill" name="task_count" script="taskcount.lua"/>
       <event type="preparedeath" name="onPrepareDeathinifi" event="script" value="aolinfinity.lua"/>
       <event type="statschange" name="ReflectDamage" event="script" value="reflectDamage.lua"/>

</creaturescripts>


 

agora nem tá dando mais o erro, só que tambem nao tá refletindo

olha se ajudar minhas vocações são novas

veja ai

 

--> vocations.xml

 

 <?xml version="1.0" encoding="UTF-8"?>
<vocations>
<vocation id="0" name="None" description="none" needpremium="0" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="1" gainmanaticks="6" gainmanaamount="1" manamultiplier="4.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="0" attackable="no">
	<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
	<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="1" name="Wizard" description="a Wizard" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="6" gainhpamount="50" gainmanaticks="3" gainmanaamount="70" manamultiplier="1.1" attackspeed="500" soulmax="100" gainsoulticks="120" fromvoc="1">
	<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
	<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="2" name="Priest" description="a Priest" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="6" gainhpamount="50" gainmanaticks="3" gainmanaamount="70" manamultiplier="1.1" attackspeed="500" soulmax="100" gainsoulticks="120" fromvoc="2">
	<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
	<skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="3" name="Archer" description="a archer" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="4" gainhpamount="65" gainmanaticks="4" gainmanaamount="60" manamultiplier="1.4" attackspeed="500" soulmax="100" gainsoulticks="120" fromvoc="3">
	<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
	<skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="4" name="Guardian" description="a guardian" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="3" gainhpamount="80" gainmanaticks="6" gainmanaamount="40" manamultiplier="3.0" attackspeed="500" soulmax="100" gainsoulticks="120" fromvoc="4">
	<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
	<skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
       <vocation id="13" name="Alchemist" description="a alchemist" needpremium="0" gaincap="25" gainhp="5" gainmana="30" gainhpticks="0" gainhpamount="60" gainmanaticks="6" gainmanaamount="65" manamultiplier="1.1" attackspeed="500" soulmax="200" gainsoulticks="120" fromvoc="13">
	<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
	<skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
       <vocation id="14" name="Creator" description="a creator" needpremium="0" gaincap="25" gainhp="5" gainmana="30" gainhpticks="0" gainhpamount="60" gainmanaticks="6" gainmanaamount="65" manamultiplier="1.1" attackspeed="500" soulmax="300" gainsoulticks="120" fromvoc="13">
	<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
	<skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="5" name="Powerful Wizard" description="a Powerful Wizard" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="4" gainhpamount="100" gainmanaticks="2" gainmanaamount="150" manamultiplier="1.1" attackspeed="500" soulmax="200" gainsoulticks="15" fromvoc="1" lessloss="30">
	<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
	<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="6" name="Divine" description="an divine" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="4" gainhpamount="100" gainmanaticks="2" gainmanaamount="150" manamultiplier="1.1" attackspeed="500" soulmax="200" gainsoulticks="15" fromvoc="2" lessloss="30">
	<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
	<skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="7" name="Sniper" description="a sniper" needpremium="1" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="150" gainmanaticks="3" gainmanaamount="130" manamultiplier="1.4" attackspeed="500" soulmax="200" gainsoulticks="15" fromvoc="3" lessloss="30">
	<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
	<skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="8" name="Horseman" description="an horseman" needpremium="1" gaincap="25" gainhp="15" gainmana="5" gainhpticks="2" gainhpamount="170" gainmanaticks="4" gainmanaamount="80" manamultiplier="3.0" attackspeed="500" soulmax="200" gainsoulticks="15" fromvoc="4" lessloss="30">
	<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
	<skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
<!--
<vocation id="9" name="Dark Mage" description="an dark mage" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="4" gainhpamount="10" gainmanaticks="2" gainmanaamount="10" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="5" lessloss="50">
	<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
	<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="10" name="Cleric" description="an cleric" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="4" gainhpamount="10" gainmanaticks="2" gainmanaamount="10" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="6" lessloss="50">
	<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
	<skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="11" name="Striker" description="an Striker" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="10" gainmanaticks="3" gainmanaamount="10" manamultiplier="1.4" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="7" lessloss="50">
	<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
	<skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="12" name="Heavy Tanker" description="an heavy tanker" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="8" gainhpamount="10" gainmanaticks="4" gainmanaamount="10" manamultiplier="3.0" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="8" lessloss="50">
	<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
	<skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
-->
</vocations>

 

abraço

Link para o comentário
Compartilhar em outros sites

Como ta o seu script de add o item que da reflect?

 

ah axo que não fiz isso, tem como me explicar ?

sou noob nessas paradas ai ainda, comecei mecher semana retrasada

 

bom, de qualquer jeito obrigado por tentar estar me ajudando, rep+ pra vc ^^

 

EDIT-

ai, botei o script de add no talkaction e funcionou, n tinha feito isso porque nao tinha entendido

agora funcionou

valeu /o\

 

---

no caso, pra deixar infinito, o script ficaria como ?

Editado por LipeFioravanti
Link para o comentário
Compartilhar em outros sites

^.^ Gostei muito do sistema, vou copiar ele pra quando eu for usa...

\o/ quem sabe você não cria um que add hit points no cara? (no limite) :( tava precisando desse!

Link para o comentário
Compartilhar em outros sites

  • 7 years later...
Em 14/08/2011 em 21:03, MatheusGlad disse:

Bem, o script funciona de uma forma. Voce adiciona um item a uma pessoa, e adiciona uma porcentagem de reflexão e o numero de vezes qeu vai refletir. Só reflete dano fisico.

 

Video:

 

 

 

Voce pode adicionar em colares, armaduras, botas, escudos e ate mesmo armas.

 

 

Instalando:

 

Vá na pasta data/lib e crie um arquivo chamado de ReflectLib.lua e adicione isso dentro:

 


function isHandedWeapon(itemuid)
   local typee = getItemWeaponType(itemuid) or 0
   if typee >= 1 and typee <= 6 then
       return CONST_SLOT_RIGHT
   end
   return -1
end

function getItemType(itemid)
   local slottypes = {"head", "body", "legs", "feet", "ring", "necklace"}
   local consts = {
   ["head"] = CONST_SLOT_HEAD,
   ["armor"] = CONST_SLOT_ARMOR,
   ["legs"] = CONST_SLOT_LEGS,
   ["feet"] = CONST_SLOT_FEET,
   ["ring"] = CONST_SLOT_RING,
   ["necklace"] = CONST_SLOT_NECKLACE
   } 
   local arq = io.open("data/items/items.xml", "r"):read("*all")
   local attributes = arq:match('<item id="' .. itemid .. '".+name="' .. getItemNameById(itemid) ..'">(.-)</item>')
   local slot = ""
   for i,x in pairs(slottypes) do
       if attributes:find(x) then
               slot = x
                   break
           end
   end
   if slot == "body" then
       slot = "armor"
   end
return consts[slot]
end

function addReflectCharges(item, charges, reflectpercent)
   if charges ~= "inf" then
       charges = charges+1
       doItemSetAttribute(item, "mcharges", charges)
       doItemSetAttribute(item, "charges", charges)
       doItemSetAttribute(item, "name", getItemNameById(getThing(item).itemid) .. " that is brand-new")
   else
       doItemSetAttribute(item, "charges", -1)
       doItemSetAttribute(item, "mcharges", "inf")
   end
   doItemSetAttribute(item, "reflect", reflectpercent)
   doItemSetAttribute(item, "description", "That item reflects " .. reflectpercent .. " percent of physical damage.")
end

function renewCharges(item)
   if getItemAttribute(item, "charges") and getItemAttribute(item, "mcharges") ~= "inf" then
       doItemSetAttribute(item, "charges", getItemAttribute(item, "mcharges"))
       doItemSetAttribute(item, "name", getItemNameById(getThing(item).itemid) .. " that is brand-new")
   end
end
 

 

 

Agora vá em data/creaturescripts/scripts e adicione o script reflectDamage.lua com esse script:

 


function onStatsChange(cid, attacker, type, combat, value)
   local slots = {CONST_SLOT_HEAD, CONST_SLOT_NECKLACE, CONST_SLOT_ARMOR, CONST_SLOT_RIGHT, CONST_SLOT_LEFT, CONST_SLOT_LEGS, CONST_SLOT_FEET, CONST_SLOT_RING}
   local reflectpercent = 0
   local itens = {}
   for i = 1, #slots do
       if getPlayerSlotItem(cid, slots[i]).uid > 1 and (getItemType(getPlayerSlotItem(cid, slots[i]).itemid) == slots[i] or isInArray({CONST_SLOT_RIGHT, CONST_SLOT_LEFT}, isHandedWeapon(getPlayerSlotItem(cid, slots[i]).uid))) and getItemAttribute(getPlayerSlotItem(cid, slots[i]).uid, "mcharges") and (getItemAttribute(getPlayerSlotItem(cid, slots[i]).uid, "charges") > 1 or getItemAttribute(getPlayerSlotItem(cid, slots[i]).uid, "mcharges") == "inf") then
           reflectpercent = reflectpercent+getItemAttribute(getPlayerSlotItem(cid, slots[i]).uid, "reflect")
           table.insert(itens, getPlayerSlotItem(cid, slots[i]))
       end
   end
   if combat == 1 and reflectpercent > 0 then
       if math.ceil(-value*((100-reflectpercent)/100)) < 0 then
           doCreatureAddHealth(cid,  math.ceil(-value*((100-reflectpercent)/100)))
           doSendAnimatedText(getCreaturePosition(cid), math.ceil(value*((100-reflectpercent)/100)), COLOR_RED)
           local a = doCreateItem(2019, 2, getCreaturePosition(cid))
           doSendMagicEffect(getCreaturePosition(cid), 0)
           doDecayItem(a)
       else
           doSendMagicEffect(getCreaturePosition(cid), 3)
       end
       if math.ceil(-value*(reflectpercent/100)) < 0 then
           doCreatureAddHealth(attacker, math.ceil(-value*(reflectpercent/100)))
           doSendAnimatedText(getCreaturePosition(attacker), math.ceil(value*(reflectpercent/100)), COLOR_GREY)
           local a = doCreateItem(2019, 2, getCreaturePosition(attacker))
           doSendMagicEffect(getCreaturePosition(attacker), 9)
           doDecayItem(a)
       end
       for i,x in pairs(itens) do
           if getItemAttribute(x.uid, "mcharges") ~= "inf" then
               doItemSetAttribute(x.uid, "charges", getItemAttribute(x.uid, "charges")-1)
               doItemSetAttribute(x.uid, "name", getItemNameById(x.itemid) .. " that has " .. getItemAttribute(x.uid, "charges")-1 .. " charge" .. (getItemAttribute(x.uid, "charges")-1 > 1 and "s" or "") .. " left")
           end
       end
   else
   return TRUE
   end
end
 

 

 

Agora na mesma pasta, procure por login.lua, e antes do ultimo return true, adicione essa linha:

 


registerCreatureEvent(cid, "ReflectDamage")
 

 

 

Agora vá em creaturescripts.xml e adicione esta tag:

 


<event type="statschange" name="ReflectDamage" event="script" value="reflectDamage.lua"/>
 

 

 

Pronto, o script esta pronto para uso.

 

O script segue com tais funçoes para voce usar em outros scripts:

 

addReflectCharges(item, charges, reflectpercent)

 

  • Função: Ela é o coraçao do script, sem ela voce nao faz nada, voce usa ela pra adicionar cargas a um item qualquer, des de que seja equipavel.

 

 

  • item - O uid do item que vai ser adicionado as cargas.
  • charges - Numero de cargas, caso voce use "inf", assim mesmo com as aspas, o item tera infinitas cargas.
  • reflectpercent - Porcentagem de reflexão que o item vai ter.

 

renewCharges(item)

 

  • Função: Recarregar as cargas de um item.

 

 

  • item - O uid do item que vai ser recarregado.

 

 

O script usado para adicionar o colar foi uma talkaction assim:

 


function onSay(cid, words, param)
   local item = doPlayerAddItem(cid, 2125)
   addReflectCharges(item, 40, 75)
return TRUE
end
 

nao entendi essa ultimate parte mano... Como adiciono isto no item ou em algum item..

Vocé fala que o script foi usada para adicionar a um colar mais nao fala como, só fala que foi usada esta action, to entendo o final nao!

 

 

como adiciono isso no talkactions??

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...