Fire Control Script

Fire Control Script

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
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Fire Control Script

Post by FLOZi »

So, I had the idea of making tank guns for AATA/TACW/WD capable of firing a variety of ammunition types.

1. HE - for buildings, troops, and general force-fire
2. HEAT/HESH - for light AFV e.g. APCs, Armoured Cars
3. APDS/Other KE rounds - for tanks

Using the weapon slave tags, they can be forced to all target the same unit. Also using the new OnlyTargetCategory<x> tag, HEAT/HESH and APDS can be limited to their appropriate targets.

The problem is making a fire control script that will always leave the same reload time between shots, whether it be 2 shots of HE or a HE then a HEAT etc., not allow multiple ammo types to fire simultaneously and only fire HE when the ground is force-attacked (also bear in mind the tank will probably have a co-axial MG (infantry-only) too). :|

Having some (more) engine support for such things would be very cool :wink:

But perhaps someone can come up with something fairly bulletproof with what is to hand.

Here's what I have so far, but this would probably allow weapon 1 to fire after an illegal reload time. The problem is that HE is allowed to shoot at anything (i could try limiting it to everything BUT the HEAT/HESH and APDS categories... but I would still have an issue with force fire)

Code: Select all

//weapon 1 = HE, 2 = HEAT/HESH, 3 = APDS

#define RELOAD 5000

static-var canFireWeap;

Create() {
  canFireWeap = 1;
  // ...etc
}

AimWeapon1(heading, pitch) {
  if (canFireWeap != 1)
    sleep RELOAD;
  canFireWeap = 1;
  // ...etc 
}

AimWeapon2(heading, pitch) {
  start-script canFire(2);
  // ...etc
}

canFire(x) {
  if (canFireWeap != x && x != 1) {
    sleep RELOAD;
    canFireWeap = x;
  }
}
User avatar
GrOuNd_ZeRo
Posts: 1370
Joined: 30 Apr 2005, 01:10

Post by GrOuNd_ZeRo »

Well, I had a thought on this...

Primary weapon should be able to force fire at all times, even if it's air only or has a catagory only.

having catagory only for HE weapons and having HEAT/HESH weapons would greatly reduce the firing simultanious problem, not saying it wont happen, i'm sure it will.

I suggest to add new catagories to units:

'Light' for soft armored targets, HEAT/HESH would target
'armor' for tanks

It's a pretty decent idea that HE is for general purpose firing, however, you probably want machineguns to target everything, maybe the Coax mg's should only fire infantry.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Post by FLOZi »

currently i have it set up with a 'HE' category etc, so you can be really specific, coax only target inf. Currently it will use the right weapon for the right target, but it can fire one right after another still, and it has rather strange behaviour when force firing.
Archangel of Death
Posts: 854
Joined: 28 Jan 2005, 18:15

Post by Archangel of Death »

but it can fire one right after another still
Have you tried in script reload control? Something like:

Code: Select all

static-var  ... hasfired;
Create()
{
	...
	hasfired = 0; 
	...
}	
Reload()
{
	sleep 2450; //Adjust for the amount of time the weapons take to reload
	hasfired = 0;
}
AimWeaponX(heading, pitch)
{
	signal SIG_AIM;
	set-signal-mask SIG_AIM;
	// aiming stuff
	while( hasfired == 1 )
	{
		sleep 100;
	}
	start-script RestoreAfterDelay();
	return (1);
}
FireWeaponX()
{
	hasfired = 1;
	...
}
If I understand slaving, the new onlytarget categories right, and what you want correctly, this should do what you want.

Oh yes, and I imagine force firing on the ground will still have whatever issue it has now.
Last edited by Archangel of Death on 17 Oct 2005, 08:42, edited 2 times in total.
maestro
Posts: 352
Joined: 08 Jun 2005, 11:10

Post by maestro »

even if that applicable, that need unit to have at least 6 weapon slot (3 for gun, then missle, plus CMG/co axial)
Archangel of Death
Posts: 854
Joined: 28 Jan 2005, 18:15

Post by Archangel of Death »

Edited it a bit to hopefully clear things up.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Post by FLOZi »

I was trying to be overcomplex and do everything at once, perhaps I shall try the stock scripted reload. Though the weapons are not currently slaved, as if they are slaved to HE and HE has an OnlyTargetCategory units without the tag can't be targeted ;) The slaving isn't actually nessacery, i think.

Maestro, units can have 16 weapons in Spring :P

I'd also like to graduate KE rounds into several stages, so they did less damage at further range, so you could have;
1. HE
2. HEAT/HESH
3. APDS_0-500
4. APDS_500-1000
5. APDS_1000-1500
6. APDS_1500+
7. Coax
8. AA

And you still have 8 slots free, with which you could add in ATGM or extra APFSDS ranges :wink:
Post Reply

Return to “Engine”