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

Lua Aggressive monster spell sometimes heals target.

Dionizy

New Member
Joined
Mar 18, 2018
Messages
15
Reaction score
0
TFS 0.3.6. Sometimes it deals damage correctly, sometimes it heals target. I can't figure out what I'm doing wrong.
Spell script:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DROWNDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WATERBALL)
local function castBolt(parameters)
doCombat(parameters.cid, parameters.combat, parameters.var)
end
function onCastSpell(cid, var)
local parameters = { cid = cid, var = var, combat = combat }
    addEvent(castBolt, 0, parameters)
    addEvent(castBolt, 80, parameters)
    addEvent(castBolt, 160, parameters)
    addEvent(castBolt, 240, parameters)
    addEvent(castBolt, 320, parameters)
    addEvent(castBolt, 400, parameters)
    addEvent(castBolt, 480, parameters)
    addEvent(castBolt, 560, parameters)
    addEvent(castBolt, 640, parameters)
    addEvent(castBolt, 720, parameters)
    return true
    end

Creature file:
XML:
<attack script="monster/waterball.lua" interval="2000"  chance="85" min="-80" max="-105" target="1" />
 
Last edited:
Of course.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Falconus" nameDescription="Falconus" race="blood" experience="12000" speed="320" manacost="0">
    <health now="90000" max="90000"/>
    <look type="229" corpse="6078"/>
    <targetchange interval="2000" chance="25"/>
    <strategy attack="100" defense="0"/>
    <flags>
        <flag summonable="0"/>
        <flag attackable="1"/>
        <flag hostile="1"/>
        <flag illusionable="0"/>
        <flag convinceable="0"/>
        <flag pushable="0"/>
        <flag canpushitems="1"/>
        <flag canpushcreatures="1"/>
        <flag targetdistance="4"/>
        <flag staticattack="90"/>
        <flag runonhealth="2500"/>
    </flags>
    <attacks>
        <attack name="melee" interval="2300" min="-100" max="-500"/>
        <attack name="manadrain" interval="1500" chance="20" radius="6" target="0" min="-225" max="-375">
            <attribute key="areaEffect" value="greenshimmer"/>
        </attack>
        <attack name="lifedrain" interval="2000" chance="20" radius="6" target="0" min="-200" max="-450">
            <attribute key="areaEffect" value="redshimmer"/>
        </attack>
        <attack script="monster/falAva.lua" interval="8500"  chance="50" min="-400" max="-700" />
        <attack script="monster/falSquarewave.lua" interval="2400"  chance="50" min="-300" max="-850" />
        <attack script="monster/falIcebolt.lua" interval="5000"  chance="70" min="-70" max="-100" target="1" />
        <attack script="monster/falUE.lua" interval="3500"  chance="60" min="-400" max="-1000" />
        <attack script="monster/falParal.lua" interval="2500"  chance="20"/>
        <attack script="monster/falIcewave.lua" interval="8200" direction="1" chance="50" min="-300" max="-850" />
        <attack script="monster/falWaterwave.lua" interval="15000" direction="1" chance="50" min="-900" max="-1600" />
        <attack script="monster/falWB.lua" interval="2000"  chance="85" min="-80" max="-105" target="1" />
    </attacks>
    <defenses armor="100" defense="120">
        <defense name="healing" interval="2000" chance="20" min="1000" max="3000">
            <attribute key="areaEffect" value="blueshimmer"/>
        </defense>
        <defense name="speed" interval="3000" chance="30" speedchange="360" duration="7000">
            <attribute key="areaEffect" value="greenshimmer"/>
        </defense>
        <defense name="invisible" interval="4000" chance="20" duration="5000">
            <attribute key="areaEffect" value="blueshimmer"/>
        </defense>
    </defenses>
    <elements>
        <element firePercent="100"/>
        <element icePercent="100"/>
    </elements>
    <immunities>
        <immunity lifedrain="1"/>
        <immunity paralyze="1"/>
        <immunity outfit="1"/>
        <immunity drunk="1"/>
        <immunity invisible="1"/>
    </immunities>
    <loot>
        <item id="2148" countmax="100" chance="100000"/><!-- gold coin -->
        <item id="2148" countmax="25" chance="100000"/><!-- gold coin -->
        <item id="2393" chance="16060"/><!-- giant sword -->
        <item id="2514" chance="12050"/><!-- mastermind shield -->
        <item id="2472" chance="7000"/><!-- magic plate armor -->
        <item id="1987" chance="100000"><!-- bag -->
            <inside>
                <item id="2678" countmax="3" chance="20000"/><!-- coconut -->
                <item id="2148" countmax="100" chance="100000"/><!-- gold coin -->
                <item id="2151" countmax="4" chance="12000"/><!-- talon -->
                <item id="5903" chance="100000"/><!-- ferumbras' hat -->
                <item id="2149" countmax="3" chance="15000"/><!-- small emerald -->
                <item id="2171" chance="30000"/><!-- platinum amulet -->
                <item id="2415" chance="6000"/><!-- great axe -->
            </inside>
        </item>
    </loot>
