Creating interactive decorations
Jump to navigation
Jump to search
Actors can be made into decorations — not only non-interactive ones, but also interactive ones.
This is an example of a decoration that reacts to attacks and uses actions:
class Pulsar : Actor
{
Default
{
Height 40;
Radius 20;
+SHOOTABLE // Will react to being hit by attacks
Painchance 255; // Will always enter its Pain state sequence when damaged
PainSound "pulsar/pulse"; // Sound made when A_Pain is called
+NODAMAGE // Will not actually take any damage from being attacked but will still react
+NODAMAGETHRUST // Cannot be moved by damage
+BRIGHT // All sprites of this actor are drawn fullbright
}
States
{
Spawn:
HAX7 A -1; // This actor is not animated and shows only one sprite in its Spawn sequence
stop;
Pain:
HAX7 A 15;
HAX7 B 15 A_Pain;
HAX7 C 20 A_Explode(flags:XF_NOTMISSILE); // Will deal radius damage, like the Rocket
goto Spawn;
}
}
If you want to create a decoration that you can interact with directly, by pressing Use next to it, you can override the actor's Used virtual function:
For example, this odd varation of the explosive barrel explodes immediately when the player uses it:
class OddBarrel : ExplosiveBarrel { override bool Used (Actor user) { if (user && user.player) { A_Die(); return true; } return false; } }
For more examples and explanation, see the Used() function page.