GraveWalker
Member
- Joined
- Jan 7, 2019
- Messages
- 25
- Reaction score
- 9
Hello everyone,
I've been working on a Kamehameha spell for my game, but I've encountered an issue where the damage area of the spell does not update based on the player's direction. I would appreciate any help to figure out how to fix this problem.
Here's the current code I'm using:
The showDirectionEffect function works correctly, and the visual effect updates based on the player's direction. However, the damage area does not update properly, and it seems to remain in the same direction regardless of where the player is facing. I'm still relatively new to making scripts and have much to learn.
I would be grateful for any suggestions on how to update the damage area based on the player's direction.
Thank you in advance!
I've been working on a Kamehameha spell for my game, but I've encountered an issue where the damage area of the spell does not update based on the player's direction. I would appreciate any help to figure out how to fix this problem.
Here's the current code I'm using:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setArea(createCombatArea(AREA_BEAM5))
function onGetFormulaValues(player, level, maglevel)
local min = (level / 5) + (maglevel * 5) + 50
local max = (level / 5) + (maglevel * 10) + 100
return -min, -max
end
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local function showDirectionEffect(creature, effectX, effectY)
local position = creature:getPosition()
local direction = creature:getDirection()
if direction == DIRECTION_NORTH then
position.y = position.y - 1
position:sendMagicEffect(176)
elseif direction == DIRECTION_EAST then
position.x = position.x + 5
position:sendMagicEffect(177)
elseif direction == DIRECTION_SOUTH then
position.y = position.y + 5
position:sendMagicEffect(176)
elseif direction == DIRECTION_WEST then
position.x = position.x - 1
position:sendMagicEffect(177)
end
end
function onCastSpell(creature, variant)
creature:say("Ka...", TALKTYPE_MONSTER_SAY)
addEvent(function() creature:say("Me...", TALKTYPE_MONSTER_SAY) end, 1000)
addEvent(function() creature:say("Ha... Me...", TALKTYPE_MONSTER_SAY) end, 2000)
addEvent(function()
creature:say("HA!!!", TALKTYPE_MONSTER_SAY)
showDirectionEffect(creature, CONST_ME_ENERGYAREA)
combat:execute(creature, variant)
end, 3000)
return false
end
XML:
<instant group="attack" spellid="7" name="Kamehameha" words="kamehameha" level="0" maglevel="0" mana="100" premium="0" range="0" casterTargetOrDirection="1" blockwalls="1" cooldown="3000" groupcooldown="3000" needlearn="0" script="kamehameha.lua">
<vocation name="Son Goku" />
</instant>
I would be grateful for any suggestions on how to update the damage area based on the player's direction.
Thank you in advance!