当前位置: 首页>>代码示例>>Python>>正文


Python Engine.cmdSpawnObject方法代码示例

本文整理汇总了Python中Engine.cmdSpawnObject方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.cmdSpawnObject方法的具体用法?Python Engine.cmdSpawnObject怎么用?Python Engine.cmdSpawnObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Engine的用法示例。


在下文中一共展示了Engine.cmdSpawnObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: spawn

# 需要导入模块: import Engine [as 别名]
# 或者: from Engine import cmdSpawnObject [as 别名]
	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)	
开发者ID:buckets1337,项目名称:MotherMUD,代码行数:73,代码来源:World.py

示例2: loadMobFromFile

# 需要导入模块: import Engine [as 别名]
# 或者: from Engine import cmdSpawnObject [as 别名]

#.........这里部分代码省略.........
			moveAI = text.split(":")
		if Data.startswith('battleAI='):
			text = Data[9:-1]
			if text == 'basicBash':
				battleAI = aiBattle.basicBash
			else:
				battleAI = ''

		if Data.startswith('kind.hp='):
			newMob.kind.hp = int(Data[8:-1])
		if Data.startswith('kind.maxHp='):
			newMob.kind.maxHp = int(Data[11:-1])
		if Data.startswith('kind.pp='):
			newMob.kind.pp = int(Data[8:-1])
		if Data.startswith('kind.maxPp='):
			newMob.kind.maxPp = int(Data[11:-1])
		if Data.startswith('kind.level='):
			newMob.kind.level = int(Data[11:-1])
		if Data.startswith('kind.exp='):
			newMob.kind.exp = int(Data[9:-1])
		if Data.startswith('kind.money='):
			newMob.kind.money = int(Data[11:-1])
		if Data.startswith('kind.offense='):
			newMob.kind.offense = int(Data[13:-1])
		if Data.startswith('kind.defense='):
			newMob.kind.defense = int(Data[13:-1])
		if Data.startswith('kind.speed='):
			newMob.kind.speed = int(Data[11:-1])
		if Data.startswith('kind.guts='):
			newMob.kind.guts = int(Data[10:-1])
		if Data.startswith('kind.luck='):
			newMob.kind.luck = int(Data[10:-1])
		if Data.startswith('kind.vitality='):
			newMob.kind.vitality = int(Data[14:-1])
		if Data.startswith('kind.IQ='):
			newMob.kind.IQ = int(Data[8:-1])
		if Data.startswith('kind.inventory='):
			invString = Data[15:-1]
			if invString != '':
				#print "invString:" + invString
				invList = invString.split(', ')
				#print 'invList:' + str(invList)
				for item in invList:
					for ob in Globals.fromFileList:
						if item == ob.name:
							inventoryItems.append(item)
			else:
				inventoryItems = []
		if Data.startswith('kind.inventorySize='):
			newMob.kind.inventorySize = int(Data[19:-1])


	if currentRoomString != '':
		currentRoomCoords = currentRoomString.split(":")
		newMob.currentRoom = Globals.regionListDict[currentRoomCoords[0]][currentRoomCoords[1]]
	else:
		# newMob.currentRoom = Globals.regionListDict[newMob.region]['bullpen']
		newMob.currentRoom = None

	if expirator != None and expirator != '':
		expiratorComponent = World.expirator(newMob, expirator)
		newMob.expirator = expiratorComponent

	if moveAI != None and moveAI != []:
		newMoveAI = aiMove.movementAI(newMob, int(moveAI[1]))
		if moveAI[0] == 'basicRandom':
			newMoveAI.Timer.actionFunction = newMoveAI.basicRandom
		elif moveAI[0] == 'introvertRandom':
			newMoveAI.Timer.actionFunction = newMoveAI.introvertRandom
		elif moveAI[0] == 'extrovertRandom':
			newMoveAI.Timer.actionFunction = newMoveAI.extrovertRandom
		elif moveAI[0] == 'doNotMove':
			newMoveAI.Timer.actionFunction = newMoveAI.doNotMove

		newMob.aiMove = newMoveAI
		Globals.MoveTIMERS.remove(newMob.aiMove.Timer)

	if battleAI != None:
		newMob.aiBattle = battleAI

	#print 'invItems:' + str(inventoryItems)
	for item in inventoryItems:
		#print 'invitem:' + str(item)
		removed = False
		newItem = Engine.cmdSpawnObject(item, newMob.currentRoom, alert=False, whereFrom='mobinv')
		newMob.kind.inventory.append(newItem)
		# for obj in newMob.currentRoom.objects:
		# 	if obj.name == item:
		# 		newMob.currentRoom.objects.remove(obj)
		if newMob.currentRoom is not None:
			newMob.currentRoom.objects.remove(newItem)

	if newMob.currentRoom is not None:
		newMob.currentRoom.mobs.append(newMob)

	if expirator != None and expirator != '':
		Globals.TIMERS.remove(newMob.expirator.Timer)
		#newMob.expirator.Timer = None

	Globals.mobsFromFile.append(newMob)
开发者ID:buckets1337,项目名称:MotherMUD,代码行数:104,代码来源:MobInit.py


注:本文中的Engine.cmdSpawnObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。