[code question] spawining along a line

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
zrrion the insect
Posts: 2411
Joined: Thu Jun 25, 2009 1:58 pm
Location: Time Station 1: Moon of Glendale

[code question] spawining along a line

Post by zrrion the insect »

I am attempting to get every instance of BFGextra to spawn a line of actors between itself and the BFGball that spawned them, preferably a jagged line. I have been attempting to look this up but have thus far only found example code that included built in methods for doing some of the math (methods that zscript doesn't have)
Any help on this would be appreciated, even just pointing me towards a good tutorial/good example code would go a long way.
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: [code question] spawining along a line

Post by kodi »

Off the top of my head this ought to work with minor adjustments.

Code: Select all

double ang = GetAngle(0,AAPTR_TARGET);
double range2d = GetDistance(0, AAPTR_TARGET); 
double range3d = GetDistance(1, AAPTR_TARGET); 
double pit = atan2(range2d, self.z - target.z) //may need to reverse the z comparison, I forget the right order easily
double sparsity = 10.0;

for(int i = +; i <=  range3d/sparsity, i++)
{
//use these for spawn function arguments instead and maybe add some randomization. The proper method would be real bezier curves but I can't into math that well.
x = cos(ang) * cos(pit)*(sparsity*i);
x = sin(ang) * cos(pit)*(sparsity*i);
z = sin(pit) * (sparsity*i);
}
I think maybe a native railgun function could do the trick just as well, with custom spawnclass and a range limit of GetDistance(1, AAPTR_TARGET)
Locked

Return to “Editing (Archive)”