env_sprite

Modified

12-Jul-2023

The env_sprite entity allows you to render sprites, which are common 2D-graphics which will appear aligned to face you at all times, unless specified otherwise.

Keyvalues


OnDestroy Function ondestroyfn : Name of the function to use from already parsed .as script files when entity is destroyed (killed) in any way. If the function belongs to namespace, you must use prefix with the namespace name (e.g. mynamespace::MyFunction) for the keyvalue.

Name targetname : Set name of env_sprite so other entities can trigger it to enable or disable sprite. Depending on trigger use-type: 'On'- show sprite, 'Off'- hide sprite, 'Toggle'- toggle sprite. Can be kill-targeted.

Render FX renderfx : Set custom render FX effect. Only works when "Render Mode" is set to different than 'Normal'

  • 0 : Normal : Default rendering.
  • 1 : Slow Pulse : Transparency slow fading in and out in a loop.
  • 2 : Fast Pulse : Transparency fast fading in and out in a loop.
  • 3 : Slow Wide Pulse : Transparency slow fading in and out widely in a loop.
  • 4 : Fast Wide Pulse : Transparency fast fading in and out widely in a loop.
  • 9 : Slow Strobe : Regular slow appearing/dissapearing.
  • 10 : Fast Strobe : Regular fast appearing/dissapearing.
  • 11 : Faster Strobe : Regular very fast appearing/dissapearing.
  • 12 : Slow Flicker : Random slow appearing/dissapearing.
  • 13 : Fast Flicker : Random fast appearing/dissapearing.
  • 5 : Slow Fade Away : Not working. Fading out slowly until reaching invisibility. Works once when entity spawns or have changed it's "Render FX" at a runtime (e.g. through env_render). Requires high "FX Amount"
  • 6 : Fast Fade Away : Not working. Fading out quickly until reaching invisibility. Works once when entity spawns or have changed it's "Render FX" at a runtime (e.g. through env_render). Requires high "FX Amount"
  • 7 : Slow Become Solid : Not working. Fading in slowly from invisible to fully visible. Works once when entity spawns or have changed it's "Render FX" at a runtime (e.g. through env_render). Requires low or zero "FX Amount"
  • 8 : Fast Become Solid : Not working. Fading in quickly from invisible to fully visible. Works once when entity spawns or have changed it's "Render FX" at a runtime (e.g. through env_render). Requires low or zero "FX Amount"
  • 14 : Constant Glow : Sprites with 'Glow' render mode only. Disables sprite resizing.
  • 15 : Distort : Random distortion, looped.
  • 16 : Hologram (Distort + fade) : 'Random distortion' + 'Pulse' applied, looped.
  • 17 : Dead Player (DONT USE!)
  • 18 : Explode (Garg Like)
  • 19 : Glow Shell : Applies nice animated glowing shell on model. Color can be applied. "FX Amount" manipulates glow shell size.
  • 20 : ClampMinScale (Sprites)

