Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local config = {
- vocations = {
- -------------------------------------------
- -- None
- -------------------------------------------
- [0] = {
- numberOfSummons = 2,
- specficSummons = {},
- },
- -------------------------------------------
- -- Sorcerer
- -------------------------------------------
- [1] = {
- numberOfSummons = 2,
- specficSummons = {},
- },
- -------------------------------------------
- -- Maser Sorcerer
- -------------------------------------------
- [5] = {
- numberOfSummons = 2,
- specficSummons = {},
- },
- -------------------------------------------
- -- Necromancer
- -------------------------------------------
- [9] = {
- numberOfSummons = 3,
- specficSummons = {'undertanker'},
- -------------------------------------------
- -- Wizard
- -------------------------------------------
- [10] = {
- numberOfSummons = 2,
- specficSummons = {},
- },
- -------------------------------------------
- -- Druid
- -------------------------------------------
- [2] = {
- numberOfSummons = 2,
- specficSummons = {},
- },
- -------------------------------------------
- -- Elder Druid
- -------------------------------------------
- [6] = {
- numberOfSummons = 2,
- specficSummons = {},
- -------------------------------------------
- -- Frost Mage
- -------------------------------------------
- [13] = {
- numberOfSummons = 2,
- specficSummons = {},
- -------------------------------------------
- -- Sage
- -------------------------------------------
- [14] = {
- numberOfSummons = 2,
- specficSummons = {},
- -------------------------------------------
- -- Paladin
- -------------------------------------------
- [3] = {
- numberOfSummons = 2,
- specficSummons = {},
- -------------------------------------------
- -- Royal Paladin
- -------------------------------------------
- [7] = {
- numberOfSummons = 2,
- specficSummons = {},
- -------------------------------------------
- -- Assassin
- -------------------------------------------
- [15] = {
- numberOfSummons = 2,
- specficSummons = {},
- -------------------------------------------
- -- Defender
- -------------------------------------------
- [16] = {
- numberOfSummons = 2,
- specficSummons = {},
- -------------------------------------------
- -- Knight
- -------------------------------------------
- [4] = {
- numberOfSummons = 2,
- specficSummons = {},
- -------------------------------------------
- -- Elite Knight
- -------------------------------------------
- [8] = {
- numberOfSummons = 2,
- specficSummons = {},
- -------------------------------------------
- -- Barbarian
- -------------------------------------------
- [11] = {
- numberOfSummons = 2,
- specficSummons = {},
- -------------------------------------------
- -- Templet
- -------------------------------------------
- [12] = {
- numberOfSummons = 2,
- specficSummons = {},
- function onCastSpell(creature, variant)
- local monsterName = variant:getString()
- local monsterType = MonsterType(monsterName)
- local vocation = creature:getVocation():getId())
- if not monsterType then
- creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
- creature:getPosition():sendMagicEffect(CONST_ME_POFF)
- return false
- end
- if not getPlayerFlagValue(creature, PlayerFlag_CanSummonAll) then
- if not monsterType:isSummonable() then
- creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
- creature:getPosition():sendMagicEffect(CONST_ME_POFF)
- return false
- end
- if #creature:getSummons() >= config[vocation].numberOfSummons then
- creature:sendCancelMessage("You cannot summon more creatures.")
- creature:getPosition():sendMagicEffect(CONST_ME_POFF)
- return false
- end
- end
- local manaCost = monsterType:getManaCost()
- if creature:getMana() < manaCost and not getPlayerFlagValue(creature, PlayerFlag_HasInfiniteMana) then
- creature:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA)
- creature:getPosition():sendMagicEffect(CONST_ME_POFF)
- return false
- end
- for k,v in pairs(config) do
- if isInArray(v.specficSummons, monsterName) then
- if k ~= vocation then
- creature:sendCancelMessage("You cannot summon this creature.")
- creature:getPosition():sendMagicEffect(CONST_ME_POFF)
- return false
- end
- end
- end
- local position = creature:getPosition()
- local summon = Game.createMonster(monsterName, position, true)
- if not summon then
- creature:sendCancelMessage(RETURNVALUE_NOTENOUGHROOM)
- position:sendMagicEffect(CONST_ME_POFF)
- return false
- end
- creature:addMana(-manaCost)
- creature:addManaSpent(manaCost)
- creature:addSummon(summon)
- position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
- summon:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement