Crystal Space
Welcome, Guest. Please login or register.
November 27, 2014, 07:58:09 am

Login with username, password and session length
Search:     Advanced search
9026 Posts in 2046 Topics by 9141 Members
Latest Member: Corneliussummers
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  NPC.. how?
« previous next »
Pages: [1] Print
Author Topic: NPC.. how?  (Read 2076 times)
Freetimecoder
Newbie
*
Posts: 31


View Profile
« on: February 14, 2008, 04:33:55 pm »

Well,

it seems that I get used to CEL, but.. how can I programm selfacting entities?
All the things I've done so far, are entities, which react on keyborard input via SendMessage().
(Like it is done in the walktut sample) But I couldn't figure out, how Messages are sent and how
 I could sent something like an "Update"-message to a NPC.

hlp plz Smiley
greetings
Logged
inkolibria
Guest
« Reply #1 on: February 15, 2008, 05:26:34 pm »

Well, I don't know much about I.A., inferences, heuristics and so on and I don't know if CEL is offering something to help (depending the complexity you can search for algorithms on the net, like pathfinding and so on).
I find simple to use a states logic with "PcProperties".
http://crystalspace3d.org/cel/docs/online/api-1.2/structiPcProperties.html

You can store the actual state of the entity, like "walking", "waiting", "pissing" and program the actions for the times you set a new state:

// after telling an entity to walk
npc1.newstate:=walking
if npc1.oldstate="pissing" do
  Nothing, wait a moment just in case
else if npc1.oldstate=waiting do
  npc1.Forwardspeed:=5
  npc1.oldstate:=walking
  npc1.newstate:=null
end if


If you are doing something simple I think that the idea works.
« Last Edit: February 15, 2008, 05:38:54 pm by Inko I.A. » Logged
Freetimecoder
Newbie
*
Posts: 31


View Profile
« Reply #2 on: February 15, 2008, 05:46:21 pm »

Thanks for the reply,
but I actually asked how I can tell a CEL entity to do the AI stuff, not how to programm the AI itself. (what I've already done several times in other languages)

A inputcontrolled entity works like that:

Sendmessage(Message)
{
   if Message=this{
      do this
   }elseif Message=that{
      do that
   }
}

Sendmessage is called, when I push a key or click a mouse button etc.
But I want to create an entity, which should fully work on it's own without pushing buttons.

regards
Logged
inkolibria
Guest
« Reply #3 on: February 17, 2008, 02:29:20 pm »

I don't know how to send custom messages, never done it. Anyway, I think you can have all you need with timer, trigger and quest property classes.
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 6.188 seconds with 17 queries.