Ejemplo n.º 1
0
	def spawn(self):

		winner = Engine.selector(self.oddsList)

		if winner[0]:

			#print "winner"

			for mob in Globals.mobsFromFile:
				if mob.name == self.mob:
					refmob = mob.name
					ob = mob
				elif hasattr(self.mob, 'name') and mob.name == self.mob.name:
					refmob = mob.name
					ob = mob

			if self.mode == 'pack':		# spawns a group of mobs, the maximum size of which is determined by self.cycles. Always spawns at least one mob.
				iters = 0
				maxNum = random.randint(1, self.cycles)
				#print str(iters) + ":" + str(maxNum)
				while iters < maxNum:
					#print str(iters) + ":" + str(maxNum)
					newMortal = mortal(hp=int(ob.kind.hp), maxHp=int(ob.kind.maxHp), pp=int(ob.kind.pp), maxPp=int(ob.kind.maxPp), level=int(ob.kind.level), exp=int(ob.kind.exp), money=int(ob.kind.money), offense=int(ob.kind.offense), defense=int(ob.kind.defense), speed=int(ob.kind.speed), guts=int(ob.kind.guts), luck=int(ob.kind.luck), vitality=int(ob.kind.vitality), IQ=int(ob.kind.IQ), inventory=[], inventorySize=int(ob.kind.inventorySize), equipment={})
					newMob = Mob(ob.description, ob.currentRoom, ob.name, ob.region, ob.longDescription, ob.speech, newMortal, ob.species, None)
					if hasattr(ob, 'aiMove'):
						newAIComponent = aiMove.movementAI(newMob, ob.aiMove.time)
						if ob.aiMove.Timer.actionFunction == ob.aiMove.basicRandom:
							newAIComponent.Timer.actionFunction = newAIComponent.basicRandom
						if ob.aiMove.Timer.actionFunction == ob.aiMove.introvertRandom:
							newAIComponent.Timer.actionFunction = newAIComponent.introvertRandom
						if ob.aiMove.Timer.actionFunction == ob.aiMove.extrovertRandom:
							newAIComponent.Timer.actionFunction = newAIComponent.extrovertRandom
						if ob.aiMove.Timer.actionFunction == ob.aiMove.doNotMove:
							newAIComponent.Timer.actionFunction = newAIComponent.doNotMove
					newMob.aiMove = newAIComponent

					if hasattr(ob, 'aiBattle'):
						newMob.aiBattle = ob.aiBattle

					if hasattr(ob, 'expirator') and ob.expirator != None:
						newExpirator = expirator(newMob, ob.expirator.startingTime)
						newMob.expirator = newExpirator
					self.owner.currentRoom.mobs.append(newMob)
					newMob.currentRoom = self.owner.currentRoom
					print "$m " +str(newMob) + " " + newMob.name + " @ " + "[" +newMob.currentRoom.region + ":" + newMob.currentRoom.name + "] (pack)"
					for client in Globals.CLIENT_LIST:
						if Globals.CLIENT_DATA[str(client.addrport())].avatar is not None:
							if Globals.CLIENT_DATA[str(client.addrport())].avatar.currentRoom == newMob.currentRoom:      # if a client is in the room object just appeared in, let it know
								client.send_cc("^yA %s appeared.^~\n" %newMob.name)
					iters += 1

			elif self.mode == 'cont':	 	# always spawns exactly one mob
				newMortal = newMortal = mortal(hp=int(ob.kind.hp), maxHp=int(ob.kind.maxHp), pp=int(ob.kind.pp), maxPp=int(ob.kind.maxPp), level=int(ob.kind.level), exp=int(ob.kind.exp), money=int(ob.kind.money), offense=int(ob.kind.offense), defense=int(ob.kind.defense), speed=int(ob.kind.speed), guts=int(ob.kind.guts), luck=int(ob.kind.luck), vitality=int(ob.kind.vitality), IQ=int(ob.kind.IQ), inventory=[], inventorySize=int(ob.kind.inventorySize), equipment={})
				newMob = Mob(ob.description, ob.currentRoom, ob.name, ob.region, ob.longDescription, ob.speech, newMortal, ob.species, None)
				if hasattr(ob, 'aiMove'):
					newAIComponent = aiMove.movementAI(newMob, ob.aiMove.time)
					if ob.aiMove.Timer.actionFunction == ob.aiMove.basicRandom:
						newAIComponent.Timer.actionFunction = newAIComponent.basicRandom
					if ob.aiMove.Timer.actionFunction == ob.aiMove.introvertRandom:
						newAIComponent.Timer.actionFunction = newAIComponent.introvertRandom
					if ob.aiMove.Timer.actionFunction == ob.aiMove.extrovertRandom:
						newAIComponent.Timer.actionFunction = newAIComponent.extrovertRandom
					if ob.aiMove.Timer.actionFunction == ob.aiMove.doNotMove:
						newAIComponent.Timer.actionFunction = newAIComponent.doNotMove
				newMob.aiMove = newAIComponent

				if hasattr(ob, 'aiBattle'):
					newMob.aiBattle = ob.aiBattle

				if hasattr(ob, 'expirator') and ob.expirator != None:
					newExpirator = expirator(newMob, ob.expirator.startingTime)
					newMob.expirator = newExpirator
				self.owner.currentRoom.mobs.append(newMob)
				newMob.currentRoom = self.owner.currentRoom
				print "$m " +str(newMob) + " " + newMob.name + " @ " + "[" + newMob.currentRoom.region + ":" + newMob.currentRoom.name + "] (cont)"
				for client in Globals.CLIENT_LIST:
					if Globals.CLIENT_DATA[str(client.addrport())].avatar is not None:
						if Globals.CLIENT_DATA[str(client.addrport())].avatar.currentRoom == newMob.currentRoom:      # if a client is in the room object just appeared in, let it know
							client.send_cc("^yA %s appeared.^~\n" %newMob.name)

			elif self.mode == 'thresh':		# spawns mobs until the number of mobs in the room equals self.cycles
				resultsList = []
				for mob in self.owner.currentRoom.mobs:
					if mob.name == self.mob:
						resultsList.append(mob)
				numPresent = len(resultsList)
				#print numPresent
				if numPresent < self.cycles:
					newMortal = newMortal = mortal(hp=int(ob.kind.hp), maxHp=int(ob.kind.maxHp), pp=int(ob.kind.pp), maxPp=int(ob.kind.maxPp), level=int(ob.kind.level), exp=int(ob.kind.exp), money=int(ob.kind.money), offense=int(ob.kind.offense), defense=int(ob.kind.defense), speed=int(ob.kind.speed), guts=int(ob.kind.guts), luck=int(ob.kind.luck), vitality=int(ob.kind.vitality), IQ=int(ob.kind.IQ), inventory=[], inventorySize=int(ob.kind.inventorySize), equipment={})
					newMob = Mob(ob.description, ob.currentRoom, ob.name, ob.region, ob.longDescription, ob.speech, newMortal, ob.species, None)
					if hasattr(ob, 'aiMove'):
						newAIComponent = aiMove.movementAI(newMob, ob.aiMove.time)
						if ob.aiMove.Timer.actionFunction == ob.aiMove.basicRandom:
							newAIComponent.Timer.actionFunction = newAIComponent.basicRandom
						if ob.aiMove.Timer.actionFunction == ob.aiMove.introvertRandom:
							newAIComponent.Timer.actionFunction = newAIComponent.introvertRandom
						if ob.aiMove.Timer.actionFunction == ob.aiMove.extrovertRandom:
							newAIComponent.Timer.actionFunction = newAIComponent.extrovertRandom
						if ob.aiMove.Timer.actionFunction == ob.aiMove.doNotMove:
							newAIComponent.Timer.actionFunction = newAIComponent.doNotMove
					newMob.aiMove = newAIComponent

					if hasattr(ob, 'aiBattle'):
						newMob.aiBattle = ob.aiBattle

					if hasattr(ob, 'expirator') and ob.expirator != None:
						newExpirator = expirator(newMob, ob.expirator.startingTime)
						newMob.expirator = newExpirator
					self.owner.currentRoom.mobs.append(newMob)
					newMob.currentRoom = self.owner.currentRoom
					print "$m " +str(newMob) + " " + newMob.name + " @ " + "[" + newMob.currentRoom.region + ":" + newMob.currentRoom.name + "] (thresh)"
					for client in Globals.CLIENT_LIST:
						if Globals.CLIENT_DATA[str(client.addrport())].avatar is not None:
							if Globals.CLIENT_DATA[str(client.addrport())].avatar.currentRoom == newMob.currentRoom:      # if a client is in the room object just appeared in, let it know
								client.send_cc("^yA %s appeared.^~\n" %newMob.name)
				#else:
					#print "limit reached"

		self.timer.currentTime = self.time
		self.TIMERS.append(self.timer)
