Пример #1
0
	def Death():
		if obj['hp'] < 1:
			scene.addObject('Explosion',obj)
			logic.sendMessage('explosion', 'None')
			obj.endObject()
			scene.objects['TankGun'].endObject()
			scene.objects['CamMain']['players'] -= 1
Пример #2
0
def main(cont):
	global dest, from_quat, slerp_factor, to_quat
	own = cont.owner
	#where we are going
	dest = cam_defualt_pos.worldPosition.copy()
	diff = dest - own.worldPosition.copy()
	#lerping
	if diff.magnitude > 0.1:
		 diff *= 0.025

	if slerp_factor < 1.0:
		slerp_factor += 0.005
		#print ('slerp', slerp_factor)
	
	own.worldPosition += diff
	#slerping rotation
	quatInterpolation = from_quat.slerp(to_quat, slerp_factor)
	own.worldOrientation = quatInterpolation.to_matrix()
	#reached our destination
	if own.worldPosition == dest:
		#own.orientation = cam_defualt_pos.orientation
		logic.sendMessage('player_unfreeze')
		logic.sendMessage('HUD_on')
		render.setMousePosition(int(render.getWindowWidth() / 2), int(render.getWindowHeight() / 2))
		own.state = logic.KX_STATE1
Пример #3
0
	def Death(): #This function handles the Tank's death :(
		if obj['hp'] < 1:
			scene.addObject('Explosion',obj)
			logic.sendMessage('explosion', 'None')
			obj.endObject()
			scene.objects['TankGun'].endObject()
			scene.objects['CamMain']['players'] -= 1
Пример #4
0
	def Death():
		if obj['bounces'] > obj['maxBounces']:
			obj.endObject()
			explosion = scene.addObject('Explosion',obj)
			logic.sendMessage('rocket_explosion', 'None')
		
		if rocket_collision.positive and obj['time'] < 30:
			dict['levelScore'] += 10
			dict['rocket_kills'] += 1
			scene.addObject('Plus_10',obj,40)
			scene.objects['Plus_10'].alignAxisToVect([1.0,0,0],0,1.0)
		if collision.positive:
			enemy = collision.hitObject
			if 'player' in enemy and obj['time'] < 5.0:
				pass
			else:
				if 'enemy' in enemy:
					logic.sendMessage('hit', 'None', str(enemy))
				if 'hp' in enemy:
					enemy['hp'] -= 10
				obj.endObject()
				explosion = scene.addObject('Explosion',obj)
		if obj['hp'] < 1:
			obj.endObject()
		if obj['time'] > 600:
			obj.endObject()
		
		obj['time'] += 1.0
Пример #5
0
	def gain_xp(self, amt):
		self.xp += amt
		if self.xp >= self.xp_to_next:
			self.level += 1
			logic.sendMessage('player_level_number', str(self.level))
			print("\nWelcome to Lvl {}!\n".format(self.level))
			for i in range(3):
				stat = randint(0,3)
				if stat == 0:
					self.strength += 1
				elif stat == 1:
					self.agility += 1
				elif stat == 2:
					self.vitality += 1
				elif stat == 3:
					self.magic += 1

			announce_stats()
			
		#%progress to next lvl
		last_lvl = find_xp_for_level(self.level)
		A = self.xp - last_lvl
		B = find_xp_for_level(self.level+1) - last_lvl
		value = A / B
		
		logic.sendMessage('update_player_xp', str(value))
Пример #6
0
	def Health(self):
		cont = logic.getCurrentController()
		obj = cont.owner
		dict = logic.globalDict
		level = dict['level']
		scene = logic.getCurrentScene()
		enemyID = str(obj)[len(str(obj))-4:len(str(obj))]
		hit = cont.sensors['Message2']
		if self.type == 'kamikaze':
			col = cont.sensors['Collision']
			if col.positive:
				self.hp -= 10
				enemy = col.hitObject
				if 'enemy' in enemy:
					logic.sendMessage('hit', 'None', str(enemy))
				if 'hp' in enemy:
					enemy['hp'] -= 10
		if hit.positive:
			self.hp -= 10
		if self.hp < 1:
			if dict['level'] != 0:
				dict['levelScore'] += 100
				dict['tank_kills'] += 1
				scene.addObject('Plus_100', obj, 40)
				scene.objects['Plus_100'].alignAxisToVect([1.0,0,0],0,1.0)
			scene.addObject('Explosion',obj)
			scene.objects['EnemyGun%s%s' % (level, enemyID)].endObject()
			scene.objects['CamMain']['enemies'] -= 1
			logic.sendMessage('explosion', 'None')
			obj.endObject()
Пример #7
0
	def player_kill(self, origin):
		T = logic.globalDict['play_time']
		origin_name = origin.Name
		if origin_name == "None":
			origin_name = "Mysterious Force (probably a bug)"
		logic.globalDict['epitaph'] = "Here lies {}, slain by a {} after {}".format(self.Name, origin_name, T)
		logic.sendMessage("PLAYER_DEATH")
Пример #8
0
    def gain_xp(self, amt):
        self.xp += amt
        if self.xp >= self.xp_to_next:
            self.level += 1
            logic.sendMessage('player_level_number', str(self.level))
            print("\nWelcome to Lvl {}!\n".format(self.level))
            for i in range(3):
                stat = randint(0, 3)
                if stat == 0:
                    self.strength += 1
                elif stat == 1:
                    self.agility += 1
                elif stat == 2:
                    self.vitality += 1
                elif stat == 3:
                    self.magic += 1

            announce_stats()

        #%progress to next lvl
        last_lvl = find_xp_for_level(self.level)
        A = self.xp - last_lvl
        B = find_xp_for_level(self.level + 1) - last_lvl
        value = A / B

        logic.sendMessage('update_player_xp', str(value))
