Walk the dog?
Moderator: Moderators
-
Vic Marrow
- Colour Sergeant
- Posts: 95
- Joined: Wed Aug 20, 2003 2:31 pm
- small_sumo
- Lieutenant General
- Posts: 953
- Joined: Mon Jul 01, 2002 4:17 pm
- Contact:
-
Vic Marrow
- Colour Sergeant
- Posts: 95
- Joined: Wed Aug 20, 2003 2:31 pm
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"
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.
NOTE: This will only work with bdbodger's dogs from "The rescue"
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 downThis 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"
Last edited by Vic Marrow on Mon Oct 20, 2003 1:21 pm, edited 1 time in total.
Just one thing wrong the lines
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 .
.
go at the top of the script where you havelevel.stopdog =1 //Makes thread stop
while ((isalive self)&&( isalive local.dogguy )&&(level.stopdog == 1 ))
change the while statement at the top towhile ((isalive self)&&( isalive local.para ))
{
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 .
.
-
Vic Marrow
- Colour Sergeant
- Posts: 95
- Joined: Wed Aug 20, 2003 2:31 pm
- small_sumo
- Lieutenant General
- Posts: 953
- Joined: Mon Jul 01, 2002 4:17 pm
- Contact:
You can get the link for "The rescue" from the new maps section
http://dynamic4.gamespy.com/~map/mohaa/ ... highlight=
http://dynamic4.gamespy.com/~map/mohaa/ ... highlight=
