diff demos/rpg/scripts/actors/baseactor.py @ 563:f85762e634c5

- Added the AttackAction along with a test enemy on level 1. - Removed the getModuleByType() helper function.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 24 Jun 2010 21:27:11 +0000
parents 69d50e751c9a
children 872a7a94563e
line wrap: on
line diff
--- a/demos/rpg/scripts/actors/baseactor.py	Thu Jun 24 19:58:59 2010 +0000
+++ b/demos/rpg/scripts/actors/baseactor.py	Thu Jun 24 21:27:11 2010 +0000
@@ -62,7 +62,17 @@
 			else:
 				self._dest.showNoQuestDialog()
 		else:
-			self._dest.instance.say("Hello there!")
+			self._dest.say("Hello there!")
+			
+class AttackAction(BaseAction):	
+	def __init__(self, attacker, defender):
+		self._actiontype = Actions['ATTACK']
+		self._attacker = attacker
+		self._defender = defender
+		
+	def execute(self):
+		if self._defender.type == GameObjectTypes["ENEMY"]:
+			self._defender.say("Ouch")
 			
 class PickUpItemAction(BaseAction):
 	def __init__(self, actor, item):
@@ -155,8 +165,6 @@
 	def __init__(self, gamecontroller, layer, typename, baseobjectname, instancename, instanceid=None, createInstance=False):
 		super(Actor, self).__init__(gamecontroller, layer, typename, baseobjectname, instancename, instanceid, createInstance)
 
-		self._type = GameObjectTypes["DEFAULT"]
-
 		self._nextaction = None
 		self._inventory = []
 		self._maxinventoryitems = 20