• 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!

Spell Upgrade. HELP

Klank

Althea ¤ A New World Developer
Joined
Feb 21, 2008
Messages
1,093
Reaction score
659
Location
Norway
Hello.

I was thiking of a uniqe spell system on my ot. That players have to upgrade there spells to get them stronger. (0/5)

And at each level they would get 1 spell point.
But i wonder if anyone got a script for a npc that you can buy this upgrade for 1 spell point.

Also script for spell point each lvl.

This is just to get a harder start.

Thank you. :D
 
Okay :) I'll try that when I get back home :p but check out what I changed to the NPC so it makes it have a little more "Effect" also I added a thing so that you can have more then 5 on one spell or less on another etc... Here it is :p

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)			npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)			npcHandler:onCreatureSay(cid, type, msg) end
function onThink()					npcHandler:onThink() end
 
function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
 
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	local storage = 16002
 
 
local sorcspells = {
	["Flame Strike"] = {upgrade = 5, cost = 2, storage = 18001}, 	
	["Hells Core"] = {upgrade = 3, cost = 5, storage = 18002} 
}
local druidspells = {
	["Frigo Strike"] = {upgrade = 5, cost = 2, storage = 18101}, 	
	["Eternal Winter"] = {upgrade = 3, cost = 5, storage = 18102} 
}
local pallyspells = {
	["Ethereal Spear"] = {upgrade = 5, cost = 2, storage = 18201}, 	
	["Divine Caldera"] = {upgrade = 3, cost = 5, storage = 18202} 
}
local knightspells = {
	["Berserk"] = {upgrade = 5, cost = 2, storage = 18301}, 	
	["Fierce Berserk"] = {upgrade = 3, cost = 5, storage = 18302} 
}
 
	for v = 18000, 18400 do
		if getPlayerStorageValue(cid, v) == -1 then
			setPlayerStorageValue(cid, v, 0)
		end
	end
 
	if(getPlayerVocation(cid) == 1) or (getPlayerVocation(cid) == 5) then
		x = sorcspells[msg]
	end
	if(getPlayerVocation(cid) == 2) or (getPlayerVocation(cid) == 6) then
		x = druidspells[msg]
	end
	if(getPlayerVocation(cid) == 3) or (getPlayerVocation(cid) == 7) then
		x = pallyspells[msg]
	end
	if(getPlayerVocation(cid) == 4) or (getPlayerVocation(cid) == 8) then
		x = knightspells[msg]
	end
 
	if x then 
		if getPlayerStorageValue(cid, storage) >= x.cost then
			if getPlayerStorageValue(cid, x.storage) < x.upgrade then
				setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) - x.cost)
				setPlayerStorageValue(cid, x.storage, getPlayerStorageValue(cid, x.storage) + 1)
				selfSay('You have upgraded the spell "'..msg..'" to ['..getPlayerStorageValue(cid, x.storage)..'/'..x.upgrade..'] for '..x.cost..' points. You now have '..getPlayerStorageValue(cid, storage)..' points left.', cid)
			else
				selfSay('You have already upgraded this spell '..x.upgrade..' times.', cid)
			end
		else
			selfSay('You need '..x.cost..' points to upgrade this spell. You only have '..getPlayerStorageValue(cid, storage)..' points currently. ', cid)
		end
	end
 
	local info = (msgcontains(msg, 'info'))
	if info then
		selfSay('Each time you level up, you receive 1 point, with those points you can upgrade your spells. You currently have '..getPlayerStorageValue(cid, storage)..' points. You can see the spells you can upgrade in the {list}.', cid)
	end
 
	local list = (msgcontains(msg, 'list'))
	if list then
		if(getPlayerVocation(cid) == 1) or (getPlayerVocation(cid) == 5) then
		text = 'Spells available for Sorcerers:\n'
			for i, x in pairs(sorcspells) do
				text = text .. "\n" .. i .. " - ["..getPlayerStorageValue(cid, x.storage).."/"..x.upgrade.."]"
			end
			doShowTextDialog(cid, 6120, "" .. text)
		end
		if(getPlayerVocation(cid) == 2) or (getPlayerVocation(cid) == 6) then
		text = 'Spells available for Druids:\n'
			for i, x in pairs(druidspells) do
				text = text .. "\n" .. i .. " - ["..getPlayerStorageValue(cid, x.storage).."/"..x.upgrade.."]"
			end
			doShowTextDialog(cid, 6120, "" .. text)
		end
		if(getPlayerVocation(cid) == 3) or (getPlayerVocation(cid) == 7) then
		text = 'Spells available for Paladins:\n'
			for i, x in pairs(pallyspells) do
				text = text .. "\n" .. i .. " - ["..getPlayerStorageValue(cid, x.storage).."/"..x.upgrade.."]"
			end
			doShowTextDialog(cid, 6120, "" .. text)
		end
		if(getPlayerVocation(cid) == 4) or (getPlayerVocation(cid) == 8) then
		text = 'Spells available for Knights:\n'
			for i, x in pairs(knightspells) do
				text = text .. "\n" .. i .. " - ["..getPlayerStorageValue(cid, x.storage).."/"..x.upgrade.."]"
			end
			doShowTextDialog(cid, 6120, "" .. text)
		end
	end
 
	if not x and not list and not info then
		selfSay('What? If you want to get a spell make sure to be proper. Example: Frigo Strike = {Frigo Strike}. Not "frigo strike."', cid)
	end
	return true
