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

Discuss all aspects related to modding Zandronum here.
Post Reply
darkmessenger84
New User
Posts: 13
Joined: Mon Jul 06, 2015 8:32 pm
Location: Grantham, UK

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

#1

Post by darkmessenger84 » Sun Sep 08, 2019 3:13 pm

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.

User avatar
TDRR
 
Posts: 96
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

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

#2

Post by TDRR » Sun Sep 08, 2019 6:18 pm

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.
Venezuelans don't cry because they're weak, they cry because they have been strong for too long.

darkmessenger84
New User
Posts: 13
Joined: Mon Jul 06, 2015 8:32 pm
Location: Grantham, UK

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

#3

Post by darkmessenger84 » Sun Sep 08, 2019 6:44 pm

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.

darkmessenger84
New User
Posts: 13
Joined: Mon Jul 06, 2015 8:32 pm
Location: Grantham, UK

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

#4

Post by darkmessenger84 » Sun Sep 08, 2019 7:48 pm

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

User avatar
TDRR
 
Posts: 96
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

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

#5

Post by TDRR » Sun Sep 08, 2019 8:11 pm

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.
Venezuelans don't cry because they're weak, they cry because they have been strong for too long.

darkmessenger84
New User
Posts: 13
Joined: Mon Jul 06, 2015 8:32 pm
Location: Grantham, UK

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

#6

Post by darkmessenger84 » Sun Sep 08, 2019 8:23 pm

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.

Post Reply