Пример #9
0
	def Death():
		if obj['bounces'] > obj['maxBounces']: #Makes sure rockets only bounce once.
			obj.endObject()
			explosion = scene.addObject('Explosion',obj)
			logic.sendMessage('rocket_explosion', 'None')
		
		if rocket_collision.positive and obj['time'] < 30: #Adds ten points to your score if you kill a rocket within a certain
			dict['levelScore'] += 10								  #radius around your tank. 
			dict['rocket_kills'] += 1
			scene.addObject('Plus_10',obj,40)
			scene.objects['Plus_10'].alignAxisToVect([1.0,0,0],0,1.0)
		if collision.positive:
			enemy = collision.hitObject
			if 'player' in enemy and obj['time'] < 5.0: #Have to have this otherwise your own rockets sometimes kill you 
				pass												  #right when they spawn.
			else:
				if 'enemy' in enemy:
					logic.sendMessage('hit', 'None', str(enemy))
				if 'hp' in enemy:
					enemy['hp'] -= 10
				obj.endObject()
				explosion = scene.addObject('Explosion',obj)
		if obj['hp'] < 1:
			obj.endObject()
		if obj['time'] > 600:
			obj.endObject()
		
		obj['time'] += 1.0
Пример #10
0
def main(cont):
    own = cont.owner

    if own['dig_time'] > 1.5:
        own.endObject()
        #send death message
        logic.sendMessage(own['TYPE'] + '_dead')
        #logic.globalDict['player_engage_list'].remove(own)
Пример #11
0
 def player_kill(self, origin):
     # Special case for player death
     T = logic.globalDict["play_time"]
     origin_name = origin.Name
     if origin_name == "None":
         origin_name = "Mysterious Force (probably a bug)"
     logic.globalDict["epitaph"] = "Here lies {}, slain by a {} after {}".format(self.Name, origin_name, T)
     logic.sendMessage("PLAYER_DEATH")
Пример #12
0
def main(cont):
	own = cont.owner

	if own['dig_time'] > 1.5:
		own.endObject()
		#send death message
		logic.sendMessage(own['TYPE']+'_dead')
		#logic.globalDict['player_engage_list'].remove(own)
Пример #13
0
def Update_Radar():
	keys = ['radar.000','radar.001','radar.002','radar.003']
	msg = 'radar'
	for key in keys:
		value = gval(key)
		msg += ':' + str(value)
		value += 10
		sval(key,value)
	logic.sendMessage('radar',msg)
Пример #14
0
    def receive_identified_message(self, identifier, subject):
        """Send message to a specific instance that won't be picked up as a broadcast

        :param prefix: prefix of subject
        :param subject: subject of message
        """
        encoded_scene_info = encode_scene_info(subject, self)
        encoded_subject = encode_subject(identifier, encoded_scene_info)
        logic.sendMessage(encoded_subject)
Пример #15
0
    def receive_identified_message(self, identifier, subject):
        """Send message to a specific instance that won't be picked up as a broadcast

        :param prefix: prefix of subject
        :param subject: subject of message
        """
        encoded_scene_info = encode_scene_info(subject, self)
        encoded_subject = encode_subject(identifier, encoded_scene_info)
        logic.sendMessage(encoded_subject)
Пример #16
0
 def player_kill(self, origin):
     T = logic.globalDict['play_time']
     origin_name = origin.Name
     if origin_name == "None":
         origin_name = "Mysterious Force (probably a bug)"
     logic.globalDict[
         'epitaph'] = "Here lies {}, slain by a {} after {}".format(
             self.Name, origin_name, T)
     logic.sendMessage("PLAYER_DEATH")
Пример #17
0
def main(cont):
	#turn on the hud
	logic.sendMessage('HUD_on')
	player['torch'] = False
	#play the music
	cont.activate('docks_music')
	
	logic.globalDict['crane_go'] = False
	global crane_cam
	crane_cam = None
Пример #18
0
def main(cont):
    # turn on the hud
    logic.sendMessage("HUD_on")
    player["torch"] = False
    # play the music
    cont.activate("docks_music")

    logic.globalDict["crane_go"] = False
    global crane_cam
    crane_cam = None
Пример #19
0
	def activeCamAnimation(self, message):
		if (self.camAnimation != True):
			# Copy pos to the camera before the animation
			scene = logic.getCurrentScene()
			cam_pos = scene.objects['cam.position']
			cam_pos.worldPosition = self.cam.worldPosition
			# Active
			self.camAnimation = True
			self.deactiveTrackPlayer()
			logic.sendMessage(message)
Пример #20
0
    def kill(self):
        """
        Send message to eliminate the object
        It is called when we hit the enemy or the enemy hits us
        """
        if not self._active:
            return

        self._active = False
        logic.sendMessage(self.subject)
        self.logger.debug('kill', self._dupli_object.name)
Пример #21
0
    def kill(self):
        """
        Send message to eliminate the object
        It is called when we hit the enemy or the enemy hits us
        """
        if not self._active:
            return

        self._active = False
        logic.sendMessage(self.subject)
        self.logger.debug('kill', self._dupli_object.name)
Пример #22
0
    def setFlashlightMode(self, power=True):
        """
        Activate or Deactivate the flashlight
        """
        self.logger.debug("setFlashlightMode({0})".format(power))
        logic.sendMessage("light")

        if power:
            self._parent.sound.setVolumeLow()

        else:
            self._parent.sound.setVolumeNormal()
Пример #23
0
    def setFlashlightMode(self, power=True):
        """
        Activate or Deactivate the flashlight
        """
        self.logger.debug("setFlashlightMode({0})".format(power))
        logic.sendMessage("light")

        if power:
            self._parent.sound.setVolumeLow()

        else:
            self._parent.sound.setVolumeNormal()
Пример #24
0
def ghost_collision(cont):
    player = cont.owner
    sensor = cont.sensors['Collision']
    ghost = sensor.hitObject
    if ghost != None:
        if ghost['killable']:
            logic.sendMessage("ghost_killed", "", ghost.name, "")
            cont.activate(player.actuators['EatGhost'])
            cont.activate(player.actuators['Ghost_Killed'])
        else:
            cont.activate(player.actuators['PacmanDeath'])
            player.endObject()
Пример #25
0
    def setSonarMode(self, power=True):
        """
        Activate or Deactivate the sonar
        """
        self.logger.debug("setSonarMode({0})".format(power))
        logic.sendMessage("sonar")

        if power:
            self._parent.sound.setVolumeHigh()

        else:
            self._parent.sound.setVolumeNormal()