</monster>
 
No, it's not. Removing manadrain didn't help. I'm just curious why did you suggest that, is there some kind of bug connected with manadrain in 0.3.6 or what?
 
Nevermind, fixed it my way.
It's an offensive spell for a water mage boss that shoots 10 waterballs to a single target, every shot deals 80 - 105 drown type damage. Almost fixed it, I think it needs some kind of position refresh, all the bolts hit the same spot even if the character is running.
Lua:
local function castWaterballSegment1(cid, target, casterpos, targetpos, shooteffect)
if (isMonster(target) or isPlayer(target)) then
 doSendDistanceShoot(casterpos, targetpos, shooteffect)
end
return true
end

local function castWaterballSegment2(cid, target, damagetype, mindmg, maxdmg, magiceffect)
 if  (isMonster(target) or isPlayer(target)) then
 doTargetCombatHealth(cid, target, damagetype, mindmg, maxdmg, magiceffect)
end
return true
end


function onCastSpell(cid, var)

    local target = getCreatureTarget(cid)
    local shooteffect = CONST_ANI_WATERBALL
    
    local damagetype = COMBAT_DROWNDAMAGE
    local mindmg = -80
    local maxdmg = -105
    local magiceffect = CONST_ME_NONE
    
    addEvent(castWaterballSegment1, 0, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 0, cid, target, damagetype, mindmg, maxdmg, magiceffect)


    addEvent(castWaterballSegment1, 80, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 80, cid, target, damagetype, mindmg, maxdmg, magiceffect)


    addEvent(castWaterballSegment1, 160, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 160, cid, target, damagetype, mindmg, maxdmg, magiceffect)


    addEvent(castWaterballSegment1, 240, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 240, cid, target, damagetype, mindmg, maxdmg, magiceffect)


    addEvent(castWaterballSegment1, 320, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 320, cid, target, damagetype, mindmg, maxdmg, magiceffect)
    

    addEvent(castWaterballSegment1, 400, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 400, cid, target, damagetype, mindmg, maxdmg, magiceffect)
    

    addEvent(castWaterballSegment1, 480, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 480, cid, target, damagetype, mindmg, maxdmg, magiceffect)
    

    addEvent(castWaterballSegment1, 560, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 560, cid, target, damagetype, mindmg, maxdmg, magiceffect)
    

    addEvent(castWaterballSegment1, 640, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 640, cid, target, damagetype, mindmg, maxdmg, magiceffect)
    

    addEvent(castWaterballSegment1, 720, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 720, cid, target, damagetype, mindmg, maxdmg, magiceffect)

    return true
    end
 
Last edited:
Nevermind, fixed it my way.
It's an offensive spell for a water mage boss that shoots 10 waterballs to a single target, every shot deals 80 - 105 drown type damage. Almost fixed it, I think it needs some kind of position refresh, all the bolts hit the same spot even if the character is running.
Lua:
local function castWaterballSegment1(cid, target, casterpos, targetpos, shooteffect)
if (isMonster(target) or isPlayer(target)) then
 doSendDistanceShoot(casterpos, targetpos, shooteffect)
