ChangeSkill

From ZDoom Wiki

Jump to: navigation, search
ChangeSkill (skill)
Skill: The skill that the game will be changed to >
       0 - Very Easy
       1 - Easy
       2 - Normal
       3 - Hard
       4 - Nightmare!

Usage

Changes the current skill of the game. The skill change will take affect at the next map change. Instead of numbers (0 - 4), you can also use the following (defined in zdefs.acs):

SKILL_VERY_EASY
SKILL_EASY
SKILL_NORMAL
SKILL_HARD
SKILL_VERY_HARD

Using these will greatly increase code readability.

Examples

This is a simple example script which ends the level, adjusting the skill according to a very primitive inspection of the player's final state. The script works just like an Exit_Normal special.

script 100 (int pos)
{
	int health = GetActorProperty(0, APROP_HEALTH);
	
	if (health < 25 && GameSkill() > SKILL_VERY_EASY)
		ChangeSkill(GameSkill() - 1);
	
	if (health > 100 && GameSkill() < SKILL_HARD)
		ChangeSkill(GameSkill() + 1);
	
	Exit_Normal(pos);	
}

First the health of the player is found. Then, if they are particularly low on health, and it's possible to reduce the skill, the skill is dropped a level. On the other hand, if they are doing very well, the skill is increased. Finally the level is exited as normal.

Personal tools