Render Mode rendermode : Render mode determines how this entity is rendered.

  • 0 : Normal : Normal rendering. Entity will receive light, except if it is a sprite. "FX Amount" is obsolete when this is used.
  • 1 : Color : Brush entities only: Instead of rendering the texture, the whole entity will appear in one color, set by "FX Color". "FX Amount" sets the transparency. 0 means invisible. 255 means fully opaque.
  • 2 : Texture : Texture-only rendering. Entity will not receive light. Instead, only the texture will be rendered as is. "FX Amount" sets the transparency. 0 means invisible. 255 means fully opaque. This is used for transparent things such as windows. Tip: If you have a window separating a dark and a bright room using only one entity, you can apply a brighter glass texture to the side of the window seen from within the dark room than to the side seen from the bright room. That way, the window's brightness will look realistic from both sides, instead of from just one. Generally, darker rooms require the render amount to be lower, making the glass more transparent, or it would look illogically bright.
  • 3 : Glow : Sprites only. The sprite will appear in the same size regardless of your distance to it. In addition to that, the further away you are from it, the less visible it will be. (It's only barely visible at about 500 units far away) Good for light coronas. This renders the sprite in additive mode.
  • 4 : Solid : Brush entities only. All textures of the brush entity starting with '{' will have the last color of their palette (usually blue, black or purple) be rendered fully transparent. This is used for textures with see-through parts, such as grates and railings. Requires "FX Amount" to be set to a value greater than 0, commonly 255.
  • 5 : Additive : Works just as the "Render Mode" 'Texture', except that the entity's appearance will be added to the background instead of forming a mean. This means, black pixels of textures will be fully transparent, while full-bright pixels are added with a factor of "FX Amount" divided by 255. This is often used for sprites indicating a glowing light, as well as for overlay func_illusionaries to give a computer texture the appearance of having many small, glowing lights, screens and whatever other elements. Render-amount of 255 makes it bright. 0 makes it invisible.

FX Amount (1 - 255) renderamt : Render amount to use when other than "Render Mode" 'Normal' is used.

FX Color (R G B) rendercolor : Used with "Render Mode" 'Color' and 'Glow' to set color. Also sets color of 'Glow Shell' "Render Mode".

Pitch Yaw Roll (X Y Z) angles : Where Z means Y and Y means Z, that is, when you're thinking Hammer-grid. (Hammer uses Z for height and Y for depth, while every other sane 3D-application does this the other way round; nonetheless this keyvalue description has the letters in the conventional order) This, technically, is a 3D-vector containing Euler-angles to describe either the entity's rotation or direction of effect. E.g. a func_door_rotating will use this as its initial rotation, while a trigger_push will keep its original alignment and use this for the direction of its push-effect instead. Euler-angles are a hierarchical system to determine an object's orientation in 3D-space. A yaw-value of 0 would mean the entity would face east. (right in top-down view) 90 would mean it would face north. (up in top-down-view) After yaw, pitch is applied. Think aiming up/down with your character in first person. At last, the roll-value is applied. Think your character falling over sideways in first person. Some entities, mostly point entities, do not use the angles keyvalue for any purpose.

Framerate framerate : Sprite framerate.

Sprite Name model : Set a sprite to be displayed. Path start in modification's folder.

Scale scale : Set the scale of the sprite effect. This defaults to 0.25 if not set.

Draw Type / Orientation vp_type : Feature that allows to override view port of the sprite.

  • 0 : Default : Default setting.
  • 3 : Parallel : Parallel: Always face the player.
  • 1 : Parallel Upright : Parallel Upright: Sprites rotates around vertical axis to always face player, but it's fixed to this axis.
  • 5 : Parallel Orientated : Parallel Orientated: Rotate sprite to env_sprite angles.
  • 2 : Facing Upright : Facing Upright: Not supported/unused.
  • 4 : Orientated : Orientated: Sprite is oriented to the worlds, uses it's angles and it's not rotating.

Flags


  • 1 : Start on : Causes the env_sprite effect to be visible from map-load onwards. Useful when the env_sprite has a targetname. Makes little to no sense in combination with "Play Once".

  • 2 : Play Once : If set, the sprite animation won't loop and end after cycling through all of its frames once. If the sprite is not animated, only the first frame will show for a moment.

  • 4 : Once + Remove : If set along with "Play once", causes the env_sprite entity to be removed from the game after having played. Useful for saving some entities.

  • 2048 : Not in Deathmatch : Obsolete in Sven Co-op. Makes the entity don't appear in Multiplayer Games.

To make sprite work properly use "Render Mode" with optional "FX Amount". Most sprites can make use of 'Glow' or 'Additive' render modes (most sprites are in 'additive' format), however sprites with 'alphatest' works best with 'Texture' mode (background gets removed, image is opaque), while 'indexalpha' sprites are rendered properly only in 'Solid' and 'Texture', in any other mode they appearance is invalid. You can use third party tools like Sprite Explorer to check format of sprite if you are not sure, or check this Sprite List to check format type each sprite.

Sprite alignment can also be set through the sprite itself. To do this, edit byte at offset 8 (meaning the 9th byte) in the sprite file using a HEX editor: 00: Sprite fixed on vertical axis- SPR_VP_PARALLEL_UPRIGHT; 01: Not supported- SPR_FACING_UPRIGHT; 02: Normal behaviour, sprite always faces you- SPR_VP_PARALLEL; 03: Sprite is fixed in space and can be rotated using angles- SPR_ORIENTED; 04: As SPR_VP_PARALLEL, but sprite can be rotated relatively to perspective using angles- SPR_VP_PARALLEL_ORIENTED.

Oriented mode sprites tend to have problems with angle co-ordinates in hammer so its best to set them manually starting from [180,180,180] instead of [0,0,0]. In addition don't use negative numbers; instead subtract from 360. Also use 360 instead of 0 and carefully watch the use of hammer transforms as it will likely give you numbers that might look fine in hammer but will not work in-game. If you are still having troubles with angles not appearing in map I have an example RMF included in the example file download at the bottom (called "oriented_angles.rmf"). Taken from: http://www.the303.org/tutorials/gold_sprite.htm.

There is no key as of yet to set the initial frame of the env_sprite for it to draw. This must be done manually by changing the env_sprite's "frame" key via trigger_changevalue.