• 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 should hit xxxx times after being casted! TFS 1.3

Kodis

~|Profi|~
Joined
Dec 30, 2008
Messages
2,122
Reaction score
28
Location
Germany
Hello,

I am having a little issue with my spell in TFS 1.3


My Code:
Lua:
local west1 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
}

local west2 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
}




local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_NONE)
combat:setFormula(COMBAT_FORMULA_DAMAGE, -250.0, 0, -300.0, 0)
--combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
combat:setArea(createCombatArea(west1))


local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_NONE)
combat2:setFormula(COMBAT_FORMULA_DAMAGE, -250.0, 0, -300.0, 0)
--combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
combat2:setArea(createCombatArea(west2))

local effect = {
    [DIRECTION_NORTH] = 151,
    [DIRECTION_EAST] = 148,
    [DIRECTION_SOUTH] = 151,
    [DIRECTION_WEST] = 148
}

local effect2 = {
    [DIRECTION_NORTH] = 150,
    [DIRECTION_EAST] = 149,
    [DIRECTION_SOUTH] = 152,
    [DIRECTION_WEST] = 147
}


function onCastSpell(creature, variant)
    addEvent(function() creature:say("Final", TALKTYPE_MONSTER_SAY) end, 0)
    addEvent(function() creature:say("Flaaash!", TALKTYPE_MONSTER_SAY) end, 0)
    combat:setParameter(COMBAT_PARAM_EFFECT, effect[creature:getDirection()])
    combat2:setParameter(COMBAT_PARAM_EFFECT, effect2[creature:getDirection()])
    return combat:execute(creature, variant), combat2:execute(creature, variant)
end

and my problem is I would like to let my character say Final then Flaaash (0.2seconds after I casted the spell) + the actuall animation/spell
and currently I tried it like this:

Code:
addEvent(function() combat:setParameter(COMBAT_PARAM_EFFECT, effect[creature:getDirection()]) return combat:execute(creature, variant) end, 200)
addEvent(function() combat2:setParameter(COMBAT_PARAM_EFFECT, effect2[creature:getDirection()]) return combat2:execute(creature, variant) end, 200)

It actually does exactly what I said above and how I want it BUT when I run and cast the spell it shoots exactly in the opposite direction for example
I run west it shoots east I run north it shoots south,only when I stand its 100% accurate.

Anybody knows how to fix that little issue?

Thanks in Advance
Kind Regards
 

Qbazzz

Pół człowiek, pół litra
Joined
Jul 3, 2009
Messages
105
Solutions
1
Reaction score
94
Location
inside of the box
Lua:
addEvent(function() creature:say("Flaaash!", TALKTYPE_MONSTER_SAY) end, 0)
You cannot pass creature metatable like this, because its triggered in upcoming time and you cannot assure that creature as as variable is valid.

You can try to do something like this(maybe need some adjust):
Lua:
creature:say("Flaaash!", TALKTYPE_MONSTER_SAY)
addEvent(function(creatureid) Creature(creatureid):say("Flaaash!", TALKTYPE_MONSTER_SAY) end, 200, creature:getId())
 
OP
OP
Kodis

Kodis

~|Profi|~
Joined
Dec 30, 2008
Messages
2,122
Reaction score
28
Location
Germany
Well it does work (the text) but my issue is that when I say the spell and turn or walk the spell will still use the old positon
 
Top