Exemple #1
0
def _drop_command(command, index):
    """Throw melee weapon on 'drop'."""
    player = Player(index)
    class_name = getattr(player.active_weapon, 'classname', None)
    if class_name not in _melee_weapons:
        return True

    if not _available_count[player.userid]:
        TextMsg(MESSAGE_STRINGS['Empty']).send(index)
        return

    _available_count[player.userid] -= 1
    TextMsg(MESSAGE_STRINGS['Remaining']).send(
        index,
        current=_available_count[player.userid],
        total=int(total_max),
    )

    start_location = player.eye_location
    velocity = player.view_coordinates - start_location
    weapon = Weapon.create(class_name)
    weapon.spawn()
    weapon.teleport(origin=start_location, velocity=velocity * 200)
    _throwers[weapon.index] = player.userid

    delay = int(remove_delay)
    weapon.delay(delay, weapon.remove)
Exemple #2
0
    def restore_weapons(self):
        self.strip()
        for weapon_dict in self.saved_weapons:
            weapon = Weapon.create(weapon_dict['classname'])
            weapon.teleport(self.player.origin, None, None)
            weapon.spawn()

            weapon.clip = weapon_dict['clip']
            if weapon_dict['ammo'] is not None:
                weapon.ammo = weapon_dict['ammo']
    def restore_weapons(self):
        self.strip()
        for weapon_dict in self.saved_weapons:
            weapon = Weapon.create(weapon_dict['classname'])
            weapon.teleport(self.player.origin, None, None)
            weapon.spawn()

            if weapon_dict['clip'] is not None:
                weapon.clip = weapon_dict['clip']

            if weapon_dict['ammo'] is not None:
                weapon.ammo = weapon_dict['ammo']