comparison demos/rpg/scripts/actors/baseactor.py @ 524:6037f79b0dcf

Multiple quests now work. Added the item layer. Made movement more like diablo by allowing you to hold and drag the left mouse button. All objects are now loaded from a separate "allobjects" file. Specific item attributes are loaded from the map objects file (like position). This allows for the possibility of multiple instances using the same FIFE model.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 27 May 2010 21:11:37 +0000
parents d01eb65b2726
children 796d49ab9380
comparison
equal deleted inserted replaced
523:d01eb65b2726 524:6037f79b0dcf
52 self._dest = destobj 52 self._dest = destobj
53 53
54 def execute(self): 54 def execute(self):
55 print "talking to: " + self._dest.instance.getId() 55 print "talking to: " + self._dest.instance.getId()
56 56
57 if self._dest.haveQuest(): 57 if self._dest.type == GameObjectTypes["QUESTGIVER"]:
58 if not self._dest.activequest: 58 if self._dest.haveQuest():
59 self._dest.offerNextQuest() 59 if not self._dest.activequest:
60 self._dest.offerNextQuest()
61 else:
62 self._dest.completeQuest()
60 else: 63 else:
61 self._dest.completeQuest() 64 self._dest.instance.say("I've got nothing for you... leave me alone.", 2500)
62 else: 65 else:
63 self._dest.instance.say("I've got nothing for you... leave me alone.", 2500) 66 self._dest.instance.say("Hello there!")
64 67
65 ActorStates = {'STAND':0, 68 ActorStates = {'STAND':0,
66 'WALK':1, 69 'WALK':1,
67 'ATTACK':2} 70 'ATTACK':2}
68 71
75 self._object.stand() 78 self._object.stand()
76 self._object.performNextAction() 79 self._object.performNextAction()
77 80
78 class Actor(BaseGameObject): 81 class Actor(BaseGameObject):
79 def __init__(self, gamecontroller, instancename, instanceid=None, createInstance=False): 82 def __init__(self, gamecontroller, instancename, instanceid=None, createInstance=False):
83
84 if not hasattr(self, "_type"):
85 self._type = GameObjectTypes["NPC"]
86
80 super(Actor, self).__init__(gamecontroller, instancename, instanceid, createInstance) 87 super(Actor, self).__init__(gamecontroller, instancename, instanceid, createInstance)
81 88
82 self._walkspeed = self._gamecontroller.settings.get("RPG", "DefaultActorWalkSpeed", 4.0) 89 self._walkspeed = self._gamecontroller.settings.get("RPG", "DefaultActorWalkSpeed", 4.0)
83 90
84 self._actionlistener = ActorActionListener(self._gamecontroller, self) 91 self._actionlistener = ActorActionListener(self._gamecontroller, self)
85 92
86 self._nextaction = None 93 self._nextaction = None
87 94
88 self.stand() 95 self.stand()
89
90 self._type = GameObjectTypes["NPC"]
91 96
92 def stand(self): 97 def stand(self):
93 self._state = ActorStates["STAND"] 98 self._state = ActorStates["STAND"]
94 self._instance.act('stand', self._instance.getFacingLocation()) 99 self._instance.act('stand', self._instance.getFacingLocation())
95 100
142 name = property(_getName, _setName) 147 name = property(_getName, _setName)
143 text = property(_getText, _setText) 148 text = property(_getText, _setText)
144 149
145 class QuestGiver(Actor): 150 class QuestGiver(Actor):
146 def __init__(self, gamecontroller, instancename, instanceid=None, createInstance=False): 151 def __init__(self, gamecontroller, instancename, instanceid=None, createInstance=False):
152 self._type = GameObjectTypes["QUESTGIVER"]
147 super(QuestGiver, self).__init__(gamecontroller, instancename, instanceid, createInstance) 153 super(QuestGiver, self).__init__(gamecontroller, instancename, instanceid, createInstance)
148 154
149 self._type = GameObjectTypes["QUESTGIVER"]
150 self._quests = [] 155 self._quests = []
151 156
152 self._activequest = None 157 self._activequest = None
153 158
154 def addQuest(self, quest): 159 def addQuest(self, quest):