Author Topic: NPC database question  (Read 514 times)

Offline atury

  • Level 4
  • *
  • Posts: 12
  • Reputation: +0/-0
    • View Profile
NPC database question
« on: October 24, 2010, 06:00:52 PM »
Ok, first off, I'm really new to programming. I'm learning RoR because I just don't feel like learning PHP. Anyway. My question would actually work for either, but here goes:

I am trying to figure out how to handle having NPCs that give players unique items. Example: Roger Dodger gives Player1 the Sword of Destruction. Roger Dodger is now -1 Sword of Destruction and Player1 is now + 1 Sword of Destruction (inventory). Obviously, in Player1's game world, you want it so that he can't just go off and sell the item and come back to the same NPC and get another one. So our NPC, Roger Dodger only has 1 Sword of Destruction to give to Player1.  The problem is he also needs to be able to give that same item to any other player who encounters him.

My newb brain can't figure out how to do the database to account for this, because just having a NPC table with the items in a column would make it so that only one player could obtain that item. How do you make it so the NPCs have items for all the players and then have it so the NPC always registers that they no longer have the item once a player obtains it without affecting other players?

Does that even make sense?   

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: NPC database question
« Reply #1 on: October 24, 2010, 06:05:42 PM »
Unique item that can not be discarded. NPC that gave it is irrelevant.

Offline atury

  • Level 4
  • *
  • Posts: 12
  • Reputation: +0/-0
    • View Profile
Re: NPC database question
« Reply #2 on: October 24, 2010, 06:14:00 PM »
I think you're trying to say that the item is not "unique" if other players can also get it. I failed to clarify that this is not an MMOPRG I'm planning, but a single player game. If I have 100 people playing the game, and the adventure leads them to these NPCs that drop loot for doing the quests, I don't see how I can use a database table for NPCs to handle this, as the inventory would be depleted after one player accomplished their quest. 

Maybe if I rephrase the question: how can I make it so each player's interaction with the NPCs is custom to them while still being completely planned out (non-random)?

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: NPC database question
« Reply #3 on: October 24, 2010, 06:47:10 PM »
Unique = only one instance of the item for a particular player can exist.

Ignore NPC, the NPC gives nothing (it only looks to the player as if NPC was doing something).

When you encounter the NPC you check player's inventory. If the unique item is present it means it has been given by the NPC already. If not present generate the item. So it's like the other way round, it is not NPC affecting inventory but inventory affecting NPC behaviour.

Offline atury

  • Level 4
  • *
  • Posts: 12
  • Reputation: +0/-0
    • View Profile
Re: NPC database question
« Reply #4 on: October 24, 2010, 08:27:28 PM »
Awesome. Thanks for helping me out, that way makes absolute sense.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal