User:Cvoxalury/Readiness

From Valve Developer Community
Jump to: navigation, search

Overview

Readiness is an AI system in the Half-Life 2 Half-Life 2 series available to the Player Companion class (CNPC_PlayerCompanion) and its inheritors (namely, npc_citizen, npc_alyx, npc_barney).

The purpose of readiness is to modify the activities, sequences, and facets of behavior of a particular NPC depending on their readiness level. In practice, it is used to make characters look and act more alert, scared, anxious and so on, without the overhead of needing scripted_sequences or other AI management entities.

Readiness levels

The levels are:

enum AIReadiness_t
{
	AIRL_PANIC = -2,
	AIRL_STEALTH = -1,
	AIRL_RELAXED = 0,
	AIRL_STIMULATED,
	AIRL_AGITATED,
};

AIRL_RELAXED, AIRL_STIMULATED AIRL_AGITATED were the original 3 levels available in Half-Life 2. Half-Life 2: Episode One Half-Life 2: Episode One expanded it by adding "panic" and "stealth".

Activity remapping

The activities are remapped based on 🖿/scripts/actremap.txt


Full contents of Ep1's actremap.txt 
//"ACT_IDLE" - This is the name of the original activity
//{
//	"remapactivity" "ACT_IDLE_RELAXED" - This is the name of the activy we're going to remap to.
//	"readiness"	"AIRL_STIMULATED" - This is the value of the readiness level
//	"aiming"	"TRS_FALSE" - Does this activity aim a weapon
//}

// "extra"
// Use extra to add extra information that is specific to certain classes.
// For example, citizens use readiness and aiming so they specify the values there.
// Valid readiness level names:
//	AIRL_PANIC
//	AIRL_STEALTH
//	AIRL_RELAXED
//	AIRL_STIMULATED
//	AIRL_AGITATED

// Valid aiming values names:
// 	TRS_FALSE - This animation doesn't aim
//	TRS_TRUE - This animation needs to aim
//	TRS_NONE - Don't care

