Walk the dog?

Post your scripting questions / solutions here

Moderator: Moderators

Vic Marrow
Colour Sergeant
Posts: 95
Joined: Wed Aug 20, 2003 2:31 pm

Walk the dog?

Post by Vic Marrow »

If I type:

Code: Select all

$dog setmotionanim dog_walk_bored
$dog glue $para
The dog will walk with the para where ever he goes, but right at the same orgin as the para (between his legs).

If I type:

Code: Select all

$dog setmotionanim dog_walk_bored
$dog bind $para
When the para walks to the waypoint, the dog gets up, starts the dog walk animation, but he dosen't move from his orgin. (he just walks in place). How can I get the dog to follow behind or along side the para?
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Doesn't it walk forward when you omit the bind / glue lines altogether?
Image
Vic Marrow
Colour Sergeant
Posts: 95
Joined: Wed Aug 20, 2003 2:31 pm

Post by Vic Marrow »

Yes the dog will walk foward, but I would like him to follow or walk along side the para he does it with the glue command but right between the para's legs (it looks funny). I thought bind was like glue except the dog would follow behind. I also tried distance = 20 but this didn't work I probely didn't use it correctly. I guess I could send the dog to the same waypoints as the para, but I thought thats what bind would do. It seems like "bind" binds the dog to his start orgin.
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

What if you make a script_origin beside or behind $para bind that to $para and then glue the dog to the script_origin.
Vic Marrow
Colour Sergeant
Posts: 95
Joined: Wed Aug 20, 2003 2:31 pm

Post by Vic Marrow »

I tried the script_orgin. This didn't work. I tried:

Code: Select all

$dog turnto $para
$dog setmotionanim dog_walk_bored
And the dog would go where ever the para went . He would follow behind, but when the para would pause to look or light a smoke the dog would move around him untill he moved again. One cool thing with "turnto", when I shoot the para, the dog will chase and attack me. When I used "glue" and I shot and killed the para, the dog would bark but not chase. He stayed glued to the dead para. To get the dog to move to a waypoint I tried:

Code: Select all

$dog walkto $wp1
This didn't work. But then I tried:

Code: Select all

$dog turnto $wp1
$dog setmotionanim dog_walk_bored
wait 11
$dog anim dog_rest
And this worked. The "wait 11" is the time it takes the dog to get to the waypoint. Dogs don't seem to work like regular ai.
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Yes I know dogs dont work like ai . I got the dog to work like ai in my map "The rescue" you can find that map in the new maps forum . What I did was make a custom dog and a custom new_generic_dog.tik . In the tik is ai aliases for animation but with dog animations substituted for ai animations . The custom dogs will respond to commands like walkto or runto . Like I said before when you manually control ai or dogs you need to do every thing includeing makeing a method for stopping and starting the dog walking , running , turning etc . I don't know how exactly without experimenting and makeing test maps . Maybe try


while(isalive $para)
{
$dog turnto $para
while((vector_length ( $dog.origin - $para.origin ) < 32)&&($dog.thinkstate != "attack"))
{
$dog setmotionanim dog_walk_bored
$dog waittill flaggedanimdone
}
$dog setmotionanim dog_stand_idle
waitframe
}
Vic Marrow
Colour Sergeant
Posts: 95
Joined: Wed Aug 20, 2003 2:31 pm

Post by Vic Marrow »

I tried your code and somthing strange happened. When it was time for the dog to move, the game locked up the dog was vibrating slightly. The error message said something about dog_collar sound not found. I have all the dog sounds aliascached in my script and they all work. Only when I put in this command the game locked, and dog sounds didnt work.
I down loaded your map "The rescue". (very cool) I put it in my "main" folder and by doing this, your dogs were quaked into radiant. So I used your dog (I removed the avitar because I just using it for single player map).
Man!! I like your dogs alot better. Like you said you can use the human commands like "walkto", "runto", etc. How did you get so good with scripting? Are you self taught or a ex-2015 employee. Your dog .tik impresses me. So now this opened up a whole new list of things to try. Still can't get the dog to follow like I want. but what I got is ok.
I tried:

Code: Select all

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

$dog walkto $path4
$dog waittill movedone 


$para exec global/patrol_path.scr::patrol $path5

$dog walkto $path5
$dog waittill movedone
$dog anim dog_rest
wait 2
$dog animscript "anim/continue_last_anim.scr"
The dog will follow, but if the para stops the dog will pass him. This dosn't look too bad. What I need is a "while" command that that tells the dog to wait at a waypoint until the para starts moving again. I tried a few with no luck. I don't know s**t about scripting.
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Well you can use the code from "The rescue" to make the dog follow that is what I did in the map . It only works with the custom dogs .

