ID:148928
 
In my newest game, there are grenades and rockets. I already have them as projectiles exactly like I want, but I need to know how to give every mob in the area splash damage (so that the rocket doesn't need to actually hit them). Any ideas?

Also, if anyone knows how to make the 1, 3, 7, and 9 keys strafe (as in Proelium), please tell me!
Cybermattr wrote:
In my newest game, there are grenades and rockets. I already have them as projectiles exactly like I want, but I need to know how to give every mob in the area splash damage (so that the rocket doesn't need to actually hit them). Any ideas?

Actually this one's easy enough:
proc/SplashDamage(damage,mob/owner,turf/center,radius=3)
var/maxrsq=radius*(radius+1)
for(var/turf/T in view(radius,center))
var/rsq=(T.x-center.x)*(T.x-center.x)+(T.y-center.y)*T.y-center.y)
if(rsq>maxrsq) continue
new /obj/effect/explosion(T)
for(var/atom/movable/A in T)
A.Damage(owner,damage) // Damage() should exist for all atoms

That'll create an explosion in a roughly circular area. If you want to reduce damage for people farther from the center, I'd try this:
A.Damage(owner,damage-round(damage*rsq/maxrsq))

Also, if anyone knows how to make the 1, 3, 7, and 9 keys strafe (as in Proelium), please tell me!

These would be controlled by directional procs like client/SouthWest() (1), client/SouthEast() (3), etc.

Lummox JR
In response to Lummox JR (#1)
Lummox JR wrote:

var/rsq=(T.x-center.x)*(T.x-center.x)+(T.y-center.y)*T.y-cen ter.y)

you are missing the '(' in front of T.y-center.y

Should be var/rsq=(T.x-center.x)*(T.x-center.x)+(T.y-center.y)*(T.y-ce nter.y)

Just thought i would point that out
In response to Soori-99 (#2)
yeah, that could cause some nasty errors if someone were dumb enough to actually cut and paste out of the forums.
In response to Lummox JR (#1)
as Lummox JR said strafing would be done with the client/Southwest() and the like

client
Southwest()
if(mob.dir==EAST || mob.dir==WEST)
mob.Move(get_step(mob,SOUTH))
if(mob.dir==NORTH || mob.dir==SOUTH)
mob.Move(get_step(mob,WEST))

Southeast()
if(mob.dir==EAST || mob.dir==WEST)
mob.Move(get_step(mob,SOUTH))
if(mob.dir==NORTH || mob.dir==SOUTH)
mob.Move(get_step(mob,EAST))

Northwest()
if(mob.dir==EAST || mob.dir==WEST)
mob.Move(get_step(mob,NORTH))
if(mob.dir==NORTH || mob.dir==SOUTH)
mob.Move(get_step(mob,WEST))

Northeast()
if(mob.dir==EAST || mob.dir==WEST)
mob.Move(get_step(mob,NORTH))
if(mob.dir==NORTH || mob.dir==SOUTH)
mob.Move(get_step(mob,EAST))


that should do it; as always some1 will correct anything thats wrong for me
In response to LostRealm (#4)
Your strafe procs could stand to be a little simpler; I recomment using the turn() proc to find the direction 90° left or right of mob.dir.

Lummox JR
In response to Soori-99 (#2)
Soori-99 wrote:
Lummox JR wrote:

var/rsq=(T.x-center.x)*(T.x-center.x)+(T.y-center.y)*T.y-cen ter.y)

you are missing the '(' in front of T.y-center.y

Should be var/rsq=(T.x-center.x)*(T.x-center.x)+(T.y-center.y)*(T.y-ce nter.y)

Just thought i would point that out

Good catch. Thanks.
Whenever I post a long code example there tends to be a typo or two in it.

Lummox JR
In response to LostRealm (#4)
thanks guys

check out "Honor Among Thieves", that's the game I'm incorporating all this into. It's at http://www.byond.com/hub/Cybermattr/HonorAmongThieves so at least take a look, please.

and i tried the strafing thing, it doesn't work the way i expected... oh well.