• 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 Volatile Spiderling

kamilwxx

This account is inactive.
Joined
Dec 7, 2013
Messages
86
Reaction score
19
Volatile Spiderling
forgottenserver 1.0

FjnkO.gif

Summons a spider that remains on the field for up to 5 seconds. At the end of its duration or when dying the spider will explode, dealing poison damage to nearby enemies and poisoning them.
  • data/creaturescripts/creaturescripts.xml
    Code:
        <event type="death" name="VolatileSpiderling" script="volatilespiderling.lua"/>
  • data/creaturescripts/scripts/volatilespiderling.lua
    Code:
    local combat = Combat()
    combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_POISONDAMAGE)
    combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_POISONAREA)
    combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -0.4, 0, -0.5, 0)
    combat:setArea(createCombatArea(AREA_CROSS1X1))
    
    local condition = Condition(CONDITION_POISON)
    condition:setParameter(condition, CONDITION_PARAM_DELAYED, 1)
    
    local damageTable = {
        {4, -3},
        {9, -2},
        {20, -1}
    }
    for i = 1, #damageTable do
        local t = damageTable[i]
        condition:addDamage(t[1], 4000, t[2])
    end
    
    combat:setCondition(condition)
    
    
    function onDeath(cid, ...)
        local creature = Creature(cid)
        combat:execute(creature, numberToVariant(cid))
        return true
    end
  • data/spells/spells.xml

    Code:
            <instant group="attack" spellid="9" name="Volatile Spiderling" words="utevo res tera" lvl="40" mana="0" selftarget="1" prem="1" exhaustion="2000" groupcooldown="2000" needlearn="0" script="attack/volatile spiderling.lua">
                    <vocation name="Paladin"/>
                    <vocation name="Royal Paladin"/>
            </instant>
  • data/spells/scripts/attack/volatile spiderling.lua
    Code:
    local combat = Combat()
    combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_POISONDAMAGE)
    combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_POISONAREA)
    combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -0.4, 0, -0.5, 0)
    combat:setArea(createCombatArea(AREA_CROSS1X1))
    
    local condition = Condition(CONDITION_POISON)
    condition:setParameter(condition, CONDITION_PARAM_DELAYED, 1)
    
    local damageTable = {
        {4, -3},
        {9, -2},
        {20, -1}
    }
    for i = 1, #damageTable do
        local t = damageTable[i]
        condition:addDamage(t[1], 4000, t[2])
    end
    
    combat:setCondition(condition)
    
    
    function onCastSpell(cid, var)
        local player = Player(cid)
        if player == nil then
            return false
        end
    
        local playerPos = player:getPosition()
        if player:getMana() < 20 then
            player:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA)
            playerPos:sendMagicEffect(CONST_ME_POFF)
            return false
        end
    
        if #player:getSummons() >= 2 then
            player:sendCancelMessage("You cannot summon more creatures.")
            playerPos:sendMagicEffect(CONST_ME_POFF)
            return false
        end
    
        local creatureId = doSummonCreature("Spider", playerPos)
        if creatureId == false then
            player:sendCancelMessage(RET_NOTENOUGHROOM)
            playerPos:sendMagicEffect(CONST_ME_POFF)
            return false
        end
    
        local monster = Monster(creatureId)
        monster:setMaster(player)
        monster:registerEvent("VolatileSpiderling")
    
        addEvent(function(cid)
            local creature = Creature(cid)
            if creature ~= nil then
                combat:execute(creature, numberToVariant(cid))
                creature:getPosition():sendMagicEffect(CONST_ME_HITBYPOISON)
                creature:remove()
            end
        end, 5000, creatureId)
    
        player:addMana(-20)
        player:addManaSpent(20)
    
        monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        playerPos:sendMagicEffect(CONST_ME_MAGIC_BLUE)
        return true
    end
 
Last edited:
Really creative spell.
Great work!

PS: I have a question.
For what it's for?

Code:
local damageTable = {
{4, -3},
{9, -2},
{20, -1}
}
for i = 1, #damageTable do
local t = damageTable[i]
condition:addDamage(t[1], 4000, t[2])
end
 
