check_walls(mob/m)
var/target_location=m.loc
var/obj/path_checker=new/obj(loc)
path_checker.density=1
path_checker.icon='mob.dmi'
var/obstacle_true
path_checker.dir=get_dir(path_checker,target_location)
var/temprange=Arange
var/old_path_checker_location
while(temprange)
temprange--
old_path_checker_location=path_checker.loc
step(path_checker,path_checker.dir)
if(old_path_checker_location==path_checker.loc)
obstacle_true=1
del path_checker
break
if(obstacle_true)
obstacle=1
else
del path_checker
obstacle=0
damage_process(mob/m)
missile('bullet.dmi',src,m)
Problem description:
So basically the idea is, for the AI calling this procedure, is checking to see if anything is obstructing a long ranged attack before going. I'm not sure if there's a better way of checking, because right now I'm just having an object run the path to check. Is there a better way? Because this doesn't work.
Anyways, the mob/m argument is the target of course.
Another question I would love to know the answer to:
If you'd take note of the "obstacle" variable, you'd notice it's purpose is not even used in this block of code. It's actually because the lines of code for AI() call the "check walls proc" and immediatly after checks to see if check walls was true or not by checking the obstacle variable. Is there anyway to check if it returned it or not without checking with a variable? It seems ugly.
Here's the rest of the code, just to maybe clear up my jumbled explanation..
soldier
icon='mob.dmi'
icon_state="Rsoldier"
var
mob/owner
Arange=5
obstacle
New(mob/owner)
owner=owner
ai_attack()
proc
ai_attack()
spawn for()
sleep(10)
for(var/mob/m in oview(src,Arange))
if(m.team!=team)
check_walls(m)
if(!obstacle)
damage_process(m)
Currently, (even though this
Actually one other thing I'm unsure about is why you're using an obj as the path checker. You can just use a var that keeps track of what turf the path starts on and where the target is, and then your pathfinding routine can check if there's a path from point A to point B or not.
Lummox JR