ID:144250
 
Code:
mob
verb
Throw()
if(usr.grenades<=1)
return
usr<<"Not enought grenades"
else
usr.grenades-=1
if(usr.dir == NORTH)
var/obj/g = new/obj/grenade
g.loc = locate(usr.x+1, usr.y, usr.z)
g.dir = NORTH
walk(g,usr.dir)
sleep(6)


var/obj/a = new/obj/BOOM
var/obj/b = new/obj/BOOM
var/obj/c = new/obj/BOOM
var/obj/d = new/obj/BOOM
var/obj/e = new/obj/BOOM
var/obj/f = new/obj/BOOM
var/obj/k = new/obj/BOOM
var/obj/h = new/obj/BOOM
var/obj/i = new/obj/BOOM

a.loc = locate(g.x+1, g.y, g.z)
b.loc = locate(g.x, g.y, g.z)
c.loc = locate(g.x+1, g.y+1, g.z)
d.loc = locate(g.x, g.y+1, g.z)
e.loc = locate(g.x+1, g.y-1, g.z)
f.loc = locate(g.x, g.y-1, g.z)
k.loc = locate(g.x-1, g.y+1, g.z)
h.loc = locate(g.x-1, g.y, g.z)
i.loc = locate(g.x-1, g.y-1, g.z)


del(g)
sleep(2)
del(a)
del(b)
del(c)
del(d)
del(e)
del(f)
del(k)
del(h)
del(i)




Problem description:

how do i add area damage for every1 near grenade?
Add the damage to everyone around him using for() and oview().
In response to Pyro_dragons
Pyro_dragons wrote:
Add the damage to everyone around him using for() and oview().
I dont know how to do that, im sry im not a good coder
In response to Poal
would
for(var/mob/M in oview(1,g))
var/damage=100
view()<<"Boom!"
M.health-=damage
work?
In response to Poal
What you would do is look for players around the oview() of the target. M is the target, so lets make P in players around him.

for(var/mob/P in oview(M,1)) //you put the reference first, then the distance, the ref being the target that was hit.
view(M) << "Boom!" //use M, the target, as view ref
var/damage = 100
P.health -= damage


Don't copy paste this. It's just an untested example.
In response to Pyro_dragons
Pyro_dragons wrote:
> for(var/mob/P in oview(M,1)) //you put the reference first, then the distance, the ref being the target that was hit.
> view(M) << "Boom!" //use M, the target, as view ref
> var/damage = 100
> P.health -= damage

Don't copy paste this. It's just an untested example.

And one that will say Boom! for each person hit.
In response to Pyro_dragons
Pyro_dragons wrote:
What you would do is look for players around the oview() of the target. M is the target, so lets make P in players around him.

> for(var/mob/P in oview(M,1)) //you put the reference first, then the distance, the ref being the target that was hit.
> view(M) << "Boom!" //use M, the target, as view ref
> var/damage = 100
> P.health -= damage

Don't copy paste this. It's just an untested example.

oview() and all of the other procs like it, like range() and view(), have the parameters set so that it's (range,center).
:P
In response to D4RK3 54B3R
D4RK3 54B3R wrote:
oview() and all of the other procs like it, like range() and view(), have the parameters set so that it's (range,center).
:P

Actually, in all of them, you may pass the arguments in any order.

By the way, using oview() for things like explosions/area-damage is silly. It shows you don't know enough about DM and probably think it's the only way (or built-in proc) to get it done, but there's no reason in the world for explosions to be view/sight-infulenced; use range() instead. You also need to know the difference between the 'o' procs and the regular versions (oview()+view(),orange()+range()), using oview() or orange() will skip the center object, which isn't what you want.
In response to Kaioken
You really should use some sort of circle to do it, so it is more realistic.
proc
getcircle(atom/M, radius)
var/list/circle = list()
var/turf/T
for(T as turf in range(radius+3,M))
if(distance(T, M) < radius + 0.5)
circle += T
return circle
distance(atom/M,atom/N)
return sqrt((N.x-M.x)**2 + (N.y-M.y)**2)
mob
verb
Explode()
var/list/L = getcircle(src,5)
for(var/turf/T in L)
new /obj/explosion(T)
for(var/mob/M in L)
M<<"Boom!"