Code: Select all

dog_follow local.dogguy:

println "dog thread active "

self.destination = local.dogguy
self.distance = 128
self.waittime=1
self.friendrange = 128

local.dmteam = local.dogguy.dmteam

while ((isalive self)&&( isalive local.dogguy )&&(local.dogguy.hasdog==1)&&(local.dogguy.dmteam == local.dmteam))
{
	if !(self.thinkstate==attack)
	self waitthread follow_player local.dogguy

waitframe

}

local.dogguy.hasdog=0

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 runto self.destination.origin 
			
			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 runto self.destination.origin 
			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
Just take out the dm parts and the local.dogguy.hasdog parts

$mydog thread dog_follow $myai

for the other code maybe change it a bit so the turnto is outside of the loop and add the other lines as well .

$dog turnto $para

while(isalive $para)
{
while((vector_length ( $dog.origin - $para.origin ) < 32)&&($dog.thinkstate != "attack"))
{
$dog setmotionanim dog_walk_bored
$dog waittill flaggedanimdone
}
if($dog.thinkstate != "attack")
{
$dog setmotionanim dog_stand_idle
$dog waittill flaggedanimdone
}
waitframe
}
User avatar
small_sumo
Lieutenant General
Posts: 953
Joined: Mon Jul 01, 2002 4:17 pm
Contact:

Post by small_sumo »

Will you be releasing a test map of this. It sounds very cool. have you guys looked into the dog and handler stuff in mohaa, theres all kinds of scripting and animations but I have never seen it used?

Good work guys.
Image

www.smallsumo.tk

Yeah Truth above Honor Man ;)
Vic Marrow
Colour Sergeant
Posts: 95
Joined: Wed Aug 20, 2003 2:31 pm

Post by Vic Marrow »

I tried your script from "The rescue" and I get an error message in my console "self is NULL" and after that the script stops running. The ai keep doing what they were doing before the dog_follow thread. Some of my problem with scripting is understanding how the game recognizes "self"
If I have in my script "$dog thread dog_follow $para" Then does the game recognize "self" as being the same as "$dog" In all the script that is written after: "dog_follow local.para:" until "end" stops it ? And if that's true, if you were to write "$para thread dog_follow $dog" Then the game would recognize "self" as being the same as "$para" ? Then when you have "local.para" Does that mean the game will recognize $para in the thread as well as in the whole script? Sorry for making this confuseing, But I'm lost (as usual) local.huh?
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Psst... do a search :wink:
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

self is the entity that called the thread so self is the dog if an ai called the thread too then self will be the ai as well , each thread instance runs separate . If self is Null then there is no entity with the targetname that called the thread , so if you put $myguy thread dog_follow $myguy2 then self is also $myguy . If $myguy does not exist then self will be Null . Also the thread loops if the while statement is true .
while ((isalive self)&&( isalive local.dogguy )&&(local.dogguy.hasdog==1)&&(local.dogguy.dmteam == local.dmteam))
{
if !(self.thinkstate==attack)
self waitthread follow_player local.dogguy

waitframe

}
Take out the hasdog and dm lines those were for something else

while ((isalive self)&&( isalive local.dogguy ))
{
Vic Marrow
Colour Sergeant
Posts: 95
Joined: Wed Aug 20, 2003 2:31 pm

Post by Vic Marrow »

I did take out those lines. My problem was I had the thread definition (or what ever you call it) put into my script after "main:" Once I took it out of "main:" and put it after "end" it worked good. I think that was the problem. Now I got another question. Once I get the dog to a certain waypoint I would like the thread to end (dog stop following the para). How do I get the thread to stop running? I tried a lot of different things but I coulden't stop it. I would like to give the dog some other commands but he won't do them. Thanks for all your help.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

:?

'end' should do it, or if you want something more fancy you can do:

main:
// your cool stuff here !!
delete

or:

main:
commanddelay 0.5 delete
// your code here, don't take more than 0.5 secs ;)

Obviously this is very 'ugly' code, so better just use 'end' :)
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

The code loops because of the while statement so add to that statement

main:
.....
$mydog thread dog_follow $myai
$myai walkto $mynode
$myai waitill movedone
level.stopdog = 0
....
end
//*********************************************************
dog_follow local.dogguy:
.....
level.stopdog =1
.....
while ((isalive self)&&( isalive local.dogguy )&&(level.stopdog == 1 ))
....
....
end
Post Reply