Restricted-arc weapons and Spring's aiming code. - Page 2

Restricted-arc weapons and Spring's aiming code.

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

It's not strange... just broken. That said, my solution works fairly well, most of the time. I see the occasional borked bit, due to how slowly the refresh occurs, but it's something I can live with.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

that is all fine and good argh, but the rest of us do not want to use a null gun to point the unit right.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Post by FLOZi »

smoth wrote:that is all fine and good argh, but the rest of us do not want to use a null gun to point the unit right.
indeed. /me whipcracks at titan :P
User avatar
ILMTitan
Spring Developer
Posts: 410
Joined: 13 Nov 2004, 08:35

Post by ILMTitan »

Committing a fix right now. It was actually a larger problem of units not checking for attackers and close enemy units correctly while idling, but was most obvious in restricted arc weapons due to the fact that the weapons would often attack the target on their own when in range. Revision #3181
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Kick-ass. Will check it out immediately.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Ok, tested it.

On the one hand, it works very well, in terms of detecting targets. I'd say that that bug is fixed.

On the other hand... well, it's doing something funky still: whenever AimWeaponX() is being invoked (i.e., whenever an enemy enters LOS) restricted-arc weapons are doing this bizarre behavior where they constantly return to 0 on the Y-axis, instead of remaining aimed. This happens every frame or so, and looks quite bad.

This is specific to restricted-arc weapons- non-restricted ones don't show this behavior. It's almost like they are constantly being sent a 0 vector, instead following directions from the BOS, so they first turn due to the BOS, then are told to turn towards 0 Y, then spin further towards the target, etc. It effectively makes units lock up when aiming to the sides of a wide arc.

I've seen this problem since I first messed with restricted-arc weapons, but I got around it by using code like this:

Code: Select all

heading_01 = heading;
 	if ( heading_01 <= 32768 )
 	{
 		turn torso to y-axis heading speed <300.0>;
 	}
 	if ( heading_01 > 32768 )
 	{
 		turn torso to y-axis 0 - heading speed <300.0>;
 	}
This code basically told the Piece to either spin to the right or the left, depending on the vector to the target.

Well... this code no longer seems to help any. There's something very funky in the way that restricted-arc weapons are being aimed by Spring... it's almost like it's checking to see if they've passed their maximum-allowed angle, along with everything else- and if they have, instead of *stopping* their rotation, which is what they should do, they're attempting to rotate back to 0 Y :| This is, obviously, not ideal.

So, I checked through the code...
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

...hmm... this is interesting, and might be where this odd behavior starts (from Weapon.cpp):

Code: Select all

short int heading=GetHeadingFromVector(wantedDir.x,wantedDir.z);
			short int pitch=(short int) (asin(wantedDir.dot(owner->updir))*(32768/PI));
			std::vector<int> args;
			args.push_back(short(heading-owner->heading));
			args.push_back(pitch);
			owner->cob->Call(COBFN_AimPrimary+weaponNum,args,ScriptCallback,this,0);
If I'm reading this right, then this argument, unlike OTA, will return a short, instead of a short int, which means that the number returned is frequently negative. So therefore, if I write my code like this:

Code: Select all

	heading_01 = heading;
 	if ( heading_01 < 0)
 	{
 		turn torso to y-axis heading speed <300.0>;
 	}
 	if ( heading_01 >= 0)
 	{
 		turn torso to y-axis 0 - heading speed <300.0>;
 	}
... it should work.

<tests>

Nope, the exact same problem is occurring- it keeps trying to return to 0 Y.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Hmm. Might this be happening because Heading and Pitch aren't being calculated the same way, and are returning very different values?

maybe it should be:

short int heading=(short int) (asin(wantedDir.dot(owner->frontdir))*(32768/PI));
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

This is still broken, please fix so that I can make pretty videos of my latest project ;)
User avatar
ILMTitan
Spring Developer
Posts: 410
Joined: 13 Nov 2004, 08:35

Post by ILMTitan »

It seemed to be working ok with Gundam. I think before I can fix what you want, I may need to learn a little more about modding. What unit are you testing with, anyway (I assume it is in nano-blobs)?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Funny thing happened- right after I got done with lunch, I went through the code and found that the problem is scripting, not with the code. Big fat nevermind- it's working properly, if the script behaves itself ;)
User avatar
ILMTitan
Spring Developer
Posts: 410
Joined: 13 Nov 2004, 08:35

Post by ILMTitan »

Good to know. Argh, thank you for being such an awesome tester.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

LOL! "Awesome tester"... I should've caught my scripting error three weeks ago :oops: Ah well, it's all fixed and works, which is all that really matters.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

I was just psyched to see it getting looked at again, thanks guys.
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Post by Guessmyname »

So does arc-aiming work now?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Yes.
Post Reply

Return to “Engine”