Пример #26
0
    def setSonarMode(self, power=True):
        """
        Activate or Deactivate the sonar
        """
        self.logger.debug("setSonarMode({0})".format(power))
        logic.sendMessage("sonar")

        if power:
            self._parent.sound.setVolumeHigh()

        else:
            self._parent.sound.setVolumeNormal()
Пример #27
0
    def set_netmode(self, netmode):
        # Load configuration
        print("Loading network information from {}".format(DATA_PATH))
        file_path = logic.expandPath("//{}".format(DATA_PATH))
        # self.configuration_file_names = {path.splitext(f)[0] for f in listdir(file_path)}
        main_definition_path = path.join(file_path, "main.definition")

        # Load network information
        with open(main_definition_path, "r") as file:
            world_settings = load(file)

        self.network_update_interval = 1 / world_settings['tick_rate']
        self.metric_interval = world_settings['metric_interval']

        print("Set netmode", Netmodes[netmode])
        self.world = World(netmode, logic.getLogicTicRate(), file_path)
        logic.world = self.world

        if netmode == Netmodes.server:
            port = world_settings['port']
            self.world.rules = Rules()

        else:
            port = 0

        self.network_manager = NetworkManager(self.world, "", port)

        # Time since last sent
        self.time_since_sent = 0.0

        # Set network as active update function
        self.on_step = self.step_network
        self.cleanup = lambda: self.network_manager.stop()

        self._listeners['METHOD_INVOKE'] = self._on_invoke_method
        self._listeners['RPC_INVOKE'] = self._on_invoke_rpc
        self._listeners['PAWN_REASSOCIATE'] = self._on_controller_reassign
        self._listeners['SELF_MESSAGE'] = self._on_self_message

        self._listeners['SCENE_MESSAGE'] = self._on_scene_message
        self._listeners['PAWN_ASSOCIATE'] = self._on_controller_assign
        self._listeners['TO_NEW_PAWN'] = self._on_new_pawn_message

        if netmode == Netmodes.client:
            self._listeners['CONNECT_TO'] = self._on_connect_to

        # Set network state
        self._update_network_state()

        logic.sendMessage(encode_subject("NETWORK_INIT"))

        print("Network started")
Пример #28
0
    def set_netmode(self, netmode):
        # Load configuration
        print("Loading network information from {}".format(DATA_PATH))
        file_path = logic.expandPath("//{}".format(DATA_PATH))
        # self.configuration_file_names = {path.splitext(f)[0] for f in listdir(file_path)}
        main_definition_path = path.join(file_path, "main.definition")

        # Load network information
        with open(main_definition_path, "r") as file:
            world_settings = load(file)

        self.network_update_interval = 1 / world_settings['tick_rate']
        self.metric_interval = world_settings['metric_interval']

        print("Set netmode", Netmodes[netmode])
        self.world = World(netmode, logic.getLogicTicRate(), file_path)
        logic.world = self.world

        if netmode == Netmodes.server:
            port = world_settings['port']
            self.world.rules = Rules()

        else:
            port = 0

        self.network_manager = NetworkManager(self.world, "", port)

        # Time since last sent
        self.time_since_sent = 0.0

        # Set network as active update function
        self.on_step = self.step_network
        self.cleanup = lambda: self.network_manager.stop()

        self._listeners['METHOD_INVOKE'] = self._on_invoke_method
        self._listeners['RPC_INVOKE'] = self._on_invoke_rpc
        self._listeners['PAWN_REASSOCIATE'] = self._on_controller_reassign
        self._listeners['SELF_MESSAGE'] = self._on_self_message

        self._listeners['SCENE_MESSAGE'] = self._on_scene_message
        self._listeners['PAWN_ASSOCIATE'] = self._on_controller_assign
        self._listeners['TO_NEW_PAWN'] = self._on_new_pawn_message

        if netmode == Netmodes.client:
            self._listeners['CONNECT_TO'] = self._on_connect_to

        # Set network state
        self._update_network_state()

        logic.sendMessage(encode_subject("NETWORK_INIT"))

        print("Network started")
Пример #29
0
def announce_stats():
	player = logic.getCurrentScene().objects['System']['sys'].player['ent']
	xp = str(player.fighter.xp)
	strength = str(player.fighter.strength)
	agi = str(player.fighter.agility)
	vit = str(player.fighter.vitality)
	mag = str(player.fighter.magic)
	
	logic.sendMessage('show_xp', xp)
	logic.sendMessage('show_str', strength)
	logic.sendMessage('show_agi', agi)
	logic.sendMessage('show_vit', vit)
	logic.sendMessage('show_mag', mag)			
Пример #30
0
def announce_stats():
    player = logic.getCurrentScene().objects['System']['sys'].player['ent']
    xp = str(player.fighter.xp)
    strength = str(player.fighter.strength)
    agi = str(player.fighter.agility)
    vit = str(player.fighter.vitality)
    mag = str(player.fighter.magic)

    logic.sendMessage('show_xp', xp)
    logic.sendMessage('show_str', strength)
    logic.sendMessage('show_agi', agi)
    logic.sendMessage('show_vit', vit)
    logic.sendMessage('show_mag', mag)
Пример #31
0
def main():
	cont = logic.getCurrentController()
	own = cont.owner
	hp_changed = cont.sensors['hp_changed'].positive
	
	if hp_changed:
		if logic.globalDict['player_hp'] > own['hp']:
			#hp went down
			logic.sendMessage('hp_down')
			logic.globalDict['player_hp'] = own['hp']
		elif logic.globalDict['player_hp'] < own['hp']:
			#hp went down
			logic.sendMessage('hp_up')
			logic.globalDict['player_hp'] = own['hp']
