ID:174405
 
Hello!
I am using the S-projectile library.
How can I get mobs to fire back at the players?

Any help would be greatly appreciated!

~GokuSS4Neo~
mob/verb/FireBehind()
var/obj/projectile/P = new(get_step(src,turn(src.dir,180)))
walk(P,turn(src.dir,180))


This will make the projectile behind you and walk the opposite direction.
In response to Unknown Person
Sorry, I didn't make myself very clear. I don't want people to fire backwards, I want the monsters to fire at the players.

~GokuSS4Neo~
In response to Gokuss4neo
In your normal monster wandering code, do a check for players in view(src) and if you find one, fire some stuff at them. You could also wait for a monster to be attacked by a player and cause retaliation in that proc.
In response to Jon88
Jon88 wrote:
In your normal monster wandering code, do a check for players in view(src) and if you find one, fire some stuff at them. You could also wait for a monster to be attacked by a player and cause retaliation in that proc.


It's the "fire some stuff at them" that I don't know how to do. I know the rest.

Thank you anyway though!

~GokuSS4Neo~
In response to Gokuss4neo
Okay, expanding from Unknown Person's code then...
mob/monster/proc/FireBehind()
var/obj/projectile/P = new(get_step(src,turn(src.dir,180)))
walk(P,turn(src.dir,180))

That will cause a projectile to be fired behind the monster. You could also have a targeted version.
mob/monster/proc/FireAtEnemy(mob/M)
var/obj/projectile/P = new(get_step(src,src.dir))
walk_towards(P,M)
Which would create a projectile object in front of the monster, and have it walk towards M.
In response to Jon88
Thank you!

~GokuSS4Neo~