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

Death mob DMG

Crystals

Member
Joined
Sep 28, 2024
Messages
58
Reaction score
10
TFS 1.4.2:

Hi,

I'm trying to create a spell that causes an explosion when a monster dies. I've tried creating a spell in various ways but I haven't succeeded, maybe someone can help.

The last version I tested is this:

.xml:

LUA:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Erupto" nameDescription="an erupting orc" race="blood" experience="2500" speed="220" manacost="0">
    <health now="100" max="100"/>
    <look type="5" corpse="5966"/>
    <targetchange interval="4000" chance="0"/>
    
    <flags>
        <flag summonable="0"/>
        <flag attackable="1"/>
        <flag hostile="1"/>
        <flag illusionable="0"/>
        <flag convinceable="0"/>
        <flag pushable="0"/>
        <flag canpushitems="0"/>
        <flag canpushcreatures="0"/>
        <flag targetdistance="1"/>
        <flag staticattack="90"/>
        <flag runonhealth="15"/>
        <flag canwalkonenergy="0"/>
        <flag canwalkonfire="1"/>
        <flag canwalkonpoison="0"/>
    </flags>

    <attacks>
        <attack name="melee" interval="2000" min="0" max="-35"/>
        <spell name="Erupto Aura" interval="2000" chance="100" range="0" target="0" script="monster/Tower/erupto_aura.lua"/>
        <spell name="erupto_death" trigger="onDeath" chance="100" range="0" target="0" script="monster/Tower/erupto_death.lua"/>
    </attacks>

    <defenses armor="10" defense="10"/>
    
    <voices interval="5000" chance="10">
        <voice sentence="Feel my wrath!"/>
        <voice sentence="Burn in flames!"/>
    </voices>
    
    <loot>
        <item id="2148" countmax="5" chance="100000"/>
    </loot>
</monster>

spell:


Code:
print("[ERUPTO] Death spell script loaded!")

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
combat:setFormula(COMBAT_FORMULA_DAMAGE, 200, 0, 500, 0)

local area = createCombatArea({
    {1, 1, 1},
    {1, 2, 1},
    {1, 1, 1}
})
combat:setArea(area)

function onCastSpell(creature, var)
    local pos = creature:getPosition()
    
    local params = {
        type = 2,
        value = pos.x,     
        value2 = pos.y,
        value3 = pos.z
    }

    combat:execute(creature, params)
    
    return true
end
 
Solution
I DID NOT TEST THIS CODE

In monster XML file add:
XML:
    <script>
        <event name="CustomMonsterDeath"/>
    </script>
In data/creaturescripts/creaturescripts.xml add:
XML:
    <event type="death" name="CustomMonsterDeath" script="custom_monster_death.lua"/>
Create file data/creaturescripts/scripts/custom_monster_death.lua and paste:
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
combat:setFormula(COMBAT_FORMULA_DAMAGE, 200, 0, 500, 0)

local area = createCombatArea({
    {1, 1, 1},
    {1, 2, 1},
    {1, 1, 1}
})
combat:setArea(area)

function onDeath(creature)
    combat:execute(creature...
I DID NOT TEST THIS CODE

In monster XML file add:
XML:
    <script>
        <event name="CustomMonsterDeath"/>
    </script>
In data/creaturescripts/creaturescripts.xml add:
XML:
    <event type="death" name="CustomMonsterDeath" script="custom_monster_death.lua"/>
Create file data/creaturescripts/scripts/custom_monster_death.lua and paste:
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
combat:setFormula(COMBAT_FORMULA_DAMAGE, 200, 0, 500, 0)

local area = createCombatArea({
    {1, 1, 1},
    {1, 2, 1},
    {1, 1, 1}
})
combat:setArea(area)

function onDeath(creature)
    combat:execute(creature, Variant(creature:getPosition()))

    return true
end
 
Solution
Back
Top