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

Spell which make summon depend on vocation

BugaS

Donżuan
Joined
Mar 12, 2009
Messages
1,219
Reaction score
9
Location
NYC
Hey guys!

I'm looking for a spell which will make ONLY one summon but it make a summon depend on vocation. For example Sorcerer will make fire elemental, Knight rat etc.

Is it possible? I'm using tfs 0.4
 
Solution
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...
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
 
Solution
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

Is there an easy way to update scripts like these to TFS 1.3? (for noobs like me)?

Cuz this one looks AWESOME! But for some reason these people won't update their TFS. So all the old scripts and new good ones are unusable for people who are CURRENTLY involved in the community.
 
Back
Top