end
return true
end

local function castWaterballSegment2(cid, target, damagetype, mindmg, maxdmg, magiceffect)
 if  (isMonster(target) or isPlayer(target)) then
 doTargetCombatHealth(cid, target, damagetype, mindmg, maxdmg, magiceffect)
end
return true
end


function onCastSpell(cid, var)

    local target = getCreatureTarget(cid)
    local shooteffect = CONST_ANI_WATERBALL
   
    local damagetype = COMBAT_DROWNDAMAGE
    local mindmg = -80
    local maxdmg = -105
    local magiceffect = CONST_ME_NONE
   
    addEvent(castWaterballSegment1, 0, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 0, cid, target, damagetype, mindmg, maxdmg, magiceffect)


    addEvent(castWaterballSegment1, 80, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 80, cid, target, damagetype, mindmg, maxdmg, magiceffect)


    addEvent(castWaterballSegment1, 160, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 160, cid, target, damagetype, mindmg, maxdmg, magiceffect)


    addEvent(castWaterballSegment1, 240, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 240, cid, target, damagetype, mindmg, maxdmg, magiceffect)


    addEvent(castWaterballSegment1, 320, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 320, cid, target, damagetype, mindmg, maxdmg, magiceffect)
   

    addEvent(castWaterballSegment1, 400, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 400, cid, target, damagetype, mindmg, maxdmg, magiceffect)
   

    addEvent(castWaterballSegment1, 480, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 480, cid, target, damagetype, mindmg, maxdmg, magiceffect)
   

    addEvent(castWaterballSegment1, 560, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 560, cid, target, damagetype, mindmg, maxdmg, magiceffect)
   

    addEvent(castWaterballSegment1, 640, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 640, cid, target, damagetype, mindmg, maxdmg, magiceffect)
   

    addEvent(castWaterballSegment1, 720, cid, target, getCreaturePosition(cid), getCreaturePosition(target), shooteffect)
    addEvent(castWaterballSegment2, 720, cid, target, damagetype, mindmg, maxdmg, magiceffect)

    return true
    end
try this?
Lua:
local function castWaterballSegment1(cid, target, casterPos, targetPos, shootEffect)
    if isMonster(target) or isPlayer(target) then
        doSendDistanceShoot(casterPos, targetPos, shootEffect)
    end
    return true
end

local function castWaterballSegment2(cid, target, damageType, minDmg, maxDmg, magicEffect)
    if isMonster(target) or isPlayer(target) then
        doTargetCombatHealth(cid, target, damageType, minDmg, maxDmg, magicEffect)
    end
    return true
end

local function castDelayedWaterBalls(cid, damageType, minDmg, maxDmg, magicEffect, shootEffect, iterations)
    local target = getCreatureTarget(cid)
    castWaterballSegment1(cid, target, getCreaturePosition(cid), getCreaturePosition(target), shootEffect)
    castWaterballSegment2(cid, target, damageType, minDmg, maxDmg, magicEffect)
    if iterations > 1 then
        addEvent(castDelayedWaterBalls, 80, cid, damageType, minDmg, maxDmg, magicEffect, shootEffect, iterations - 1)
    end
end

function onCastSpell(cid, var)
    local castAmount = 10
    castDelayedWaterBalls(cid, COMBAT_DROWNDAMAGE, -80, -105, CONST_ME_NONE, CONST_ANI_WATERBALL, castAmount)
    return true
end
 
Almost working, there are errors whenever a monster is killed with one of the waterballs no. 1-9.
Code:
[28/03/2018 18:29:40] [Error - Spell Interface] 
[28/03/2018 18:29:40] In a timer event called from: 
[28/03/2018 18:29:40] data/spells/scripts/monster/terkaWB.lua:onCastSpell
[28/03/2018 18:29:40] Description: 
[28/03/2018 18:29:40] (luaGetThingPosition) Thing not found
Also I need to check what happens if the caster dies when shooting waterballs.
 
Back
Top