Implemented NPC movement (random)
[butaba-adventures.git] / npcs.py
diff --git a/npcs.py b/npcs.py
index d368833..26732c2 100644 (file)
--- a/npcs.py
+++ b/npcs.py
@@ -6,17 +6,37 @@ import os.path
 
 class NPC:
        # initalize the NPC
-       def __init__ (self, charname, row, col, image=None, portrait=None, dialogues=[],
-                               currentdialog=0, is_dead=False):
+       def __init__ (self, charname, row, col, imageleft, imageright, imagefront,
+                               imageback, portrait, position, movement_area=(0,0,0,0), movement_speed = 10,
+                               dialogues=[], currentdialog=0, is_dead=False):
                # name of the character
                self.charname = charname
                # row and column to appear (in level)
                self.row = row
                self.col = col
-               # image to represent on level
-               self.image = image
+               # initial row and col - to track the movement area
+               self.initrow = row
+               self.initcol = col
+               # images to represent on level
+               self.imageleft = imageleft
+               self.imageright = imageright
+               self.imagefront = imagefront
+               self.imageback = imageback
+
                # portrait on dialogues
                self.portrait = portrait
+
+               # movement area limits (left, right top, and bottom) in which the NPC can
+               # move around in the level randomly.
+               self.leftlimit, self.rightlimit, self.toplimit, self.bottomlimit = movement_area
+
+               # chance of movement (speed) - that is chance of movement in a turn out of 500 -lower
+               # the value lower the speed
+               self.movement_speed = movement_speed
+
+               # position of the character
+               self.position = position
+
                # dialogue set for NPC
                # each dialogue in the set is a path to an XML file containing the dialogue
                self.dialogues = dialogues
@@ -29,6 +49,9 @@ class NPC:
 
 # Bulisa is Butaba's friend
 class Bulisa (NPC):
-       def __init__ (self, row, col, image, portrait, dialogues=[], currentdialog=0):
-               NPC.__init__ (self, "Bulisa", row, col, image, portrait, dialogues, currentdialog)
+       def __init__ (self, row, col, imageleft, imageright, imagefront,
+                               imageback, portrait, position, movement_area=(0,0,0,0),
+                               dialogues=[], currentdialog=0):
+               NPC.__init__ (self, "Bulisa", row, col, imageleft, imageright, imagefront,
+                               imageback, portrait, position, movement_area, 20, dialogues, currentdialog)