예제 #1
0
 def start_rampage(self):
     self.rampage = True
     self.rampage_kills.clear()
     self.rampage_reenable_rapid_hack_detect = self.rapid_hack_detect
     self.rapid_hack_detect = False
     self.rampage_call = callLater(RAMPAGE_DURATION, self.end_rampage)
     if RAMPAGE_DURATION > 4.0:
         self.rampage_warning_call = callLater(
             RAMPAGE_DURATION - 3.0,
             fog_switch,
             self,
             self.protocol.get_fog_color,
             RAMPAGE_FOG_FUNC)
     if RAMPAGE_REFILLS:
         self.refill()
     if RAMPAGE_RELOADS:
         weapon = self.weapon_object
         was_shooting = weapon.shoot
         weapon.reset()
         weapon_reload = loaders.WeaponReload()
         weapon_reload.player_id = self.player_id
         weapon_reload.clip_ammo = weapon.current_ammo
         weapon_reload.reserve_ammo = weapon.current_stock
         weapon.set_shoot(was_shooting)
         self.send_contained(weapon_reload)
     send_fog(self, RAMPAGE_FOG_COLOR)
     if ANNOUNCE_RAMPAGE:
         message = S_RAMPAGE_START.format(player=self.name)
         self.protocol.send_chat(message, global_message=None)
예제 #2
0
def clear_ammo(connection):
    weapon_reload = loaders.WeaponReload()
    weapon_reload.player_id = connection.player_id
    weapon_reload.clip_ammo = 0
    weapon_reload.reserve_ammo = 0
    connection.weapon_object.clip_ammo = 0
    connection.weapon_object.reserve_ammo = 0
    connection.send_contained(weapon_reload)
		def refillAndSetHPAmmo(self):
			currentHP = self.hp
			weaponLoader = loaders.WeaponReload()
			weaponLoader.player_id = self.player_id
			weaponLoader.clip_ammo = self.weapon_object.current_ammo
			weaponLoader.reserve_ammo = self.weapon_object.current_stock
			connection.refill(self)
			self.send_contained(weaponLoader)
			connection.set_hp(self, currentHP, kill_type=FALL_KILL)
예제 #4
0
 def check_for_ammo_refill(self):
     if self.ammo_refills > 0 and self.weapon_object.current_stock == 0:
         self.weapon_object.current_stock = self.weapon_object.stock
         weapon_reload = loaders.WeaponReload()
         weapon_reload.player_id = self.player_id
         weapon_reload.clip_ammo = self.weapon_object.ammo
         weapon_reload.reserve_ammo = self.weapon_object.stock
         self.send_contained(weapon_reload)
         self.ammo_refills -= 1
         self.send_chat(
             "Your ammo has been refilled! (refills left: %d)" %
             self.ammo_refills)
예제 #5
0
create_player = loaders.CreatePlayer()
intel_pickup = loaders.IntelPickup()
intel_capture = loaders.IntelCapture()
intel_drop = loaders.IntelDrop()
player_left = loaders.PlayerLeft()
set_hp = loaders.SetHP()
existing_player = loaders.ExistingPlayer()
kill_action = loaders.KillAction()
chat_message = loaders.ChatMessage()
map_data = loaders.MapChunk()
map_start = loaders.MapStart()
state_data = loaders.StateData()
ctf_data = loaders.CTFState()
tc_data = loaders.TCState()
change_weapon = loaders.ChangeWeapon()
weapon_reload = loaders.WeaponReload()
handshake_init = loaders.HandShakeInit()
version_request = loaders.VersionRequest()


def check_nan(*values):
    for value in values:
        if math.isnan(value):
            return True
    return False

def parse_command(value):
    try:
        splitted = shlex.split(value)
    except ValueError:
        # shlex failed. let's just split per space