Пример #1
0
def wcs_teleport_command(command_info, player:convert_userid_to_player, x:float, y:float, z:float):
    if player is None:
        return

    location = Vector(x, y, z)
    origin = player.origin
    angles = QAngle(*player.get_property_vector('m_angAbsRotation'))

    forward = Vector()
    right = Vector()
    up = Vector()
    angles.get_angle_vectors(forward, right, up)

    forward.normalize()
    forward *= 10

    playerinfo = player.playerinfo
    mins, maxs = playerinfo.mins, playerinfo.maxs
    players = TraceFilterSimple(PlayerIter())

    for _ in range(100):
        ray = Ray(location, location, mins, maxs)
        trace = GameTrace()
        engine_trace.trace_ray(ray, ContentMasks.PLAYER_SOLID, players, trace)

        if not trace.did_hit():
            player.teleport(origin=location)
            break

        location -= forward

        if location.get_distance(origin) <= 10.0:
            break
Пример #2
0
def _wcs_teleport(command):
    userid = int(command[1])
    x = float(command[2])
    y = float(command[3])
    z = float(command[4])
    target_location = Vector(
        x,
        y,
        z,
    )
    player = Player.from_userid(userid)
    origin = player.origin
    angles = QAngle(*player.get_property_vector('m_angAbsRotation'))
    forward = Vector()
    right = Vector()
    up = Vector()
    angles.get_angle_vectors(forward, right, up)
    forward.normalize()
    forward *= 10.0
    loop_limit = 100
    can_teleport = 1
    while is_player_stuck(player.index, target_location):
        target_location -= forward
        loop_limit -= 1
        if target_location.get_distance(origin) <= 10.0 or loop_limit < 1:
            can_teleport = 0
            break
    if can_teleport == 1:
        player.teleport(target_location, None, None)
Пример #3
0
    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
Пример #4
0
def effect127(model, skin, position, angle, velocity, flags, effects):
    """
    est_effect_27 <player filter> <delay> <model> <subtype/skin> <position x y z> <angle p y r> <velocity x y z> <flags> <effects>
    """
    if not isinstance(model, Model):
        model = Model(model)

    if not isinstance(position, Vector):
        position = Vector(*position)

    if not isinstance(angle, QAngle):
        angle = QAngle(*angle)

    if not isinstance(velocity, Vector):
        velocity = Vector(*velocity)

    te = TempEntity('physicsprop')
    te.model = model
    te.skin = skin
    te.origin = position
    te.angles = angle
    te.velocity = velocity
    te.flags = flags
    te.effects = effects

    return te
Пример #5
0
def effect112(model, origin, angle, size, velocity, randomization, count, time,
              flags):
    """
    est_effect_12 <player filter> <delay> <model> <origin x y z> <angle p y r> <Size x y z> <velocity x y z> <randomization> <count> <time> <flags>

    """
    if not isinstance(model, Model):
        model = Model(model)

    if not isinstance(origin, Vector):
        origin = Vector(*origin)

    if not isinstance(angle, QAngle):
        angle = QAngle(*angle)

    if not isinstance(size, Vector):
        size = Vector(*size)

    if not isinstance(velocity, Vector):
        velocity = Vector(*velocity)

    te = TempEntity('Break Model')
    te.model = model
    te.origin = origin
    te.rotation = angle
    te.size = size
    te.velocity = velocity
    te.randomization = randomization
    te.count = count
    te.life_time = time
    te.flags = flags

    return te
Пример #6
0
    def get_view_angle(self):
        """Return the player's view angle.

        :rtype: QAngle
        """
        eye_angle_y = self.eye_angle.y
        eye_angle_y = (eye_angle_y + 360) if eye_angle_y < 0 else eye_angle_y
        return QAngle(self.eye_angle.x, eye_angle_y, self.rotation.z)
Пример #7
0
    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)
Пример #8
0
    def load(self):
        """Load spawn points from the spawn points data file for the current map."""
        # Skip if the file doesn't exist
        if not self.json_file.exists():
            return

        # Read the spawn points data file into memory
        with self.json_file.open() as f:
            contents = json.load(f)

        # Append each entry as a `SpawnPoint` object
        for data in contents:
            self.append(SpawnLocation(*data['vector'], QAngle(*data['angle'])))
