Hard Light Productions Forums

Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: Droid803 on March 29, 2008, 11:53:38 pm

Title: More than 4 turrets firing?
Post by: Droid803 on March 29, 2008, 11:53:38 pm
The game only seems to target an enemy with 4 turrets per target, no more. I have no idea why this happens, or why such a stupid limit exists anyway. I would actually be fine with it, if only the AI wasn't so retarded about it.

I have this ship with 2 BGreens and 3 TerSlashes facing the enemy, as well as a few blobs (THT's), but the enemy is out of blob range. Anyone with half a mind can know to shoot at the other ship with beams, not useless blob turrets, especially when out of blob range. However, the AI enjoys being absolutely retarded and tries to shoot at the enemy using its blob turrets, leaving its beams (which are freed), deactivated for 99% of the time, and occasionally firing a shot with a TerSlash. (the wait in between beam fires is like...2-3 minutes). This is absurd. This is also a problem that plagues several good custom ships - mostly in broadside action. Notably, the Raynor likes using its deck and missile turrets over its beams...that pisses me off to no end. Its got 10 heavy beam cannons, and it wants to shoot the enemy with its blobs, when they are out of range >.>

Why didn't I put this is FRED discussion? I know I can use fire-beam, but its rather retarded to have to do that every single time I want my ship to shoot the enemy (even with looping functions). What I'm asking is - is there a way to make the AI prefer using beams, not blob turrets to shoot at the enemy? Do any of the weapon flags handle this? (ie. Big Ship, Huge). The wiki isn't very helpful on this aspect.

Even better, is there a way to remove the stupid 4-turret limit?
Title: Re: More than 4 turrets firing?
Post by: blowfish on March 30, 2008, 12:03:29 am
Move it a little farther.  Turrets tend to be not quite sure what "out of range" means (they use the model's bounding box or radius or something, not the actual model geometry).
Title: Re: More than 4 turrets firing?
Post by: Droid803 on March 30, 2008, 12:15:13 am
That's hardly a fix... I guesst hat would work in scripted battles...but urr, that would mean the fire-beam is more reliable anyway.
Even when they're up close, they still try and blob each other...which results in pointlessly long and exhausting battles. :(

maybe i should take this up with the SCP people?
Title: Re: More than 4 turrets firing?
Post by: blowfish on March 30, 2008, 12:16:59 am
If there are no fighters around, you could use turret-lock, but no interesting mission has no fighters around.
Title: Re: More than 4 turrets firing?
Post by: Flaming_Sword on March 30, 2008, 12:19:22 am
You also have to consider the firing arcs of the weapons involved (they're in the pof and you can check/edit with PCS2). I've also had far more than 4 turrets targetting capital ships.
Title: Re: More than 4 turrets firing?
Post by: Droid803 on March 30, 2008, 12:27:38 am
If there's more than one target, yes, more than 4 will fire...
I would know, since I have the SCa Shiamak mounting 6 beams per side. Only 4 ever fire at one target (and its a different 4 every time). The limit is 4 per target.

Turret lock...would work for a cinematic battle, definitely :D but then, so would fire-beam.

Editing firing arcs? That would hamper the blob's ability to intercept bombs, the only reason they're there. *sigh* so there's no fix...darn.
Title: Re: More than 4 turrets firing?
Post by: Flaming_Sword on March 30, 2008, 12:55:48 am
Hmm, I'm seeing it with a reskinned Iceni and a reskinned Shiamak with widened firing arcs (160 instead of 90). The new weapons I have make it much more obvious, it seems. I wonder why it was done this way?
Title: Re: More than 4 turrets firing?
Post by: Backslash on March 30, 2008, 01:18:54 am
The range thing may well be a bug.  But do double-check the tables to make sure +Range is not a strange number that doesn't correspond to $Lifetime * $Velocity .  Because if it's higher, the AI thinks it can hit when it can't.  Or are you using just FS2 table weapons?

Have you tried different difficulties?  I know that affects how many turrets can target the player, but I don't know if that applies for everyone else.

I agree that the current behavior is not good.  Problem is, it's hard to track down something like this in the complicated AI turret code.  I'm hoping somebody who knows the code a bit better will weigh in here.
Title: Re: More than 4 turrets firing?
Post by: WMCoolmon on March 30, 2008, 02:02:45 am
Look up "same turret cooldown". That will prevent scaling of the cooldown time (based on difficulty, etc) between shots for the weapon when it's mounted on a turret.

The turret code, IIRC, uses a dot product to determine whether a given target can be fired upon. There was code that used more advance collision detection to determine the same, but it was removed as it broke backwards compatibility and was never reimplemented. At least, as far as I know, it hasn't been reimplemented; there was some talk about doing it not too long ago (~3-6 months I'd guess)
Title: Re: More than 4 turrets firing?
Post by: Flaming_Sword on March 30, 2008, 02:22:10 am
Difficulty is definitely affecting the number of turrets targetting something. It'll be something to think about when designing missions, I guess. I'm also very tempted to grab the source, but I've got plenty to do as it is. :(
Title: Re: More than 4 turrets firing?
Post by: Akalabeth Angel on March 30, 2008, 03:12:31 am
      I encountered the same problem when I was trying to make some Renegade Legion test ship. I put 6 turrets on one side, but only four of them would ever fire at the target ship. I thought the problem was that my model was screwed up, but by this thread I guess that's not the case. (well, my model's screwed up alright . .. but the 4 turrets thing ain't my fault  :lol: )

      Hmmn, and I just noticed that if you look at the FS2 ships . ..  4 turrets is usually a design decision. Think. . . Sathanas has 4 BFReds, Ravana has 2 LReds, 2 SReds . . . Deimos doesnt have more than 3 at any one target. The Orion I think can only bear 4 or so beam turrets to any one side. Seems [V] sure knew about that darn limit :(
Title: Re: More than 4 turrets firing?
Post by: Wanderer on March 30, 2008, 03:20:48 am
On a brief glance at the code there is this...
Code: [Select]
00635: int max_turrets = 3 + Game_skill_level * Game_skill_level;Basically translates to 3, 4, 7, 12, or 19 as the maximum amount of turrets targeting the same target (according to set difficulty level... very easy, easy, normal, hard, insane respectively). Assuming it is in use and not commented away...
Title: Re: More than 4 turrets firing?
Post by: Akalabeth Angel on March 30, 2008, 03:37:07 am
On a brief glance at the code there is this...
Code: [Select]
00635: int max_turrets = 3 + Game_skill_level * Game_skill_level;Basically translates to 3, 4, 7, 12, or 19 as the maximum amount of turrets targeting the same target (according to set difficulty level... very easy, easy, normal, hard, insane respectively). Assuming it is in use and not commented away...

     I just tried it out and it works that way with my test ship. Very Easy I guess = 0, Easy = 1 and Medium = 2 since my ship fired 3, 4 and all 6 turrets respectively.

     That's kinda . . .wierd. Not sure how it affects uh, gameplay really. I mean, If that's a limit vs the player, makes sense . . but versus other ships? What's the problem if two ships kill eachother faster on harder difficulties than easier? And I guess the Sathanas only fires 3 beams in very easy? (or does the fire-beam override it. Don't think I ever played bear baiting on Veasy).
Title: Re: More than 4 turrets firing?
Post by: Wanderer on March 30, 2008, 03:49:24 am
No idea.. But that is hard coded setting and unless it is modified in the sourcecode (like made an option to the ai_profiles.tbl) then you may just need to bump the difficulty level to get the turrets firing they way you like.
Title: Re: More than 4 turrets firing?
Post by: Nuke on March 30, 2008, 04:06:14 am
i see this in the ragnarok class as well, ive yet to see the ship firing all of its 4 forward beam cannons all at once (possibly because the 10 or so long range missile turrets eat up all the slots for active turrets on a target).
Title: Re: More than 4 turrets firing?
Post by: Zoltan on March 30, 2008, 04:38:21 am
On a brief glance at the code there is this...
Code: [Select]
00635: int max_turrets = 3 + Game_skill_level * Game_skill_level;Basically translates to 3, 4, 7, 12, or 19 as the maximum amount of turrets targeting the same target (according to set difficulty level... very easy, easy, normal, hard, insane respectively). Assuming it is in use and not commented away...

     I just tried it out and it works that way with my test ship. Very Easy I guess = 0, Easy = 1 and Medium = 2 since my ship fired 3, 4 and all 6 turrets respectively.

     That's kinda . . .wierd. Not sure how it affects uh, gameplay really. I mean, If that's a limit vs the player, makes sense . . but versus other ships? What's the problem if two ships kill eachother faster on harder difficulties than easier? And I guess the Sathanas only fires 3 beams in very easy? (or does the fire-beam override it. Don't think I ever played bear baiting on Veasy).

There is no fire-beam in Bearbaiting just beam-free-all, and the Sathanas does only fire three beams on very easy. :(
Title: Re: More than 4 turrets firing?
Post by: Vasudan Admiral on March 30, 2008, 05:59:10 am
Seems to me that there should really be an override for this in Fred, since there are definitely instances where you might not want that limitation imposed on the ships in the mission, such as the one in Nukes example.
Title: Re: More than 4 turrets firing?
Post by: TrashMan on March 30, 2008, 06:12:23 am
Agreed.
Can the code monkeys externalize this limit?
Title: Re: More than 4 turrets firing?
Post by: Woolie Wool on March 30, 2008, 09:45:20 am
Even better would be an extra setting for the maximum turrets which can target the player, allowing huge broadsides on easy difficulty levels without worrying about Alpha 1 being raped.
Title: Re: More than 4 turrets firing?
Post by: Droid803 on March 30, 2008, 11:34:10 am
Argh, so that's why its four. Difficulty.
This limit needs extermination, or at least a way to easily modify... well, thanks for figuring this out :)
Now I can eagerly await a fix.
Title: Re: More than 4 turrets firing?
Post by: blowfish on March 30, 2008, 12:27:38 pm
No idea.. But that is hard coded setting and unless it is modified in the sourcecode (like made an option to the ai_profiles.tbl) then you may just need to bump the difficulty level to get the turrets firing they way you like.

Seems like it wouldn't be too hard to add to ai_profiles.tbl ... if only the XCode project file was up do date so I could compile and test things :mad:
Title: Re: More than 4 turrets firing?
Post by: Backslash on March 30, 2008, 01:31:30 pm
Wow, good find, Wanderer.  I figured it'd be a bit more obscure.
What's the problem if two ships kill eachother faster on harder difficulties than easier?
I can think of a few situations where someone wanted the battle to last a certain length or to proceed a certain way.  That's kind of what "same turret cooldown" is for.  Still, there should be the option.

I'm going to take a stab at this.  What do you guys think it should be named?
Title: Re: More than 4 turrets firing?
Post by: TrashMan on March 30, 2008, 01:48:35 pm
max_turret_ownage_target
&
max_turret_ownage_player
Title: Re: More than 4 turrets firing?
Post by: Droid803 on March 30, 2008, 01:49:29 pm
Seconded.
Title: Re: More than 4 turrets firing?
Post by: WMCoolmon on March 30, 2008, 01:50:15 pm
 :lol:
Title: Re: More than 4 turrets firing?
Post by: Backslash on March 30, 2008, 03:14:06 pm
Wow that WAS easy.  If only more features were like this.

I have now committed the change and edited the wiki (http://www.hard-light.net/wiki/index.php/Ai_profiles.tbl).
Title: Re: More than 4 turrets firing?
Post by: Droid803 on March 30, 2008, 03:33:52 pm
 :eek:
Its done? YAY!
Thank you!
Title: Re: More than 4 turrets firing?
Post by: Akalabeth Angel on March 30, 2008, 03:50:35 pm
       So how does this work?  Does a person have to re-download the 3.6.9 or whatever to use this? Or . . . just make some file with the directions in it???
Title: Re: More than 4 turrets firing?
Post by: blowfish on March 30, 2008, 03:53:24 pm
You would need a new build to get this to work.  By new I mean today or after.  You could try to download the source  from SVN and compile it yourself, or wait for someone else to release a new build.
Title: Re: More than 4 turrets firing?
Post by: Akalabeth Angel on March 30, 2008, 04:08:59 pm
You would need a new build to get this to work.  By new I mean today or after.  You could try to download the source  from SVN and compile it yourself, or wait for someone else to release a new build.

      Okay, that's what I figured. Don't need it _today_ anyway . . . but I'll download it sometime in the future :)
Title: Re: More than 4 turrets firing?
Post by: Aardwolf on March 30, 2008, 06:42:35 pm
Will changing this affect Bearbaiting in the main FS2 campaign?

I've noticed on very easy it doesn't fire all 3 at once, the fourth is delayed slightly.
Title: Re: More than 4 turrets firing?
Post by: blowfish on March 30, 2008, 06:46:11 pm
Will changing this affect Bearbaiting in the main FS2 campaign?

I've noticed on very easy it doesn't fire all 3 at once, the fourth is delayed slightly.

This would cause it to fire all four at once, like it does on easy and all other difficulties.  Doesn't really matter though, 2 BFReds is more than enough to rape a Hecate in one shot.
Title: Re: More than 4 turrets firing?
Post by: Droid803 on March 30, 2008, 09:08:48 pm
Actually, you can leave it default, you can just change it to however you like.
So, there's basically no downside to this feature. YAY!
Title: Re: More than 4 turrets firing?
Post by: nvsblmnc on March 31, 2008, 01:47:23 am
Will this change be inlcuded in future XT builds?

(They're the only ones that give me anything resembling a framerate)
Title: Re: More than 4 turrets firing?
Post by: Backslash on March 31, 2008, 03:46:33 am
You're welcome. :) Big thanks to Wanderer for finding that code so fast.  I'm still surprised how easy that turned out to be.

I still think the original problem mentioned needs looking at -- even if it is set in the table that a ship can only fire 4 turrets at once, it should be smart enough to realize "oh, those blob turrets are out of range, let's fire something else".  Or maybe a customizable priority could be added, in which we could specify "beams before everything".  I'm taking a look, but I'm fairly certain it won't be nearly as easy a fix.
Title: Re: More than 4 turrets firing?
Post by: blowfish on March 31, 2008, 09:54:29 am
You're welcome. :) Big thanks to Wanderer for finding that code so fast.  I'm still surprised how easy that turned out to be.

I still think the original problem mentioned needs looking at -- even if it is set in the table that a ship can only fire 4 turrets at once, it should be smart enough to realize "oh, those blob turrets are out of range, let's fire something else".  Or maybe a customizable priority could be added, in which we could specify "beams before everything".  I'm taking a look, but I'm fairly certain it won't be nearly as easy a fix.

Probably you would want huge weapons to fire first too.
Title: Re: More than 4 turrets firing?
Post by: asyikarea51 on March 31, 2008, 10:24:10 am
I thought I saw this feature before in an obsolete version under a very different name a long time ago (Max turrets that can target the player based on difficulty level or something)... but I kept thinking I was just dreaming when I couldn't find it in the wiki.

Oh well, guess it's back with an added feature...

What time was this committed anyway? I just updated my repository a few minutes ago... (oh wait. I think I got it already. :lol:)
Title: Re: More than 4 turrets firing?
Post by: Wanderer on March 31, 2008, 04:22:07 pm
Decided to dig the code a tad deeper...

If you are interested in checking other stuff for ai_profiles.tbl... Granted i just searched the code for 'game_skill_level' with win grep and dropped all those already included in the ai profiles. So the stuff i found could be unused or commented away...  The seemingly heavy use of the 'game_skill_level' in ai code might explain why it some times seems like tweaking ai table is useless. Same goes for the series of settings related to easiest difficulty - though clever fredding allows for avoiding the most of the potential pitfalls. If i'm not totally wrong the more interesting bits are the ai stealth detection scaling options as well as the options for ship to ship collision damage and asteroid strength.

Also interesting thing is the usage of 'aip->ai_class' in the code. Apparently - remember i could well be wrong, even though the comments in the code seem to agree with my judgment - it is the index value of the ai class. And it is used also in certain ai checks. Basically this means that for example (BtRL) Cylon AI set to 1st AI slot in the ai.tbl will have different behavior from the identical Cylon AI set to next to last slot (remembering traitor slot) - which certainly does not make AI tweaking any easier.

Both greps IMHO have some value for coders so i thought it might be best to post them here.

[attachment deleted by ninja]
Title: Re: More than 4 turrets firing?
Post by: blowfish on March 31, 2008, 06:45:50 pm
That ai_class thing was an *odd* choice by :v:
Title: Re: More than 4 turrets firing?
Post by: chief1983 on March 31, 2008, 10:13:55 pm
Just curious, where was the max turret fix commited?  CVS/SVN?  Stable/Unstable/HEAD/3.6.9?  I imagine that if it's in unstable SVN we won't see a build with it for a little while, but I doubt it's in stable since it sounds like it wasn't even ever compiled.  And, Taylor just released a Mac source dump with a working XCode file over on the SCP forum, if the interested parties hadn't noticed yet.  I'd link but...well, I'll let you find out why I won't bother linking to anything for another day or so.
Title: Re: More than 4 turrets firing?
Post by: blowfish on March 31, 2008, 10:17:12 pm
This feature didn't seem to work in that build...
Title: Re: More than 4 turrets firing?
Post by: Backslash on March 31, 2008, 10:23:53 pm
Trunk.  (So, SVN and stable.)  Yesterday, pretty much right when I posted.  Being so recent it's not in any recent build yet that I know of, and I can't post any links at all successfully since it's just about April 1st... ;)
Title: Re: More than 4 turrets firing?
Post by: Goober5000 on April 02, 2008, 12:05:17 am
I still think the original problem mentioned needs looking at -- even if it is set in the table that a ship can only fire 4 turrets at once, it should be smart enough to realize "oh, those blob turrets are out of range, let's fire something else".  Or maybe a customizable priority could be added, in which we could specify "beams before everything".  I'm taking a look, but I'm fairly certain it won't be nearly as easy a fix.
Agreed on all counts.  Nice work, btw. :yes:


Quote
Also interesting thing is the usage of 'aip->ai_class' in the code. Apparently - remember i could well be wrong, even though the comments in the code seem to agree with my judgment - it is the index value of the ai class. And it is used also in certain ai checks. Basically this means that for example (BtRL) Cylon AI set to 1st AI slot in the ai.tbl will have different behavior from the identical Cylon AI set to next to last slot (remembering traitor slot) - which certainly does not make AI tweaking any easier.
I think the code assumes that AI classes will be arranged from easiest to hardest.  But yeah, that should really be recoded (with proper flags in ai_profiles for compatability).
Title: Re: More than 4 turrets firing?
Post by: Flaming_Sword on April 10, 2008, 06:46:41 am
 :bump:

Okay, I finally gave in and grabbed the trunk. I found out the hard way that you can't actually replace the built-in ai profile, only add new ones and set the default to one of them. Do you think this is worth mentioning in the wiki here (http://www.hard-light.net/wiki/index.php/Ai_profiles.tbl)? Maybe an extra sentence or two.