GetZAt

From ZDoom Wiki
Jump to: navigation, search

float GetZAt ([float x[, float y[, float angle[, int flags[, int pick_pointer]]]]])

Usage

Gets the Z of the floor or ceiling at coordinates x and y based on flags. Unlike the floorz and ceilingz Actor properties, this function is fully aware of portals and 3D floors.

This function is capable of succeeding where A_CheckFloor and A_CheckCeiling have their shortcomings -- over ledges and at the edges of a hitbox. With a proper loop, an actor can detect if any part of the pointed actor is truly on the ground or touching the ceiling in its entirety or not.

Note that this function is to be used where an expression is expected. It is mostly useful when combined with A_JumpIf or Anonymous Functions.

Parameters

  • x: The x coordinates based on relativity to the pointer. Positive numbers move the check forward, negative moves it behind.
  • y: Similar to X but for side-to-side. Positive numbers move the check to the right of the actor, negative moves it to the left.
  • angle: The offset amount added to the actor's current angle. Positive amounts rotate the check to the left, negative to the right.
  • flags: Flags can be combined with the | symbol. They are as follows:
  • GZF_ABSOLUTEPOS: Relativity is disabled and the x/y coordinates are absolute.
  • GZF_ABSOLUTEANG: angle is not added to the actor's current angle.
  • GZF_CEILING: The function checks for the ceiling's z instead of the floor's.
  • GZF_3DRESTRICT: Ignores Z on top of midtextures and 3D floors that are above the pointer's position.
  • GZF_NOPORTALS: Ignores the existence of portals and does not traverse into other sectors.
  • GZF_NO3DFLOOR: Ignores all 3D floors above or below the pointer between it and the true floor/ceiling.
  • pick_pointer: The pointer to examine. Default is AAPTR_DEFAULT. See actor pointers.

Return value

Returns the float value of floorz or ceilingz based on the flags above.

Examples

This custom version of Blood enters a Death state upon hitting the floor and then leaves a pool on the floor (which is a flat sprite). However, in order to make sure that the flat sprite doesn't stick out into the air when it falls near a ledge or on a narrow stair, four GetZAt checks are introduced. Unless the floor height of four points 12 units away and around the center of the BetterBlood actor is equal to the floor height of the actor itself (i.e. its center), the pool doesn't appear.

Actor BetterBlood : Blood replaces Blood
{
-ALLOWPARTICLES
+MISSILE
states
	{
	Spawn:
		BLUD CBA 8
		wait
	Death:
		TNT1 A 0 A_JumpIf(GetZAt(24,0) == floorz && GetZAt(-24,0) == floorz && GetZAt(0,24) == floorz && GetZAt(0,-24) == floorz, 1)
		stop
		TNT1 A 0 A_ChangeFlag("FLATSPRITE",1)
		TNT1 A 0 A_Jump(256,1,2,3,4)
		SPLT A -1
		stop
		SPLT B -1
		stop
		SPLT C -1
		stop
		SPLT D -1	
		stop
	}
}