Page 2 of 2

Posted: Sat Oct 18, 2003 12:31 pm
by Vic Marrow
Yes!!!!!!!! this worked bdbodger. Thanks for all your help (and your dogs). You should teach a class on scripting. :D :D :D

Posted: Sun Oct 19, 2003 6:20 am
by small_sumo
Would you please post the entire script, or make available a test map? If it helps I will poast it as a tut on my site, over 6000 visitors in 2 months.

:)

Posted: Mon Oct 20, 2003 5:02 am
by Vic Marrow
You don't want my crummy script, but I can show you what made the dog follow and rest.

This part is between "main:" and "end"

Code: Select all

$dog thread dog_follow $para  //This starts the thread

 
level.script = patrol_path.scr
$para exec global/patrol_path.scr::patrol $path4 //This moves the para
$para waittill movedone

$para exec global/patrol_path.scr::patrol $path5 //This moves the para
$para waittill movedone
level.stopdog = 0 //This stops the thread


$dog walkto $dp2 //New command for dog to go to different waypoint
$dog waittill movedone
$dog anim dog_rest // Makes dog lay down
wait 2
$dog animscript "anim/continue_last_anim.scr" // Keeps dog down

This part is the thread definition thanks to bdbodger. This is in my script after "end" I did put it between "main:" and "end" and thats why at first it did't work.



Code: Select all

dog_follow local.para:

println "dog thread active " 

self.destination = local.para // My ai's targetname
self.distance = 20 
self.waittime=1 
self.friendrange = 20 
 
level.stopdog =1 //Keeps  thread running. = 0 stops it. 
while ((isalive self)&&( isalive local.para )&&(level.stopdog == 1 )) 

{ 
   if !(self.thinkstate==attack) 
   self waitthread follow_player local.para 

waitframe

} 

println "Dog thread ending" 

end 
follow_player local.followed: 

      self.destination = local.followed 

      local.movethread = -1 

      self.movedoneradius = self.distance 
          
      if (vector_length (self.destination.origin - self.origin) > self.distance + self.friendrange) 
      { 

         self walkto self.destination.origin //walkto was runto
          
         local.stand = 0 
         self waittill movedone 

         if !(self.destination) 
         self.destination = null 

         if (vector_length (self.destination.origin - self.origin) < self.distance + self.friendrange) 
         { 
	    self exec global/stand.scr
         } 

      } 
      else 
      { 
         if (local.stand == 0) 
         { 
	    self exec global/stand.scr  
            local.stand = 1 
         } 
      wait 1 
      } 

      if (vector_length (self.destination.origin - self.origin) > self.distance + self.friendrange) 
      { 
          
         self walkto self.destination.origin // Was runto
         local.stand = 0 
         thread movedone 
         local.movethread = parm.previousthread 
      } 


      if ((local.movethread != -1) && (local.movethread != NIL)) 
      local.movethread delete 

      local.dest = self.destination.origin 
      local.runnertime = level.time + 2 

      while (((self.movedone == 0) && (vector_length (local.dest - self.origin) > (self.distance + self.friendrange))) && (local.runnertime > level.time)) 
      { 
         if (self.waittime == -1) 
         waitframe 
      else 
         wait self.waittime 
      } 



end 
//////////////////////////////////////////////////////////// 

movedone: 
   self.movedone = 0 
   self waittill movedone 
   self.movedone = parm.movedone 
end

//////////////////////////////////////////////////////

NOTE: This will only work with bdbodger's dogs from "The rescue"

Posted: Mon Oct 20, 2003 12:24 pm
by bdbodger
Just one thing wrong the lines
level.stopdog =1 //Makes thread stop
while ((isalive self)&&( isalive local.dogguy )&&(level.stopdog == 1 ))
go at the top of the script where you have
while ((isalive self)&&( isalive local.para ))
{
change the while statement at the top to
level.stopdog =1 //Makes thread stop
while ((isalive self)&&( isalive local.para )&&(level.stopdog == 1 ))

also level.stopdog = 1 keeps the thread running level.stopdog = 0 stops it
if you don't take the level.stopdog = 1 away from the bottom of the script then the dog will keep following if you set level.stopdog = 0 while the dog is moveing because at the end of the thread you set it back to 1 after you set it to 0 in the first thread you posted . If it is easier for you change it so that level.stopdog = 0 keeps the thread running . The while statement is "while what is in the brackets is true" the thread runs .
.

Posted: Mon Oct 20, 2003 1:26 pm
by Vic Marrow
Opps! I edited the post and fixed it. :oops:
Like I said you don't want my crummy script. Before I changed it bdbodger it still worked (don't know why) but I changed it so it is done the correct way.

Posted: Tue Oct 21, 2003 12:21 am
by small_sumo
Where can I get "The rescue" maybe I should have a look at that first, thanks for posting your script for me I really appreciate it.

:)

Posted: Tue Oct 21, 2003 2:43 am
by bdbodger
You can get the link for "The rescue" from the new maps section

http://dynamic4.gamespy.com/~map/mohaa/ ... highlight=