"npc_playercompanion"
{
	//ACT_IDLE
	"ACT_IDLE"
	{
		"remapactivity" "ACT_IDLE_RELAXED"
		
		"extra"
		{
			"readiness"	"AIRL_RELAXED"
			"aiming"	"TRS_NONE"
			"weaponrequired" "TRUE"
		}

	}
	"ACT_IDLE"
	{
		"remapactivity" "ACT_IDLE_STIMULATED"
		
		"extra"
		{
			"readiness"	"AIRL_STIMULATED"
			"aiming"	"TRS_FALSE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_IDLE"
	{
		"remapactivity" "ACT_IDLE_AIM_STIMULATED"
	
		"extra"
		{
			"readiness"	"AIRL_STIMULATED"
			"aiming"	"TRS_TRUE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_IDLE"
	{
		"remapactivity" "ACT_IDLE_AGITATED"
	
		"extra"
		{
			"readiness"	"AIRL_AGITATED"
			"aiming"	"TRS_NONE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_IDLE"
	{
		"remapactivity" "ACT_IDLE_STEALTH"
	
		"extra"
		{
			"readiness"	"AIRL_STEALTH"
			"aiming"	"TRS_NONE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_IDLE"
	{
		"remapactivity" "ACT_CROUCH_PANICKED"
	
		"extra"
		{
			"readiness"	"AIRL_PANIC"
			"aiming"	"TRS_NONE"
			"weaponrequired" "FALSE"
		}
	}


	//ACT_IDLE_ANGRY
	"ACT_IDLE_ANGRY"
	{
		"remapactivity" "ACT_IDLE_RELAXED"
	
		"extra"
		{
			"readiness"	"AIRL_RELAXED"
			"aiming"	"TRS_NONE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_IDLE_ANGRY"
	{
		"remapactivity" "ACT_IDLE_STIMULATED"
		
		"extra"
		{
			"readiness"	"AIRL_STIMULATED"
			"aiming"	"TRS_FALSE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_IDLE_ANGRY"
	{
		"remapactivity" "ACT_IDLE_AIM_STIMULATED"
	
		"extra"
		{
			"readiness"	"AIRL_STIMULATED"
			"aiming"	"TRS_TRUE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_IDLE_ANGRY"
	{
		"remapactivity" "ACT_IDLE_AGITATED"
	
		"extra"
		{
			"readiness"	"AIRL_AGITATED"
			"aiming"	"TRS_NONE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_IDLE_ANGRY"
	{
		"remapactivity" "ACT_IDLE_STEALTH"
	
		"extra"
		{
			"readiness"	"AIRL_STEALTH"
			"aiming"	"TRS_NONE"
			"weaponrequired" "TRUE"
		}
	}

	//ACT_CROUCHIDLE
	"ACT_CROUCHIDLE"
	{
		"remapactivity" "ACT_CROUCHIDLE_STIMULATED"
		
		"extra"
		{
			"readiness"	"AIRL_RELAXED"
			"aiming"	"TRS_FALSE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_CROUCHIDLE"
	{
		"remapactivity" "ACT_CROUCHIDLE_STIMULATED"
		
		"extra"
		{
			"readiness"	"AIRL_STIMULATED"
			"aiming"	"TRS_FALSE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_CROUCHIDLE"
	{
		"remapactivity" "ACT_CROUCHIDLE_AIM_STIMULATED"
	
		"extra"
		{
			"readiness"	"AIRL_STIMULATED"
			"aiming"	"TRS_TRUE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_CROUCHIDLE"
	{
		"remapactivity" "ACT_CROUCHIDLE_AGITATED"
	
		"extra"
		{
			"readiness"	"AIRL_AGITATED"
			"aiming"	"TRS_NONE"
			"weaponrequired" "TRUE"
		}
	}

	//ACT_WALK
	"ACT_WALK"
	{
		"remapactivity" "ACT_WALK_RELAXED"
		
		"extra"
		{
			"readiness"	"AIRL_RELAXED"
			"aiming"	"TRS_NONE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_WALK"
	{
		"remapactivity" "ACT_WALK_STIMULATED"
		
		"extra"
		{
			"readiness"	"AIRL_STIMULATED"
			"aiming"	"TRS_FALSE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_WALK"
	{
		"remapactivity" "ACT_WALK_AIM_STIMULATED"
		
		"extra"
		{
			"readiness"	"AIRL_STIMULATED"
			"aiming"	"TRS_TRUE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_WALK"
	{
		"remapactivity" "ACT_WALK_AGITATED"
		
		"extra"
		{
			"readiness"	"AIRL_AGITATED"
			"aiming"	"TRS_FALSE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_WALK"
	{
		"remapactivity" "ACT_WALK_STEALTH"
		
		"extra"
		{
			"readiness"	"AIRL_STEALTH"
			"aiming"	"TRS_FALSE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_WALK"
	{
		"remapactivity" "ACT_WALK_AIM_STEALTH"
		
		"extra"
		{
			"readiness"	"AIRL_STEALTH"
			"aiming"	"TRS_TRUE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_WALK"
	{
		"remapactivity" "ACT_WALK_PANICKED"
		
		"extra"
		{
			"readiness"	"AIRL_PANIC"
			"aiming"	"TRS_NONE"
			"weaponrequired" "FALSE"
		}
	}


	//ACT_RUN
	"ACT_RUN"
	{
		"remapactivity" "ACT_RUN_RELAXED"
		
		"extra"
		{
			"readiness"	"AIRL_RELAXED"
			"aiming"	"TRS_NONE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_RUN"
	{
		"remapactivity" "ACT_RUN_STIMULATED"
		
		"extra"
		{
			"readiness"	"AIRL_STIMULATED"
			"aiming"	"TRS_FALSE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_RUN"
	{
		"remapactivity" "ACT_RUN_AIM_STIMULATED"
		
		"extra"
		{
			"readiness"	"AIRL_STIMULATED"
			"aiming"	"TRS_TRUE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_RUN"
	{
		"remapactivity" "ACT_RUN_AGITATED"
		
		"extra"
		{
			"readiness"	"AIRL_AGITATED"
			"aiming"	"TRS_FALSE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_RUN"
	{
		"remapactivity" "ACT_RUN_STEALTH"
		
		"extra"
		{
			"readiness"	"AIRL_STEALTH"
			"aiming"	"TRS_FALSE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_RUN"
	{
		"remapactivity" "ACT_RUN_AIM_STEALTH"
		
		"extra"
		{
			"readiness"	"AIRL_STEALTH"
			"aiming"	"TRS_TRUE"
			"weaponrequired" "TRUE"
		}
	}
	"ACT_RUN"
	{
		"remapactivity" "ACT_RUN_PANICKED"
		
		"extra"
		{
			"readiness"	"AIRL_PANIC"
			"aiming"	"TRS_NONE"
			"weaponrequired" "FALSE"
		}
	}
}

In code

Effects on AI behavior

Using in maps

I/O

Considerations