Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

NPC avoids hero

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Bagne
ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA




Joined: 19 Feb 2003
Posts: 518
Location: Halifax

PostPosted: Sat May 08, 2010 6:29 am    Post subject: NPC avoids hero Reply with quote

How does the NPC hero-avoidance behaviour work:
Do they avoid the hero's tile coordinates, or the hero's pixel coordinates?

I might be "putting" a hero in between two tiles (and having NPCs avoid him).
If multi-threads happens before I actually commit to making this part of my game (not sure when I will), I might write my own behaviour for the NPCs.
_________________
Working on rain and cloud formation
Back to top
View user's profile Send private message
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sat May 08, 2010 7:20 am    Post subject: Reply with quote

Tiles. Pretty much all of the map walkabout logic uses tiles, and there's a lot of weird behaviour resulting, like NPCs getting stuck if they're partway between tiles.

The thing to remember is that the tile an NPC or hero is on is defined to be the tile that its top left corner is on.

The NPC movement types are all really primitive, but I don't want to change them because it would change lots of old games. May have to add lots of new movement types (like chase/avoid that uses simple pathfinding), but it could get confusing. Also, I want to add parameters to each movement type, so for example you could specify how often a "Random" NPC moves, how often/far it walks in deliberate paths to random nearby destinations, etc.

Adding NPC movement scripts is going to be pretty cool. I really ought to fast-track multitasking/script threads/that stuff over the other new script features.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Bagne
ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA




Joined: 19 Feb 2003
Posts: 518
Location: Halifax

PostPosted: Sat May 08, 2010 11:27 am    Post subject: Reply with quote

Sounds cool!
So by path-finding, do you mean a command where you say
WALK NPC TO XY (destinationX,destinationY)
and it does a magical A* algorithm, and walks there on its own?

I was thinking of writing up an A* thingajig ... it could come in handy ... but I don't know the theory behind it or anything. There's pseudo-code on wikipedia, but I didn't follow it very well :-S
I don't know the definition of all these open and closed sets ... or how to describe a graph node in Hspeak.
Slices make good tree nodes, because both are structured hierarchially, but graph nodes don't appear to be hierarchical, so slices might not work as well ... although I suppose you could do it differently and store handles of adjacent graph nodes in their extras.
_________________
Working on rain and cloud formation
Back to top
View user's profile Send private message
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sat May 08, 2010 6:15 pm    Post subject: Reply with quote

Bagne wrote:
Sounds cool!
So by path-finding, do you mean a command where you say
WALK NPC TO XY (destinationX,destinationY)
and it does a magical A* algorithm, and walks there on its own?


Well, I'm planning to add that too, but I was actually talking about Avoid Hero and Chase Hero NPC movement types which use pathfinding (not necessarily A*: when you're running away, what is the destination?) so that they don't get stuck in corners.

Bagne wrote:
I was thinking of writing up an A* thingajig ... it could come in handy ... but I don't know the theory behind it or anything. There's pseudo-code on wikipedia, but I didn't follow it very well :-S
I don't know the definition of all these open and closed sets ... or how to describe a graph node in Hspeak.
Slices make good tree nodes, because both are structured hierarchially, but graph nodes don't appear to be hierarchical, so slices might not work as well ... although I suppose you could do it differently and store handles of adjacent graph nodes in their extras.


The A* algorithm is normally given for search on a general graph. But when your graph is a grid, you can store it as a 2D array (ie, in the OHR just use a tilemap or passmap) and don't need an explicit graph. This makes things quite a bit easier, and slices are perfect for the open and closed sets.

Newbie Power and I wrote an A* implementation using slices for his tactical RPG. Admittedly it took a loooong time to sort out all the bugs (problems with slice commands), but it's actually fairly short.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group