ID:172269
 
im trying really hard to do an area damage thing like throwing a grenade and it exploding and damaging an area

i would really appreciate anyone who can suggest ay code that i could use

ive been trying for a few days now and i just cant seem to get it.

please help!!
At first I thought this was gonna be a gimme code post, but you used the word suggest, so i wont hold it against you.

As for the damage to be done, first you need to decide how the grendae is going to work. Is the player going to throw it 5 tiles in front of him? Will he set up a stationary time bomb? Will he hold down a button to build up power for longer throws? Will he click where he wants to throw the grenade?

After deciding that, figure out where the grenade will show up(the direction the player is facing, only 5 steps forward maybe?). Then,use a Missle() to show the grenade travelling to the point where it will land. I'm not sure whether byond waits for missle to be done before it goes on to the next command though.

Then its a simple issue of creating an object where the grenade landing, and using something like:

for(mob/M in oview(1))

Make sure to use the in the OBJECTS PROC and not the player's verb/proc/mob/whatever.

Then, you can create some fire objects within one square of where the grenade landed. That's a SIMPLE overview of what you need to do for grenades. And I might be mistaken in a few parts, but that's how ID do it.
In response to Mooseboy
oview(1) would be completely incorrect there. You'd want oview(src,1) or oview(1,src).
In response to Garthor
Garthor wrote:
oview(1) would be completely incorrect there. You'd want oview(src,1) or oview(1,src).
You would use use the latter, as the format is <FONT COLOR=green>oview(Dist,Center=usr)</FONT>.

Example:
mob/verb/Throw_Grenade()
//...create the grenade and move it to its target location how ever you want to.
O.Blow_Up()
obj/grenade/Blow_Up()
for(var/mob/M in oview(1,src))
M<<"Bang!"
In response to Xallius
Xallius wrote:
Garthor wrote:
oview(1) would be completely incorrect there. You'd want oview(src,1) or oview(1,src).
You would use use the latter, as the format is <FONT COLOR=green>oview(Dist,Center=usr)</FONT>.

No, you can use either. Those view functions will allow you to do it either way.

Also, since this is a grenadelike damaging object I will point out that view would be more appropriate than oview since oview will not damage anything on top of the grenade. I doubt you have ever been standing directly over a grenade when it has blown, but I will tell you right now (not from experience) that you do not want to be since it does in fact damage things standing on it.
In response to Loduwijk
Considering that src would be the grenade, oview() is correct. oview() excludes the center, not the turf center is on.
In response to Garthor
Oops, I think Loduwijk is right, you want center(1,src) so you can include all mobs at the same loc as the grenade.
Also, I didn't know that the arguments for view() procedures were interchangeable, sorry Garthor.
In response to Xallius
No, he's wrong. oview(1,src) excludes src, NOT the turf src is on.
In response to Garthor
Behold the power of copy and paste!

Format:
oview(Dist,Center=usr)
Returns:
A list of visible objects within Dist tiles of Center, excluding Center.
Args:
Dist: A number.
Center: An object on the map.

If it's a visible object and it's at the Center tile, it will be excluded.
In response to Xallius
Exactly what I was saying. oview(1,src) would be the 9 turfs around the grenade, and everything on them.
In response to Garthor
Thanks! I did not realise that, I thought it did not include the center tile as well. I must have read it wrong way back when. I wonder why people have not brought this up before (At least not that I have seen), everyone seems to use it with the idea that it excludes the center tile and everything in it; and most all uses of oview I have seen people make are in the assumption that it will not register anything on the tile along with you and are done so that you cannot select anything on the tile with you.

I seem to have been learning a thing here and there lately. I suppose what they say is true, "You learn something new every month or two."