Bug- Firing Weapons via COB

Bug- Firing Weapons via COB

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

Moderator: Moderators

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

Bug- Firing Weapons via COB

Post by Argh »

Ok, I've had time to test this feature, after getting some help from Rattle, and here's the scoop:

Big problem 1:

The weapons fire straight up! I dunno if that's because I set up the weapon with a restricted aim vector, to prevent bad animation behaviors, or not, yet.

Big problem 2:

The weapons don't seem to obey angle changes from the point that I'm firing from. Instead, they seem to be getting their angle from the point used in the COB to aim the weapon, only with 90 degrees added.

I'll do further tests when I get home... maybe I did something wrong. I didn't have long to test this today before Work.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Nope, there is definitely something wrong. Tried replacing the points with a single triangle, declaring dir=dir in the weapon, and other stuff... didn't work. Very strange... it works perfectly for ExplosionGenerators, but not for weapons- it's always 90 degrees off, exactly, from the actual vector, no matter which way I turn the points. Maybe a square... hmm... nope.

Very disappointing. I can get the weapon to fire exactly the wrong way, lol... but not the right one.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

After several more experiments, I'm giving up for now. I can get emit-sfx 2048 to shoot shots on +Y of the aiming Piece, but it will not spawn the weapons on +Z, like it should, and I can't seem to get it to ever "understand" that it is being fired from a Piece that has been moved. It's gotta be something veeeeeery simple, but I just don't have time to bughunt this one any more, guys.

I'll try again when it's been looked into- I'm out of time.
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

Hm indeed... seems to happen to ballistic weapons only. They ignore object rotation.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Only ballistic? Meh... what a bummer. Ah well.
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

I've been testing LOS weapons before... so I have no idea if there's more about it.
User avatar
MadRat
Posts: 532
Joined: 24 Oct 2006, 13:45

Post by MadRat »

Could the bug be as simple as the wrong vectors are being computed? When thinking in 3D it gets awfully easy to figure stuff on the wrong axis.
User avatar
ILMTitan
Spring Developer
Posts: 410
Joined: 13 Nov 2004, 08:35

Post by ILMTitan »

When scripting, is the x-y plane horizontal, or the x-z?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

XZ.
User avatar
Nemo
Spring 1944 Developer
Posts: 1376
Joined: 30 Jan 2005, 19:44

Post by Nemo »

Bump. Has this been worked around/solved yet? I'd like to make use of this, but so far all my script-fired weapons have shot off into random directions.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

So far as I know, no, the limitations of things being fired via script have not been addressed yet. Which is too bad, because this is potentially a very useful feature.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Only way I know is to use non-ballistic weapons. Or maybe turning the fire points downwards by 90°.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Turning the firepoints doesn't work :P
User avatar
Nemo
Spring 1944 Developer
Posts: 1376
Joined: 30 Jan 2005, 19:44

Post by Nemo »

I've been trying with a beamlaser, but it shoots in a random direction every time. Eh, oh well.
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

Random now? It needed a target before it can be emitted last time I checked, i.e. you need to use attack at least once or spring crashed or something.

It would be good if beam lasers and ballistics would fire straight ahead like LOS weapons. I assume lightning weapons behave like beam lasers.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

I will test this again tonight, and see if any of the bugfixes have changed this situation.

Devs, I hate to have to beg, but this should really get to the point where it functions correctly. Firing weapons through script is, now that I've had more time to think about it, a major feature improvement to the game engine.

Why?

If we can fire from script, and have the weapon obey the Projectile code once firing, we can finally escape from the tyranny of OTA-style aiming and target validations. This is a very big deal.

Currently, weapons fire something like this (with a couple of major exceptions, like dropped stuff):

