ID:156727
 
How would I go about looking for objects and turfs in someones view and creating thunder over that object/turf?

Here's what I got so far: This is just for the object: Water.

                        var/obj/O=/obj/Water3
for(O in oview(3,src))
var/obj/Thunder/C=new(O.loc)
for(var/mob/M in range(0,C))
if(M!=src||M!=src.Ally)
src.Electrify(M)
You'd want for(var/obj/Water3/O in oview(3,src))
In response to Garthor (#1)
Garthor wrote:
You'd want for(var/obj/Water3/O in oview(3,src))

Alright I got that down but how would I include the loop to also look for "turf/Water"?
In response to AbdelJN (#2)
For multiple types, you'll need to broaden the scope of the search and then filter them manually, so:

for(var/atom/A in oview(3,src))
var/turf/target_loc
if(istype(A, /turf/Water))
target_loc = A
else if(istype(A, /obj/Water3))
target_loc = A.loc
if(target_loc)
//do stuff
In response to Garthor (#3)
Garthor wrote:
For multiple types, you'll need to broaden the scope of the search and then filter them manually, so:

for(var/atom/A in oview(3,src))
> var/turf/target_loc
> if(istype(A, /turf/Water))
> target_loc = A
> else if(istype(A, /obj/Water3))
> target_loc = A.loc
> if(target_loc)
> //do stuff

Thank you ^.^ It's working 100%.