Skill script help: making a projectile magic skill

No idea where to start on this idea I want to have it check if mana is above zero and the basically send a fireball type sprite access the screen in the direction the player is facing. Any suggestions?

The player's confirm and cancel events run when you press the A or B button, that would be a good way for the player to shoot a fireball.

Checking if mana is above zero is simple, just start with if mana>0 then. Remember to decrease mana afterwards too!

For sending a projectile across the screen you have two options. You can make the fireball as a sprite, item or world tile and swap it into the room, or you can make the fireball as a player tile and draw it over the room. I would prefer the second option as it means you don't have to worry about swapping the tiles back to what they should be underneath, and you can use transparency in your fireball tile.

When the player first casts the fireball (lets say in the confirm event) you could record its starting position and direction in some variables. You can use the game's loop event to update the fireball every frame. In the player's draw event you can then draw the fireball in its new position (if it hasn't hit something and exploded!).

2 Likes

Thank you this gives me a good starting place.

On confirm do
If mana>0 then
Mana --
Ignore
Player direction variables ect.
Then a loop to update spell position on screen
Wait 0.2 then
Listen
End
End

started working on the skill and the up and down Cast works good so far. but the left is not working at all

on confirm do
if mana>0 then
mana--
mskullX = event.x
mskullY = event.y
mskullX += event.dx
mskullY += event.dy
if event.dx==1 then
mskullTile = "mskullRight"
elseif event.dx==1 then
mskullTile = "mskullLeft"
wait 0.2 then
mskullX -= 1
call "Castmskull"
wait 0.2 then
mskullX -= 1
call "Castmskull"
end
end
elseif event.dy==1 then
mskullTile = "mskullDown"
wait 0.2 then
mskullY += 1
call "Castmskull"
wait 0.2 then
mskullY += 1
call "Castmskull"
elseif event.dy==-1 then
mskullTile = "mskullUp"
wait 0.2 then
mskullY -= 1
call "Castmskull"
wait 0.2 then
mskullY -= 1
call "Castmskull"
end
end
end
end
end

	tileAtmskullPos = name mskullX,mskullY
	
	if tileAtmskullPos=="white" then
		call "Castmskull"
	elseif tileAtmskullPos=="enemy" then
		call "Castmskull"
	end
end

end

on Castmskull do
ignore
tell mskullX,mskullY to
swap mskullTile
wait 0.2 then
swap "white"
listen
end
end
endstrong text

Your code hasn't pasted perfectly into the forum so it is hard to read. Make sure when pasting code to put three backticks ( ``` ) on the lines above and below it, that'll display it as a preformatted code block.

From a quick look you appear to have

if event.dx==1 then

followed by

elseif event.dx==1 then

I suspect you really meant the latter to check for -1 not 1, that would explain why left is not being handled at all.