mob
proc
Slashing(weapon) //Setup a Slashing attack
if (Active("Melee Attack"))
return
Attacking = 1
var/Attack/Melee/Slashing/A = new(src.loc)
A.step_x = step_x
A.step_y = step_y
A.Attacker = src
A.dir=src.dir
if (weapon == "Right")
if (RWeapon)
A.Dist = RWeapon.Slashing+R.Slashing
else
A.Dist = R.Slashing
if (A.Dist)
if (dir == NORTH)
step(A,NORTHEAST,20)
sleep(1)
step(A,WEST,16)
sleep(1)
step(A,WEST,16)
A.dir = NORTHWEST
sleep(1)
else if (dir == EAST)
step(A,SOUTHEAST,20)
sleep(1)
step(A,NORTH,16)
sleep(1)
step(A,NORTH,16)
A.dir = NORTHEAST
sleep(1)
else if (dir == WEST)
step(A,NORTHWEST,20)
sleep(1)
step(A,SOUTH,16)
sleep(1)
step(A,SOUTH,16)
A.dir = SOUTHWEST
sleep(1)
else if (dir == SOUTH)
step(A,SOUTHWEST,20)
sleep(1)
step(A,EAST,16)
sleep(1)
step(A,EAST,16)
A.dir = SOUTHEAST
sleep(1)
else if (weapon == "Left")
A.Dist = LWeapon.Slashing+L.Slashing
if (A.Dist)
if (dir == NORTH)
step(A,NORTHWEST,20)
sleep(1)
step(A,EAST,16)
sleep(1)
step(A,EAST,16)
A.dir = NORTHEAST
sleep(1)
else if (dir == EAST)
step(A,NORTHEAST,20)
sleep(1)
step(A,SOUTH,16)
sleep(1)
step(A,SOUTH,16)
A.dir = SOUTHEAST
sleep(1)
else if (dir == WEST)
step(A,SOUTHWEST,20)
sleep(1)
step(A,SOUTH,16)
sleep(1)
step(A,SOUTH,16)
A.dir = NORTHWEST
sleep(1)
else if (dir == SOUTH)
step(A,SOUTHEAST,20)
sleep(1)
step(A,WEST,16)
sleep(1)
step(A,WEST,16)
A.dir = SOUTHEAST
sleep(1)
Attacking = 0
del A
The code above is what I'm using for a basic 1 tile slash attack, unfortunately this seems a bit choppy. My hope is to find a way to set up different sizes of attacks from 1 to 8 tiles, representing a single tile in front of the attack to a full 360 degree attack. The problem is keeping the attack centered at the front o the attacker.
Below is some additional code used with the above code.
Attack
parent_type = /obj/
var
Dist = 0 // How far the attack will travel
mob/Attacker //The person who started the Attack
Melee
icon = 'MeleeAttack.dmi'
Slashing
icon_state = "Slash"
step_size = 16
mob
verb
Slashing_Strike()
if (RWeapon)
Slashing("Right")
if (LWeapon)
Slashing("Left")
if (!LWeapon && !RWeapon)
return
mob
proc
Hit(mob/Defender)
return 1
Damage(mob/Defender)
The other problem is when the attack passes over a mob it doesn't activate the attack. Below is the code that should cause damage. I'm not sure if Im calling it in the wrong spot or if I did something wrong.
mob
Crossed(M)
if (M == typesof(/Attack))
var/Attack/A = M
if (Hit(src))
var/dmg = A.Attacker.Damage(src)
world << "[A.Attacker] hits [src]."
StatusLose(A.Attacker,dmg,"Health")
A.Dist-= 2
return 1
else
..()
Any help would be much appreciated.
And then at second glance, it appears your Dist variable is given some value and then never used for anything other than checking if it has a value other than 0/null. I don't know if this is intended, but it doesn't seem like it.