Ejemplo n.º 2
0
	def spawn(self):
		if self.active:
		 	#if self.startingLocation[0] is not None:
			#print self.active

			if self.repeat:
				self.timer.currentTime = self.time
				#print "repeatTime: " + str(self.timer.currentTime)
				self.TIMERS.append(self.timer)
				#print str(self.timer) + " repeated. " + str(Globals.TIMERS)

			elif self.cycles > 1:
				self.cycles -= 1
				#Globals.TIMERS.remove(self.timer)
				self.timer.currentTime = self.time
				#print "cycleTime: " + str(self.timer.currentTime)
				Globals.TIMERS.append(self.timer)
				#print "cycles -1 " + str(Globals.TIMERS)

			winner = Engine.selector(self.oddsList)
			if winner[0]:
				#print self.active
				#print self.owner.owner.currentRoom
				#print self.startingLocation
				#self.obj.currentRoom = self.startingLocation[0]	# tell the object what room it is in

				for obj in Globals.fromFileList:
					if obj.name == self.obj.name:
						refobj = obj.name
						ob = obj

				#print self.active
				newObject = Engine.cmdSpawnObject(refobj, self.startingLocation[0], whereFrom='objSpawner', spawnContainer=self.owner.owner.spawnContainer)
				#print self.active
				#print str(newObject.name) + " added timer " + str(newObject.kind.objectSpawner.timer)
				#print "ob " +str(ob.kind.objectSpawner.active)
				#print self.active
				#print newObject.spawnContainer
				#print self.owner.owner
				# if self.startingLocation[0] is not None:
				#self.startingLocation[0].objects.append(self.obj)
				# else:
				# 	pass	# add the new object to the room

				stuffed = self.stuff(newObject, True)		# try shoving items in containers if they should be there instead of in the room

				# for client in Globals.CLIENT_LIST:
				# 	if Globals.CLIENT_DATA[str(client.addrport())].avatar is not None:
				# 		if Globals.CLIENT_DATA[str(client.addrport())].avatar.currentRoom == self.startingLocation[0]:		# if a client is in the room object just appeared in, let it know
				# 			if not stuffed:
				# 				client.send_cc("^BA %s appeared.^~\n" %self.owner.owner.name)
				# print "repeat:" + str(self.repeat)
				# print "cycles:" + str(self.cycles)
				# print "timer:" + str(self.timer)
				#print "currentTime:" + str(self.obj.kind.objectSpawner.timer.currentTime)
				# print "time:" + str(self.timer.time)
				# print "name:" + str(self.owner.owner.name)


					#print "$o  "+ str(self.owner.owner)+ " "+ str(self.owner.owner.name) + " @ [" + str(self.startingLocation[0].region) + ":" + str(self.startingLocation[0].name) +"]"

			# else:
			# 	self.obj.kind.objectSpawner.timer.currentTime = self.time
			# 	#print self.timer.time
			# 	Globals.TIMERS.append(self.obj.kind.objectSpawner.timer)
			# 	print "noWin " + str(Globals.TIMERS)
	
		else:
			if self.owner.owner.spawnContainer is not None:
				if not(self.owner.owner in self.owner.owner.spawnContainer.kind.inventory):
					stuffed = self.stuff(self.owner.owner, False)