Home| What is Steam| Community| News| Cyber Cafés| Forums| Support| Stats

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Rate Thread Display Modes
Old 11-24-2008, 07:09 PM   #1
kill3rtomato
 
Join Date: Jun 2008
Reputation: 0
Posts: 14
Pathfinding in Source?

Well, here I am. I'm sure you can guess I have a problem, since I'm asking (:

Anyways, I have a little entity that runs around randomly at the moment. What I want it to do is find a path to the player and follow it, like the Zombie, using the node graph and whatnot. Well, I honestly have no idea where to start. I looked around the code for Zombie, Antlion, Combine Soldier, but I didn't really find anything that is of much use (that I know of...) so I don't really know where to start..

I would really like to know how it all works.. is the pathfinding ONLY for NPCs? (Meaning I'd have to make my own NPC), applies to anything? I'm so confused
kill3rtomato is offline   Reply With Quote
Old 11-25-2008, 01:05 AM   #2
Winston
 
Join Date: Jul 2007
Reputation: 38
Posts: 2,194
It might be possible to hijack it, but the pathfinding behaviour is coded into NPCs, so the easiest way is probably to make a very simple NPC.
Winston is offline   Reply With Quote
Old 11-25-2008, 01:49 AM   #3
sormii
 
Join Date: Jul 2008
Reputation: 2
Posts: 143
I suggest you to play around with npc code, it's not so hard as you might first think. You should take a look at other npc code and then build your very own simple npc from the template which is monster_dummy.cpp

I found the zombie, combine and rebel npc code very messy so probably the best way to go is to use either monster_dummy or some sort of simple npc such as barney.

Very good and detailed tutorial here http://developer.valvesoftware.com/w...mming_Overview
and
http://developer.valvesoftware.com/wiki/Creating_an_NPC

Once you have a vision how npc's work just play around with your npc code and eventually everything related to npc code seems very clear.

Last edited by sormii : 11-25-2008 at 01:52 AM.
sormii is offline   Reply With Quote
Old 11-25-2008, 04:09 PM   #4
kill3rtomato
 
Join Date: Jun 2008
Reputation: 0
Posts: 14
Well, I guess I'll have to work with NPCs.. although I'm pretty confused by how they work. What I gathered from the tut on the VDC, was that the NPC first finds out what's happening around him, then it picks a state, then it selects a schedule.

The appropriate schedule, which is a list of tasks, is executed. It will continue to execute until it's either interrupted (by a defined interruption) or until it ends.. then it picks something else to do..

So.. am I right?
kill3rtomato is offline   Reply With Quote
Old 11-26-2008, 01:12 AM   #5
Winston
 
Join Date: Jul 2007
Reputation: 38
Posts: 2,194
Sounds right to me
Winston is offline   Reply With Quote
Old 11-26-2008, 10:33 AM   #6
kill3rtomato
 
Join Date: Jun 2008
Reputation: 0
Posts: 14
Another question based on the NPC.. when it goes through that whole process and picks a schedule, made up of the tasks, it will go through them, and only end when all tasks are done (or is interrupted).

So, the NPC will not gather what's going on around him/pick state/select new schedule until the old one is done or is interrupted?

So when he's interrupted it will just go through the whole process again? Meaning the whole process of finding out what's going on around him, picking the state, picking schedule only happens once in a while?
kill3rtomato is offline   Reply With Quote
Old 11-26-2008, 03:18 PM   #7
kill3rtomato
 
Join Date: Jun 2008
Reputation: 0
Posts: 14
Well, I basically figured out the NPC, all it's schedules, tasks, conditions, etc.. I guess it really wasn't as hard as it looked

But now I just need to figure out how to make the NPC follow the player around.. so pathfinding.. how does it work again for the NPC?
kill3rtomato is offline   Reply With Quote
Old 11-26-2008, 03:20 PM   #8
Winston
 
Join Date: Jul 2007
Reputation: 38
Posts: 2,194
Basically yeah. He's constantly looking around him though, and setting conditions that may or may not interrupt him. For instance, an idle schedule will be interrupted by seeing an enemy, but a shooting-an-enemy schedule won't.
Winston is offline   Reply With Quote
Old 11-26-2008, 10:06 PM   #9
kill3rtomato
 
Join Date: Jun 2008
Reputation: 0
Posts: 14
Ok, well I'm back to the start now I guess.

Figured out the NPCs, got all the schedules to work and whatnot, but I can't figure out how to get the NPC to find a path to the player, and go through the path.. Help?
kill3rtomato is offline   Reply With Quote
Old 11-27-2008, 01:56 AM   #10
Winston
 
Join Date: Jul 2007
Reputation: 38
Posts: 2,194
Something like this?

Code:
AI_DEFINE_SCHEDULE
(
	        SCHED_FOLLOW_MASTER,
	
	        "       Tasks"
	        "               TASK_SET_FAIL_SCHEDULE                  SCHEDULE:SCHED_IDLE_STAND"
	        "               TASK_SET_TOLERANCE_DISTANCE             200"
	        "               TASK_GET_PATH_TO_PLAYER                 0"
	        "               TASK_RUN_PATH                                   0"
	        ""
	        "       Interrupts"
);
All those tasks are default ones.
Winston is offline   Reply With Quote
Old 11-27-2008, 10:20 AM   #11
kill3rtomato
 
Join Date: Jun 2008
Reputation: 0
Posts: 14
Doesn't seem to work. It's probably something I'm doing wrong with the NPC.. why do sparks spawn above it's head periodically? I'm sure that has something to do with this..
kill3rtomato is offline   Reply With Quote
Old 11-27-2008, 12:02 PM   #12
sormii
 
Join Date: Jul 2008
Reputation: 2
Posts: 143
I had some problems also a while back
http://forums.steampowered.com/forum...d.php?t=735294
sormii is offline   Reply With Quote
Old 11-27-2008, 03:28 PM   #13
kill3rtomato
 
Join Date: Jun 2008
Reputation: 0
Posts: 14
Ok, now I'm REALLY confused.. thanks to sormii (I think xp) the whole schedule system works. The NPC picks the schedule to follow the player and it's great, etc...

But it seems to have some issues with the tasks. Out of all the shared tasks, it will only do the ones that don't involve any moving around. If there's a task that requires moving, the NPC will sit there and sparks will spawn above it's head...

???
kill3rtomato is offline   Reply With Quote
Old 11-27-2008, 03:38 PM   #14
z33ky
 
Join Date: May 2008
Reputation: 79
Posts: 4,632
I don't know much about AI/NPC-coding, but aren't there any warnings in the console?
If not, post your code.

Other NPCs are working, right?
z33ky is offline   Reply With Quote
Old 11-27-2008, 03:51 PM   #15
kill3rtomato
 
Join Date: Jun 2008
Reputation: 0
Posts: 14
Quote:
Originally Posted by z33ky View Post
I don't know much about AI/NPC-coding, but aren't there any warnings in the console?
If not, post your code.

Other NPCs are working, right?
Yup. Zombies still try to eat me, citizens still follow me, it's just my NPC.

And there's nothing in the console. It's just the sparks, otherwise I would at least have some clue as to what is going on

edit: I know that the schedule is working because one of the tasks is to face the player, and my NPC does that. It just won't move (wander doesn't work either)
kill3rtomato is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Steam News Update Archive sciss0rz General Steam Discussion 62 12-18-2009 05:46 PM
Source Towers Open Source One3yed Source Coding 12 01-06-2009 11:18 AM
Source SDK Updated!!!! TheArxinal Source SDK General Discussion 7 11-08-2007 06:28 AM


All times are GMT -8. The time now is 11:16 AM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Site Content Copyright Valve Corporation 1998-2009, All Rights Reserved.