Page 1 of 2
Minimum distance possible for artillery pieces?
Posted: 28 Oct 2008, 06:54
by hughperkins
Question: how easy is it to make artillery have a minimum range of fire? ie:
* it's a builtin parameter for units?
* It's doable with lua somehow?
* It's not possible?
* Something else?
(reason: thinking of making a mission screenplay where you go around with a radar jammer ,taking out artillery positions. Obviously would work less well if the first position blows one's pathetic commando units to smithereens)
Re: Minimum distance possible for artillery pieces?
Posted: 28 Oct 2008, 14:19
by KDR_11k
You can force the unit to lock up when a secondary weapon that's slaved to the primary targets something in the COB, gets more complex if you want to add proper retargetting and all that. Good luck.
Re: Minimum distance possible for artillery pieces?
Posted: 28 Oct 2008, 14:20
by AF
You can make lua block attack commands that are within a certain range of the unit, though fi the target moves into that range hmmm, maybe it would require a little extra logic
Re: Minimum distance possible for artillery pieces?
Posted: 28 Oct 2008, 16:16
by Guessmyname
KDR_11k wrote:You can force the unit to lock up when a secondary weapon that's slaved to the primary targets something in the COB, gets more complex if you want to add proper retargetting and all that. Good luck.
Not really. Isn't there a COB define that does that automatically? CHANGE_TARGET or somesuch. I'll have a look...
Yep. set CHANGE_TARGET to <integer>; will change the target for the <integer> weapon, ie set CHANGE_TARGET 1; will make weapon 1 look for a new target.
Okay, this is entirely theoretical, but...
Set up your artillery weapon as normal. Use the 1st weapon slot for this.
Add a second, dummy weapon (I'd use weapontype=melee; for this) with no damage and the 'inner range' you want.
Then, in the script...
Code: Select all
//At the start of the script
static-var innerRange;
//further down
AimWeapon1(heading, pitch)
{
//standard aiming stuff here
if(innerRange==1)
{
set CHANGE_TARGET to 1;
}
return(TRUE);
}
VarReset()
{
sleep 100;
innerRange=0;
}
AimWeapon2(heading, pitch)
{
innerRange = 1;
start-script VarReset();
return(TRUE);
}
Actually, I'm less sure that that will work (it's resetting innerRange as soon as Weapon 2 is out of range that's the problem), but it's worth trying.
Re: Minimum distance possible for artillery pieces?
Posted: 28 Oct 2008, 21:13
by Forboding Angel
minbarrelangle = "-25", Weapon tag... iirc this is prolly what you're looking for.
Re: Minimum distance possible for artillery pieces?
Posted: 28 Oct 2008, 22:04
by Peet
Minbarrelangle is aesthetic, not functional.
Re: Minimum distance possible for artillery pieces?
Posted: 29 Oct 2008, 01:20
by hughperkins
Ok, so I'll conclude that it's kindof possible to vaguely fudge it possibly, but far from trivial.
Re: Minimum distance possible for artillery pieces?
Posted: 29 Oct 2008, 01:52
by lurker
If the arty is big enough, it's trivial to keep it from aiming low or aiming vertically enough; it just needs an if angle < blah in the script. All the posts here have been about setting a specific range, which is tricky.
Re: Minimum distance possible for artillery pieces?
Posted: 29 Oct 2008, 03:16
by REVENGE
Why don't we have a minimum range tag that just works?
Re: Minimum distance possible for artillery pieces?
Posted: 29 Oct 2008, 03:43
by Guessmyname
Oh please. Simple, easily understood ways of implementing things are for lazy people! Real men do things the HARD WAY!
Re: Minimum distance possible for artillery pieces?
Posted: 29 Oct 2008, 07:24
by hughperkins
lurker wrote:If the arty is big enough, it's trivial to keep it from aiming low or aiming vertically enough; it just needs an if angle < blah in the script. All the posts here have been about setting a specific range, which is tricky.
Oh, so you're saying it's relatively easy to make sure that an artillery piece can't shoot units near it, just not really easy to control precisely what is meant by "near"?
Re: Minimum distance possible for artillery pieces?
Posted: 29 Oct 2008, 10:07
by Guessmyname
lurker wrote:If the arty is big enough, it's trivial to keep it from aiming low or aiming vertically enough; it just needs an if angle < blah in the script. All the posts here have been about setting a specific range, which is tricky.
You could also do that with a vertical fire-arc using a really big cone > 180 degrees
Re: Minimum distance possible for artillery pieces?
Posted: 29 Oct 2008, 10:22
by REVENGE
Well, did OTA have a tag for doing so? I just thought it was weird the SY's didn't have it in their original design.
Re: Minimum distance possible for artillery pieces?
Posted: 29 Oct 2008, 17:30
by zwzsg
REVENGE wrote:Well, did OTA have a tag for doing so?
Yes, it had.
Re: Minimum distance possible for artillery pieces?
Posted: 29 Oct 2008, 18:18
by FLOZi
No it didn't.

Re: Minimum distance possible for artillery pieces?
Posted: 29 Oct 2008, 20:40
by yuritch
Guessmyname wrote:...Okay, this is entirely theoretical, but...
Set up your artillery weapon as normal. Use the 1st weapon slot for this.
Add a second, dummy weapon (I'd use weapontype=melee; for this) with no damage and the 'inner range' you want.
Then, in the script... (an example script)
This isn't quite what it appears to be :) This script will cause the arty to jam if an enemy approaches it, even if it was firing at some other target (that stayed outside of the min range). Might be useful for some mods (for ex. if you want your melee units to be able to block enemy shooters from firing).
If you want to check for minimum range, do it in the AimWeaponX script for the arty weapon, use get TARGET_ID to find out which unit it targets, and then use get UNIT_XZ on that unit and the firing unit to calculate the distance. That's probably best kept on long-reload weapons only as all those calls can in theory slow the game down if used on a fast reload spammable units.
Re: Minimum distance possible for artillery pieces?
Posted: 29 Oct 2008, 23:45
by AF
Lets not forget the obligatory lua script that draws the minimum distance to stop users complaining about bugs that arent really bugs at all
Re: Minimum distance possible for artillery pieces?
Posted: 30 Oct 2008, 01:03
by zwzsg
FLOZi wrote:No it didn't.

Then how comes guardian, thuds, and bertha, cannot fire at their feet? And that when you force fire them too close, then they go into the mode where they have extra range but you have to aim manually? (Gnug tip #41)
Re: Minimum distance possible for artillery pieces?
Posted: 30 Oct 2008, 02:06
by FLOZi
Bug with TA's aiming code
Re: Minimum distance possible for artillery pieces?
Posted: 30 Oct 2008, 02:39
by zwzsg
What you call a bug, I call a feature!