Пример #32
0
 def recieveGunMsg(self):
     gunpos = self.cont.sensors["GunPos"]
     if(gunpos.positive):
         gunData = [ i for i in gunpos.bodies[gunpos.subjects.index("GunPos")].split(',')]
         
         self.pitch = self.convert(float(gunData[0])*-1)
         self.roll = self.convert(float(gunData[1])*-1)
         
         self.trigger = int(float(gunData[2]))
         self.wheel = int(float(gunData[3]))
         self.hat = int(float(gunData[4]))
         self.keys = int(float(gunData[5]))
         
         if(self.trigger):
             #self.log.msg("trigger")
             logic.sendMessage("Trigger", '1') 
         
         #self.log.msg("hat: "+str(self.hat)) 
         return True
Пример #33
0
    def hurt(self, damage, origin=None):
        if origin == None:
            origin = self.owner
        self.HP -= damage

        if self.HP <= 0:
            # self.owner.state = 'dead'
            print("R.I.P.   {} has died at the hands of {}".format(self.owner.Name, origin.Name))
            # self.owner.sys['sys'].props.remove(self.owner.own)
            if self.owner.own["thing"] != "Player":
                self.owner.kill(origin)
            elif self.owner.own["thing"] == "Player":
                self.owner.player_kill(origin)

        elif self.HP >= self.maxHP:
            self.HP = self.maxHP
        if self.owner.own["thing"] == "Player":
            value = self.HP / self.maxHP
            logic.sendMessage("update_player_hp", str(value))
        print("{}/{} HP remaining for {}".format(self.HP, self.maxHP, self.owner.Name))
Пример #34
0
def Update_Motors():
	sl = limit_sr(gval('motor_left'))
	sr = limit_sr(gval('motor_right'))
	
	slm = sl / 10
	srm = sr / 10
	
	msg = 'motors:'+str(sl)+":"+str(sr)
	logic.sendMessage('motors',msg)
	sl *= 0.5
	sr *= 0.5			
	sval('motor_left',sl)
	sval('motor_right',sr)
	for i in range(0,10):
		v =  recalc(slm*3,srm*3)
		Update_Robot(v[0],v[1],v[2],v[3],v[4],v[5])

	obj = getObject('head')
	val = obj.localOrientation.to_euler('XYZ').z/Pi()*180
	msg = 'head_rotate:'+str(-val)
	logic.sendMessage('head_rotate',msg)
Пример #35
0
def init(cont):
	own = cont.owner
	
	if own['used_crane'] == False and logic.globalDict['crane_go'] == True:
		print ('starting crane')
		
		#set crane cam
		crane_cam = cont.sensors['crane_cam'].owner
		crane_head = cont.sensors['crane_head'].owner
		ship_target = cont.sensors['ship_target'].owner
		scene = logic.getCurrentScene()
		scene.active_camera = crane_cam
		#freeze player
		logic.sendMessage('player_freeze')
		logic.sendMessage('HUD_off')
		#send message
		logic.sendMessage('crane')
		#set player position
		player.position = own.position
		player.orientation = own.orientation
		#start crane
		cont.activate('crane_cam_rot')
		own['using_crane'] = True
		own.state = logic.KX_STATE1
		crane_head.state = logic.KX_STATE2
		ship_target.state = logic.KX_STATE2
	else:
		own.state = logic.KX_STATE2
Пример #36
0
def main(cont):
    own = cont.owner
    scene = logic.getCurrentScene()
    ray = cont.sensors["Ray"]
    #detector = cont.sensors["Detector"]
    reload = cont.sensors["Reload"]
    
    if reload.positive and own["Magazines"] > 0:
        own["Magazines"] += -1
        logic.sendMessage("Clips", str(own["Magazines"]))
        own["Bullets"] = 100
        logic.sendMessage("Ammo", "100") 
        cont.activate(cont.actuators["Reload"])
        
        
    if cont.sensors["Shoot"].positive:

        if own["Bullets"]>0:
            own["Bullets"] += -1
            logic.sendMessage("Ammo", str(own["Bullets"]))
            if ray.positive:
                #Add the laser targeting pointer to the scene
                own["Dist"] = own.getDistanceTo(ray.hitObject)
                render.drawLine(own.worldPosition,ray.hitPosition,[100,255,0])              
                hitObject = ray.hitObject
                bulletForce= scene.addObject("BulletForce",own,3)  
                bulletForce.worldPosition = Vector(ray.hitPosition) +(Vector(ray.hitNormal)*0.01) 
                #bulletForce.worldPosition = cont.ray.worldPosition
                bulletHole= scene.addObject("BulletHole",own,200)       
                #position the bullet baed on the ray, give a margin factor due to rendering collision
                bulletHole.worldPosition = Vector(ray.hitPosition) +(Vector(ray.hitNormal)*0.01)
                bulletHole.alignAxisToVect(ray.hitNormal,2)

            cont.activate(cont.actuators["Fire"])
            #cont.activate(cont.actuators["MuzzleFlash"])
Пример #37
0
	def Update():
		
		#obj.localPosition.z = 1.0
		
		scene.addObject('EffectRocket1',obj)
		scene.addObject('EffectRocket2',obj)
		
		motion.useLocalDLoc = True
		motion.useLocalDRot = True
		motion.dLoc = [0.0, obj['speed'] ,0.0]
		obj.applyForce([0.0, 0.0, 9.82], 0)
		cont.activate(motion)
		
		obj['time'] += 1
		if obj['time'] > 2:
			if collision.positive:
				enemy = collision.hitObject
				if 'enemy' in enemy:
					logic.sendMessage('hit', 'None', str(enemy))
				if 'hp' in enemy:
					enemy['hp'] -= 10
				obj.endObject()
				explosion = scene.addObject('Explosion',obj)
				logic.sendMessage('rocket_explosion', 'None')
		
		if obj['hp'] < 1:
			obj.endObject()
			explosion = scene.addObject('Explosion',obj)
			logic.sendMessage('rocket_explosion', 'None')
Пример #38
0
def init(cont):
    own = cont.owner

    if own['used_crane'] == False and logic.globalDict['crane_go'] == True:
        print('starting crane')

        #set crane cam
        crane_cam = cont.sensors['crane_cam'].owner
        crane_head = cont.sensors['crane_head'].owner
        ship_target = cont.sensors['ship_target'].owner
        scene = logic.getCurrentScene()
        scene.active_camera = crane_cam
        #freeze player
        logic.sendMessage('player_freeze')
        logic.sendMessage('HUD_off')
        #send message
        logic.sendMessage('crane')
        #set player position
        player.position = own.position
        player.orientation = own.orientation
        #start crane
        cont.activate('crane_cam_rot')
        own['using_crane'] = True
        own.state = logic.KX_STATE1
        crane_head.state = logic.KX_STATE2
        ship_target.state = logic.KX_STATE2
    else:
        own.state = logic.KX_STATE2
