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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 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)
Ejemplo n.º 4
0
def effect107(model, start_point, end_point, frame_rate, life_time, width,
              fade_length, amplitude, red, green, blue, alpha, speed):
    """
    est_effect_07 <player filter> <delay> <model> <start entity> <end entity> <framerate> <life> <width> <spread> <amplitude> <red> <green> <blue> <alpha> <speed>
    """
    if not isinstance(model, Model):
        model = Model(model)

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

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

    te = TempEntity('BeamPoints')
    te.model = model
    te.halo = model
    te.start_point = start_point
    te.end_point = end_point
    te.frame_rate = frame_rate
    te.life_time = life_time
    te.start_width = width
    te.end_width = width
    te.fade_length = fade_length
    te.amplitude = amplitude
    te.red = red
    te.green = green
    te.blue = blue
    te.alpha = alpha
    te.speed = speed

    return te
Ejemplo n.º 5
0
def effect102(model, start_entity_index, start_point, end_entity_index,
              end_point, frame_rate, life_time, start_width, end_width,
              fade_length, amplitude, red, green, blue, alpha, speed):
    """
    est_effect_02 <player filter> <delay> <model> <start entity> <start position x y z> <end entity> <end position x y z> <framerate> <life> <start width> <end width> <fade distance> <amplitude> <red> <green> <blue> <alpha> <speed>
    """
    if not isinstance(model, Model):
        model = get_model_instance(model)

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

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

    te = TempEntity('BeamEntPoint')
    te.model = model
    te.halo = model
    te.start_entity_index = start_entity_index
    te.start_point = start_point
    te.end_entity_index = end_entity_index
    te.end_point = end_point
    te.frame_rate = frame_rate
    te.life_time = life_time
    te.start_width = start_width
    te.end_width = end_width
    te.fade_length = fade_length
    te.amplitude = amplitude
    te.red = red
    te.green = green
    te.blue = blue
    te.alpha = alpha
    te.speed = speed

    return te
Ejemplo n.º 6
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 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)
Ejemplo n.º 8
0
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)
Ejemplo n.º 9
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()
Ejemplo n.º 10
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()
Ejemplo n.º 11
0
def effect3(model, x1, y1, z1, x2, y2, z2, life_time, start_width, end_width,
            red, green, blue, alpha):
    """
    est_effect 3 <player filter> <delay> <model> (start <x> <y> <z>) (end <x> <y> <z>) <life> <width> <end width> <red> <green> <blue> <alpha>
    """
    if not isinstance(model, Model):
        model = Model(model)

    te = TempEntity('BeamPoints')
    te.model = model
    te.halo = model
    te.start_point = Vector(x1, y1, z1)
    te.end_point = Vector(x2, y2, z2)
    te.life_time = life_time
    te.start_width = start_width
    te.end_width = end_width
    te.red = red
    te.green = green
    te.blue = blue
    te.alpha = alpha

    return te
Ejemplo n.º 12
0
def _est_effect(command):
    todo = str(command[1])
    filter = str(command[2])
    delay = float(command[3])
    if todo == "1":
        te = TempEntity('Armor Ricochet')
        te.position = Vector(float(command[4]), float(command[5]),
                             float(command[6]))
        te.direction = Vector(float(command[7]), float(command[8]),
                              float(command[9]))
        te.create()
    if todo == "2":
        te = TempEntity('BeamEntPoint')
        te.alpha = int(command[13])
        te.blue = int(command[12])
        te.green = int(command[11])
        te.end_width = float(command[9])
        te.life_time = float(command[7])
        te.start_width = float(command[8])
        te.end_entity_index = Player.from_userid(int(command[6])).index
        te.halo_index = Model(str(command[4])).index
        te.model_index = Model(str(command[4])).index
        te.start_entity_index = Player.from_userid(int(command[5])).index
        te.red = int(command[11])
        te.create()
    if todo == "3":
        te = TempEntity('BeamPoints')
        model = Model(str(command[4]))
        x1 = float(command[5])
        y1 = float(command[6])
        z1 = float(command[7])
        x2 = float(command[8])
        y2 = float(command[9])
        z2 = float(command[10])
        life = float(command[11])
        width = int(command[12])
        end_width = int(command[13])
        red = int(command[14])
        green = int(command[15])
        blue = int(command[16])
        alpha = int(command[17])
        te.alpha = alpha
        te.green = green
        te.blue = blue
        te.red = red
        te.end_width = end_width
        te.life_time = life
        te.start_width = width
        te.halo_index = model.index
        te.model_index = model.index
        te.end_point = Vector(x1, y1, z1)
        te.start_point = Vector(x2, y2, z2)
        te.create()
    if todo == "4":
        te = TempEntity('BeamFollow')
        te.alpha = int(command[13])
        te.blue = int(command[12])
        te.green = int(command[11])
        te.end_width = int(command[8])
        te.life_time = float(command[6])
        te.start_width = int(command[7])
        te.entity_index = Player.from_userid(int(command[5])).index
        te.fade_length = int(command[9])
        te.halo_index = Model(str(command[4])).index
        te.model_index = Model(str(command[4])).index
        te.red = int(command[10])
        te.create()
    if todo == "5":
        te = TempEntity('BeamRing')
        te.alpha = int(command[14])
        te.blue = int(command[13])
        te.green = int(command[12])
        te.amplitude = float(command[10])
        te.end_width = int(command[8])
        te.life_time = float(command[7])
        te.start_width = int(command[8])
        te.end_entity_index = int(command[6])
        te.halo_index = Model(str(command[4])).index
        te.model_index = Model(str(command[4])).index
        te.speed = int(command[15])
        te.start_entity_index = Player.from_userid(int(command[5])).index
        te.red = int(command[11])
    #est_effect [BeamRing] <player Filter> <delay> <model> <userid> <end index> <life> <width> <spread> <amplitude> <Red> <Green> <Blue> <Alpha> <speed>
    if todo == "6":
        te = TempEntity('Large Funnel')
        te.model_index = Model(str(command[4])).index
        te.reversed = int(command[8])
        te.origin = Vector(float(command[5]), float(command[6]),
                           float(command[7]))
        te.create()
        #est_effect [LargeFunnel] <player Filter> <delay> <model> <x> <y> <z> <reversed>
    if todo == "7":
        te = TempEntity('Smoke')
        te.scale = float(command[8])
        te.frame_rate = int(command[9])
        te.model_index = Model(str(command[4])).index
        te.model = Model(str(command[4]))
        te.origin = Vector(float(command[5]), float(command[6]),
                           float(command[7]))
        te.create()
    if todo == "8":
        te = TempEntity('Metal Sparks')
        te.direction = Vector(float(command[8]), float(command[9]),
                              float(command[10]))
        te.position = Vector(float(command[5]), float(command[6]),
                             float(command[7]))
        te.create()
        #est_effect [MetalSparks] <player Filter> <delay> <model> <x> <y> <z> (towards <x> <y> <z>) +
    if todo == "9":
        te = TempEntity('GaussExplosion')
        te.type = int(command[11])
        te.direction = Vector(float(command[8]), float(command[9]),
                              float(command[10]))
        te.origin = Vector(float(command[5]), float(command[6]),
                           float(command[7]))
        te.create()
        #est_effect [GaussExplosion] <player Filter> <delay> <model> <x> <y> <z> (towards <x> <y> <z>) <type>
    if todo == "10":
        te = TempEntity('BeamRingPoint')
        te.alpha = int(command[17])
        te.blue = int(command[16])
        te.green = int(command[15])
        te.amplitude = float(command[13])
        te.end_width = float(command[11])
        te.life_time = float(command[10])
        te.start_width = float(command[11])
        te.end_radius = float(command[9])
        te.start_radius = float(command[8])
        te.fade_length = int(command[12])
        te.halo_index = Model(str(command[4])).index
        te.model_index = Model(str(command[4])).index
        te.speed = int(command[18])
        te.center = Vector(float(command[5]), float(command[6]),
                           float(command[7]))
        te.red = int(command[14])
        te.create()
    if todo == "11":
        te = TempEntity('GlowSprite')
        te.life_time = float(command[8])
        te.scale = float(command[9])
        te.brightness = int(command[10])
        te.model_index = Model(str(command[4])).index
        te.origin = Vector(float(command[5]), float(command[6]),
                           float(command[7]))
        te.create()