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

Leveling Up Spells and Potions

Werewolf

Forbidden Ascension
Joined
Jul 15, 2012
Messages
886
Reaction score
123
IM sorry if this seems like a rather Large Request but my Players asked that the level up spell/potion script be added to the server, However i am unable to make it.

My players have described this script to be like so:

Each Spells has a Level up script, each time you use a spell. it gains exp, once it hits X amount of exp it levels up. When the spell levels up. the spell itself becomes a little bit stronger. like Increased Magiclevel/ Skill Damage Multiplier + 0.2% Per level up, with a max level up of level 20-50 (how ever much is possible, more = better

The Potions Work in the same way as the spells, Use the potions to gain exp, upon level up. the healing amount is increased.


If someone has a script like this, Or is Willing to make it. My players will be very grateful for your assistance as would i.

Thank you for reading my Post and i hope someone would be very kind as to answer such a giant request such as this.

Rep++
and personal Respect++
 
All i really need is One spell with this system, and i will be able to make the rest of the spells myself, i just need to know how the script works ( in script form, not idea)
 
Last edited:
Here is an example of one of my spells
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_USECHARGES, true)

function onGetFormulaValues(cid, level, skill, attack, factor)
    local skillTotal, levelTotal = skill + attack, level / 5
    return -(skillTotal * 3.0 + levelTotal), -(skillTotal * 3 + levelTotal)
end

local condition = createConditionObject(CONDITION_PHYSICAL)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 0)
addDamageCondition(condition, 10, 100, -10)
setCombatCondition(combat, condition)

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
 
Well...
There are a few ways to make a system like this, however all of them are more or less complicated and require a lot of work.
1) Completly in lua:
this system requires the most changes as you have to change each lua file (all spells and potions) as it's individual.
2) Slight source changes + lua:
probably the easiest way if you are a bit familiar with c++ and the source code of your engine.
you just need to to make the changes in the right sections in c++ so you save a lot of time and don't have to edit every single lua file.
3) Completly in sources:
Fastest way if you know what you do but hard to edit the formulas if you change them very often as you have to re compile everytime.

Choose which you prefer and I'll provide you some basic code, on how to build it accordingly.


Kind regards, Evil Hero.
 
i think Option
1) Completely in lua:
this system requires the most changes as you have to change each lua file (all spells and potions) as it's

is best suited, For i am Re-Making all my spells anyways.
Is anyone capable of making just 1 or maybe 2 Example spells that use this system?
All i need is an example script and i'll be able to make it for the rest of my spells easily. i just don't know how to make this script till i see one that works.
 
ok just made this quickly (however havn't tested it)
Code:
spellStartValue = 5000
spells =
{
   {name="TESTSPELL", maxLevel = 50, multiplier = 1.0},
   {name="TESTSPELL2", maxLevel = 30, multiplier = 1.3}
}

function getSpellLevel(cid, name)
   for i = 1,#spells do
     if spells[i].name == name then
       return getPlayerStorageValue(cid,(spellStartValue + (i * 2 - 1)))
     else
       print("ERROR: Spell is not listed")
     end
   end
end

function spentSpell(cid, name)
   for i = 1,#spells do
     if spells[i].name == name then
       if getSpellLevel(cid, name) < getSpellMaxLevel(name) then
         local multi = spells[i].multiplier
         setPlayerStorageValue(cid, (spellStartValue + (i * 2)), getPlayerStorageValue(cid,(spellStartValue + (i * 2))) + (20 * multi))
         if getSpellSpentFormula(getSpellLevel(cid, name)) < getSpellSpent(cid, name) then
           doPlayerSendTextMessage(cid, 22, "You have advanced your spell: ".. spells[i].name .." from level ".. getSpellLevel(cid, name) .." to ".. getSpellLevel(cid, name) + 1 ..".")
           setPlayerStorageValue(cid, (spellStartValue + (i * 2 - 1)), getSpellLevel(cid, name) + 1)
         end
       end
     else
       print("ERROR: Spell is not listed")
     end
   end
end

function getSpellSpentFormula(lvl)
   return lvl == 1 and 100 or (100 * lvl)
end

function getSpellMaxLevel(name)
   for i = 1,#spells do
     if spells[i].name == name then
       return spells[i].maxLevel
     else
       print("ERROR: Spell is not listed")
     end
   end
end

function getSpellSpent(cid, name)
   for i = 1,#spells do
     if spells[i].name == name then
       return getPlayerStorageValue(cid,(spellStartValue + (i * 2)))
     else
       print("ERROR: Spell is not listed")
     end
   end
end
just put that entire thing into 102-spells.lua

here a version of your spell with my functions included.
Code:
local spellName = "TESTSPELL"
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_USECHARGES, true)

function onGetFormulaValues(cid, level, skill, attack, factor)
local spellLvl = getSpellLevel(cid, spellName)
local skillTotal, levelTotal = skill + attack, level / 5
   return -((skillTotal * 3.0 + levelTotal) + (((skillTotal * 3.0 + levelTotal) * spellLvl) * 0.22)) , -(((skillTotal * 3 + levelTotal) + (((skillTotal * 3 + levelTotal) * spellLvl) * 0.22))
end

local condition = createConditionObject(CONDITION_PHYSICAL)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 0)
addDamageCondition(condition, 10, 100, -10)
setCombatCondition(combat, condition)

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(cid, var)
local ret = false
   if doCombat(cid, combat, var) then
     spentSpell(cid, spellName)
     ret = true
   end
   return ret
end

as said it is not tested neither is the formula any good just made you a quick example on how to do it.
if you have further questions just feel free to post them.

Kind regards, Evil Hero.
 
Last edited:
Back
Top