I am trying to use A_SpawnItemEx to snap and spawn an object at regular intervals (eg. every 16th/32nd map unit) by attempting to use a derivation of this formula to determine spawn offsets to achieve the desired effect, but I'm struggling to make it work as floor, ceil and round function are borked in DECORATE and also ZDoom wiki doesn't help as it is not explicit clear whether x, y, & z DECORATE variables are in integer or fixed point format. ZDoom's Wiki page on fixed point numbers also needs addressing because some of the wording is misleading.
Pseudocode below.
Will be grateful is somebody could point me in the right direction or help me out.
Code: Select all
Actor ObjectSpawner
{
var int user_xSnap;
var int user_ySnap;
var int user_zSnap;
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SetUserVar(user_xSnap,((x + 32/2) / 32) * 32)
TNT1 A 0 A_SpawnItemEx("ObjectToBeSnapped",x-(user_xSnap),0,0,0,0,0,0,SXF_CLIENTSIDE|SXF_ABSOLUTEANGLE|SXF_ABSOLUTEPOSITION)
TNT1 A 1
Stop
}
}