LevelPostProcessor
Note: This feature is for ZScript only. |
Classes: LevelPostProcessor
This ZScript class is run on map initialization and allows for some broader changes in terms of thing placement, flags, sector and line textures, etc. Adding one to your zscript is enough for it to be run automatically, it does not need to be linked elsewhere.
The postprocessor runs on the freshly loaded level data. No actors have been spawned yet, no static linedef and sector actions have been performed and no thing based initialization has been done. So you can alter things like static_init linedefs, sector specials, or thing types that do not result in a spawned actor (e.g. a slope marker, polyobj spots, SecAct things), or move vertices around.
Upon running, it calls its internal function Apply, which you can override to perform any of the below listed actions.
Internally, this class is mostly used to apply compatibility and fixes to a list of known map issues, a full list of which can be seen here
Constants
const SKILLS_ALL = 31 const MODES_ALL = MTF_SINGLE | MTF_COOPERATIVE | MTF_DEATHMATCH
Methods
- protected void Apply(Name checksum, String mapname)
- This action is run automatically on level load. It receives the checksum hash and the lump mapname (ie MAP01)
- Note: this method is executed automatically on startup but it's NOT virtual, so it must be defined as
protected void
, NOTvirtual void
.
Non-static
- native void ClearSectorTags(int sector)
- native void AddSectorTag(int sector, int tag)
- native void ClearLineIDs(int line)
- native void AddLineID(int line, int tag)
- native void OffsetSectorPlane(int sector, int plane, double offset)
- native void SetSectorPlane(int sector, int plane, vector3 normal, double d)
- native uint GetThingCount()
- native uint AddThing(int ednum, Vector3 pos, int angle = 0, uint skills = SKILLS_ALL, uint flags = MODES_ALL)
- native int GetThingEdNum(uint thing)
- native void SetThingEdNum(uint thing, int ednum)
- native vector3 GetThingPos(uint thing)
- native void SetThingXY(uint thing, double x, double y)
- native void SetThingZ(uint thing, double z)
- native int GetThingAngle(uint thing)
- native void SetThingAngle(uint thing, int angle)
- native uint GetThingSkills(uint thing)
- native void SetThingSkills(uint thing, uint skills)
- native uint GetThingFlags(uint thing)
- native void SetThingFlags(uint thing, uint flags)
- native int GetThingID(uint thing)
- native void SetThingID(uint thing, int id)
- native int GetThingSpecial(uint thing)
- native void SetThingSpecial(uint thing, int special)
- native int GetThingArgument(uint thing, uint index)
- native Name GetThingStringArgument(uint thing)
- native void SetThingArgument(uint thing, uint index, int value)
- native void SetThingStringArgument(uint thing, Name value)
- native void SetVertex(uint vertex, double x, double y)
- native double, bool GetVertexZ(uint vertex, int plane)
- native void SetVertexZ(uint vertex, int plane, double z)
- native void RemoveVertexZ(uint vertex, int plane)
- native void SetLineVertexes(uint Line, uint v1, uint v2)
- native void FlipLineSideRefs(uint Line)
- native void SetLineSectorRef(uint line, uint side, uint sector)
- native Actor GetDefaultActor(Name actorclass)
- void FlipLineVertexes(uint Line)
- void FlipLineCompletely(uint Line)
- void SetWallTexture(int line, int side, int texpart, String texture)
- void SetWallTextureID(int line, int side, int texpart, TextureID texture)
- void SetLineFlags(int line, int setflags, int clearflags = 0)
- void SetLineActivation(int line, int acttype)
- void ClearLineSpecial(int line)
- void SetLineSpecial(int line, int special, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0, int arg5 = 0)
- void SetSectorSpecial(int sectornum, int special)
- void SetSectorTextureID(int sectornum, int plane, TextureID texture)
- void SetSectorTexture(int sectornum, int plane, String texture)
- void SetSectorLight(int sectornum, int newval)
- void SetWallYScale(int line, int side, int texpart, double scale)
Examples
The following example will search for things with the ednum 2048 (AmmoBox) and replace them with ednum 2007 (clips)
class MyLevelPostProcessor : LevelPostProcessor
{
protected void Apply(Name checksum, String mapname)
{
for (int i = 0; i < GetThingCount(); i++)
{
int ednum = GetThingEdNum(i);
if(ednum == 2048) // ammo box
{
SetThingEdNum(i, 2007);
}
}
}
}