Changeset 287 for trunk/game/scripts


Ignore:
Timestamp:
09/20/09 23:51:51 (10 years ago)
Author:
orlandov
Message:

Ticket #74: Patch by or1andov, Integrate dialogue GUI and engine into game.

It should now be possible to engage in a conversation with NPC characters by
selecting talk from their context menu. fixes[s:trac, t:74]

Known Issues:


  • the GUI is terrible. instead of a dialog window, we could use a better looking background image and fixed position widgets
  • requires PyYAML to be installed sudo apt-get install python-yaml easy_install PyYAML
  • we have to create a simple state model for the PC can remember tasks
  • need to make NPC's be able to remember things - need a model in NPCs for this
  • no way currently to give or take items from npc's; again, more model work. this could be done by adding another callback similar to start_quest. may be necessary for npc's to have an inventory for this
  • The dialogue engine is not hooked up to specific NPC's... it currently always loads dialogue/sample.yaml - need to have the dialogue looked up from some XML attribute
  • dialogue is not broken off if the PC moves away from the NPC
  • npc image is hardcoded, it should use the image specified in the yaml file
Location:
trunk/game/scripts
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/engine.py

    r264 r287  
    239239        # out 
    240240        npc = self.gameState.getObjectById(npcInfo.ID) 
    241         if npc: 
    242             npc.talk() 
    243         self.gameState.PC.approach([npc.getLocation().getLayerCoordinates().x, npc.getLocation().getLayerCoordinates().y]) 
     241        self.gameState.PC.approach([npc.getLocation().getLayerCoordinates().x, npc.getLocation().getLayerCoordinates().y], TalkAction(self, npc)) 
    244242 
    245243    def loadMap(self, map_name, map_file): 
  • trunk/game/scripts/hud.py

    r277 r287  
    1717 
    1818import shutil, fife, pychan 
     19import pychan.widgets as widgets 
    1920from pychan.tools import callbackWithArguments as cbwa 
    2021from scripts.parpgfilebrowser import PARPGFileBrowser 
     
    2223from scripts import inventory 
    2324from scripts.popups import ExaminePopup, ContainerGUI 
     25from scripts.dialoguegui import DialogueGUI 
    2426 
    2527class Hud(object): 
     
    171173        self.main_menu.hide() 
    172174        self.menu_displayed = False 
     175 
    173176 
    174177    def initializeHelpMenu(self): 
     
    534537        self.examine_box = ExaminePopup(self.engine, title, desc) 
    535538        self.examine_box.showPopUp() 
     539 
     540    def showDialogue(self, npc): 
     541        """Show the NPC dialogue window 
     542           @type npc: ??? 
     543           @param npc: the npc that we are having a dialogue with""" 
     544        dialogue = DialogueGUI(npc) 
     545        dialogue.initiateDialogue() 
  • trunk/game/scripts/objects/action.py

    r277 r287  
    7272        """Examine the box.""" 
    7373        self.engine.view.hud.createExamineBox(self.examineName, self.examineDesc) 
     74 
     75class TalkAction(Action): 
     76    """An action to represent starting a dialogue""" 
     77    def __init__(self, engine, npc): 
     78        """@type engine: Engine reference 
     79           @param engine: A reference to the engine. 
     80           @type examineName: String 
     81           @param examineName: Name of the object to be examined. 
     82           @type examineName: String 
     83           @param examineName: Description of the object to be examined. 
     84           """ 
     85        self.engine = engine 
     86        self.npc = npc 
     87         
     88    def execute(self): 
     89        """Examine the box.""" 
     90        pc = self.engine.gameState.PC 
     91        pc.behaviour.agent.act('stand', self.npc.getLocation()) 
     92        self.npc.talk(pc) 
     93        self.engine.view.hud.showDialogue(self.npc) 
  • trunk/game/scripts/objects/actors.py

    r278 r287  
    242242        self.behaviour.agent.move('run', location, self.behaviour.speed+1) 
    243243 
    244     def talk(self): 
     244    def talk(self, pc): 
    245245        """ Makes the NPC ready to talk to the PC 
    246246            @return: None""" 
    247         self.state = _AGENT_STATE_TALK 
     247        self.behaviour.state = _AGENT_STATE_TALK 
     248        self.behaviour.pc = pc.behaviour.agent 
    248249        self.behaviour.idle() 
    249250     
Note: See TracChangeset for help on using the changeset viewer.