Args: target (Vector): A valid point (x, y, z) within the game world. Returns: bool: True if the given Vector is within the player's field of view, False otherwise. """ IsInFieldOfView = self.make_virtual_function( IS_IN_FIELD_OF_VIEW_OFFSET, Convention.THISCALL, (DataType.POINTER, DataType.POINTER), DataType.BOOL) return IsInFieldOfView(self, target) @property def next_direction(self): self.last_direction = -self.last_direction return self.last_direction def get_number_origin(self): """Returns the spawn position for the FloatingNumber based on the player's current height.""" number_origin = self.origin # Adjust the origin according to player height. number_origin.z += self.maxs.z + (5 * self.model_scale) return number_origin # Dictionary used to store Player instances. player_instances = PlayerDictionary(PlayerFDN)
return player def _save_player_data(player): """Save player's RPG data into the database.""" _database.save_player_data(player.steamid, player.level, player.xp, player.credits) for skill in player.skills: _database.save_skill_data(player.steamid, skill.class_id, skill.level) # ====================================================================== # >> GLOBALS # ====================================================================== _database = rpg.database.Database(PLUGIN_DATA_PATH / 'rpg.db') _players = PlayerDictionary(_new_player) _tr = LangStrings('rpg') # ====================================================================== # >> DATABASE FUNCTIONS # ====================================================================== def unload(): """Store players' data and close the the database.""" _data_save_repeat.stop() _save_everyones_data() _database.close() @Event('player_disconnect')
self._multiplier = config_manager[self._cvar_higher] else: self._multiplier = 1.0 @property def multiplier(self): return self._multiplier # ============================================================================= # >> GLOBAL VARIABLES # ============================================================================= caches_to = PlayerDictionary(lambda index: PlayerSettingCache( index, bot_damage_settings['modifier_to'], 'damage_to_lower_multiplier', 'damage_to_higher_multiplier' )) caches_from = PlayerDictionary(lambda index: PlayerSettingCache( index, bot_damage_settings['modifier_from'], 'damage_from_lower_multiplier', 'damage_from_higher_multiplier' )) # ============================================================================= # >> EVENTS # ============================================================================= @Event('player_spawn')
"https://steamcommunity.com/id/its_iPlayer" PublicConVar(name=info.basename + "_version", value=info.version, description=info.description) # ============================================================================= # >> CONSTANTS # ============================================================================= STUCK_RELEASE_TIMEOUT = 4.0 VEC_P2P_OFFSET = Vector(0, 0, 80) # ============================================================================= # >> GLOBAL VARIABLES # ============================================================================= saved_locs = PlayerDictionary(lambda index: None) selected_p2p_first = PlayerDictionary(lambda index: None) # ============================================================================= # >> TRANSLATION # ============================================================================= LANG = LangStrings(info.basename) SAY_PLAYER_DISCONNECT = SayText2(LANG["player_disconnected"]) SAY_LOC_SAVED = SayText2(LANG["loc_saved"]) SAY_NO_LOC_SAVED = SayText2(LANG["no_loc_saved"]) SAY_SELF_TELEPORTED_TO = SayText2(LANG["self_teleported_to"]) SAY_TELEPORTED_TO_ME = SayText2(LANG["teleported_to_me"]) SAY_TELEPORTED_TO_SAVED_RS = SayText2(LANG["teleport_to_saved_rs"]) SAY_TOGGLE_DISABLED = SayText2(LANG["auto_toggle_disable"]) SAY_TOGGLE_ENABLED = SayText2(LANG["auto_toggle_enable"]) SAY_SAVE_LOCATION_FIRST = SayText2(LANG["save_location_first"])
'wcsadmin_githubaccess': 1, 'wcsadmin_managementaccess': 1, 'wcsadmin_playersmanagement': 1, 'wcsadmin_raceaccess': 1, 'vip_raceaccess': 1 } } } with open(CFG_PATH / 'privileges.json', 'w') as outputfile: json_dump(privileges, outputfile, indent=4) _restrictions = WeaponRestrictionHandler() # TODO: Should I even be using this? _players = PlayerDictionary() _global_bypass = False _round_started = True _delays = defaultdict(set) # ============================================================================ # >> CLASSES # ============================================================================ class _PlayerMeta(type): def __new__(mcs, name, bases, odict): cls = super().__new__(mcs, name, bases, odict) cls._players = {} cls._cache_userids = {} cls._cache_indexes = {}
from entities.entity import Entity from entities.hooks import EntityCondition, EntityPreHook from events import Event from memory import make_object from players.entity import Player from players.dictionary import PlayerDictionary # Bot Damage from .core.cache import caches_from, caches_to from .core.cvars import config_manager from .core.settings import bot_damage_settings # ============================================================================= # >> GLOBAL VARIABLES # ============================================================================= sent_popups = PlayerDictionary(lambda index: False) # ============================================================================= # >> EVENTS # ============================================================================= @Event('player_spawn') def on_player_spawn(game_event): if not config_manager['send_popup_on_connect']: return player = Player.from_userid(game_event['userid']) if player.is_bot(): return if sent_popups[player.index]:
try: block = world[x, y, z] except IndexError: continue if block is not None: result.append(block) if not result: block = self.block if block is not None: result.append(block) return result rats = PlayerDictionary(RatPlayer) class EntitySpawnRequest: def __init__( self, prototype, origin, callback, sound_effects=False, priority=False, bypass_max_ent_limit=False): self._prototype = prototype self._origin = origin self._callback = callback self._sound_effects = sound_effects self._bypass_max_ent_limit = bypass_max_ent_limit self._performed = False if self.can_perform():
def call_clientcommands(self, command_name, *args, **kwargs): self.race.call_events(command_name, *args, **kwargs) items = self.items.copy() for item in items: item.call_clientcommands(command_name, *args, **kwargs) def take_damage(self, *args, **kwargs): global ignore_damage_events ignore_damage_events = True super().take_damage(*args, **kwargs) ## core player_dict = PlayerDictionary(factory=Player) ignore_damage_events = False @OnClientFullyConnect def on_client_fully_connect(index): if index == 0: return player = player_dict[index] ##player.is_connected = True @OnClientDisconnect def _player_cleanup(index): player = player_dict[index] player.call_events("player_death", player=player, attacker=None)
## IMPORTS from .config import PLAYER_CLASS from .inventories import Inventory from events import Event from players.dictionary import PlayerDictionary ## ALL DECLARATION __all__ = ('player_inventories', ) ## PLAYER DICT CONSTRUCTION player_inventories = PlayerDictionary(PLAYER_CLASS) ## PLAYER INVENTORY MANAGEMENT _activated = [] @Event('player_spawn') def _on_player_connect_create_inv(event_data): 'Initialisation of Inventory for each joining player.' userid = event_data['userid'] global _activated if not userid in _activated: player = player_inventories.from_userid(userid) player.inventory = Inventory(player)
self.player_class = player_class if self.player.team in VGUI_PANEL_NAMES: VGUIMenu(VGUI_PANEL_NAMES[self.player.team]).send( self.player.index) def is_authorized_to_bypass(self, player_class): permission = (BYPASS_PERMISSION_BASE + '.' + CLASS_NAME_BY_ID[player_class]) return auth_manager.is_player_authorized(self.player.index, permission) # ============================================================================= # >> PLAYER DICTIONARIES # ============================================================================= balanced_players = PlayerDictionary(BalancedPlayer) # ============================================================================= # >> EVENTS # ============================================================================= @Event('player_changeclass') def on_player_changeclass(game_event): player_class = game_event['class'] if player_class not in CLASS_NAME_BY_ID: return balanced_player = balanced_players.from_userid(game_event['userid']) team = balanced_player.player.team if team not in TEAM_NAMES: return
__all__ = ( 'players', 'unload_database', ) ## SETUP PLAYER def setup_player(index): player = Player(index) load_player_data(player) load_hero_data(player) return player ## GLOBALS players = PlayerDictionary(factory=setup_player) def unload_database(): manager.connection.commit() manager.connection.close() ## DATABASE MANAGMENT @Event('player_disconnect') def _on_disconnect_save_data(event_data): player = players.from_userid(event_data['userid']) save_player_data(player) save_hero_data(player) del players[player.index] @Event('player_death') def _on_death_save_data(event_data):
''' ''' __all__ = ( 'player_dictionary', 'PlayerDictionary', ) from players.dictionary import PlayerDictionary from .entity import Player # # # player_dictionary = PlayerDictionary(Player)
from entities.entity import Entity from entities.hooks import EntityCondition, EntityPostHook, EntityPreHook from events import Event from listeners import OnEntityDeleted, OnLevelInit, OnPlayerRunCommand from mathlib import Vector from memory import make_object from paths import GAME_PATH from players.constants import PlayerButtons from players.dictionary import PlayerDictionary from .info import info MAPDATA_PATH = GAME_PATH / "mapdata" / "limit_zones" ZONE_ENTITY_CLASSNAME = "trigger_multiple" players = PlayerDictionary() nojump_counters = PlayerDictionary(factory=lambda index: 0) noduck_counters = PlayerDictionary(factory=lambda index: 0) speed_cap_seqs = PlayerDictionary(factory=lambda index: list()) def dict_to_vector(dict_): return Vector(dict_['x'], dict_['y'], dict_['z']) class Zone: def __init__(self, dict_): mins = dict_to_vector(dict_['mins']) maxs = dict_to_vector(dict_['maxs']) properties = { 'nojump': dict_['properties']['nojump'],
2: 'sniper_push_chance', 3: 'soldier_push_chance', 4: 'demo_push_chance', 5: 'medic_push_chance', 6: 'heavy_push_chance', 7: 'pyro_push_chance', 8: 'spy_push_chance', 9: 'engineer_push_chance', } cvar_restartgame = ConVar('mp_restartgame') cvar_bot_quota = ConVar('tf_bot_quota') bot_quota = None train_watchers_by_team = {} bot_professions = PlayerDictionary(lambda index: BotProfession.BLOCK) temp_teams = PlayerDictionary(lambda index: 0) game_rules = None class_limit_interface = ExternalPluginInterface('class_limit') # ============================================================================= # >> CLASSES # ============================================================================= class BotProfession(IntEnum): BLOCK = 0 PUSH = 1 # =============================================================================