Пример #39
0
    def hurt(self, damage, origin=None):
        if origin == None:
            origin = self.owner
        self.HP -= damage

        if self.HP <= 0:
            #self.owner.state = 'dead'
            print("R.I.P.   {} has died at the hands of {}".format(
                self.owner.Name, origin.Name))
            #self.owner.sys['sys'].props.remove(self.owner.own)
            if self.owner.own['thing'] != 'Player':
                self.owner.kill(origin)
            elif self.owner.own['thing'] == 'Player':
                self.owner.player_kill(origin)

        elif self.HP >= self.maxHP:
            self.HP = self.maxHP
        if self.owner.own['thing'] == 'Player':
            value = self.HP / self.maxHP
            logic.sendMessage('update_player_hp', str(value))
        print("{}/{} HP remaining for {}".format(self.HP, self.maxHP,
                                                 self.owner.Name))
Пример #40
0
def main(cont):
    global camera, scene
    scene = logic.getCurrentScene()

    camera = cont.owner

    ###main controls###
    if keyboard.events[events.TKEY] == ACTIVE:
        camera["laser"] = True
    elif keyboard.events[events.TKEY] == 0:
        camera["laser"] = False
    if mouse.events[events.LEFTMOUSE] == ACTIVE:
        logic.sendMessage("pop", "", "Camera")
        fire_primary()
    elif mouse.events[events.RIGHTMOUSE] == ACTIVE:
        logic.sendMessage("pop", "", "Camera")
        newobject = addObject("Carbon", camera, [0, 0, -100])
        saveObject(newobject)
        newobject.add_glow()
    elif keyboard.events[events.SPACEKEY] == ACTIVE:
        newobject = addObject("Antimatter", camera, [0, 0, -500])
    elif keyboard.events[events.RKEY] == ACTIVE:
        scene.restart()
        return

    ## numkeys ##
    elif keyboard.events[events.ONEKEY] == ACTIVE:
        change_primary("Hydrogen")
    elif keyboard.events[events.TWOKEY] == ACTIVE:
        change_primary("Oxygen")
    elif keyboard.events[events.THREEKEY] == ACTIVE:
        change_primary("Nitrogen")
    elif keyboard.events[events.FOURKEY] == ACTIVE:
        change_primary("Bromine")
    elif keyboard.events[events.FIVEKEY] == ACTIVE:
        change_primary("Hydroxide")
    elif keyboard.events[events.SIXKEY] == ACTIVE:
        change_primary("Hydron")
Пример #41
0
    def __init__(self, level, xp, strength, agility, vitality, magic, HP):
        self.level = level
        self.xp = xp

        self.strength = strength
        self.agility = agility
        self.vitality = vitality
        self.magic = magic

        self.HP = HP

        self.armor = 4

        #All this needs to be getted from __init__
        self.turn_rate = 0.08
        self.move_speed = 0.3
        self.attack_range = 3.0
        self.attack_rate = 60
        self.attack_counter = self.attack_rate

        self.target = None

        logic.sendMessage('update_player_xp', '0.0')
Пример #42
0
	def __init__(self, level, xp, strength, agility, vitality, magic,
					HP):
		self.level = level
		self.xp = xp
		
		self.strength = strength
		self.agility = agility
		self.vitality = vitality
		self.magic = magic
		
		self.HP = HP
		
		self.armor = 4
		
		#All this needs to be getted from __init__
		self.turn_rate = 0.08
		self.move_speed = 0.3
		self.attack_range = 3.0
		self.attack_rate = 60
		self.attack_counter = self.attack_rate
		
		self.target = None
		
		logic.sendMessage('update_player_xp', '0.0')
Пример #43
0
def initGame():
	# Init constant
	logic.OBJECT_CONSTANT = ObjectConstant()

	# Init dungeon
	logic.currentDungeon = 0

	if not 'Objects' in logic.globalDict:
		# Init logic globalDict Object
		logic.globalDict['Objects'] = []

		# Set default obj
		addObject('Rubis vert', 'green_rupee', 'Un rubis vert vaut 1 rubi.', 'Fantastique 1 rubi..... Il y\'a beaucoup mieux c\'est sur...', 1, 1)
		addObject('Epee debutant', 'basic_sword', 'L\'Epee du debutant !', 'Vous avez obtenu de quoi agress... vous defendre !', EQUIPEMENT, 'basic_sword')
		addObject('Epee  mystique', 'basic_sword', 'L\'Epee des fees !', 'Vous avez obtenu l\'epee mystique des fee !', EQUIPEMENT, 'mystic_sword')
		addObject('Epee  du hero', 'basic_sword', 'L\'Epee des fees !', 'Vous avez obtenu l\'epee mystique des fee !', EQUIPEMENT, 'hero_sword')
		addObject('Bouclier en bois', 'wood_shield', 'Bouclier en bois d\'une ancienne civilisation', 'Vous avez obtenu un bouclier en bois !', EQUIPEMENT, 'wood_shield')
		addObject('Cle du donjon', 'dungeon_key', 'Un clé de donjon', 'Vous avez obtenu une cle du donjon !', KEY, 0)

		# Global dict for
		logic.globalDict['Chests'] = {'chest.basic_sword' : False}

	# Finally send init message
	logic.sendMessage("INIT_LEVEL")
Пример #44
0
	def Update():
		
		rocketDist = .05 + Dist((obj.worldPosition[0], obj.worldPosition[1], 0.0), (obj['rocketInitLoc'][0], obj['rocketInitLoc'][1], 0.0))
		enemyDist = Dist((obj['rocketInitLoc'][0], obj['rocketInitLoc'][1], 0.0), (obj['vertList'][obj['vect']][0], obj['vertList'][obj['vect']][1], 0.0))
		if obj['vect'] <= (obj['vectNum'] - 1) and rocketDist >= enemyDist:
			obj.alignAxisToVect(mathutils.Vector((obj['vertList'][obj['vect'] + 1][0] - obj['vertList'][obj['vect']][0], obj['vertList'][obj['vect'] + 1][1] - obj['vertList'][obj['vect']][1], obj['vertList'][obj['vect'] + 1][2] - obj['vertList'][obj['vect']][2])), 1, 1.0)
			verticalDist = (Dist((0.0, 0.0, obj['vertList'][obj['vect']][2]), (0.0, 0.0, obj['vertList'][obj['vect']+1][2])))
			obj['speed'] = (obj['vertList'][int(obj['vectNum']/2)][2] - obj.worldPosition[2])/25 + verticalDist/20 + .1
			obj['vect'] += 1
		if rocketDist > 0.7*(Dist(obj['rocketInitLoc'], obj['vertList'][len(obj['vertList'])-1])) and obj['shadowInit'] == False:
			obj['shadow'].setVisible(True)
			obj['shadow'].worldScale = [(1-(obj.worldPosition[2]/27.5)), (1-(obj.worldPosition[2]/27.5)), 1]
		#for i in range(0,obj['vectNum']):
		#	render.drawLine(obj['vertList'][i],obj['vertList'][i+1],[0.0,0.0,0.0])
		
		scene.addObject('EffectRocket1',obj)
		scene.addObject('EffectRocket2',obj)
		
		motion.useLocalDLoc = True
		motion.useLocalDRot = True
		motion.dLoc = [0.0, obj['speed'] ,0.0]
		obj.applyForce([0.0, 0.0, 9.82], 0)
		cont.activate(motion)
		
		#render.drawLine(obj.worldPosition, obj.worldPosition + obj.orientation[0]*2, [0.0,0.0,0.0])
		obj['time'] += 1
		if obj['time'] > 2:
			if obj.worldPosition[2] < 1:
				obj['hp'] -= 10
			if collision.positive:
				enemy = collision.hitObject
				if 'enemy' in enemy:
					logic.sendMessage('hit', 'None', str(enemy))
				if 'hp' in enemy:
					enemy['hp'] -= 10
				obj.endObject()
				scene.objects['Shadow'].endObject()
				explosion = scene.addObject('Explosion',obj)
				logic.sendMessage('rocket_explosion', 'None')
		
		if obj['hp'] < 1:
			obj.endObject()
			scene.objects['Shadow'].endObject()
			explosion = scene.addObject('Explosion',obj)
			logic.sendMessage('rocket_explosion', 'None')
Пример #45
0
	def Update():
		for i in range (0,361,10):
				i *= (math.pi/180)
				#detects if the enemy is far enough away to be allowed to lay another mine
				ray = obj.rayCast(obj.worldPosition + mathutils.Vector((obj['dist']*math.sin(i),obj['dist']*math.cos(i),0)), obj, obj['dist'], "miner", 0, 0, 0)
				#render.drawLine(obj.worldPosition, obj.worldPosition + mathutils.Vector((obj['dist']*math.sin(i),obj['dist']*math.cos(i),0)), [1.0, 1.0, 1.0])
				if ray[0] != None:
					logic.sendMessage('mine_near','',str('EnemyRocketInit%s%s' % (level, str(ray[0])[len(str(ray[0]))-4:len(str(ray[0]))])))
		if collision.positive and obj['time'] > 10:
			enemy = collision.hitObject
			scene.addObject('Explosion',enemy)
			if 'enemy' in enemy:
				logic.sendMessage('hit', 'None', str(enemy))
			if 'hp' in enemy:
				enemy['hp'] -= 10
			obj.endObject()
			obj.parent.endObject()
			explosion = scene.addObject('Explosion',obj)
			logic.sendMessage('rocket_explosion', 'None')
		obj['time'] += 1
Пример #46
0
 def throwRock(self):
     """
     Throw a rock (to hit a pendulum)
     """
     self.logger.debug("throwRock()")
     logic.sendMessage("rock")
Пример #47
0
    def ChangePlate(o, x, y):
        object = str(o)
        if o['neighborMine'] == 1:
            #Das Feld hat eine Mine in der Nähe
            logic.sendMessage("1", "shot", object)
        elif o['neighborMine'] == 2:
            #Das Feld hat zwei Minen in der Nähe
            logic.sendMessage("2", "shot", object)
        elif o['neighborMine'] == 3:
            #Das Feld hat drei Minen in der Nähe
            logic.sendMessage("3", "shot", object)
        elif o['neighborMine'] == 4:
            #Das Feld hat vier Minen in der Nähe
            logic.sendMessage("4", "shot", object)
        elif o['neighborMine'] == 5:
            #Das Feld hat fünf Minen in der Nähe
            logic.sendMessage("5", "shot", object)
        elif o['neighborMine'] == 6:
            #Das Feld hat fünf Minen in der Nähe
            logic.sendMessage("6", "shot", object)
        else:
            #Das Feld hat keine Mine in der Nähe
            logic.sendMessage("0", "shot", object)
        minenzahl = str(o['neighborMine'])
        print("Unter der Platte: " + object + " sind/ist " + minenzahl +
              " Mine/n.")

        scene = bge.logic.getCurrentScene()
        cont = bge.logic.getCurrentController()
        own = cont.owner
        obj = scene.objects

        x = str(x)
        y = str(y)
        xy = (x + ";" + y)

        objdel = obj[xy]
        objdel.endObject()  #Ausblenden des Objektes
