Strack
Member
- Joined
- May 15, 2009
- Messages
- 199
- Reaction score
- 14
At first sorry for my english...
Well, for those who know about naruto I supose they imagine what does these scripts do. I'm still bit newbie on Lua so it could have been done better... but runs perfectly
credits: Strack & cybershot for help in function
in data/lib/050-function.lua add:
on creaturescripts/login.lua add:
on creaturescripts/script create a new .lua, name it sharingan and add:
in creaturescripts.xml add:
now on spells.xml add:
in scripts/ create a new .lua named sharingan and add:
on those spells u want to be learned add:
if you want me to explain it just say it, if u want to add more spells to be learned u must configure creaturescripts/sharingan.lua, and add:
12002 -> storage for the spell
'kaiten' ->name of the spell
300 -> probability from 1 to 300 to learn the spell
If u like it Rep++
Well, for those who know about naruto I supose they imagine what does these scripts do. I'm still bit newbie on Lua so it could have been done better... but runs perfectly
credits: Strack & cybershot for help in function
in data/lib/050-function.lua add:
Code:
--- Sharingan function by Strack, and to cybershot for solving a problem :P
function doPlayerLearnSpellRandomProb(cid, storage, spell, prop)
local tid = getPlayerByNameWildcard(getPlayerName(cid))
local pos = getPlayerPosition(cid)
if(type(spell) == 'string') then
if not getPlayerLearnedInstantSpell(cid, spell) then --chekea si esta aprendida la magia, si lo esta se salta este paso
if getCreatureStorage(cid, storage) > 0 then --comprueba que tenga el storage (el storage ha de ser el mismo que en las spells, cada spell tiene su propio storage)
local fors = getCreatureStorage(tid, storage)
for i = 1, fors do
local luck = math.random(prop) --probabilidad 1 entre 300 de aprender, cuantos mas ataques de la magia alla recibido, mas value tendra el storage y mas veces se repetira este for
if luck == 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Has aprendido el jutsu "..spell.."")
doSendMagicEffect(pos, 12)
doPlayerLearnInstantSpell(cid,spell)
break
else
doSendMagicEffect(pos, CONST_ME_POFF)
end
end
doCreatureSetStorage(cid, storage, 0)
end
end
end
return true
end
on creaturescripts/login.lua add:
Code:
setPlayerStorageValue(cid, 12000, -1)
on creaturescripts/script create a new .lua, name it sharingan and add:
Code:
--Script made by Strack
function onLogin(cid)
doPlayerLearnSpellRandomProb(cid, 12001, 'chidori', 300)
doPlayerLearnSpellRandomProb(cid, 12002, 'kaiten', 300)
return true
end
in creaturescripts.xml add:
Code:
<event type="login" name="sharingan" event="script" value="sharingan.lua"/>
now on spells.xml add:
Code:
<instant name="Sharingan" words="sharingan" lvl="8" mana="60" prem="1" aggressive="0" selftarget="1" exhaustion="1000" needlearn="0" event="script" value="sharingan.lua">
</instant>
in scripts/ create a new .lua named sharingan and add:
Code:
--Script made by Strack
local storage = 12000 -- storage for sharingan
local sec = 10 -- seconds that u'll have sharingan activated
function onCastSpell(cid, var)
if getCreatureStorage(cid,storage) < 1 then
doCreatureSetStorage(cid, storage, 1)
doSendMagicEffect(getThingPos(cid), 13)
doPlayerSendCancel(cid,'Sharingan is now activated')
addEvent(setPlayerStorageValue, sec * 1000, cid, storage, -1)
return true
elseif getCreatureStorage(cid, storage) == 1 then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid,'Your sharingan is already activated.')
return false
end
return true
end
on those spells u want to be learned add:
Code:
function onTargetCreature(cid, target)
if getPlayerStorageValue(target, 12000) == 1 then --storage of sharingan its the same on all spells
if getPlayerLearnedInstantSpell(target, 'kaiten') == FALSE then -- name of the same spell where u put this
return doPlayerSetStorageValue(target, 12002, getCreatureStorage(target, 12002)+1) -- storage that will give, every spell have their own storage
end
end
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
if you want me to explain it just say it, if u want to add more spells to be learned u must configure creaturescripts/sharingan.lua, and add:
Code:
doPlayerLearnSpellRandomProb(cid, 12002, 'kaiten', 300)
'kaiten' ->name of the spell
300 -> probability from 1 to 300 to learn the spell
If u like it Rep++
Last edited: