示例#1
0
 def armor(self, value):
     minqlx.set_armor(self.id, value)
示例#2
0
    def death_monitor(self, victim, killer, data):
        with self.lock:
            if self.game.state == "in_progress" and self._rounds > 0:
                try:
                    if victim in self.in_game:
                        self.in_game.remove(victim)
                except Exception as e:
                    if self.logging_enabled:
                        minqlx.log_exception(self)
                    minqlx.console_print(
                        "^4Battle Royale Remove Victim from self.in_game Exception: {}"
                        .format(e))
                remaining = len(self.in_game)
                try:
                    if not self.last_2:
                        if killer is not None:
                            start_health = self.get_cvar(
                                "g_startingHealth", int)
                            if self._bonus[0] > 0:
                                health = killer.health
                                if health < start_health * 2 - self._bonus[0]:
                                    minqlx.set_health(killer.id,
                                                      health + self._bonus[0])
                                else:
                                    minqlx.set_health(killer.id,
                                                      start_health * 2)
                            if self._bonus[1] > 0:
                                armor = killer.armor
                                if armor < start_health * 2 - self._bonus[1]:
                                    minqlx.set_armor(killer.id,
                                                     armor + self._bonus[1])
                                else:
                                    minqlx.set_armor(killer.id,
                                                     start_health * 2)

                        @minqlx.delay(0.2)
                        def spec_player():
                            if victim in self.teams()["free"]:
                                self.move_player(victim, "spectator", True,
                                                 self._deaths)

                        spec_player()
                        self._deaths += 1
                except Exception as e:
                    if self.logging_enabled:
                        minqlx.log_exception(self)
                    minqlx.console_print(
                        "^4Battle Royale Not Last 2 Death Monitor Exception: {}"
                        .format(e))

                if remaining == 2 and len(self.last_two) == 0:
                    try:
                        self.last_two = self.in_game.copy()
                        self.last_2 = True
                        self.last_2_standing()
                    except Exception as e:
                        if self.logging_enabled:
                            minqlx.log_exception(self)
                        minqlx.console_print(
                            "^4Battle Royale 2 Remaining Death Monitor Exception: {}"
                            .format(e))
                elif remaining == 1:
                    try:
                        self.move_player(victim, "spectator", True,
                                         self._deaths)
                        if killer is not None and killer != victim:
                            self.msg(
                                "{} ^7killed {} ^7for the round win.".format(
                                    killer, victim))
                            try:
                                self._wins[killer.steam_id] += 1
                            except KeyError:
                                self._wins[killer.steam_id] = 1
                            except Exception as e:
                                if self.logging_enabled:
                                    minqlx.log_exception(self)
                                minqlx.console_print(
                                    "Battle Royale Death Monitor Round Win Exception: {}"
                                    .format(e))
                            self._deaths = 0
                            self.last_2 = False
                            self.round_win(killer, killer.health, killer.armor)
                        else:
                            for player in self.last_two:
                                if victim.steam_id != player.steam_id:
                                    winner = player
                            self.msg(
                                "{} ^4Died^7, giving {} ^7the round win. ^1{} ^7Health and ^2{} ^7Armor remaining."
                                .format(victim, winner, winner.health,
                                        winner.armor))
                            try:
                                self._wins[winner.steam_id] += 1
                            except KeyError:
                                self._wins[winner.steam_id] = 1
                            except Exception as e:
                                if self.logging_enabled:
                                    minqlx.log_exception(self)
                                minqlx.console_print(
                                    "Battle Royale Death Monitor Round Win Exception: {}"
                                    .format(e))
                            self._deaths = 0
                            self.last_2 = False
                            self.round_win(winner, winner.health, winner.armor)
                    except Exception as e:
                        if self.logging_enabled:
                            minqlx.log_exception(self)
                        minqlx.console_print(
                            "^4Battle Royale Death Monitor Exception: {}".
                            format(e))
示例#3
0
 def last_2_standing(self):
     deal_damage = self.get_cvar("qlx_brLast2Damage", int)
     delay = self.get_cvar("qlx_brDamageDelay", int)
     for pl in self.players():
         super().play_sound("sound/vo/sudden_death.ogg", pl)
     self.msg(
         "^3Last 2 remaining^7. ^1{0} ^3damage every ^2{1} ^3seconds to unengaged "
         "players begins in ^2{1} ^3seconds^7. Type {2}last2 for a complete explanation"
         .format(deal_damage, delay, self.get_cvar("qlx_commandPrefix")))
     damage = [
         self.last_two[0].stats.damage_dealt,
         self.last_two[1].stats.damage_dealt
     ]
     time.sleep(delay)
     count = 1
     must_slap = self.get_cvar("qlx_brSlapAfterTimePeriods", int)
     half_time = self.get_cvar("qlx_brHalfTimePeriod", int)
     slap = self.get_cvar("qlx_brUseSlapDmg", bool)
     while self.last_2 and len(self.last_two) == 2:
         try:
             new_damage = [
                 self.last_two[0].stats.damage_dealt,
                 self.last_two[1].stats.damage_dealt
             ]
             if count >= must_slap or damage == new_damage:
                 specs = self.teams()["spectator"]
                 for player in self.last_two:
                     health = player.health
                     armor = player.armor
                     sub_armor = int(deal_damage * .666)
                     sub_health = deal_damage - sub_armor
                     if armor <= sub_armor:
                         set_armor = 0
                         minqlx.set_armor(player.id, 0)
                         sub_health += sub_armor - armor
                     else:
                         set_armor = armor - sub_armor
                         minqlx.set_armor(player.id, set_armor)
                     if slap:
                         if health - sub_health <= 0:
                             minqlx.console_command("slap {} {}".format(
                                 player.id, health - 1))
                             if self.logging_enabled:
                                 minqlx.console_print(
                                     "{} was damaged! ^4Health ^2{} ^7to ^1{} ^7:"
                                     " ^4Armor ^2{} ^7to ^1{}".format(
                                         player, health, 1, armor,
                                         set_armor))
                             for p in specs:
                                 p.tell(
                                     "{} was damaged! ^4Health ^2{} ^7to ^1{} ^7: ^4Armor ^2{} ^7to ^1{}"
                                     .format(player, health, 1, armor,
                                             set_armor))
                         else:
                             minqlx.console_command("slap {} {}".format(
                                 player.id, sub_health))
                             set_health = health - sub_health
                             if self.logging_enabled:
                                 minqlx.console_print(
                                     "{} was damaged! ^4Health ^2{} ^7to ^1{} ^7:"
                                     " ^4Armor ^2{} ^7to ^1{}".format(
                                         player, health, set_health, armor,
                                         set_armor))
                             for p in specs:
                                 p.tell(
                                     "{} was damaged! ^4Health ^2{} ^7to ^1{} ^7: ^4Armor ^2{} ^7to ^1{}"
                                     .format(player, health, set_health,
                                             armor, set_armor))
                     else:
                         if health - sub_health <= 0:
                             set_health = 1
                             minqlx.set_health(player.id, 1)
                         else:
                             set_health = health - sub_health
                             minqlx.set_health(player.id, set_health)
                         player.center_print("^1Damage")
                         super().play_sound(
                             "sound/player/doom/pain75_1.wav", player)
                         if self.logging_enabled:
                             minqlx.console_print(
                                 "{} was damaged! ^4Health ^2{} ^7to ^1{} ^7:"
                                 " ^4Armor ^2{} ^7to ^1{}".format(
                                     player, health, set_health, armor,
                                     set_armor))
                         for p in specs:
                             p.tell(
                                 "{} was damaged! ^4Health ^2{} ^7to ^1{} ^7: ^4Armor ^2{} ^7to ^1{}"
                                 .format(player, health, set_health, armor,
                                         set_armor))
             else:
                 damage = new_damage
             if half_time > 0 and count >= must_slap + half_time:
                 time.sleep(delay / 2)
             else:
                 time.sleep(delay)
             count += 1
         except Exception as e:
             if self.logging_enabled:
                 minqlx.log_exception(self)
             minqlx.console_print(
                 "^4Last 2 Standing While loop Exception: {}".format(e))
示例#4
0
 def armor(self, value):
     minqlx.set_armor(self.id, value)