Trait Conditions

Paul Chote edited this page Mar 4, 2017 · 3 revisions
Clone this wiki locally

This documentation is a work in progress. If you think you can improve it, then please do!

Trait conditions were first implemented in playtest-20170303 as a replacement for the older Actor-Upgrades system. It provides a way for certain traits to activate or deactivate other traits in order to build more complicated actor behaviours.

If a trait accepts the RequiresCondition field (see Trait Documentation) then it can be enabled or disabled using a condition expression. The simplest condition expressions are boolean equations that combine condition variables with && (and) or || or.

An example of this is the Thumper infantry in Dune 2000, which includes the following trait YAML:

		DeployedCondition: deployed
		Facing: 128
		AllowedTerrainTypes: Sand, Spice, Dune, SpiceSand
		Speed: 43
		RequiresCondition: !deployed
		RequiresCondition: !deployed
		Sequence: thump
		RequiresCondition: deployed
		Sequence: thump-sand
		RequiresCondition: deployed
		SoundFile: THUMPER1.WAV
		Interval: 60
		RequiresCondition: deployed
		Intensity: 1000
		Falloff: 0, 0, 0, 100, 100, 100, 25, 11, 6, 4, 3, 2, 1, 0
		RequiresCondition: deployed

The GrantConditionOnDeploy trait grants a condition named deployed when the player clicks or uses a hotkey to deploy the actor. This condition is then used to disable Mobile (to stop the actor from moving), WithInfantryBody, WithSpriteBody, and WithIdleOverlay to switch the normal infantry artwork with the stationary thumping artwork, AmbientSound to enable the "thumping" sound, and finally AttractsWorms to attract worms to the area.

Conditions can also be accepted from external sources (e.g. map scripts, warheads, or other actors) by adding an ExternalCondition on the consuming actor. An example of this is the Iron Curtain in Red Alert:

The ^IronCurtainable default is inherited by actors that can the Iron Curtain can be applied to, and defines:

		RequiresCondition: invulnerability
		RequiresCondition: invulnerability
		Modifier: 0
		Condition: invulnerability
		Condition: invulnerability

The ExternalCondition trait makes the actor accept the invulnerability condition which can then be consumed by the other traits that enable the expected iron curtain effects.

The condition is granted by the GrantExternalConditionPower trait on the IRON actor:

		Icon: invuln
		ChargeTime: 120
		Description: Invulnerability
		LongDesc: Makes a group of units invulnerable\nfor 20 seconds.
		Duration: 500
		SelectTargetSpeechNotification: SelectTarget
		InsufficientPowerSpeechNotification: InsufficientPower
		BeginChargeSpeechNotification: IronCurtainCharging
		EndChargeSpeechNotification: IronCurtainReady
		DisplayRadarPing: True
		Condition: invulnerability
		OnFireSound: ironcur9.aud

TODO: Explain condition levels and other more complicated uses