def _on_player_spawn(self, player, **kwargs): for target in player_dict.values(): if target.team == player.team and not target.dead: target.health += self.health send_wcs_saytext_by_index(self._msg_spawn.format(health=self.health), player.index)
def _on_player_attack(self, attacker, victim, **kwargs): if randint(0, 101) < self.chance: for index in attacker.weapon_indexes(): break v1 = attacker.origin damaged = False for target in player_dict.values(): if target.index == victim.index or target.team == attacker.team or target.dead: continue v2 = target.origin if v1.get_distance(v2) < self.range: ricochet = TempEntity('Armor Ricochet', position=victim.origin) ricochet.create() target.take_damage(self.damage, attacker_index=attacker.index, weapon_index=index, skip_hooks=True) damaged = True if damaged: send_wcs_saytext_by_index(self._msg_a, attacker.index)
def _on_player_ultimate(self, player, **kwargs): if self.level == 0: return _cooldown = self.cooldowns['ultimate'] if _cooldown <= 0: location = player.origin hit = False for target in player_dict.values(): in_fov = self.is_in_fov(player, target) distance = location.get_distance(target.origin) if target.team != player.team and in_fov and distance < self.range: hit = True target.stuck = True color = target.color target.color = Color(0, 0, 0, 255) target.delay(self.duration, setattr, args=(target, 'stuck', False)) target.delay(self.duration, setattr, args=(target, 'color', color)) send_wcs_saytext_by_index( self._msg_a.format(name=target.name, time=self.duration), player.index) if hit: self.cooldowns['ultimate'] = 15 else: send_wcs_saytext_by_index(self._msg_f, player.index) else: send_wcs_saytext_by_index(self._msg_c.format(time=_cooldown), player.index)
def _find_players_within(self, player, length=99999, exclusions=[]): targets = [] for target in player_dict.values(): if target.dead or target.team == player.team or target in exclusions or target.ultimate_immune: continue distance = player.origin.get_distance(target.origin) if distance < length: targets.append(target) return targets
def _on_round_end(event_data): winner = event_data['winner'] for player in player_dict.values(): if not player.race.__class__ in get_rotd_classes(): return if player.team == winner: player.race.experience_up(experience_for_win.cvar.get_int()) rotd_experience_up.send(player.index, amount=experience_for_win.cvar.get_int(), reason=win_reason)
def _repeat(self): for player in player_dict.values(): if player.origin.get_distance(self._center) < (self.range / 2) and player.team != self._player.team and not player.playerinfo.is_dead(): if player not in self._players_hit: player.take_damage(self.damage, attacker_index=self._player.index, weapon_index=self.weapon_index, skip_hooks=True) if not player.is_slowed: speed = player.speed player.speed *= self.slow self._players_hit.add(player) Delay(1, setattr, args=(player, 'speed', speed)) Delay(1, self._players_hit.discard, args=(player, )) ice_sound.origin = player.origin ice_sound.play()
def player_death(self, player, **kwargs): for target in player_dict.values(): if player.origin.get_distance( target.origin ) <= self.range and target.team != player.team: target.take_damage(self.magnitude, attacker_index=player.index, skip_hooks=True) send_wcs_saytext_by_index(self._msg_a.format(name=target.name), player.index) self.explosion.create(origin=player.origin) ## remove the item player.items.remove(self)
def _find_closest_player(self, player, team_index, length=99999, exclusions=[]): _target = None for target in player_dict.values(): if target.dead or target.team_index == team_index or target in exclusions or target.ultimate_immune: continue _distance = player.origin.get_distance(target.origin) if _distance < length: _target = target length = _distance return _target
def _on_player_death(self, player, **kwargs): if self.level == 0 or randint(0, 101) > self.chance: return num = randint(0, 3) if num == 0: ## Respawn player.delay(1.5, player.spawn) player.delay(2, self._force_drop_weapons, args=(player, )) for weapon in self.weapons: player.delay(3, player.give_named_item, args=(weapon, )) if self.location: player.delay(2.2, player.teleport, args=(self.location, )) send_wcs_saytext_by_index(self._msg_respawn, player.index) elif num == 1: ## Explode for target in player_dict.values(): if player.origin.get_distance( target.origin ) <= self.range and player.team != target.team: target.take_damage(self.magnitude, attacker_index=player.index, skip_hooks=True) send_wcs_saytext_by_index( self._msg_explode.format(name=target.name), player.index) self.explosion.create(origin=player.origin) elif num == 2: ## Health Give for target in player_dict.values(): if not target.dead and target.team == player.team: target.health += self.health send_wcs_saytext_by_index(self._msg_health, player.index) else: ## Cash Give for target in player_dict.values(): if not target.dead and target.team == player.team: target.cash += self.cash send_wcs_saytext_by_index(self._msg_cash, player.index)
def _on_player_ultimate(self, player, **kwargs): if self.level == 0: return _cooldown = self.cooldowns['ultimate'] if _cooldown <= 0: enemy_team = 5 - player.team all_players = player_dict.values() possible_players = list(filter(lambda x: x.team == enemy_team and not x.ultimate_immune and not x.dead, all_players)) if len(possible_players) > 0: target = choice(possible_players) target.armor -= self.armour target.take_damage(self.health, attacker_index=player.index, skip_hooks=True) player.health += self.health player.armor += self.armour send_wcs_saytext_by_index(self._msg_a.format(health=self.health, armour=self.armour, name=target.name), player.index) self.cooldowns['ultimate'] = self.cooldown else: send_wcs_saytext_by_index(self._msg_f, player.index) else: send_wcs_saytext_by_index(self._msg_c.format(time=_cooldown), player.index)
def _repeat(self, player): for ward_origin in self._wards: end_point = ward_origin.copy() end_point.z += 150 self._draw_ward(ward_origin) for target in player_dict.values(): if target.origin.get_distance(ward_origin) < ( self.range / 2) and target.team != player.team and not target.dead: if target not in self._players_hit: self._players_hit.add(target) target_point = target.origin.copy() target_point.z += 40 target.take_damage(self.damage, attacker_index=player.index, weapon_index=self.weapon_index) self.beam.create(start_point=end_point, end_point=target_point, life_time=0.2, start_width=5, end_width=1) Delay(1, self._players_hit.discard, args=(target, ))
def _find_first_player_model(self, team): for target in player_dict.values(): if team == target.team_index: return target.model
def _on_levelbank_players_menu_build(menu, index): menu.clear() for player in player_dict.values(): menu.append(PagedOption(player.name, player))