diff src/parpg/objects/action.py @ 78:c25c734bd2a7

Modifications to make talking with npcs possible again. Special actions won't work yet though.
author KarstenBock@gmx.net
date Thu, 08 Sep 2011 15:18:39 +0200
parents ad75fa042b99
children 5508000aceaf
line wrap: on
line diff
--- a/src/parpg/objects/action.py	Thu Sep 08 15:17:28 2011 +0200
+++ b/src/parpg/objects/action.py	Thu Sep 08 15:18:39 2011 +0200
@@ -289,8 +289,10 @@
     def execute(self):
         """Talk with the NPC when close enough, otherwise move closer.
            @return: None"""
-        player_char = self.model.game_state.getObjectById("PlayerCharacter").fifeagent
-        npc_coordinates = self.npc.getLocation().getLayerCoordinates()
+        player_char = self.model.game_state.\
+                    getObjectById("PlayerCharacter").fifeagent
+        npc_coordinates = self.npc.fifeagent.behaviour.getLocation().\
+                        getLayerCoordinates()
         pc_coordinates = player_char.behaviour.agent.\
                             getLocation().getLayerCoordinates()
         
@@ -301,27 +303,37 @@
         
         # If we are too far away, we approach the NPC again
         if distance_squared > 2:
-            player_char.approach([self.npc.getLocation().
-                         getLayerCoordinates().x,
-                         self.npc.getLocation().
-                         getLayerCoordinates().y], 
-                        TalkAction(self.controller,
-                                   self.npc, self.commands))        
+            player_char.behaviour.approach(
+                [npc_coordinates.x, npc_coordinates.y],
+                        TalkAction(self.controller, 
+                                   self.npc, 
+                                   self.commands
+                                   )
+            )        
         else:
-            player_char.behaviour.agent.act('stand', self.npc.getLocation())
+            player_char.behaviour.agent.act(
+                'stand', 
+                self.npc.fifeagent.behaviour.getLocation()
+            )
     
-            if self.npc.dialogue is not None:
-                dialogue_controller = DialogueController(self.controller.engine,
-                                                         self.view,
-                                                         self.model,
-                                                         self.controller.application)
-                self.controller.application.manager.push_mode(dialogue_controller)
+            if self.npc.dialogue.dialogue is not None:
+                dialogue_controller = DialogueController(
+                    self.controller.engine,
+                    self.view,
+                    self.model,
+                    self.controller.application
+                )
+                self.controller.application.manager.push_mode(
+                    dialogue_controller
+                )
                 dialogue_controller.startTalk(self.npc)
             else:
-                self.npc.behaviour.agent.say("Leave me alone!", 1000)
+                self.npc.fifeagent.behaviour.agent.say("Leave me alone!", 1000)
                 
-            self.model.game_state.getObjectById("PlayerCharacter").fifeagent.behaviour.idle()
-            self.model.game_state.getObjectById("PlayerCharacter").fifeagent.nextAction = None
+            self.model.game_state.getObjectById("PlayerCharacter").\
+                fifeagent.behaviour.idle()
+            self.model.game_state.getObjectById("PlayerCharacter").\
+                fifeagent.behaviour.nextAction = None
             super(TalkAction, self).execute()
 
 class UseAction(Action):