Пример #9
0
def effect126(position, angle, scale, type_):
    """
    est_effect_26 <player filter> <delay> <position x y z> <angle p y r> <scale> <type>
    """
    if not isinstance(position, Vector):
        position = Vector(*position)

    if not isinstance(angle, QAngle):
        angle = QAngle(*angle)

    te = TempEntity('Metal Sparks')
    te.origin = position
    te.angles = angle
    te.scale = scale
    te.type = type_

    return te
Пример #10
0
def effect129(decal, position, angle, distance):
    """
    est_effect_29 <player filter> <delay> <decal> <position x y z> <angle p y r> <distance>
    """
    if not isinstance(decal, Decal):
        decal = Decal(*decal)

    if not isinstance(position, Vector):
        position = Vector(*position)

    if not isinstance(angle, QAngle):
        angle = QAngle(*angle)

    te = TempEntity('Player Decal')
    te.decal = decal
    te.origin = position
    te.rotation = angle
    te.distance = distance

    return te
Пример #11
0
    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)
Пример #12
0
    def set_view_coordinates(self, coords):
        """Force the player to look at the given coordinates.

        :param Vector coords: The coordinates the player should look at.
        """
        coord_eye_vec = coords - self.eye_location

        # Calculate the y angle value
        atan = math.degrees(math.atan(coord_eye_vec.y / coord_eye_vec.x))
        if coord_eye_vec.x < 0:
            y_angle = atan + 180
        elif coord_eye_vec.y < 0:
            y_angle = atan + 360
        else:
            y_angle = atan

        # Calculate the x angle value
        x_angle = 0 - math.degrees(
            math.atan(coord_eye_vec.z /
                      math.sqrt(coord_eye_vec.y**2 + coord_eye_vec.x**2)))

        # Set the new angle
        self.teleport(None, QAngle(x_angle, y_angle, self.rotation.z), None)
Пример #13
0
def convert_to_qangle(angle):
    return QAngle(*[float(x) for x in angle.split(',')])
Пример #14
0
    def _on_player_attack(self, attacker, victim, **eargs):
        if randint(
                1, 100
        ) > self.poison_chance or victim.userid in self.poisoned or self.level == 0:
            return

        self.poisoned.add(victim.userid)

        for index in attacker.weapon_indexes():
            break

        victim.delay(0.5,
                     victim.take_damage,
                     args=(self.poison_damage, ),
                     kwargs=dict(attacker_index=attacker.index,
                                 weapon_index=index))
        victim.delay(1,
                     victim.take_damage,
                     args=(self.poison_damage, ),
                     kwargs=dict(attacker_index=attacker.index,
                                 weapon_index=index))
        victim.delay(2,
                     victim.take_damage,
                     args=(self.poison_damage, ),
                     kwargs=dict(attacker_index=attacker.index,
                                 weapon_index=index))
        victim.delay(3,
                     victim.take_damage,
                     args=(self.poison_damage, ),
                     kwargs=dict(attacker_index=attacker.index,
                                 weapon_index=index))
        victim.delay(4.5,
                     victim.take_damage,
                     args=(self.poison_damage, ),
                     kwargs=dict(attacker_index=attacker.index,
                                 weapon_index=index))
        victim.delay(7,
                     victim.take_damage,
                     args=(self.poison_damage, ),
                     kwargs=dict(attacker_index=attacker.index,
                                 weapon_index=index))
        Delay(7, self.poisoned.discard, args=(victim.userid, ))

        send_wcs_saytext_by_index(self._msg_a.format(name=victim.name),
                                  attacker.index)

        # EFFECT

        effect = Entity.create('env_smokestack')

        location = victim.origin
        location.z += 48

        effect.teleport(location, None, None)
        effect.base_spread = 12
        effect.spread_speed = 0
        effect.start_size = 3
        effect.end_size = 2
        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, 255, 0)
        effect.add_output('SmokeMaterial Effects/Redflare.vmt')
        effect.turn_on()
        attach_entity_to_player(victim, effect)

        poison_sound.origin = location
        poison_sound.play()

        Delay(7, self.kill_effect, args=(effect, ))
Пример #15
0
def teleport_player(player, spawnpoint_name):
    spawnpoint = MapData.spawnpoints[spawnpoint_name]
    player.origin = Vector_MathLib(*spawnpoint.origin)
    player.view_angle = QAngle(*spawnpoint.angles)