Codex NG
Recurrent Flamer
- Joined
- Jul 24, 2015
- Messages
- 2,994
- Solutions
- 12
- Reaction score
- 1,657
I wrote this some time ago back on another account and sadly removed it from the forums.
It was originally written for 1.0, but does work for 1.2
This should be placed in the global.lua
This is saved in chatchannels
data\chatchannels\chatchannels.xml
data\chatchannels\scripts\spells.lua
Example:
data\actions\scripts\spells.lua
Example in a spell
It was originally written for 1.0, but does work for 1.2
This should be placed in the global.lua
Code:
function upGradeSpells(player, words, tier, max)
if player:getStorageValue(SPELL_WORDS[words]) < max then
if player:getStorageValue(SPELL_WORDS[words]) < TIER[tier] then
player:setStorageValue(SPELL_WORDS[words], TIER[tier])
player:getPosition():sendMagicEffect(CONST_ME_CONFETTI_HORIZONTAL)
doCreatureSay(cid, tier, TALKTYPE_ORANGE_1, false, 0, player:getPosition())
elseif player:getStorageValue(SPELL_WORDS[words]) == TIER[tier] then
player:sendCancelMessage("You've already scribed a this version of the spell.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
else
player:sendCancelMessage("You already have a higher spell version scribed.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
else
player:sendCancelMessage("You've reached the maximum tier for this spell.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
end
Code:
--light, haste, single targets, area, single target heal, support spell, speed
SPELL_WORDS =
{
["exura dis"] = 1001,
["exevo dis flam hur"] = 1002,
["exiva"] = 1003,
["exori min flam"] = 1004,
["utevo lux"] = 1005,
["exura"] = 1006,
["exani tera"] = 1007,
["exura ico"] = 1008,
["exana pox"] = 1009,
["exani hur"] = 10010,
["exori vis"] = 10011,
["exori tera"] = 10012,
["exevo con"] = 10013,
["utevo gran lux"] = 10014,
["exori flam"] = 10015,
["exevo pan"] = 10016,
["adevo grav pox"] = 10017,
["utamo vita"] = 10018,
["utani hur"] = 10019,
["adevo grav flam"] = 10020,
["exori frigo"] = 10021,
["adori min vis"] = 10022,
["adana pox"] = 10023,
["adura gran"] = 10024,
["exori moe ico"] = 10025,
["exevo con pox"] = 10026,
["exori mort"] = 10027,
["exori ico"] = 10028,
["adeta sio"] = 10029,
["adito grav"] = 10030,
["exevo con mort"] = 10031,
["adevo grav vis"] = 10032,
["exevo flam hur"] = 10033,
["exura sio"] = 10034,
["exevo frigo hur"] = 10035,
["exura gran"] = 10036,
["utani gran hur"] = 10037,
["exeta res"] = 10038,
["adori blank"] = 10039,
["adito tera"] = 10040,
["exana vis"] = 10041,
["exevo vis lux"] = 10042,
["utevo res ina"] = 10043,
["exori con"] = 10044,
["exevo con hur"] = 10045,
["adori tera"] = 10046,
["adura vita"] = 10047,
["adevo mas pox"] = 10048,
["adori vis"] = 10049,
["exevo con flam"] = 10050,
["utani tempo hur"] = 10051,
["utevo res"] = 10052,
["utori flam"] = 10053,
["utevo vis lux"] = 10054,
["exana ina"] = 10055,
["adevo mas flam"] = 10056,
["adevo res flam"] = 10057,
["adori san"] = 10058,
["adori flam"] = 10059,
["adevo ina"] = 10060,
["adana mort"] = 10061,
["adevo grav vita"] = 10062,
["adori frigo"] = 10063,
["exori hur"] = 10064,
["adori mas vis"] = 10065,
["adori mas tera"] = 10066,
["exevo gran vis lux"] = 10067,
["adevo mas grav pox"] = 10068,
["exura vita"] = 10069,
["exana flam"] = 10070,
["adori mas frigo"] = 10071,
["adori mas flam"] = 10072,
["adevo mas hur"] = 10073,
["adevo grav tera"] = 10074,
["utura mas sio"] = 10075,
["utori mas sio"] = 10076,
["utito mas sio"] = 10077,
["utamo mas sio"] = 10078,
["adevo mas grav flam"] = 10079,
["exevo con grav"] = 10080,
["exori mas"] = 10081,
["utori vis"] = 10082,
["utana vid"] = 10083,
["exori"] = 10084,
["exura san"] = 10085,
["exura gran mas res"] = 10086,
["adevo mas vis"] = 10087,
["exevo vis hur"] = 10088,
["exevo tera hur"] = 10089,
["exori san"] = 10090,
["exevo gran frigo hur"] = 10091,
["utori kor"] = 10092,
["adevo mas grav vis"] = 10093,
["exeta vis"] = 10094,
["exeta con"] = 10095,
["exana kor"] = 10096,
["adori gran mort"] = 10097,
["utura"] = 10098,
["utori pox"] = 10099,
["exevo mas san"] = 100100,
["adana ani"] = 100101,
["utamo tempo san"] = 100102,
["exevo gran mas tera"] = 100103,
["utamo tempo"] = 100104,
["exevo gran mas vis"] = 100105,
["exori amp vis"] = 100106,
["exevo con vis"] = 100107,
["utito tempo san"] = 100108,
["exura gran san"] = 100109,
["exevo gran mas frigo"] = 100110,
["exevo gran mas flam"] = 100111,
["utito tempo"] = 100112,
["exori gran tera"] = 100113,
["exori gran flam"] = 100114,
["exori min"] = 100115,
["utori san"] = 100116,
["utori mort"] = 100117,
["exori gran vis"] = 100118,
["exana mort"] = 100119,
["exura gran ico"] = 100120,
["exori gran frigo"] = 100121,
["exori max flam"] = 100122,
["exori max tera"] = 100123,
["exori gran con"] = 100124,
["exori gran"] = 100125,
["exori max frigo"] = 100126,
["exori max vis"] = 100127,
["utura gran"] = 100128,
["exori gran ico"] = 100129
}
TIER =
{
["Apprentice"] = 0,
["Journeyman"] = 1,
["Adept"] = 2,
["Expert"] = 3,
["Master"] = 4,
["Grandmaster"] = 5
}
This is saved in chatchannels
data\chatchannels\chatchannels.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<channels>
<channel id="2" name="Tutor" script="tutor.lua" />
<channel id="3" name="World Chat" public="1" script="worldchat.lua" />
<channel id="4" name="Spells" public="1" script="spells.lua" />
<channel id="5" name="Trade" public="1" script="advertising.lua" />
<channel id="6" name="Advertising-Rookgaard" public="1" script="advertising-rook.lua" />
<channel id="7" name="Help" public="1" script="help.lua" />
<channel id="8" name="Gamemaster" script="gamemaster.lua" />
</channels>
data\chatchannels\scripts\spells.lua
Code:
local CHANNEL_CHARACTER = 4
local tier =
{
[0] = "[ Apprentice ]",
[1] = "[ Journeyman ]",
[2] = "[ Adept ]",
[3] = "[ Expert ]",
[4] = "[ Master ]",
[5] = "[ Grandmaster ]"
}
local function listSpells(player)
local count = getPlayerInstantSpellCount(player)
local text = ""
local t = {}
for i = 0, count - 1 do
local spell = getPlayerInstantSpellInfo(player, i)
if spell.level ~= 0 then
if spell.manapercent > 0 then
spell.mana = spell.manapercent .. "%"
end
t[#t+1] = spell
end
end
table.sort(t, function(a, b) return a.level < b.level end)
local prevLevel = -1
for i, spell in ipairs(t) do
local line = ""
if prevLevel ~= spell.level then
if i ~= 1 then
line = "\n"
end
line = line .. "\nSpells for Level " .. spell.level .. "\n"
prevLevel = spell.level
player:sendChannelMessage(cid, line, TALKTYPE_CHANNEL_O, CHANNEL_CHARACTER)
end
if player:getStorageValue(SPELL_WORDS[spell.words]) > 0 then
local index = player:getStorageValue(SPELL_WORDS[spell.words])
text = " " .. spell.words .. " " .. tier[index] .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
else
text = " " .. spell.words .. " " .. tier[0] .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
end
player:sendChannelMessage(cid, text, TALKTYPE_CHANNEL_Y, CHANNEL_CHARACTER)
end
end
function onJoin(player)
addEvent(listSpells, 100, player)
return true
end
function onSpeak(player, type, message)
player:sendCancelMessage("You may not speak in this chat.")
return false
end
data\actions\scripts\spells.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
upGradeSpells(cid, "exevo pan", 1, item)
return true
end
Example in a spell
Code:
local food = {
2666, -- meat
2671, -- ham
2681, -- grape
2674, -- apple
2689, -- bread
2690, -- roll
2696 -- cheese
}
function onCastSpell(creature, var)
if not creature:isPlayer() then
return false
end
if creature:getStorageValue(SPELL_WORDS["exevo pan"]) > 0 then
-- if the tier is higher then apprentice increase the amount of food created
creature:addItem(food[math.random(#food)], (creature:getStorageValue(SPELL_WORDS["exevo pan"]) + 1))
creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
else
-- else give 1 piece of food
creature:addItem(food[math.random(#food)], 1)
creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
end
return true
end
Last edited: