示例#1
0
 def update_trail(self):
     """Create the smoke trail for the given entity."""
     entity = TempEntity('Smoke')
     entity.origin = self.entity.origin
     entity.model = _model
     entity.scale = 1
     self.create_temp_entity(entity)
示例#2
0
def est_effect_02(command):
    if len(command) == 19:
        #est_Effect_02 <player Filter> <delay> <model> <start ent> <start position "X Y Z"> <end ent> <end position "X Y Z"> <framerate> <life> <start width> <end width> <fade distance> <amplitude> <R> <G> <B> <A> <speed>
        str_vec = command[5]
        str_vec = str_vec.split(",")
        vec = Vector(float(str_vec[0]), float(str_vec[1]), float(str_vec[2]))
        str_vec = command[7]
        str_vec = str_vec.split(",")
        vec2 = Vector(float(str_vec[0]), float(str_vec[1]), float(str_vec[2]))
        te = TempEntity('BeamEntPoint',
                        start_entity_index=int(command[4]),
                        start_point=Vector(float(command[5])),
                        end_entity_index=int(command[6]),
                        end_point=vec2,
                        model_index=Model(str(command[3])).index,
                        halo_index=Model(str(command[3])).index,
                        frame_rate=int(command[8]),
                        life_time=float(command[9]),
                        start_width=int(command[10]),
                        end_width=int(command[11]),
                        fade_length=int(command[12]),
                        amplitude=int(command[13]),
                        red=int(command[14]),
                        green=int(command[15]),
                        blue=int(command[16]),
                        alpha=int(command[17]),
                        speed=int(command[18]))
        te.create(delay=float(command[2]))
示例#3
0
def square(recipients, start, end, **kwargs):
    """Create a square using the temporary effect ``BeamPoints``.

    :param RecipientFilter recipients:
        Players that should see the beam.
    :param Vector start:
        Upper left corner of the square.
    :param Vector end:
        Lower right corner of the square.
    :param kwargs:
        Additional attributes that will be send to the effect.
    """
    x1, y1, z1 = start
    x2, y2, z2 = end

    a = start
    b = Vector(x2, y2, z1)
    c = Vector(x1, y1, z2)
    d = end

    lines = (
        (a, b),
        (b, d),
        (d, c),
        (c, a),
    )

    for p1, p2 in lines:
        entity = TempEntity('BeamPoints')
        entity.start_point = p1
        entity.end_point = p2
        for attr, value in kwargs.items():
            setattr(entity, attr, value)

        entity.create(recipients)
    def _on_player_ability(self, player, **kwargs):
        if self.level == 0:
            return

        _cooldown = self.cooldowns['ability']
        if _cooldown <= 0:
            player.health = min(player.health + self.health, 150)
            send_wcs_saytext_by_index(self._msg_a.format(amount=self.health),
                                      player.index)

            location = player.origin
            location.z += 40
            self._effect = TempEntity('GlowSprite',
                                      model_index=self._model.index,
                                      life_time=0.8,
                                      amplitude=6,
                                      origin=location,
                                      scale=1.5,
                                      brightness=255)
            self._effect.create()

            heal_sound.index = player.index
            heal_sound.origin = location
            heal_sound.play()

            self.cooldowns['ability'] = 10

        else:
            send_wcs_saytext_by_index(self._msg_c.format(time=int(_cooldown)),
                                      player.index)
    def _on_player_pre_attack(self, attacker, victim, **kwargs):
        if randint(
                1,
                100) < 10 + self.level and not victim.stuck and self.level > 0:
            victim.base_velocity = Vector(0, 0, 400)
            victim.delay(0.8, victim.__setattr__, args=('stuck', True))
            victim.delay(1.8, victim.__setattr__, args=('stuck', False))

            bottom_vector = victim.origin
            top_vector = victim.origin
            top_vector.z += 100
            _effect = TempEntity('BeamPoints',
                                 alpha=255,
                                 red=100,
                                 blue=255,
                                 green=100,
                                 amplitude=10,
                                 end_width=20,
                                 start_width=20,
                                 life_time=2,
                                 fade_length=2,
                                 halo_index=self._model.index,
                                 model_index=self._model.index,
                                 start_point=top_vector,
                                 end_point=bottom_vector)
            _effect.create()

            stun_sound.index = victim.index
            stun_sound.origin = victim.origin
            stun_sound.play()
示例#6
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.cooldowns = CooldownDict()
        self._godmode = False
        self.model._precache()
        self.effect = TempEntity('GlowSprite', model=self.model, scale=1.5, brightness=255)
示例#7
0
    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)
示例#8
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
示例#9
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.weapons = []
     self.location = None
     self.explosion = TempEntity('Explosion',
                                 magnitude=100,
                                 scale=40,
                                 radius=self.range)
示例#10
0
class LifestealSkill(Skill):
    _msg_a = '{{PALE_GREEN}}Healed {{GREEN}}{heal} {{PALE_GREEN}}HP by {{DULL_RED}}stealing {{PALE_GREEN}}life from {{RED}}{name}.'

    laser = Model("sprites/lgtning.vmt", True)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.max_health = self.parent.parent.health + 100
        self.beam = TempEntity('BeamPoints',
                               alpha=255,
                               red=255,
                               green=0,
                               blue=0,
                               life_time=1.0,
                               model_index=self.laser.index,
                               start_width=7,
                               end_width=7,
                               frame_rate=255,
                               halo_index=self.laser.index)

    @property
    def chance(self):
        return self.level * 8

    @property
    def leech_multiplier(self):
        return 0.6

    @events('player_spawn')
    def _on_player_spawn(self, player, **kwargs):
        self.max_health = player.health + 100

    @events('player_pre_attack')
    def _on_player_pre_attack(self, attacker, victim, info, **kwargs):
        if self.level == 0:
            return

        heal = int(info.damage * self.leech_multiplier)
        can_heal = self.max_health > attacker.health + heal

        if self.chance > randint(0, 100) or not can_heal:
            return

        attacker.health += heal

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

        weapon = attacker.active_weapon
        if weapon and weapon.weapon_name.split(
                "_")[-1] not in weapon_manager.projectiles:
            start_location = weapon.origin.copy()
            start_location.z += 40
            end_location = attacker.get_view_coordinates()

            self.beam.create(start_point=start_location,
                             end_point=end_location)
示例#11
0
class BlowUpBaby(Item):
    category = "Offensive"
    cost = 5000
    description = "Explode when die."

    _msg_purchase = '{GREEN}Purchased {DULL_RED}Blow Up Baby.'

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.explosion = TempEntity('Explosion',
                                    magnitude=100,
                                    scale=40,
                                    radius=self.range)

    @classmethod
    def is_available(cls, player):
        item_count = sum(isinstance(item, cls) for item in player.items)
        return player.cash >= cls.cost and not player.dead and item_count < 1

    @classproperty
    def requirement_string(cls):
        return "${}".format(cls.cost)

    @classproperty
    def requirement_sort_key(cls):
        return cls.cost

    def on_purchase(self, player):
        super().on_purchase(player)
        player.cash -= self.cost
        send_wcs_saytext_by_index(self._msg_purchase, player.index)

    @property
    def range(self):
        return 200

    @property
    def magnitude(self):
        return 35

    @events('player_death', 'player_suicide')
    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 _on_player_pre_victim(self, attacker, victim, info, **eargs):
        if self.level == 0:
            return

        if victim.ground_entity == -1:
            info.damage *= 1 - 0.06 * self.level
            send_wcs_saytext_by_index(self._msg_a.format(name=attacker.name),
                                      victim.index)
            ricochet = TempEntity('Armor Ricochet', position=victim.origin)
            ricochet.create()
示例#13
0
 def update_trail(self):
     """Create the sparks trail for the given entity."""
     entity = TempEntity('Sparks')
     entity.origin = self.entity.origin
     direction = self.entity.base_velocity
     direction.negate()
     entity.direction = direction
     entity.trail_length = 3
     entity.magnitude = 1
     self.create_temp_entity(entity)
示例#14
0
def est_effect_09(command):
    #est_Effect_09 - Beam Spline Effect est_Effect_09 <player Filter> <delay> <model> <points> <rgPoints "X Y Z">
    if len(command) == 6:
        str_vec = command[5]
        str_vec = str_vec.split(",")
        vec = Vector(float(str_vec[0]), float(str_vec[1]), float(str_vec[2]))
        te = TempEntity('BeamSpline',
                        points_length=int(command[4]),
                        points=vec)
        te.create(delay=float(command[2]))
