Page 1 of 1

[DECORATE] Interpolation of x,y,z variables in A_SpawnItemEx woes

Posted: Sun Sep 08, 2019 3:13 pm
by darkmessenger84
Hello.

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
		
	}
	
}
Thank you in advance.

[DECORATE] Re: Interpolation of x,y,z variables in A_SpawnItemEx woes

Posted: Sun Sep 08, 2019 6:18 pm
by TDRR
Use an ACS script and set the value with it like this:
TNT1 A 0 A_SpawnItemEx("ObjectToBeSnapped",ACS_NamedExecuteWithResult("scriptname"),0,0,0,0,0,0,SXF_CLIENTSIDE|SXF_ABSOLUTEANGLE|SXF_ABSOLUTEPOSITION)

You can pass arguments, of course.

Use ACSUtils because IIRC floor, ceil and round aren't in Zandronum.

[DECORATE] Re: Interpolation of x,y,z variables in A_SpawnItemEx woes

Posted: Sun Sep 08, 2019 6:44 pm
by darkmessenger84
I found another solution where I used DECORATE to truncate the first five bits from the integer by right shifting and left shifting back, followed by subtracting the resulting integer from the original X coordinate.

My next problem is, as this object is being spawned at the crosshair every tic, there is micro jitter due to the lack of rounding.

[DECORATE] Re: Interpolation of x,y,z variables in A_SpawnItemEx woes

Posted: Sun Sep 08, 2019 7:48 pm
by darkmessenger84
I ultimately went the ACS route.

And after some polish, this is the fruit of my labour. Vertical placement however is a bit finicky.
Image

[DECORATE] Re: Interpolation of x,y,z variables in A_SpawnItemEx woes

Posted: Sun Sep 08, 2019 8:11 pm
by TDRR
Oh, now i see, another Doomcraft project? I hope this one does see the light of day and is better than the old one though.

[DECORATE] Re: Interpolation of x,y,z variables in A_SpawnItemEx woes

Posted: Sun Sep 08, 2019 8:23 pm
by darkmessenger84
Nah, I'm just screwing around with my own personal mod. I was going to use this as a weapon to lay temporary defensive fortifications.