• 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 Directional spells

Watchdog87

Member
Joined
Mar 2, 2014
Messages
30
Solutions
1
Reaction score
5
Hello! I have a problem with a script. I'm trying to make a spell execute in the direction the character is facing. I did not create this script, I took it from somewhere on these forums.

It works but only for 1 tile and doesn't work for the whole area of what is stated in combat:setArea. I tested changing
Code:
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_NONE)
to
Code:
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
and it did work but only for 1 or 2 directions, so I need a way to make "CONST_ME_NONE" reflect to whatever direction the execution gives.

I hope I made sense, thanks in advance!

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_NONE)
combat:setFormula(COMBAT_FORMULA_DAMAGE, 0, -100, 0, -200)
combat:setArea(createCombatArea(AREA_SQUAREWAVE5, AREADIAGONAL_SQUAREWAVE5))

local effect = {
    [DIRECTION_NORTH] = CONST_ME_FIREAREA,
    [DIRECTION_EAST] = CONST_ME_ENERGYHIT,
    [DIRECTION_SOUTH] = CONST_ME_MORTAREA,
    [DIRECTION_WEST] = CONST_ME_POISONAREA
}


function onCastSpell(creature, variant)
    creature:getPosition():sendMagicEffect(effect[creature:getDirection()])
    return combat:execute(creature, variant)
end
 
add direction="1" in your spells.xml for that spell

Oh my god. I forgot to give proper information cause I was up all night, tired as hell.

What I mean is that I need spells whose sprites are directional. Right now the sprites grow from the center out so it doesn't matter what direction your character is looking, it will still look logical. If I want to make a laser spell it will show the wrong direction if I change character direction.

Notice how it changes in the middle of the character, but not for the whole area.


spelldown.PNGspellup.PNGspellright.PNGspellleft.PNG
 
Last edited:
I found the solution eventually.

 
Solution
Back
Top