Last edited:
It adds poison to the condition. Poison damage starts at 3 HP for 4 turns, followed by 9 turns with 2 HP and 20 turns with 1 HP each, which adds up to 50 HP over a period of 2 minutes and 12 seconds (text copied from this article).
 
Really nice bro :) as always :D
 
Would be funnier if the spider chased the target to explode instead (and I developed a similar function for a spell before)
 
How to make a spider not gain experience too?
Thanks
Sorry for double post :/
 
I quite like this spell, but I want the player to be the damager rather than the spider (for loot/pvp/console damage reasons etc).
Plus I wanted the damage to scale based on magic level like every other.

spells\scripts\volatile spiderling.lua
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_POISONDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_POISONAREA)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

local condition = Condition(CONDITION_POISON)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)

local damageTable = {
    {3, -15},
    {4, -10},
    {5, -5},
    {5, -3},
    {5, -2},
    {5, -1}
}

for i = 1, #damageTable do
    local t = damageTable[i]
    condition:addDamage(t[1], 4000, t[2])
end

combat:setCondition(condition)


function onCastSpell(cid, var)
    local player = Player(cid)
    if player == nil then
        return false
    end
 
    local level = player:getLevel()
    local maglevel = player:getMagicLevel()
    local min = (level / 5) + (maglevel * 1.8) + 25
    local max = (level / 5) + (maglevel * 2.85) + 45
    combat:setFormula(COMBAT_FORMULA_DAMAGE, -min, 0, -max, 0)
 
    local playerPos = player:getPosition()
    if #player:getSummons() >= 2 then
        player:sendCancelMessage("You cannot summon more creatures.")
        playerPos:sendMagicEffect(CONST_ME_POFF)
        return false
    end

    local creatureId = doSummonCreature("Spider", playerPos)
    if creatureId == false then
        player:sendCancelMessage(RET_NOTENOUGHROOM)
        playerPos:sendMagicEffect(CONST_ME_POFF)
        return false
    end

    local monster = Monster(creatureId)
    monster:setMaster(player)
    monster:registerEvent("VolatileSpiderling")

    addEvent(function(cid)
        local creature = Creature(cid)
        if creature ~= nil then
            local player = creature:getMaster()
            if player then
                combat:execute(player, numberToVariant(cid))
            else
                combat:execute(creature, numberToVariant(cid))
            end
            creature:getPosition():sendMagicEffect(CONST_ME_HITBYPOISON)
            creature:remove()
        end
    end, 5000, creatureId)

    monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    playerPos:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    return true
end

creaturescripts\scripts\volatilespiderling.lua
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_POISONDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_POISONAREA)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

local condition = Condition(CONDITION_POISON)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)

local damageTable = {
    {3, -15},
    {4, -10},
    {5, -5},
    {5, -3},
    {5, -2},
    {5, -1}
}

for i = 1, #damageTable do
    local t = damageTable[i]
    condition:addDamage(t[1], 4000, t[2])
end

combat:setCondition(condition)

function onDeath(cid, ...)
    local creature = Creature(cid)
    local master = creature:getMaster()
    if master then
        local level = master:getLevel()
        local maglevel = master:getMagicLevel()
        local min = (level / 5) + (maglevel * 1.8) + 25
        local max = (level / 5) + (maglevel * 2.85) + 45
        combat:setFormula(COMBAT_FORMULA_DAMAGE, -min, 0, -max, 0)
        combat:execute(master, numberToVariant(cid))
    else
        combat:setFormula(COMBAT_FORMULA_DAMAGE, -10, 0, -20, 0)
        combat:execute(creature, numberToVariant(cid))
    end
    return true
end

It's also better to have the manacosts in spell.xml, no idea why it's in the script itself:
XML:
<instant group="attack" name="Volatile Spiderling" words="volatile spiderling" lvl="23" mana="60" selftarget="1" prem="1" exhaustion="2000" groupcooldown="2000" needlearn="0" script="attack/volatile spiderling.lua">
 
Last edited:
Back
Top