ChangeLevel (ZScript)

struct LevelLocals
Void ChangeLevel(String LevelName, Int Position, Int Flags, Int Skill);

Note: This feature is for ZScript only.

Usage

Changes the level the player is in, similar to the ChangeLevel ACS function.

Parameters

  • String LevelName
The name of the level to change to.
  • Int Position
The player start spot to start the new level at.
  • Int Flags
The flags to use for the level change. This is the list of possible flags, to combine them, use the | seperator.
    • CHANGELEVEL_KEEPFACING: The player spawns in the new level retaining the same, pitch, angle, and roll they had before the function was called.
    • CHANGELEVEL_RESETINVENTORY: Reset the players' inventory to the defaults for their player class.
    • CHANGELEVEL_NOMONSTERS: Remove all the monsters from the level the player enters.
    • CHANGELEVEL_CHANGESKILL: Change the skill level of the level.
    • CHANGELEVEL_NOINTERMISSION: Don't show the intermission screens between the previous level and the one being entered.
    • CHANGELEVEL_RESETHEALTH: Reset the players' health to the default for their player class.
  • CHANGELEVEL_PRERAISEWEAPON: Start the level with the players' weapon already raised.
  • Int Skill
Changes the skill level of the map that will be entered.

(Need more info)

Examples

Below is the code for a Cyberdemon that when killed, changes the current level to a level with the name of "FinalMap", and resets the players' inventory and health.

Class SuperDuperCyberdemon : Cyberdemon
{
	Default
	{
		Health 10000;
		DamageMultiply 2.0;
		Scale 2.0;
		Radius 80;
		Height 220;
		PainChance 10;
		Speed 6;
	}
	Bool BeginLevelExitTimer; //If set to true, the timer below will increment every tick.
	Int ExitTimer; //The timer used to give a delay to the Cyberdemon changing the level.
	Override Void Die (Actor Source, Actor Inflictor, Int DmgFlags, Name MeansOfDeath)
	{
		Super.Die (Source, Inflictor, DmgFlags, MeansOfDeath);
		BeginLevelExitTimer = True;
		Return Super.Die (Source, Inflictor, DmgFlags, MeansOfDeath);
	}
	Override Void Tick()
	{
		Super.Tick();
		If (BeginLevelExitTimer)
		{
			ExitTimer++; //Increment the timer.
		}
		If (ExitTimer >= 35*5)
		{
			Level.ChangeLevel("FinalMap",0,CHANGELEVEL_RESETINVENTORY|CHANGELEVEL_RESETHEALTH|CHANGELEVEL_CHANGESKILL); //Change level.
		}
	}
}


This article is issued from Zdoom. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.