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

TFS 1.X+ Spell

alcapone

Member
Joined
Jan 13, 2021
Messages
246
Reaction score
19
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONHIT)

combat:setArea(createCombatArea({
{1},
{1},
{1},
{3},
}))

function spellCallback(param)
    local tile = Tile(Position(param.pos))
    if tile then
        if tile:getTopCreature() and tile:getTopCreature():isMonster() then
            if tile:getTopCreature():getName():lower() == "demon" then
        
              
                tile:getTopCreature():remove()
             tile.createItem(6500,1,Position(33856,31860,7))
            end
        end
    end
end

function onTargetTile(cid, pos)
    local param = {}
    param.cid = cid
    param.pos = pos
    param.count = 0
    spellCallback(param)
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")

function onCastSpell(creature, var)
 
    return combat:execute(creature, var)
end

I'm having problems with this magic what I'm trying to do is when the wave hits the monster demon it is removed and the item appears in place but it is bringing down the server
 
Solution
I have tested the code and it works I have passed it to Revscript so that you can also test it and notify us of the result:

data/scripts/exunademon.lua
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONHIT)

combat:setArea(createCombatArea({
{1},
{1},
{1},
{3},
}))

function onTargetTile(player, position)
    local tile = Tile(position)
    if tile then
        local creature = tile:getTopVisibleCreature(player)
        if creature and creature:isMonster() and creature:getName() == "Demon" then
            creature:remove()
            Game.createItem(6500, 1, position)
        end
    end
end...
Well, I can say that this line is incorrect
Lua:
tile.createItem(6500,1,Position(33856,31860,7))
it should be..
Lua:
Game.createItem
So in your instance.. it would be
Lua:
function spellCallback(param)
	local tile = Tile(Position(param.pos))
	if tile then
		local creature = tile:getTopCreature()
		if creature:isMonster() and creature:getName():lower() == "demon" then
			creature:remove()
			Game.createItem(6500, 1, Position(33856, 31860, 7))
		end
	end
end
 
Well, I can say that this line is incorrect
Lua:
tile.createItem(6500,1,Position(33856,31860,7))
it should be..
Lua:
Game.createItem
So in your instance.. it would be
Lua:
function spellCallback(param)
    local tile = Tile(Position(param.pos))
    if tile then
        local creature = tile:getTopCreature()
        if creature:isMonster() and creature:getName():lower() == "demon" then
            creature:remove()
            Game.createItem(6500, 1, Position(33856, 31860, 7))
        end
    end
end

2021-03-28 21:46:00 - #0 0x000055555570e7b5 in Monster::doAttacking(unsigned int) ()
2021-03-28 21:46:00 - No symbol table info available.
2021-03-28 21:46:00 - #1 0x00005555555c3620 in Game::checkCreatures(unsigned long) ()
2021-03-28 21:46:00 - No symbol table info available.
2021-03-28 21:46:00 - #2 0x00005555557c0eaa in Dispatcher::threadMain() ()
2021-03-28 21:46:00 - No symbol table info available.
2021-03-28 21:46:00 - #3 0x00007ffff7b10e6f in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
2021-03-28 21:46:00 - No symbol table info available.
2021-03-28 21:46:00 - #4 0x00007ffff78414a4 in start_thread (arg=0x7fffede19700) at pthread_create.c:456
2021-03-28 21:46:00 - __res = <optimized out>
 
2021-03-28 21:46:00 - #0 0x000055555570e7b5 in Monster::doAttacking(unsigned int) ()
2021-03-28 21:46:00 - No symbol table info available.
2021-03-28 21:46:00 - #1 0x00005555555c3620 in Game::checkCreatures(unsigned long) ()
2021-03-28 21:46:00 - No symbol table info available.
2021-03-28 21:46:00 - #2 0x00005555557c0eaa in Dispatcher::threadMain() ()
2021-03-28 21:46:00 - No symbol table info available.
2021-03-28 21:46:00 - #3 0x00007ffff7b10e6f in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
2021-03-28 21:46:00 - No symbol table info available.
2021-03-28 21:46:00 - #4 0x00007ffff78414a4 in start_thread (arg=0x7fffede19700) at pthread_create.c:456
2021-03-28 21:46:00 - __res = <optimized out>
Could you compile with debug symbols
 
I have tested the code and it works I have passed it to Revscript so that you can also test it and notify us of the result:

data/scripts/exunademon.lua
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONHIT)

combat:setArea(createCombatArea({
{1},
{1},
{1},
{3},
}))

function onTargetTile(player, position)
    local tile = Tile(position)
    if tile then
        local creature = tile:getTopVisibleCreature(player)
        if creature and creature:isMonster() and creature:getName() == "Demon" then
            creature:remove()
            Game.createItem(6500, 1, position)
        end
    end
end

combat:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile")

local spell = Spell("instant")
function spell.onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end

spell:name("Delete Demons")
spell:words("exuna demon")
spell:group("attack")
spell:vocation("sorcerer", "master sorcerer", "druid", "elder druid")
spell:id(24)
spell:cooldown(1 * 1000)
spell:groupCooldown(1 * 1000)
spell:level(8)
spell:mana(35)
spell:needDirection(true)
spell:isPremium(true)
spell:register()
 
Solution
I have tested the code and it works I have passed it to Revscript so that you can also test it and notify us of the result:

data/scripts/exunademon.lua
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONHIT)

combat:setArea(createCombatArea({
{1},
{1},
{1},
{3},
}))

function onTargetTile(player, position)
    local tile = Tile(position)
    if tile then
        local creature = tile:getTopVisibleCreature(player)
        if creature and creature:isMonster() and creature:getName() == "Demon" then
            creature:remove()
            Game.createItem(6500, 1, position)
        end
    end
end

combat:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile")

local spell = Spell("instant")
function spell.onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end

spell:name("Delete Demons")
spell:words("exuna demon")
spell:group("attack")
spell:vocation("sorcerer", "master sorcerer", "druid", "elder druid")
spell:id(24)
spell:cooldown(1 * 1000)
spell:groupCooldown(1 * 1000)
spell:level(8)
spell:mana(35)
spell:needDirection(true)
spell:isPremium(true)
spell:register()
is it possible for a monster to use it?
 
is it possible for a monster to use it?
Yes, it is possible, just remove the vocations, and remove the words, and then add the spell to the monster's attack list

spell name and chance is enough

xml example:
XML:
<attack name="Delete Demons" interval="2000" chance="100" />

revscript example:
Lua:
    monster.attacks = {
        {name = "Delete Demons", interval=2000, chance = 100}
    }
 
Back
Top