示例#15
0
文件: effects.py 项目: herlak/WCS
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
示例#16
0
def est_effect_24(command):
    if len(command) == 6:
        str_vec = command[4]
        str_vec = str_vec.split(",")
        vec = Vector(float(str_vec[0]), float(str_vec[1]), float(str_vec[2]))
        #est_Effect_24 - Large Funnel Effect est_Effect_24 <player Filter> <delay> <model> <Position "X Y Z"> <reversed>
        te = TempEntity('Large Funnel',
                        model_index=Model(str(command[3])).index,
                        origin=vec,
                        reversed=int(command[5]))
        te.create(delay=float(command[2]))
示例#17
0
class EarthgrabTotem(Skill):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.model = Model('sprites/blueflare1.vmt', True)
        self.model._precache()
        self.effect = TempEntity('BeamRingPoint',
                                 start_radius=120,
                                 end_radius=0,
                                 model_index=self.model.index,
                                 halo_index=self.model.index,
                                 life_time=1.5,
                                 amplitude=10,
                                 red=10,
                                 green=255,
                                 blue=10,
                                 alpha=245,
                                 flags=0,
                                 start_width=6,
                                 end_width=6)

        if not root_sound.is_precached:
            root_sound.precache()

    @classproperty
    def description(cls):
        return 'Root your enemies to the ground, 16-24% chance.'

    @classproperty
    def max_level(cls):
        return 8

    _msg_a = '{{GREEN}}Rooted {{RED}}{name} {{PALE_GREEN}}to the ground.'
    _msg_b = '{{PALE_GREEN}}You have been {{GREEN}}rooted {{PALE_GREEN}}to the ground by {{RED}}{name}.'

    @events('player_pre_attack')
    def _on_player_pre_attack(self, attacker, victim, **kwargs):
        if self.level == 0:
            return

        if randint(1, 100) <= 16 + self.level and not victim.stuck:
            victim.stuck = True
            victim.delay(1.5, victim.__setattr__, args=('stuck', False))

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

            root_sound.index = victim.index
            root_sound.origin = victim.origin
            root_sound.play()

            self.effect.create(center=victim.origin)
            self.effect.create(center=victim.origin, start_radius=80)
示例#18
0
def est_effect_15(command):
    if len(command) == 9:
        #est_Effect_15 - Bubble Trail Effect est_Effect_15 <player Filter> <delay> <model> <Min "X Y Z"> <Max "X Y Z"> <heigth> <count> <speed>
        te = TempEntity('Bubble Trail',
                        model_index=Model(str(command[3])).index,
                        halo_index=Model(str(command[3])).index,
                        mins=vec,
                        maxs=vec2,
                        height=int(command[6]),
                        count=int(command[7]),
                        speed=int(command[8]))
        te.create(delay=float(command[2]))
示例#19
0
文件: effects.py 项目: herlak/WCS
def effect1(model, x, y, z, dx, dy, dz):
    """
    est_effect 1 <player filter> <delay> <model> (position <x> <y> <z>) (direction <x> <y> <z>)
    """
    if not isinstance(model, Model):
        model = Model(model)

    te = TempEntity('Armor Ricochet')
    te.position = Vector(x, y, z)
    te.direction = Vector(dx, dy, dz)

    return te
def box(recipients, start, end, **kwargs):
    """Create a box using the temporary effect ``BeamPoints``.

    :param RecipientFilter recipients:
        Players that should see the beam.
    :param Vector start:
        Upper left corner of the box.
    :param Vector end:
        Lower right corner of the box.
    :param kwargs:
        Additional attributes that will be send to the effect.
    """
    x1, y1, z1 = start
    x2, y2, z2 = end

    a = start
    b = Vector(x2, y1, z1)
    c = Vector(x2, y1, z2)
    d = Vector(x1, y1, z2)
    e = Vector(x1, y2, z1)
    f = Vector(x2, y2, z1)
    h = Vector(x1, y2, z2)
    g = end

    lines = (
        # First square
        (a, b),
        (b, c),
        (c, d),
        (d, a),

        # Second square
        (e, f),
        (f, g),
        (g, h),
        (h, e),

        # Connection between both squares
        (a, e),
        (b, f),
        (c, g),
        (d, h)
    )

    entity = TempEntity('BeamPoints')
    for attr, value in kwargs.items():
        setattr(entity, attr, value)

    for p1, p2 in lines:
        entity.start_point = p1
        entity.end_point = p2

        entity.create(recipients)
示例#21
0
def bullet_impact(event):
    """Called whenever a bullet hits something."""
    entity = TempEntity('World Decal')

    # Create the decal at the impact location
    entity.origin = Vector(*tuple(event.get_float(key) for key in 'xyz'))

    # Choose a random paintball material and precache it. It will return an
    # index.
    entity.decal_index = engine_server.precache_decal(random.choice(materials))

    entity.create()
示例#22
0
文件: effects.py 项目: herlak/WCS
def effect8(model, x, y, z, dx, dy, dz):
    """
    est_effect 8 <player filter> <delay> <model> <x> <y> <z> (towards <x> <y> <z>)
    """
    if not isinstance(model, Model):
        model = Model(model)

    te = TempEntity('Metal Sparks')
    te.position = Vector(x, y, z)
    te.direction = Vector(dx, dy, dz)

    return te
示例#23
0
文件: effects.py 项目: herlak/WCS
def effect9(model, x, y, z, dx, dy, dz, type_):
    """
    est_effect 9 <player filter> <delay> <model> <x> <y> <z> (towards <x> <y> <z>) <type>
    """
    if not isinstance(model, Model):
        model = Model(model)

    te = TempEntity('GaussExplosion')
    te.origin = Vector(x, y, z)
    te.direction = Vector(dx, dy, dz)
    te.type = type_

    return te
示例#24
0
文件: effects.py 项目: herlak/WCS
def effect128(position, player_index, entity_index):
    """
    est_effect_28 <player filter> <delay> <position x y z> <playerindex> <entity>
    """
    if not isinstance(position, Vector):
        position = Vector(*position)

    te = TempEntity('Player Decal')
    te.origin = position
    te.player_index = player_index
    te.entity_index = entity_index

    return te
示例#25
0
文件: effects.py 项目: herlak/WCS
def effect6(model, x, y, z, reversed_):
    """
    est_effect 6 <player filter> <delay> <model> <x> <y> <z> <reversed>
    """
    if not isinstance(model, Model):
        model = Model(model)

    te = TempEntity('Large Funnel')
    te.model = model
    te.origin = Vector(x, y, z)
    te.reversed = reversed_

    return te
示例#26
0
class AthenaSpear(Skill):
    model = Model("sprites/lgtning.vmt")

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.model._precache()
        self.effect = TempEntity('BeamRingPoint',
                                 model=self.model,
                                 start_radius=20,
                                 end_radius=500,
                                 life_time=3,
                                 start_width=100,
                                 end_width=100,
                                 spread=10,
                                 amplitude=0,
                                 red=255,
                                 green=105,
                                 blue=155,
                                 alpha=255,
                                 speed=50)

    @classproperty
    def description(cls):
        return 'Spear your enemy for 5-13 extra damage. 2-10% chance.'

    @classproperty
    def max_level(cls):
        return 4

    @property
    def chance(self):
        return 2 + (self.level * 2)

    @property
    def extra_damage(self):
        return 5 + (self.level * 2)

    _msg_a = '{{LIGHT_BLUE}}Athena\'s Spear {{PALE_GREEN}}dealt {{DULL_RED}}{damage} {{PALE_GREEN}}extra to {{RED}}{name}{{PALE_GREEN}}.'

    @events('player_pre_attack')
    def _on_player_pre_attack(self, attacker, victim, info, **kwargs):
        if victim.dead or randint(0, 101) > self.chance or self.level == 0:
            return

        damage = randint(5, self.extra_damage)
        info.damage += damage
        send_wcs_saytext_by_index(
            self._msg_a.format(damage=damage, name=victim.name),
            attacker.index)
        self.effect.create(center=victim.origin)
示例#27
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.cooldowns = CooldownDict()
     self.beam = TempEntity('BeamPoints',
                            alpha=255,
                            red=255,
                            green=200,
                            blue=200,
                            life_time=1.0,
                            start_width=15,
                            end_width=15,
                            frame_rate=255)
     self.laser = Model('sprites/lgtning.vmt')
     self.laser._precache()
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.beam = TempEntity('BeamRingPoint',
                            alpha=255,
                            red=255,
                            green=0,
                            blue=0,
                            life_time=1.0,
                            model_index=self.laser.index,
                            start_width=7,
                            end_width=7,
                            frame_rate=255,
                            halo_index=self.laser.index,
                            speed=1)
示例#29
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.max_health = self.parent.parent.health + 100
     self.beam = TempEntity('BeamPoints',
                            alpha=255,
                            red=255,
                            green=0,
                            blue=0,
                            life_time=1.0,
                            model_index=self.laser.index,
                            start_width=7,
                            end_width=7,
                            frame_rate=255,
                            halo_index=self.laser.index)
示例#30
0
def effect120(model,
              position,
              scale,
              frame_rate,
              flags,
              radius,
              magnitude,
              normal=None,
              material=None):
    """
    est_effect_20 <player filter> <delay> <model> <position x y z> <scale> <framerate> <flags> <radius> <magnitude> [normal x y z] [material type]
    """
    if not isinstance(position, Vector):
        position = Vector(*position)

    te = TempEntity('Explosion')
    te.position = position
    te.scale = scale
    te.frame_rate = frame_rate
    te.flags = flags
    te.radius = radius
    te.magnitude = magnitude

    if normal is not None:
        if not isinstance(normal, Vector):
            normal = Vector(*normal)

        te.normal = normal

    if material is not None:
        if isinstance(material, str):
            # /game/server/func_break.h
            # typedef enum { matGlass = 0, matWood, matMetal, matFlesh, matCinderBlock, matCeilingTile, matComputer, matUnbreakableGlass, matRocks, matWeb, matNone, matLastMaterial } Materials;
            material = {
                'glass': 0,
                'wood': 1,
                'metal': 2,
                'flesh': 3,
                'cinderblock': 4,
                'ceilingtile': 5,
                'computer': 6,
                'unbreakableglass': 7,
                'rocks': 8,
                'web': 9
            }.get(material.lower(), 0)

        te.material_type = material

    return te
示例#31
0
文件: effects.py 项目: herlak/WCS
def effect130(start, end):
    """
    est_effect_30 <player filter> <delay> <start x y z> <end x y z>
    """
    if not isinstance(start, Vector):
        start = Vector(*start)

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

    te = TempEntity('Show Line')
    te.start = start
    te.end = end

    return te
示例#32
0
文件: effects.py 项目: herlak/WCS
def effect135(decal, position):
    """
    est_effect_35 <player filter> <delay> <Decal> <Position x y z>
    """
    if not isinstance(decal, Decal):
        decal = Decal(decal)

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

    te = TempEntity('World Decal')
    te.decal = decal
    te.position = position

    return te
示例#33
0
文件: effects.py 项目: herlak/WCS
def effect125(position, direction):
    """
    est_effect_25 <player filter> <delay> <position x y z> <direction x y z>
    """
    if not isinstance(position, Vector):
        position = Vector(*position)

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

    te = TempEntity('Metal Sparks')
    te.position = position
    te.direction = direction

    return te
示例#34
0
文件: effects.py 项目: herlak/WCS
def effect109(model, points_length, points):
    """
    est_effect_09 <player filter> <delay> <model> <point count> <points x y z>
    """
    if not isinstance(model, Model):
        model = Model(model)

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

    te = TempEntity('BeamSpline')
    te.points_length = points_length
    te.points = points

    return te
示例#35
0
文件: effects.py 项目: herlak/WCS
def effect124(model, origin, reversed_):
    """
    est_effect_24 <player filter> <delay> <model> <position x y z> <reversed>
    """
    if not isinstance(model, Model):
        model = Model(model)

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

    te = TempEntity('Large Funnel')
    te.model = model
    te.origin = origin
    te.reversed = reversed_

    return te
示例#36
0
    def create_trail(self):
        """Create the beam trail for the given entity."""
        # Get the values for the beam color
        rgb = str(self.convars['beam_color'])

        # Use try/except to split the color values
        try:
            color = Color(*map(int, rgb.split(',')))

        # Otherwise, set the colors to a default value
        except ValueError:
            color = Color(127, 127, 127)

        # Create the beam effect
        entity = TempEntity('BeamFollow')
        entity.start_width = 6
        entity.end_width = 6
        entity.color = color
        entity.model = _model
        entity.halo = _model
        entity.entity_index = self.entity.index
        entity.life_time = 2
        self.create_temp_entity(entity)
    def listener_on_entity_spawned(self, base_entity):
        if base_entity.classname != 'flashbang_projectile':
            return

        index = base_entity.index
        entity = Entity(index)

        for player in self._players:
            if player.inthandle == entity.owner_handle:
                break
        else:
            return

        temp_entity = TempEntity('BeamFollow')
        temp_entity.entity_index = index
        temp_entity.model_index = BEAM_MODEL.index
        temp_entity.halo_index = BEAM_MODEL.index
        temp_entity.life_time = 1
        temp_entity.start_width = 3
        temp_entity.end_width = 3
        temp_entity.fade_length = 1
        temp_entity.red = 255
        temp_entity.green = 255
        temp_entity.blue = 255
        temp_entity.alpha = 150

        temp_entity.create(RecipientFilter())
def ball(recipients, center, radius, steps=15, upper_half=True, lower_half=True, **kwargs):
    """Create a ball by using the remporary effect ``BeamRingPoint``.

    :param RecipientFilter recipients:
        Players that should see the beam.
    :param Vector center:
        The center location of the ball.
    :param float radius:
        The radius of the ball.
    :param int steps:
        Number of rings that should be used to create the ball.
    :param bool upper_half:
        If False, the upper half of the ball isn't created.
    :param bool lower_half:
        If False, the lower half of the ball isn't created.

    .. note::

        The number of steps is used for the lower and upper half. So, if you
        define 15 steps, 29 rings are created (the center ring is shared by
        both halves).
    """
    # Make sure that at least one argument is True
    assert not (upper_half == lower_half == False)

    entity = TempEntity('BeamRingPoint')
    for attr, value in kwargs.items():
        setattr(entity, attr, value)

    step = float(radius) / steps
    for x in range(steps):
        dist = step * x
        org = Vector(*center)
        org.z += dist
        rad = 2 * radius * (1 - (float(x) / steps) ** 2) ** 0.5

        if upper_half:
            entity.center = org
            entity.start_radius = rad
            entity.end_radius = rad - 0.1

            entity.create(recipients)

        if x and lower_half:
            org.z -= 2 * dist
            entity.center = org
            entity.start_radius = rad
            entity.end_radius = rad - 0.1

            entity.create(recipients)
def beam(recipients, start, end, parent=False, **kwargs):
    """A simple wrapper for the temporary effect ``BeamEntPoint``.

    :param RecipientFilter recipients:
        Players that should see the beam.
    :param int/BaseEntity/Vector start:
        The start location of the beam.
    :param int/BaseEntity/Vector end:
        The end location of the beam.
    :param bool parent:
        If True, the beam will be parented to the given entities.
    :param kwargs:
        Additional attributes that will be send to the effect.
    """
    _entity = kwargs.pop('_entity', None)
    if _entity is None:
        entity = TempEntity('BeamEntPoint')
        for attr, value in kwargs.items():
            setattr(entity, attr, value)
    else:
        entity = _entity

    def get_vec(value):
        if isinstance(value, int):
            return Entity(value).origin
        elif isinstance(value, BaseEntity):
            return Entity(value.index).origin
        else:
            return value

    if parent:
        if isinstance(start, int):
            entity.start_entity_index = start
        elif isinstance(start, BaseEntity):
            entity.start_entity_index = start.index
        else:
            entity.start_point = start
    else:
        entity.start_point = get_vec(start)

    if parent:
        if isinstance(end, int):
            entity.end_entity_index = end
        elif isinstance(end, BaseEntity):
            entity.end_entity_index = end.index
        else:
            entity.end_point = end
    else:
        entity.end_point = get_vec(end)

    for attr, value in kwargs.items():
        setattr(entity, attr, value)

    entity.create(recipients)
示例#40
0
def _create_beam(start, end, color):
    """Create the beam from the player/weapon's origin to the victim's."""
    width = int(beam_width)
    entity = TempEntity('BeamPoints')
    entity.start_point = start
    entity.start_width = width
    entity.end_point = end
    entity.end_width = width
    entity.color = color
    entity.life_time = int(beam_time)
    entity.model = _model
    entity.halo = _model
    entity.create()
示例#41
0
 def update_trail(self):
     """Create the smoke trail for the given entity."""
     entity = TempEntity('Dust')
     entity.origin = self.entity.origin
     entity.size = 20
     self.create_temp_entity(entity)