1. AimWeaponX() Returns TRUE when the Piece named in AimFromWeaponX is within the Tolerance angle value (this is respected by Spring- I have tested this pretty thoroughly- I should note that values under 512 don't seem to ever return TRUE however) and the script conditions (wait-for-turn), etc. have all been met.

If the Tolerance value satisfies, but the script does not return TRUE, Spring seems to have a timer that forces the weapon to fire anyhow (I have not tested this for awhile, but the last time I checked, this was still true). This was probably to compensate for poorly-coded stuff in XTA's scripts, and should almost certainly be removed from the COBHandler, but as I cannot cite the code where it is occuring at this time, I will shut up for now ;)

2. When AimFromWeaponX returns TRUE, FireWeaponX gets called.

This is completely unnecessary. Yup... you don't need this code at all. It may have been needed in OTA for some reason, but in Spring, there's no need to execute another loop of code (let alone another loop that has a few annoying exceptional cases hard-coded... again, to deal with issues that were specific to XTA and early builds of SWS).

If we can fire weapons and have them obey vector controls and the Projectile settings correctly (this is, obviously, a little more complicated than simply creating the Projectile at the point- in the case of Guided weapons, it needs to have the target passed to it by the Unit that is firing the weapon), then we can just keep this cycle within one code loop. Ok, we'd still need an outside loop for switching barrels, but that's minor and occasionally useful.


What can we do with this, if it actually works right?

Here are a few examples:

1. A weapon that, as it fires over time, decreases/increases in accuracy. This could be done either with random Y/X angle changes at the firepoint that grew formulaically, or by calling multiple weapons depending on how many previous shots had been fired.

2. A weapon that has a true ammo state, for ground vehicles, and can only be restored after a long waiting period. This can be done somewhat successfully now, but it occasionally locks up- I have yet to see a solution for this that is 100% reliable. It's very hard to get, for example, a Katyuska type of weapon, which has, say, 24 shots, and can either blow them all at once, in series, in combinations, or whatever, but is then "out of ammo" and cannot fire again.

3. Weapons that have totally different properties could all be launched in a common salvo. For example, you could have "missiles" that are actually just ballistic weapons, but each one released could have different properties, giving them different ranges or accuracy or damage or... whatever.

4. It'd make sweeping beams ala Supcom even easier to make.


Mainly, I would really like to be able to free my weapons from the assumptions inherent in Spring's current code. Ideally, the game engine would look for a possible target for WeaponX... then let me control everything that happens next. The way it works right now isn't terrible, but it could certainly be more flexible and useful with this change in place :-)
User avatar
Peet
Malcontent
Posts: 4384
Joined: 27 Feb 2006, 22:04

Post by Peet »

Argh wrote: 4. It'd make sweeping beams ala Supcom even easier to make.
YAAAY!

/me is rather excited to see these in action.
User avatar
PauloMorfeo
Posts: 2004
Joined: 15 Dec 2004, 20:53

Post by PauloMorfeo »

Argh wrote:...
4. It'd make sweeping beams ala Supcom even easier to make.
...
That means that they are already possible to some extent? There is mucho interest in here to know how.

My version of the TLL commander has one of those lasers and it is working marvelously beautifully except for the fact that the laser changes direction sudenly, never smoothly... Hmmmmmm .. i am going to try and remove the "wait for turn" in the script. Maybe like that he won't stop firing.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Argh wrote:2. When AimFromWeaponX returns TRUE, FireWeaponX gets called.

This is completely unnecessary. Yup... you don't need this code at all.
Weapons don't necessarily fire the moment the script allows them to, if e.g. the target has moved into a position where the weapon can't reach it, the attack order was cancelled, the weapon requires ressources that aren't available, the weapon isn't done reloading, etc.
2. A weapon that has a true ammo state, for ground vehicles, and can only be restored after a long waiting period. This can be done somewhat successfully now, but it occasionally locks up- I have yet to see a solution for this that is 100% reliable. It's very hard to get, for example, a Katyuska type of weapon, which has, say, 24 shots, and can either blow them all at once, in series, in combinations, or whatever, but is then "out of ammo" and cannot fire again.
Seemed to work fine for me in GINTA though my reload script didn't just wait for a while, it refilled ammo when an ammo depot was detected nearby.
4. It'd make sweeping beams ala Supcom even easier to make.
Not that they're difficult to make currently...
Post Reply

Return to “Engine”