Author Topic: How do you program for NPCs?  (Read 648 times)

Offline atury

  • Level 4
  • *
  • Posts: 12
  • Reputation: +0/-0
    • View Profile
How do you program for NPCs?
« on: November 01, 2010, 08:34:47 AM »
My question is how do you tackle handling NPCs that give players unique options? I'm actually creating a game that's more like a website, where you collect things using earned abilities and spells, etc. I want all the NPCs to have several options for a player to choose from (if you have x then do y for me and I'll give you z). Right now I'm using Ruby on Rails for this, just to learn the framework and all that, but how would I handle this sort of thing?  How would you do it in php?  Will I need a controller/model for each NPC or can I do it through the database some how?  Maybe AJAX? (City map, click the building, up pops up character list, click character, up pops their choices?)  Just curious.

Offline CygnusX

  • Level 24
  • *
  • Posts: 303
  • Reputation: +3/-2
    • View Profile
    • Lords of Midnight
Re: How do you program for NPCs?
« Reply #1 on: November 01, 2010, 09:33:57 AM »
From my understanding, Ruby and PHP perform similar functions (server side scripts).  I'm not very familiar with Ruby, but I know PHP can grab information from a database, insert information into a database, accept user input, manipulate user input, then redisplay the manipulated data to the screen.  I believe this is the core of what you're trying to accomplish.  Now you just need to do some tutorials.

Offline 133794m3r

  • Level 22
  • *
  • Posts: 265
  • Reputation: +2/-0
    • View Profile
Re: How do you program for NPCs?
« Reply #2 on: November 01, 2010, 01:27:04 PM »
Personally i'd do as cyg says use AJAX if they have javascript enabled if not, i guess do it the old timey way. And also, be sure to just sorta well as you said pull the data that you need and have the options lead to another thing. Hard code their interactions to so speak as in the code that interprets the optiosn and then goes and gets the actual text for the optiosn from the database. Since that way you have more coded things and less DB things to worry about.

Offline atury

  • Level 4
  • *
  • Posts: 12
  • Reputation: +0/-0
    • View Profile
Re: How do you program for NPCs?
« Reply #3 on: November 02, 2010, 01:21:29 AM »
Thanks for the help guys, I think that's the way to go with this. I like that you said to do some tutorials, it's my favorite way to learn. :) I'm pretty sure that after enough tutorials I'll get the hang enough to figure out the best way to do it, just wasn't sure if there was some revolutionary way out there I hadn't thought of before.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal