def spawn_flag(self, vector): "Spawn a flag onto the map from a vector instance." # Creating a flag prop. flag = Entity.create('prop_physics_override') flag.origin = vector flag.model = Flags.STATIONARY_MODEL flag.spawn_flags = 265 flag.carrier = None flag.home = vector flag.spawn() # Simple Effect to mark Flags. entity = Entity.create('env_smokestack') entity.teleport(vector, None, None) entity.base_spread = 10 entity.spread_speed = 75 entity.initial_state = 0 entity.speed = 105 entity.rate = 100 entity.start_size = 8 entity.end_size = 4 entity.twist = 360 entity.jet_length = 100 entity.render_mode = 18 entity.render_amt = 100 entity.render_color = Color(3, 5, 253) entity.add_output('SmokeMaterial {}'.format(Flags.EFFECT_MATERIAL)) entity.turn_on() entity.set_parent(self[vector].pointer, -1) flag.effect = entity self[vector] = flag
def _on_player_pre_attack(self, attacker, victim, **kwargs): if randint(1, 100) > 20 or self.cooldowns['blizzard'] > 0 or self.level == 0: return self._center = victim.origin self._player = attacker self._players_hit.clear() self._repeater = Repeat(self._repeat) self._repeater.start(0.1) self._effect = TempEntity('BeamRingPoint', center=self._center, start_radius=self.range, end_radius=self.range+1, model_index=self._model.index, halo_index=self._model.index, life_time=7, amplitude=10, red=200, green=200, blue=255, alpha=245, flags=0, start_width=10, end_width=10) self._effect.create() self._stack = Entity.create('env_smokestack') self._stack.teleport(self._center, QAngle(0, 180, 0), None) self._stack.base_spread = self.range / 2 self._stack.spread_speed = 10 self._stack.start_size = 2 self._stack.end_size = 1 self._stack.jet_length = 100 self._stack.angles = QAngle(0, 0, 0) self._stack.rate = 600 self._stack.speed = 100 self._stack.twist = 180 self._stack.render_mode = RenderMode.TRANS_COLOR self._stack.render_amt = 100 self._stack.render_color = Color(200, 200, 255) self._stack.add_output('SmokeMaterial particle/rain.vmt') self._stack.turn_on() self._stack2 = Entity.create('env_smokestack') self._stack2.teleport(self._center, None, QAngle(0, 180, 0)) self._stack2.base_spread = self.range / 4 self._stack2.spread_speed = self.range / 2 self._stack2.start_size = 2 self._stack2.end_size = 1 self._stack2.jet_length = 100 self._stack2.angles = QAngle(0, 180, 0) self._stack2.rate = 600 self._stack2.speed = 100 self._stack2.twist = 120 self._stack2.render_mode = RenderMode.TRANS_COLOR self._stack2.render_amt = 100 self._stack2.render_color = Color(200, 200, 255) self._stack2.add_output('SmokeMaterial particle/rain.vmt') self._stack2.turn_on() send_wcs_saytext_by_index(self._msg_a.format(name=victim.name), attacker.index) self._stack.delay(7, self._stack.turn_off) self._stack2.delay(7, self._stack2.turn_off) Delay(7, self._repeater.stop) self.cooldowns['blizzard'] = 10
def create( self, origin, number, color, angle, size, without_decoy=False, velocity=None ): """Creates and combines a 'decoy_projectile' and a 'point_worldtext' to represent the FloatingNumber entity. The 'decoy_projectile' is used to add movement / animation to the 'point_worldtext'. """ # Create and setup the 'point_worldtext'. self.world_text = Entity.create('point_worldtext') self.world_text.text = number self.world_text.text_size = size self.world_text.text_color = color # Add the FloatingNumber instance to the dictionary. number_instances[self.world_text.index] = self # Don't go further if we don't need a 'decoy_projectile'. if without_decoy: return # Create and setup the 'decoy_projectile'. self.decoy = Entity.create('decoy_projectile') self.decoy.spawn() self.decoy.gravity = 0.23 self.decoy.color = INVISIBLE # Remove the 'decoy_projectile' bounce sound. self.decoy.set_property_uchar('movecollide', 0) # Make the decoy not solid. self.decoy.solid_type = SolidType.NONE self.decoy.solid_flags = SolidFlags.NOT_SOLID self.decoy.collision_group = CollisionGroup.NONE # Parent the 'point_worldtext' to the 'decoy_projectile'. self.world_text.set_parent(self.decoy, -1) self.world_text.teleport(calculate_offset(number, size), None, None) # Strip the FL_EDICT_ALWAYS flag from the 'point_worldtext' after # setting the parent, otherwise hiding the entity in the SetTransmit # hook won't work. self.state_flags = self.state_flags ^ FL_EDICT_ALWAYS self.decoy.teleport( origin, angle, velocity if velocity else Vector( random.choice(random_velocity), random.choice(random_velocity), 65 ) ) # Remove the 'decoy_projectile' after a short delay. # Since the 'point_worldtext' is parented to the 'decoy_projectile', it # will also get removed. self.decoy.delay(0.55, self.decoy.remove)
def _get_start_from_weapon(player): """Return the weapon's position.""" weapon = player.active_weapon if weapon is None: return world_model = string_tables[Model.precache_table][weapon.world_model_index] header = model_cache.get_model_header(model_cache.find_model(world_model)) has_muzzle = False for index in range(header.attachments_count): if header.get_attachment(index).name != 'muzzle_flash': continue has_muzzle = True if not has_muzzle: return bone = _find_bone(player.model_header, 'ValveBiped.Bip01_R_Hand') if bone == -1: return GetBoneTransform = player.make_virtual_function( 199, Convention.THISCALL, [DataType.POINTER, DataType.INT, DataType.POINTER], DataType.VOID, ) matrix = Matrix3x4() GetBoneTransform(player, bone, matrix) angles = matrix.angles angles.z += 180 prop = Entity.create('prop_dynamic_override') prop.model_name = world_model prop.effects = EntityEffects.NODRAW prop.solid_type = SolidType.NONE prop.origin = matrix.position prop.angle = Vector(*angles) prop.spawn() null = Entity.create('info_null') null.set_parent(prop) null.call_input('SetParentAttachment', 'muzzle_flash') origin = null.get_property_vector('m_vecAbsOrigin') null.spawn() prop.remove() return origin
def _on_player_ultimate(self, player, **eargs): if self.level == 0: return _cooldown = self.cooldowns['ultimate'] if _cooldown <= 0: duration = (self.level * 0.5) + 1 self._godmode = True Delay(duration, self.__setattr__, args=('_godmode', False)) effect = Entity.create('env_sprite') location = player.origin location.z += 40 effect.teleport(location, None, None) effect.add_output('model sprites/halo.vmt') effect.add_output('scale 10') effect.call_input('ShowSprite') attach_entity_to_player(player, effect) Delay(duration, self.kill_effect, args=(effect, )) send_wcs_saytext_by_index(self._msg_a.format(time=duration), player.index) godmode_sound.index = player.index godmode_sound.origin = player.origin godmode_sound.play() self.cooldowns['ultimate'] = 30 else: send_wcs_saytext_by_index(self._msg_c.format(time=_cooldown), player.index)
def perform(self): self._performed = True global _entities_spawned_this_approach, _entities_spawned_this_tick _entities_spawned_this_approach += 1 _entities_spawned_this_tick += 1 global _total_entities _total_entities += 1 entity = Entity.create(BLOCK_ENTITY) entity.model = self._prototype.model entity.health = self._prototype.health entity.set_property_int('m_Material', self._prototype.material) entity.teleport(self._origin) entity.spawn() if self._sound_effects: Sound( choice(_level_properties['block_restore_sounds']), index=SOUND_FROM_WORLD, volume=0.25, attenuation=Attenuation.NORMAL, origin=self._origin ).play() self._callback(entity)
def create_zombie_entities(): for zombie_spawn in zombie_spawn_storage: entity = Entity.create(zombie_spawn.classname) entity.spawn() entity.teleport(zombie_spawn.origin, zombie_spawn.angles) zombie_entities[entity.index] = entity
def take_damage(self, damage, attacker, weapon=None, skip_hooks=True): # TODO: This method should not have been called if the victim is already dead assert not self.player.dead if not self.player.dead: global _global_bypass _global_bypass = skip_hooks take_damage_info = TakeDamageInfo() take_damage_info.attacker = attacker global _global_weapon_entity if _global_weapon_entity is None: _global_weapon_entity = Entity.create('info_target') if weapon is None: _global_weapon_entity.set_key_value_string('classname', 'point_hurt') else: _global_weapon_entity.set_key_value_string('classname', f'wcs_{weapon}') take_damage_info.weapon = _global_weapon_entity.index take_damage_info.inflictor = _global_weapon_entity.index take_damage_info.damage = damage take_damage_info.type = DamageTypes.GENERIC try: self.player.on_take_damage(take_damage_info) finally: _global_bypass = False
def level_up(player): """Display the level up effect on a player.""" entity = Entity.create('env_smokestack') # This might be completely unnecessary. # The only time I can think that this might be necessary is # if the max entity limit is reached, but I am not sure this would # catch that, or if there would be another error that would occur. if not entity.basehandle.is_valid(): return entity.teleport(player.origin, None, None) entity.base_spread = 10 entity.spread_speed = 60 entity.initial_state = 0 entity.speed = 105 entity.rate = 50 entity.start_size = 7 entity.end_size = 2 entity.twist = 0 entity.jet_length = 100 entity.angles = NULL_VECTOR entity.render_mode = 18 entity.render_amt = 100 entity.render_color = Color(255, 255, 3) entity.add_output('SmokeMaterial effects/yellowflare.vmt') entity.turn_on() entity.set_parent(player.pointer, -1) Delay(2, _remove_smoke, entity)
def set_model(command): userid = int(command[1]) model = str(command[2]) if model == '0': inthandle = _remove_model(userid) if inthandle is not None: Player.from_userid(userid).color = Color(255, 255, 255, 255) return _remove_model(userid) if 'models/' not in model: model = 'models/' + model player = Player.from_userid(userid) player.color = Color(255, 255, 255, 0) model = Model(model) entity = Entity.create('prop_dynamic_override') entity.origin = player.origin entity.parent = player entity.set_model(model) entity.spawn() _game_models[entity.inthandle] = player.userid entity.add_output('OnUser1 !self,Kill,,0,1')
def wcs_sub_strip_command(command_info, player:convert_userid_to_player): if player is None: return entity = Entity.create('player_weaponstrip') entity.call_input('Strip', activator=player) entity.remove()
def strip(command): if len(command) == 2: if exists(int(command[1])): player = Player.from_userid(int(command[1])) entity = Entity.create('player_weaponstrip') entity.call_input("Strip", activator=player) entity.remove()
def create(cls, location): 'Creation of the item in game. Proceed with this...' entity = Entity.create('prop_dynamic') entity.model = cls.model entity.origin = location entity.spawn() entity.delay(0.1, entity.enable_collision, cancel_on_level_end=True) return cls(entity)
def create(cls, location): entity = Entity.create('prop_physics_override') entity.model = cls.model entity.origin = location entity.spawn_flags = 256 entity.solid_flags = 152 entity.collision_group = 11 entity.spawn() return cls(entity)
def set_weapon_name(name, prefix='wcs'): global _global_weapon_entity if _global_weapon_entity is None: _global_weapon_entity = Entity.create('info_target') _global_weapon_entity.set_key_value_string('classname', ('' if prefix is None else prefix + '_') + name) return _global_weapon_entity.index
def give_spark_entity(self): entity = self.spark_entity = Entity.create('env_spark') entity.spawn_flags = 896 entity.angles = Vector(-90, 0, 0) entity.magnitude = 8 entity.trail_length = 3 entity.set_parent(self, -1) entity.origin = self.origin entity.start_spark()
def wcs_sub_give_command(command_info, player:convert_userid_to_player, entity:str): warn('"wcs give" will be removed in the future. Use "es_give" instead.', PendingDeprecationWarning) if player is None: return entity = Entity.create(entity) entity.origin = player.origin entity.spawn()
def give_spark_entity(self): """Give the player an env_spark effect.""" entity = self.spark_entity = Entity.create('env_spark') entity.spawn_flags = 896 entity.angles = QAngle(-90, 0, 0) entity.magnitude = 8 entity.trail_length = 3 entity.set_parent(self, -1) entity.origin = self.origin entity.start_spark()
def _on_player_ability(self, player, **eargs): if self.level == 0: return cooldown = self.cooldowns["ability"] if cooldown <= 0: targets = [] for target in PlayerIter(): if player.team != target.team and not target.playerinfo.is_dead( ): targets.append(target) if len(targets) == 0: return index = randint(1, len(targets)) - 1 target = targets[index] self.target = target prepare_wcs_saytext( self._msg_a.format(player=player.name, enemy=target.name)).send() # EFFECT if self.effect: self.kill_effect(self.effect) self.effect = effect = Entity.create('env_smokestack') location = target.origin location.z += 96 effect.teleport(location, None, None) effect.base_spread = 5 effect.spread_speed = 0 effect.start_size = 7 effect.end_size = 7 effect.jet_length = 10 effect.angles = QAngle(90, 90, 90) effect.rate = 60 effect.speed = 40 effect.twist = 0 effect.render_mode = RenderMode.TRANS_COLOR effect.render_amt = 100 effect.render_color = Color(255, 255, 3) effect.add_output('SmokeMaterial Effects/Redflare.vmt') effect.turn_on() attach_entity_to_player(target, effect) self.cooldowns["ability"] = 10 else: send_wcs_saytext_by_index(self._msg_c.format(time=int(cooldown)), player.index)
def wcs_create_prop_command(command_info, player:convert_userid_to_player, path:str, health:int): if player is None: return if not path.startswith('models/'): path = f'models/{path}' entity = Entity.create('prop_physics_multiplayer') entity.origin = player.view_coordinates entity.model = Model(path) entity.spawn() entity.set_property_uchar('m_takedamage', TakeDamage.YES) entity.health = health
def spark_effect(command): x = float(command[1]) y = float(command[2]) z = float(command[3]) magnitude = int(command[4]) traillength = int(command[5]) duration = float(command[6]) entity = Entity.create('env_spark') entity.magnitude = magnitude entity.trail_length = traillength entity.origin = Vector(x, y, z) entity.call_input('StartSpark') entity.delay(duration, entity.remove)
def create_prop(command): userid = int(command[1]) propname = str(command[2]) prophealth = int(command[3]) if "models/" not in propname: propname = "models/" + propname model = Model(propname) player = Player.from_userid(userid) entity = Entity.create('prop_physics_multiplayer') entity.origin = player.view_coordinates entity.set_model(model) entity_health[entity.index] = prophealth entity.set_property_uchar("m_takedamage", 4) entity.spawn()
def wcs_explosion_point(command): userid = int(command[1]) x = float(command[2]) y = float(command[3]) z = float(command[4]) magnitude = int(command[5]) radius = int(command[6]) if exists(userid): ent = Entity.create('env_explosion') ent.set_property_int('m_iMagnitude', magnitude) ent.set_property_int('m_iRadiusOverride', radius) ent.owner_handle = inthandle_from_userid(userid) ent.spawn() ent.origin = Vector(x, y, z) ent.call_input('Explode')
def wcs_explosion_command(command_info, player:convert_userid_to_player, magnitude:int, radius:int, deal_damage:int=1): if player is None: return entity = Entity.create('env_explosion') entity.set_property_int('m_iMagnitude', magnitude) entity.set_property_int('m_iRadiusOverride', radius) entity.spawn_flags = 8 if deal_damage else 1 entity.owner_handle = player.inthandle entity.origin = player.origin entity.spawn() entity.call_input('Explode')
def create_medkit(self, userid, bombentindex, vector): try: locked = False # get player and team player = Player.from_userid(userid) pdata = self.rank.get_player_data(userid) if not int(pdata['class']) in self.rank.classes: return if not self.rank.classes[int(pdata['class'])]['can_have_medkit'] >= 1: return pteam = self.rank.get_player_team(userid) # delete old medkit if we spawn a new one self.delete_pack(userid) # create healthpack self.packs_lock.acquire() locked = True # set medkit color if pteam == 'CT': color = self.color_ct else: color = self.color_t tmp_ent = Entity.create('prop_physics_override') self.pack[player.userid] = { 'ent': tmp_ent.index, 'type': 'health', 'amount': 200, 'give': 10, 'distance': 100, 'userid': userid, 'team': pteam, 'next_glow': 0, 'color': color, } tmp_ent.origin = vector tmp_ent.model = Model('models/props/cs_italy/bin01.mdl') tmp_ent.spawn_flags = 4 tmp_ent.color = color # spawn healthpack tmp_ent.spawn() # set health tmp_ent.call_input('SetHealth', 100) tmp_ent.set_property_uchar("m_takedamage", TakeDamage.YES) self.packs_lock.release() locked = False except: if locked: self.packs_lock.release() msg('ERROR', 'could not create healthpack')
def init_capture_zone(self): self._capture_zone_entity = entity = Entity.create('trigger_multiple') entity.set_key_value_string( "model", "maps/{map_name}.bsp".format(map_name=global_vars.map_name)) entity.spawn() entity.flags = 1 # Gets triggered and angry by clients entity.solid_type = SolidType.BBOX origin = (self._cap_v1 + self._cap_v2) / 2 v1 = self._cap_v1 - origin v2 = self._cap_v2 - origin entity.origin = origin entity.mins = Vector(min(v1.x, v2.x), min(v1.y, v2.y), min(v1.z, v2.z)) entity.maxs = Vector(max(v1.x, v2.x), max(v1.y, v2.y), max(v1.z, v2.z))
def _spawn_entity(self, origin=None): floor_origin = self._find_floor(origin) if floor_origin is None: origin = self.origin else: origin = floor_origin + Vector(0, 0, FLAG_DIMENSIONS[2] / 2) self._entity = Entity.create('prop_dynamic_glow') self._entity.model = self.model if config_manager['flags_glow']: self._entity.glow_color = self.color self._entity.glow_enabled = True self._entity.set_key_value_int('glowdist', self.glow_distance) self._entity.solid_type = SolidType.VPHYSICS self._entity.teleport(origin) self._entity.spawn()
def create_nade(player, damage): ent = Entity.create('hegrenade_projectile') origin = player.origin origin[2] += 100 ent.origin = origin ent.spawn() angles = player.view_angle forward = Vector() right = Vector() up = Vector() angles.get_angle_vectors(forward, right, up) ent.damage = damage ent.set_property_vector('m_vecBaseVelocity', (forward + up) * 400) ent.thrower = player.inthandle if SOURCE_ENGINE_BRANCH == 'css': ent.model_index = rocket_model.index ent.solid_type = SolidType.NONE ent.angles = player.angles ent.set_key_value_string('targetname', "cluster") give_trail(ent, player.team)
def create_trigger(zone): """ Create an engine trigger. """ offset = 100 mins, maxs = zone.start, zone.end maxs.z += offset origin, mins, maxs = get_relative_coordinates(mins, maxs) entity = Entity.create('trigger_multiple') entity.target_name = secrets.token_hex(nbytes=16) entity.filter_name = zone.filter_name entity.model = error # error model entity.spawn() entity.origin = origin entity.mins = mins entity.maxs = maxs entity.wait = 0 entity.solid_type = SolidType.BBOX entity.effects |= 0x020 entity.spawn_flags = 257 entity.call_input('Enable') return entity
def wcs_explosion(command): userid = int(command[1]) magnitude = int(command[2]) radius = int(command[3]) if len(command) > 4: do_damage = int(command[4]) else: do_damage = 1 if exists(userid): player = Player.from_userid(userid) ent = Entity.create('env_explosion') ent.set_property_int('m_iMagnitude', magnitude) ent.set_property_int('m_iRadiusOverride', radius) if do_damage == 1: ent.spawn_flags = 8 else: ent.spawn_flags = 1 ent.owner_handle = inthandle_from_userid(userid) ent.spawn() ent.origin = player.origin ent.call_input('Explode')
def _on_player_ability(self, player, **kwargs): if self.level == 0: return _cooldown = self.cooldowns['ability'] if _cooldown <= 0: self._absorb += self.shield player.color = Color(0, 0, 255) send_wcs_saytext_by_index(self._msg_a, player.index) self.cooldowns['ability'] = 10 if self._effect: return self._effect = effect = Entity.create('env_smokestack') location = player.origin location.z += 48 effect.teleport(location, None, None) effect.base_spread = 12 effect.spread_speed = 40 effect.start_size = 1 effect.end_size = 32 effect.jet_length = 10 effect.angles = QAngle(90, 90, 90) effect.rate = 60 effect.speed = 40 effect.twist = 0 effect.render_mode = RenderMode.TRANS_COLOR effect.render_amt = 100 effect.render_color = Color(0, 0, 255) effect.add_output('SmokeMaterial Effects/Redflare.vmt') effect.turn_on() effect.set_parent(player.pointer, -1) else: send_wcs_saytext_by_index(self._msg_c.format(time=int(_cooldown)), player.index)
def _deal_damage(command): victim = int(command[1]) attacker = int(command[2]) damage = int(command[3]) if len(command) > 4: weapon = str(command[4]) else: weapon = None if exists(victim) and exists(attacker): victim_player = Player.from_userid(victim) attacker_player = Player.from_userid(attacker) victim_player.target_name = "wcs_hurtme" entity = Entity.create('point_hurt') entity.set_key_value_string("DamageTarget", "wcs_hurtme") entity.damage = damage entity.damage_type = 0 if weapon != None: entity.set_key_value_string("classname", weapon) entity.spawn() entity.call_input("Hurt", activator=attacker_player) victim_player.target_name = "wcs_donthurtme" entity.remove()
class DisposableProp(BaseItemInstance): manual_activation = True def try_activate(self, player, amount, async=True): reason = super().try_activate(player, amount, async) if reason is not None: return reason global props_disposed if props_disposed >= MAX_DISPOSED_PROPS_PER_ROUND: return strings_module['fail too_many'] coords = player.get_view_coordinates() if coords is None: return strings_module['fail wrong_place'] if coords.get_distance(player.origin) > MAX_TARGET_DISTANCE: return strings_module['fail too_far'] # TODO: Add game area check props_disposed += 1 entity = Entity.create(self['entity_classname']) entity.model = Model(self['model_path']) entity.skin = randint(self.get('skin_min', 0), self.get('skin_max', 0)) origin = coords + Vector(0, 0, self.get('z_offset', 0)) entity.teleport(origin, None, None) entity.spawn() Sound(SPAWN_SOUND_PATH, index=entity.index, attenuation=Attenuation.STATIC).play() return None
def create_prop(self): origin = self.origin + self.normal * PLANT_OFFSET self.prop = Entity.create("prop_physics_override") self.prop.target_name = "_tripmines_prop_{}".format(self.id) self.prop.model = PROP_MODEL self.prop.spawn_flags = 8 self.prop.teleport(origin, PLANT_ANGLES + Vector( -degrees(asin(self.normal.z)), degrees(atan2(self.normal.y, self.normal.x)), 0, ), None) # Make it non-solid so that the beam goes through self.prop.solid_type = 6 self.prop.collision_group = 11 self.prop.spawn() if config_manager['plant_sound'] != "": Sound( config_manager['plant_sound'], index=self.prop.index, attenuation=Attenuation.STATIC).play()
def create_zone_entities(): for zone in zones_storage: entity = Entity.create(ZONE_ENTITY_CLASSNAME) entity.set_key_value_string( "model", "maps/{map_name}.bsp".format(map_name=global_vars.map_name)) entity.spawn() entity.solid_type = SolidType.BBOX mins = Vector(min(zone.mins.x, zone.maxs.x), min(zone.mins.y, zone.maxs.y), min(zone.mins.z, zone.maxs.z)) maxs = Vector(max(zone.mins.x, zone.maxs.x), max(zone.mins.y, zone.maxs.y), max(zone.mins.z, zone.maxs.z)) maxs = (maxs - mins) / 2 entity.mins = maxs * (-1) entity.maxs = maxs entity.origin = zone.origin zone_entities[entity.index] = ZoneEntity(entity, zone)
def _player_spawn(game_event): """Give the player their level weapon.""" # Is GunGame active? if GunGameStatus.MATCH is not GunGameMatchStatus.ACTIVE: return # Use try/except to get the player's instance try: player = player_dictionary[game_event['userid']] except ValueError: return # Verify that the player is on a team if player.team_index < 2: return if not player.level: return if player.userid in _spawning_users: return _spawning_users.add(player.userid) Delay( delay=0, callback=_spawning_users.remove, args=(player.userid,), ) # Spawn protection player.give_spawn_protection() # Give the player their new weapon player.strip_weapons( not_filters={'grenade'}, remove_incendiary=player.level_weapon in incendiary_weapons, ) player.give_level_weapon() # Give CTs defusers, if need be if player.team_index == 3 and give_defusers.get_bool(): player.has_defuser = True # Give player armor, if necessary armor_type = {1: 'kevlar', 2: 'assaultsuit'}.get(give_armor.get_int()) if armor_type is not None: for entity in EntityIter('game_player_equip'): entity.remove() equip = Entity.create('game_player_equip') equip.add_output(f'{_melee_weapon} 1') equip.add_output( f'item_{armor_type} 1', caller=player, activator=player, ) # Skip bots if player.is_fake_client(): player.player_state = 0 return # Send the player their level information _send_level_info(player)
def _spawn_flag(self, options = {}, spawnflag = True): try: # stop if options dict is empty if not options: return False if options['status'] == 'T': color = self.color_t elif options['status'] == 'CT': color = self.color_ct else: color = self.color_n if spawnflag is False: tmp_flag = self.flags[options['name']]['entity'] tmp_pole = self.flags[options['name']]['entity_pole'] else: tmp_flag = Entity.create('prop_physics_override') tmp_pole = Entity.create('prop_physics_override') if options['name'] in self.flags: if self.flags[options['name']]['entity'] is not None: tmp = self.flags[options['name']]['entity'] tmp.remove() if self.flags[options['name']]['entity_pole'] is not None: tmp = self.flags[options['name']]['entity_pole'] tmp.remove() if options['status'] != 'none': tmp_flag.origin = Vector(options['X'], options['Y'], options['Z'] + self.flag_height) else: tmp_flag.origin = Vector(options['X'], options['Y'], options['Z']) tmp_flag.set_key_value_color('rendercolor', color) tmp_pole.set_key_value_color('rendercolor', color) if spawnflag is True: tmp_flag.model = self.model_flag tmp_flag.spawn_flags = 265 tmp_pole.origin = Vector(options['X'], options['Y'], options['Z']) tmp_pole.model = self.model_pole tmp_pole.spawn_flags = 265 tmp_flag.spawn() tmp_pole.spawn() self.flags_lock.acquire() self.flags[options['name']] = { 'name': options['name'], 'orderby': options['orderby'], 'X': options['X'], 'Y': options['Y'], 'Z': options['Z'], 'spawnX': options['spawn_X'], 'spawnY': options['spawn_Y'], 'spawnZ': options['spawn_Z'], 'distance': options['distance'], 'type': options['type'], 'timer': options['timer'], 'status': options['status'], 'tmp_status': options['status'], 'tmp_conquered_by': 'none', 'draw': 0, 'timestamp': '0', 't_index' : [], 'ct_index': [], 'last_glow': 0, 'entity': tmp_flag, 'entity_pole': tmp_pole, } self.flags_lock.release() except: msg('ERROR', 'could not spawn flag')
def create_beam(self): if self.prop is None: raise RuntimeError("Create prop first") end_trace_vec = self.origin + self.normal * MAX_TRACE_LENGTH trace = GameTrace() engine_trace.trace_ray( Ray(self.origin, end_trace_vec), ContentMasks.ALL, TraceFilterSimple(ignore=(self.prop.index, )), trace ) if not trace.did_hit(): return if self.owner.team == teams_by_name['ct']: beam_color = Color(100, 100, 255) else: beam_color = Color(255, 100, 100) self.beam_target = Entity.create("env_spark") self.beam_target.target_name = "_tripmines_target1_{}".format(self.id) self.beam_target.teleport(self.origin, None, None) self.beam_target.spawn() self.beam = Entity.create("env_beam") self.beam.target_name = "_tripmines_beam_{}".format(self.id) self.beam.spawn_flags = 1 self.beam.teleport(trace.end_position, None, None) self.beam.set_key_value_float('BoltWidth', 1.0) self.beam.set_key_value_int('damage', 0) self.beam.set_key_value_float('HDRColorScale', 1.0) self.beam.set_key_value_int('life', 0) self.beam.set_key_value_string( 'LightningStart', self.beam.target_name) self.beam.set_key_value_string( 'LightningEnd', self.beam_target.target_name) self.beam.set_key_value_int('Radius', 255) self.beam.set_key_value_int('renderamt', 100) self.beam.set_key_value_color('rendercolor', beam_color) self.beam.set_key_value_int('StrikeTime', 1) self.beam.set_key_value_string('texture', "sprites/laserbeam.spr") self.beam.set_key_value_int('TextureScroll', 35) self.beam.set_key_value_int('TouchType', 3) self.beam.model = BEAM_MODEL self.beam.set_property_vector('m_vecEndPos', self.origin) self.beam.spawn() self.beam.call_input('TurnOff') self.beam.call_input('TurnOn') self.activated = True if config_manager['activation_sound'] != "": Sound(config_manager['activation_sound'], index=self.prop.index, attenuation=Attenuation.STATIC).play()
def set_location(class_name, origin, angles): entity = Entity.create(class_name) entity.origin = origin entity.angles = angles