Пример #48
0
	def Message():
		ori = obj.orientation[1].copy()
		ori.x *= -1
		pos = obj.position
		toPos = pos + ori
		posL = obj.worldPosition + Scalar(obj.orientation[0], mathutils.Vector((-1,1,1)))*.5
		posR = obj.worldPosition - Scalar(obj.orientation[0], mathutils.Vector((-1,1,1)))*.5
		
		ray = obj.rayCast(toPos, obj, 10000, '', 1, 0)
		rayL = obj.rayCast(posL + Scalar(obj.orientation[1], mathutils.Vector((-1,1,1))), posL, 10000, '', 1, 0)
		rayR = obj.rayCast(posR + Scalar(obj.orientation[1], mathutils.Vector((-1,1,1))), posR, 10000, '', 1, 0)
		
		'''print("ray: ", ray[0])
		print("rayL: ", rayL[0])
		print("rayR: ", rayR[0])
		print('*************************************')'''
		
		if ray[1] != None or rayL[1] != None or rayR[1] != None:
			hitPos = [ray[1][0], ray[1][1], ray[1][2]]
			hitPosL = [rayL[1][0], rayL[1][1], rayL[1][2]]
			hitPosR = [rayR[1][0], rayR[1][1], rayR[1][2]]
		#render.drawLine(obj.position, hitPos, [0.0, 1.0, 0.0])
		#render.drawLine(posL, hitPosL, [0.0, 1.0, 0.0])
		#render.drawLine(posR, hitPosR, [0.0, 1.0, 0.0])
		if ray != None or rayL != None or rayR != None:
			if ray[0] != None:
				if Dist(ray[1], scene.objects['EvadeL'].worldPosition) > Dist(ray[1], scene.objects['EvadeR'].worldPosition):
					logic.sendMessage('hit_L', 'None', str(ray[0]))
				else:
					logic.sendMessage('hit_R', 'None', str(ray[0]))
			elif rayL[0] != None:
				if Dist(rayL[1], scene.objects['EvadeL'].worldPosition) > Dist(rayL[1], scene.objects['EvadeR'].worldPosition):
					logic.sendMessage('hit_L', 'None', str(rayL[0]))
				else:
					logic.sendMessage('hit_R', 'None', str(rayL[0]))
			elif rayR[0] != None:
				if Dist(rayR[1], scene.objects['EvadeL'].worldPosition) > Dist(rayR[1], scene.objects['EvadeR'].worldPosition):
					logic.sendMessage('hit_L', 'None', str(rayR[0]))
				else:
					logic.sendMessage('hit_R', 'None', str(rayR[0]))
