• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Sharingan -> learn spell

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:
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)
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++
 
Last edited:
that is really nice! but... your code is very ugly to see xD (no sense of offence!) and... you have to logout and login for learn the spells?
 
yes that's the problem, I dont know the function to do it at the time u get the storage :S... and yes, its a bit ugly to see i know, i just do it a bit fast and my lua knowledge is not rlly good, I think creaturescript sharingan.lua could be done better :P
 
if it is easy or not, i've not seen it on the forum, so I did and posted on here, instead of saying: 'lol its an easy spell', you could say, 'thanks for sharing it, although its not hard to do', for example
 
Awesome script! This gave me a few ideas for Mangekyo Sharingan and Amaterasu
Now for some criticism, firstly the "Sharingan" you just made is only a
special "perk" Kakashi - The Copy Ninja has, on the real basis of Sharingan,
that ability only allows you to 'perceive' everything that happens(in combat)
so you could have made it that if the player that is being attacked has the
storage of 'Sharingan' then he would be able to play a 50% chance that he
would not receive damage due to the effects of Sharingan.
Overall this is very nice!
Edit: here I tabbed them!
Code:
--Script made by Strack
 
function onLogin(cid)
local tid = getPlayerByNameWildcard(getPlayerName(cid))
 
local pos = getPlayerPosition(cid)
 
local t = {  --storage and spell
	[12001] = {'Chidori'}, 
	[12002] = {'Kaiten'},
}
	if getPlayerLearnedInstantSpell(cid, t[12001][1]) == FALSE then --checks if spell is learned
		if getPlayerStorageValue(cid, 12001) > 0 then --checks for the storage (storage must be same on the spells, every spell have their own storage
			local fors = getPlayerStorageValue(tid, 12001)
			for i = 1, fors do
				local luck = math.random(300) --probability 1 to 300 to learn, the more attacks received from the wanted spells, more value have the storage and then, more time this 'for' is repeated so more probability to learn
				if luck == 1 then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations! You have learned Chidori!")
					doSendMagicEffect(pos, 12)
					doPlayerLearnInstantSpell(cid,t[12001][1])
				break
				else
					doSendMagicEffect(pos, CONST_ME_POFF)
				end
			end
			doPlayerSetStorageValue(cid, 12001, 0)
		end
	end
 
	if getPlayerLearnedInstantSpell(cid, t[12002][1]) == FALSE then
		if getPlayerStorageValue(cid, 12002) > 0 then
			local fors = getPlayerStorageValue(tid, 12002)
			for i = 1, fors do
				local luck = math.random(300)
				if luck == 1 then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations! You have learned Kaiten")
					doSendMagicEffect(pos, 12)
					doPlayerLearnInstantSpell(cid,t[12002][1])
				break
				else
					doSendMagicEffect(pos, CONST_ME_POFF)
				end
			end
			doPlayerSetStorageValue(cid, 12002, 0)
		end
	end
 
return true 
end
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
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")
 
Last edited:
lol its an easy spell


So what you unfriendly son of a *****...Doesn't matter if it's easy or not,even a easy made spell/script can be REALLY REALLY good or cool,so your post is more than meaningless and dumb.


Btw +rep for you for making this spell :D! Love naruto! :D
 
thx all for ur comments i love u like it ^^

@shinmaru
that's true, this sharingan is only a prototype, of course i'm enhancing it with some sh1ts xD
what you say to 50% of chance to not recieve damage, one way could be by using cybershot's elemental shield, and with a chance of 50% it will give u the storage (for 1 second or less) to be invulnerable to attacks, I just did it on another spell and runs perfectly ^^

cybershot divine shields: http://otland.net/f82/mirror-absolute-shields-sp-edition-3-counterattacks-mod-68202/
 
Hey i don't understand... i have TFT Mystic Spirit 0.2.7 and this not work.. Can you tell me where to make "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")"
 
u must put it on spells u want to be learned, before onCastSpell. I have not tested it on mystic so I dont know if it runs properly.

ex: if you want to be learned 'exevo flam hur' you must add on fire wave.lua, before onCastSpell:
Code:
function onTargetCreature(cid, target) 
if getPlayerStorageValue(target, 12000) == 1 then --storage of sharingan its the same on all spells
	if 	getPlayerLearnedInstantSpell(target, 'Fire Wave') == FALSE then -- name of the same spell where u put this
        return doPlayerSetStorageValue(target, xxxxx, getCreatureStorage(target, xxxxx)+1) -- storage that will give, every spell have their own storage
	end
end
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
, change 'x' to an storage you want this spell sets, and in creaturescripts/scripts/sharingan.lua add this:
Code:
doPlayerLearnSpellRandomProb(cid, xxxxxx, 'fire wave', 300)

I hope I've helped u
 
Last edited:
updated, thanks to cybershot for helping on a problem in the function
 
well... that's a first version of the script, its better onThink, instead of onLogin, and can be improved in many ways...
 
Back
Top