end
 
 
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Hehe :) Thanks :p But is there any way so that you don't have to be specific so instead of saying "Frigo Strike" you can say "frigo strike" and it'll still work? I changed this part:
selfSay('What? If you want to get a spell make sure to be proper. Example: Frigo Strike = {Frigo Strike}. Not "frigo strike."', cid)
Since I couldn't figure it out :/ Also, how do you make it so when they say Example: Frigo Strike, the NPC will ask Would you like to upgrade the spell '..msg..' for '..x.cost..' points?
 
For the capital problem add this funtion to the NPC
Lua:
	local function addCap(first, rest)
  		return first:upper()..rest:lower()
	end
Then add :gsub("(%a)([%w_']*)", addCap) behind every x = voc[msg]
Sorc example
Lua:
	x = sorcspells[msg:gsub("(%a)([%w_']*)", addCap)]

For the yes part, that's not possible like this because else the yes becomes the msg instead of the spell name.
 
Last edited:
It works! :D Thank you so much but btw I found out a bug yesterday that I feared would happen :/ but when you die and lose a level, if you get that level back you will get an extra point.. It's this script:

Lua:
function onAdvance(cid, skill, oldlevel, newlevel)
local storage = 16002
 
    	if skill == SKILL_LEVEL then
		if getPlayerStorageValue(cid, storage) == -1 then
			setPlayerStorageValue(cid, storage, 0)
		end
		setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) + 1)
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You have been granted 1 spell upgrading point. You now have ".. getPlayerStorageValue(cid, 16002) .." points.")				
   	end
	return true
end

I saw somewhere that had NEWSKILL_LEVEL or something in this part:
Lua:
	if skill == SKILL_LEVEL then
But it didn't work xD
The only other thing I could think would to be make a storage that would start at = 8 so when you get to main once you get 9 it'll set to 9 and so on, but once you die if you get level 9 back... then it won't give you your points since the storage is already 9... if that makes sense? So like it'll compare your level with the storage = ~

If it doesn't make sense I'll try to explain it better xD
 
Woot! It works! :D

Lua:
function onAdvance(cid, skill, oldlevel, newlevel)
local storage = 16002
local levelstorage = 16003
 
    	if skill == SKILL_LEVEL then	
		if getPlayerStorageValue(cid, levelstorage) == -1 then
			setPlayerStorageValue(cid, levelstorage, 8)
		end		
		if getPlayerStorageValue(cid, storage) == -1 then
			setPlayerStorageValue(cid, storage, 0)
		end
		if getPlayerLevel(cid) > getPlayerStorageValue(cid, levelstorage) then
		setPlayerStorageValue(cid, levelstorage, getPlayerStorageValue(cid, levelstorage) + 1)
		setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) + 1)
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You have been granted 1 spell upgrading point. You now have ".. getPlayerStorageValue(cid, 16002) .." points.")				
		end
	end
	return true
end
 
Limos this is awesome , thank you! I got one more question for u at this script. When the player buys the upgrade, it will pop up a red message saying // Exori frigo is now upgraded to (2/5)

You think you can fix that ? :D

Dont really know how far i get on this server, since the other 2 guys dont got time ;/
 
Last edited:
In the edited version from EnforcedRPG, the NPC is already saying this, if you want players to get it as a normal message in red you can just use doPlayerSendTextMessage with 21.
 
Last edited:
Back
Top