Пример #49
0
def loop(cont):
	own = cont.owner
	
	global crane_cam, bug_cam
	
	trigger_1 = cont.sensors["trigger_1"].positive
	ship_1_col = cont.sensors["ship_1_col"].positive
	ship_2_col = cont.sensors["ship_2_col"].positive
	trigger_1 = cont.sensors["trigger_1"].positive
	trigger_2 = cont.sensors["trigger_2"]
	trigger_3 = cont.sensors["trigger_3"]
	food_sensor = cont.sensors["food_sensor"].positive
	food_sensor2 = cont.sensors["food_sensor2"].positive
	delay = cont.sensors["delay"].positive
	guide_col = cont.sensors["guide_col"].positive
	crane_message = cont.sensors["crane_message"].positive
	wing_nip_dead = cont.sensors["wing_nip_dead"].positive
	
	scene = logic.getCurrentScene()
	
	if own['bug_encounter'] == False:
		if trigger_3.positive:
			own['current_objective'] = 16
			own['bug_encounter'] = True
			#trigger_3.owner.endObject()
	
	#if player skips straight to the cranes
	if crane_message:
		if own['cranes_completed'] == 0:
			own['current_objective'] = 6
		elif own['cranes_completed'] == 1:
			own['current_objective'] = 8
			own['current_dialog'] +=1
			own['go_dialog'] = True
			own['ship_timer'] = 0
			
	if ship_1_col:
		own['ship_num'] = 1
	if ship_2_col:
		own['ship_num'] = 2
	
	if own['current_objective'] == 0:
		if delay:
			own['current_objective'] = 1
		if trigger_1:
			own['current_dialog'] = 1
			own['current_objective'] = 1
			own['go_dialog'] = True
			
	elif own['current_objective'] == 1:
		garway_ship.playAction('ship_1_enter', 1, 1000, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = 1)
		garway_ship2.playAction('ship_2_enter', 1, 1000, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = 1.25)
		own['current_dialog'] +=1
		own['current_objective'] = 2
		own['objective'] = 0
		own['go_dialog'] = True
		own['go_objective'] = True
		
	elif own['current_objective'] == 2:
		if trigger_1:
			own['current_dialog'] +=1
			own['current_objective'] = 3
			own['go_dialog'] = True	
			guide.state = logic.KX_STATE1
	#walk with guide
	elif own['current_objective'] == 3:
		if guide_col:
			own['current_dialog'] +=1
			own['current_objective'] = 4
			own['go_dialog'] = True	
			guide.state = logic.KX_STATE2
	#cutscene 
	elif own['current_objective'] == 4:
		if trigger_2.positive:
			own['current_dialog'] +=1
			own['current_objective'] = 5
			own['go_dialog'] = True	
			logic.sendMessage('player_freeze')
			logic.sendMessage('HUD_off')
			scene.active_camera = scene_cam_1
			scene_cam_1.playAction('scene_cam_1', 1, 1000, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = 1.5)
	#cutscene ending
	elif own['current_objective'] == 5:
		own['current_dialog'] += 1
		own['go_dialog'] = True
		own['current_objective'] = 20
	elif own['current_objective'] == 20:
		if own['current_dialog'] == 5:
			own['current_dialog'] += 1
			own['go_dialog'] = True
		if round(scene_cam_1.getActionFrame(0)) == 700:
			scene.active_camera = scene_cam_3
			scene_cam_3.playAction('scene_cam_3', 1, 300, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = 1.5)
			own['objective'] = 1
			own['go_objective'] = True
		if not scene_cam_1.isPlayingAction(0):
			logic.sendMessage('player_unfreeze')
			logic.sendMessage('HUD_on')
			scene.active_camera = player_cam
			own['current_dialog'] += 1
			own['current_objective'] = 6
			own['go_dialog'] = True
	#bug encounter
	elif own['current_objective'] == 16:
		own['current_dialog'] = 8
		cont.activate('add_bugs')
		bug_cam.playAction('bug_cam', 1, 200, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = .75)
		logic.sendMessage('player_freeze')
		logic.sendMessage('HUD_off')
		own['objective'] = 2
		scene.active_camera = bug_cam
		own['go_dialog'] = True
		own['go_objective'] = True
		own['current_objective'] = 17
		player.position = player_new_pos.position
		player.orientation = player_new_pos.orientation
	#end bug scene
	elif own['current_objective'] == 17:
		if not bug_cam.isPlayingAction(0):
			logic.sendMessage('player_unfreeze')
			logic.sendMessage('HUD_on')
			scene.active_camera = player_cam
			own['current_objective'] = 18
	#fighting bugs
	elif own['current_objective'] == 18:
		if wing_nip_dead:
			own['bug_dead_count'] += 1
		if own['bug_dead_count'] ==4:
			own['bugs_dead'] = True
			own['current_objective'] = 19
	#bugs are dead
	elif own['current_objective'] == 19:
		own['current_dialog'] = 9
		own['go_dialog'] = True
		own['current_objective'] = 6
		logic.globalDict['crane_go'] = True
		own['objective'] = 1
		own['go_objective'] = True
	#go to ships
	elif own['current_objective'] == 6:
		if not food_sensor or not food_sensor2:
			if own['ship_num'] == 1:
				garway_ship.playAction('ship_1', 1, 4000, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = 1)
			elif own['ship_num'] == 2:
				garway_ship2.playAction('ship_2', 1, 4000, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = 1)
			own['current_dialog'] = 10
			own['current_objective'] = 7
			own['go_dialog'] = True	
			logic.sendMessage('player_unfreeze')
			logic.sendMessage('HUD_on')
			logic.sendMessage('crane_over')
			scene.active_camera = player_cam
			own['cranes_completed'] = 1
	#move the bandit ship
	elif own['current_objective'] == 7:
		if not ship_group_new.isPlayingAction(0):
			ship_group_new.playAction('bandit_ship_move', 1, 4000, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = 1)
	#start bandit ship cut-scene
	elif own['current_objective'] == 8:
		if own['ship_timer'] >= 25:
			crane_cam = scene.active_camera
			scene.active_camera = bandit_cam
			bandit_cam.playAction('bandit_cam', 1, 200, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = .75)
			own['current_objective'] = 9
			own['current_dialog'] +=1
			own['go_dialog'] = True
	#switch cams
	elif own['current_objective'] == 9:
		if own['ship_timer'] >= 35:
			scene.active_camera = bandit_cam2
			bandit_cam2.playAction('bandit_cam_2', 1, 300, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = 1)
			own['current_objective'] = 10
	#bandit ship cut-scene is done
	elif own['current_objective'] == 10:
		if own['ship_timer'] >= 45:
			scene.active_camera = crane_cam
			own['current_objective'] = 11
	#back to crane
	elif own['current_objective'] == 11:
		own['current_objective'] = 12
		own['current_dialog'] +=1
		own['go_dialog'] = True
		if own['ship_num'] == 1:
			if not garway_ship.isPlayingAction(0):
				garway_ship.playAction('ship_1', 1, 4000, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = .5)
		elif own['ship_num'] == 2:
			if not garway_ship2.isPlayingAction(0):
				garway_ship2.playAction('ship_2', 1, 4000, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = .5)
	#crane while ship is leaving
	elif own['current_objective'] == 12:
		#did not get all food off
		if own['ship_timer'] >= 90:
			own['cranes_completed'] = 2
			own['current_dialog'] = 16
			own['current_objective'] = 14
			logic.sendMessage('crane_over')
			own['go_dialog'] = True	
			own['ship_timer'] = 0
			own['all_crates'] = False
	#got all food off
	elif own['current_objective'] == 14:
		logic.sendMessage('player_freeze')
		logic.sendMessage('HUD_off')
		scene.active_camera = end_scene_cam
		if own['ship_timer'] >= 15:
			logic.sendMessage('fade_out')
			own['current_objective'] = 15
	#wait for fade
	elif own['current_objective'] == 15:
		if own['ship_timer'] >=18:
			#cont.activate('end_level')
			own['current_objective'] = 21
	#end scene
	elif own['current_objective'] == 21:
		own['ship_timer'] = 0
		scene.active_camera = last_scene_cam
		logic.sendMessage('fade_in')
		player.position = player_end_pos.position
		player.orientation = player_end_pos.orientation
		guide.position = arya_end_pos.position
		guide.orientation = arya_end_pos.orientation
		ship_group_new.playAction('bandit_ship_move', 3000, 4000, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = 1)
		garway_ship2.playAction('ship_2', 3000, 4000, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = 1)
		own['current_objective'] = 22
	#send some dialogue
	elif own['current_objective'] == 22:
		if own['ship_timer'] >=5:
			own['current_dialog'] = 17
			own['go_dialog'] = True
			own['current_objective'] = 23
	elif own['current_objective'] == 23:
		if own['ship_timer'] >=10:
			if own['all_crates'] == True:
				own['current_dialog'] = 18
			else:
				own['current_dialog'] = 19
			own['go_dialog'] = True
			own['current_objective'] = 24
	elif own['current_objective'] == 24:
		if own['ship_timer'] >=20:
			logic.sendMessage('fade_out')
			own['current_objective'] = 25
	elif own['current_objective'] == 25:
		if own['ship_timer'] >=30:
			cont.activate('end_level')
	#finished with the cranes
	if own['current_objective'] == 12 or own['current_objective'] == 11 or own['current_objective'] == 8:
		if not food_sensor and not food_sensor2:
			own['cranes_completed'] = 2
			own['current_dialog'] = 15
			own['current_objective'] = 14
			own['go_dialog'] = True	
			own['ship_timer'] = 0
			logic.sendMessage('crane_over')
			own['all_crates'] = True 
			if own['ship_num'] == 1:
				if not garway_ship.isPlayingAction(0):
					garway_ship.playAction('ship_1', 1, 4000, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = 1)
			elif own['ship_num'] == 2:
				if not garway_ship2.isPlayingAction(0):
					garway_ship2.playAction('ship_2', 1, 4000, layer=0, play_mode=logic.KX_ACTION_MODE_PLAY, speed = 1)