I could probably continue naming games with this iconic ability. Instead, let's get some code!
First, create a new projectile:
projectile
random_sparks
damage = 15
icon_state = "spark"
pwidth = 20
pheight = 16
pixel_x = -6
pixel_y = -5
move_speed = 5
// make it use the MagicCombat object to deal damage
hit(mob/m)
MagicCombat.attack(owner, m, damage)
movement()
effect("flame", layer = layer - 1)
. = ..()
var/randx = rand(-1 * move_speed, move_speed)
var/randy = rand(-1 * move_speed, move_speed)
switch(dir)
if(NORTH)
randy += move_speed/3
if(SOUTH)
randy -= move_speed/3
if(EAST)
randx += move_speed/3
if(WEST)
randx -= move_speed/3
if(NORTHEAST)
randx += move_speed/6
randy += move_speed/6
if(NORTHWEST)
randx -= move_speed/6
randy += move_speed/6
if(SOUTHEAST)
randx += move_speed/6
randy -= move_speed/6
if(SOUTHWEST)
randx -= move_speed/6
randy -= move_speed/6
vel_x += randx
vel_y += randy
vel_x = max(-1 * move_speed, min(vel_x, move_speed))
vel_y = max(-1 * move_speed, min(vel_y, move_speed))
Now, add an ability to call your projectile:
Ability
Spark
name = "Spark"
icon_state = "ability-button-fireball"
description = "Shoots 3 sparks that deal 8 magic damage each."
animation = "attacking"
mana_cost = 2
cooldown = 30
can_use(mob/user)
if(user.on_cooldown("spark", "attack"))
return 0
else
return ..()
effect(mob/user)
user.cooldown("spark", cooldown)
user.cooldown("attack", 10)
for(var/i = 1, i <= 3, i++)
new /projectile/random_sparks(user, user.target)
user.noise('spark.wav', frequency = rand(0.7, 1.3))
Fire away!