Codex NG
Recurrent Flamer
- Joined
- Jul 24, 2015
- Messages
- 2,994
- Solutions
- 12
- Reaction score
- 1,657
So what this does is, it will allow you to basically conjure anything you specify, this is a spell not a talkaction.
If there is a space in the words, you have place a double quote in front of the words, just like you would with heal friend.
Example:
@Zothion Version
Code:
function aOrAn(word)
local vowels = {'a', 'e', 'i', 'o', 'u', 'x'}
return isInArray(vowels, word:sub(1, 1):lower()) and 'an '..word or 'a '..word
end
local spells = {
["adori blank"] = { lvl = 20, mana = 50, conjureId = 2260, charges = 1},
["exevo con"] = { lvl = 13, mana = 100, conjureId = 2544, charges = 15},
}
local blank = {itemid = 2260, count = 1}
function onCastSpell(creature, var)
if not creature:isPlayer() then
return false
end
local words = var['string']
if words then
if spells[words] then
if creature:getLevel() >= spells[words].lvl then
if creature:getMana() >= spells[words].mana then
if creature:getItemCount(blank.itemid) >= blank.count then
creature:addItem(spells[words].conjureId, spells[words].charges)
creature:removeItem(blank.itemid, blank.count)
else
local name = ItemType(blank.itemid):getName()
creature:sendCancelMessage("You don't have enough ".. name.. "s, you need atleast "..blank.count ..' ' .. name .." to cast this spell.")
end
else
creature:sendCancelMessage("You don't have enough mana, you need "..spells[words].mana .. " mana to create this item")
end
else
creature:sendCancelMessage("You cannot conjure "..aOrAn(words)..", you need to be level "..spells[words].lvl..".")
end
else
creature:sendCancelMessage("You cannot conjure "..aOrAn(words))
end
end
return true
end
Code:
<instant spellid="175" name="test" words="conjure" params="1" aggressive="0" script="test.lua" />
If there is a space in the words, you have place a double quote in front of the words, just like you would with heal friend.
Example:
Code:
conjure "exevo con
@Zothion Version
Code:
local function aOrAn(word)
local vowels = {'a', 'e', 'i', 'o', 'u', 'x'}
return isInArray(vowels, word:sub(1, 1):lower()) and 'an '..word or 'a '..word
end
local spells = {
["blank"] = { mana = 20, conjureId = 2260, allowPz = 1, charges = 1},
["arrows"] = { lvl = 13, mana = 100, conjureId = 2544, allowPz = 1, soul = 1, charges = 15, vocations = {4,12}},
["sd"] = { lvl = 45, mana = 200, conjureId = 2268, allowPz = 0, soul = 10, charges = 3, reagents = {{2260, 1}}, vocations = {4, 12}},
}
local function gotReagents(player, word)
if spells[word].reagents ~= nil then
for i=1,#(spells[word].reagents),1 do
if player:getItemCount((spells[word].reagents)[i][1]) < ((spells[word].reagents)[i][2]) then
player:sendCancelMessage("You are missing "..(spells[word].reagents)[i][2].." "..getItemName((spells[word].reagents)[i][1]))
return false
end
end
end
return true
end
local blank = 2260
function onCastSpell(creature, var)
if not creature:isPlayer() then
return false
end
local words = (var['string']):lower()
if spells[words] then
if (not spells[words].lvl) or (getPlayerLevel(creature) >= spells[words].lvl) then
if (not spells[words].mana) or (creature:getMana() >= spells[words].mana) then
if (not spells[words].soul) or (creature:getSoul() >= spells[words].soul) then
if (not spells[words].vocations) or isInArray(spells[words].vocations, getPlayerVocation(creature)) then
if (spells[words].reagents == nil) or gotReagents(creature, words) then
local pz = getTilePzInfo(getCreaturePosition(creature))
if not pz or (pz == spells[words].allowPz) then
if spells[words].reagents ~= nil then
for i=1,#(spells[words].reagents),1 do
creature:removeItem((spells[words].reagents)[i][1], (spells[words].reagents)[i][2])
end
end
creature:addItem(spells[words].conjureId, spells[words].charges)
creature:addMana(-((spells[words].mana) or 0))
creature:addManaSpent((spells[words].mana) or 0)
creature:addSoul(-((spells[words].soul) or 0))
creature:say("conjure "..words, TALKTYPE_MONSTER_SAY)
creature:sendTextMessage(creature, MESSAGE_STATUS_CONSOLE_BLUE, "You succesfully conjured "..spells[words].charges.." "..getItemName(spells[words].conjureId).."s.")
doSendMagicEffect(getCreaturePosition(creature), CONST_ME_TELEPORT)
else
creature:sendCancelMessage("You cannot conjure "..aOrAn(words).." inside a protection zone.")
end
else
return false
end
else
creature:sendCancelMessage("Your vocation cannot use that spell.")
end
else
creature:sendCancelMessage("You need "..spells[words].soul.." soul to cast that spell.")
end
else
creature:sendCancelMessage("You don't have enough mana, you need "..spells[words].mana .. " mana to create this item")
end
else
creature:sendCancelMessage("You do not have enough level to conjure "..aOrAn(words)..".")
end
else
creature:sendCancelMessage("You cannot conjure "..aOrAn(words))
end
return false
end
Last edited: