function getVocationBase(id)
local vocationInfo = getVocationInfo(id)
if vocationInfo.promotedVocation == id then
return vocationInfo.fromVocation
end
return id
end
local config = {
[1] = {monsterName = "Fire Elemental", manaCost = 50},
[2] = {monsterName = "Earth Elemental, manaCost = 50},
[3] = {monsterName = "Minotaur Archer", manaCost = 40},
[4] = {monsterName = "Minotaur Guard", manaCost = 45}
}
function onCastSpell(cid, variant)
local cfg = config[getVocationBase(getPlayerVocation(cid))]
if not cfg then
return false
end
local monsterInfo = getMonsterInfo(cfg.monsterName)
if not monsterInfo then
doPlayerSendCancel(cid...
function getVocationBase(id)
local vocationInfo = getVocationInfo(id)
if vocationInfo.promotedVocation == id then
return vocationInfo.fromVocation
end
return id
end
local config = {
[1] = {monsterName = "Fire Elemental", manaCost = 50},
[2] = {monsterName = "Earth Elemental, manaCost = 50},
[3] = {monsterName = "Minotaur Archer", manaCost = 40},
[4] = {monsterName = "Minotaur Guard", manaCost = 45}
}
function onCastSpell(cid, variant)
local cfg = config[getVocationBase(getPlayerVocation(cid))]
if not cfg then
return false
end
local monsterInfo = getMonsterInfo(cfg.monsterName)
if not monsterInfo then
doPlayerSendCancel(cid, "Monster could not be found.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return false
end
if not getPlayerFlagValue(cid, PlayerFlag_CanSummonAll) then
if not monsterInfo.summonable then
doPlayerSendCancel(cid, "Sorry not possible.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return false
end
if #getCreatureSummons(cid) >= 1 then
doPlayerSendCancel("You cannot summon more creatures.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return false
end
end
if getCreatureMana(cid) < config.manaCost not getPlayerFlagValue(cid, PlayerFlag_HasInfiniteMana) then
doPlayerSendCancel(cid, "Sorry not enough of mana.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return false
end
local summon = doSummonMonster(cid, cfg.monsterName)
if not summon then
doPlayerSendCancel(cid, "Sorry not enough of room.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return false
end
doCreatureAddMana(cid, cfg.manaCost)
doPlayerAddSpentMana(cid, cfg.manaCost)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
return true
end
Urgh hate older tfs....
Code:function getVocationBase(id) local vocationInfo = getVocationInfo(id) if vocationInfo.promotedVocation == id then return vocationInfo.fromVocation end return id end local config = { [1] = {monsterName = "Fire Elemental", manaCost = 50}, [2] = {monsterName = "Earth Elemental, manaCost = 50}, [3] = {monsterName = "Minotaur Archer", manaCost = 40}, [4] = {monsterName = "Minotaur Guard", manaCost = 45} } function onCastSpell(cid, variant) local cfg = config[getVocationBase(getPlayerVocation(cid))] if not cfg then return false end local monsterInfo = getMonsterInfo(cfg.monsterName) if not monsterInfo then doPlayerSendCancel(cid, "Monster could not be found.") doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) return false end if not getPlayerFlagValue(cid, PlayerFlag_CanSummonAll) then if not monsterInfo.summonable then doPlayerSendCancel(cid, "Sorry not possible.") doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) return false end if #getCreatureSummons(cid) >= 1 then doPlayerSendCancel("You cannot summon more creatures.") doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) return false end end if getCreatureMana(cid) < config.manaCost not getPlayerFlagValue(cid, PlayerFlag_HasInfiniteMana) then doPlayerSendCancel(cid, "Sorry not enough of mana.") doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) return false end local summon = doSummonMonster(cid, cfg.monsterName) if not summon then doPlayerSendCancel(cid, "Sorry not enough of room.") doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) return false end doCreatureAddMana(cid, cfg.manaCost) doPlayerAddSpentMana(cid, cfg.manaCost) doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE) return true end