SetActorProperty: Difference between revisions

From ZDoom Wiki
Jump to navigation Jump to search
(Added APROP_Friendly)
Line 27: Line 27:
| <tt>APROP_JumpZ</tt> || Player's jump speed
| <tt>APROP_JumpZ</tt> || Player's jump speed
|- style="background-color: #eee"
|- style="background-color: #eee"
| <tt>APROP_Friendly</tt> || Actor is friendly to the player and hostile to enemies.
| <tt>APROP_Friendly</tt> || Actor is friendly to the player and hostile to enemies. {{svn}}
|- style="background-color: #ddd"
|- style="background-color: #ddd"
| <tt>APROP_SeeSound</tt> || Sound played when actor sees the player (defined in SNDINFO)
| <tt>APROP_SeeSound</tt> || Sound played when actor sees the player (defined in SNDINFO)

Revision as of 15:42, 9 August 2007

Prototype

void SetActorProperty(int tid, int property, int value);

Description

Sets a property (listed below) of the actor(s) with the specified tid to value.

Actor Properties

APROP_Health Actor's current health
APROP_Speed Actor's speed

For monsters, this is the distance they move every time A_Chase is called. For projectiles, this is the distance they move each tic. For players, this is multiplied by the player's class speed to determine the final speed the player will move for each tic that they have a movement key held down. Consequently, the standard APROP_Speed for a player is always 1.0, no what their actual speed is.

APROP_Damage Actor's missile damage
APROP_Alpha Alpha value for STYLE_Translucent. Range is [0.0, 1.0]
APROP_RenderStyle How the actor is rendered (listed below)
APROP_Ambush Whether actor is "deaf" or not
APROP_Invulnerable Actor will not lose any health
APROP_JumpZ Player's jump speed
APROP_Friendly Actor is friendly to the player and hostile to enemies. (development version only)
APROP_SeeSound Sound played when actor sees the player (defined in SNDINFO)
APROP_AttackSound Sound played when the actor attacks(defined in SNDINFO)
APROP_PainSound Sound played when the actor is injured(defined in SNDINFO)
APROP_DeathSound Sound played when the actor dies(defined in SNDINFO)
APROP_ActiveSound Sound played when the actor is walking around(defined in SNDINFO)

Render Styles

STYLE_None 0 Do not draw
STYLE_Normal 1 Normal; just copy the image to the screen
STYLE_Fuzzy 2 Draw silhouette using "fuzz" effect
STYLE_SoulTrans 3 Draw translucent with amount in r_transsouls
STYLE_OptFuzzy 4 Draw as fuzzy or translucent, based on user preference
STYLE_Translucent 64 Draw translucent
STYLE_Add 65 Draw additive

Examples

script 1 (void)
{
   //makes things with tid 13 fuzzy, have 1000 health, the 
   //boss brain death sound and doubles their current speed
   //(try it, it's fun! ;) )
   SetActorProperty(13, APROP_RenderStyle, STYLE_Fuzzy);
   SetActorProperty(13, APROP_Health, 1000);
   SetActorProperty(13, APROP_DeathSound, "brain/death");
   SetActorProperty(13, APROP_Speed, (GetActorProperty(13, APROP_Speed) * 2));
}

Player speed

Setting the player's speed is an operation that seems to frequently be done incorrectly. As an example, consider an enter script that gives the player 75% of normal speed:

The wrong way
script 1 enter
{
   SetActorProperty(0, APROP_Speed, (GetActorProperty(0, APROP_Speed) * 3 / 4));
}

The problem with this script is that it alters the player's previous speed. If this script is used on multiple maps in a hub or even just a single map that gets revisited in a hub, players will find themselves going slower and slower as they switch maps in the hub. There is a much simpler way to do this, knowing that a player's normal speed is always 1.0:

The right way
script 1 enter
{
   SetActorProperty(0, APROP_Speed, 0.75);
}