Author Topic: Forcing AI to fight at range  (Read 4685 times)

0 Members and 1 Guest are viewing this topic.

Offline bigchunk1

  • bigchunk1 = Awesome²
  • 29
  • ...and by awesome I mean Jerk!
Forcing AI to fight at range
I am trying to get a squadron to engage a convoy from a distance with the Maxim cannon. However when given a standard 'attack' order retail AI gets in very close to the target and strafes the hull. I would rather have the AI stay back and shoot the target from a safe distance.

My attempt involves the use of the every-time argument. I have read stickies that suggest that the use of this conditional is reserved only when necessary but I can't think of a better way to get the results I want. The logic is 'every-time' the fighter is within a certain distance the speed of the fighter is set to zero via coordinate manipulation. Essentially the fighter cannot move but, I think it should be able to turn and shoot just fine. 
but, I can't seem to get the 'every-time' conditional to work. In fact, it never becomes true. If I replace 'every-time' with 'when' the event works as predicted but only one time. The fighter just speeds up again after it has be stopped to 0 speed for that single frame.

(sorry could not figure out how to post images so I just made an attachment of the event in question)

Another work around I thought of involves waypoints where the fighter must constantly run back to a waypoint when it ventures too close, but I think this will make the attack of the fighter very ineffective because the fighter will spend more time running around than shooting. I would prefer if it just sat in one spot and fired the Maxim at far off targets until it is given new orders. Is there a way I can get this effect? Also, why isn't the 'every-time' conditional working in the given event?

Thanks for reading this, I have been at this for a day or so and the issue has completely halted my progress on a mission. 


[attachment deleted by admin]
BP Multi
The Antagonist
Zacam: Uh. No, using an effect is okay. But you are literally using the TECHROOM ani as the weapon effect.

 

Offline Trivial Psychic

  • 212
  • Snoop Junkie
Re: Forcing AI to fight at range
If your convoy is gonna be in motion, you could simply have your fighter attack from the rear of it, give it orders to follow the convoy's waypoint and cap its speed to match the convoy ships.  That way, it'll never get closer than a certain distance.  I'm not sure however, if a fighter will fire its weapons at a hostile that crosses its path while following waypoints.
The Trivial Psychic Strikes Again!

 

Offline Enioch

  • 210
  • Alternative History Word Writer
Re: Forcing AI to fight at range
What about using the ai-keep-safe-distance SEXP? Never used it myself, don't know if it works... and how it works. It claims that the ai will keep a safe distance from all enemy ships, so this might not be what you want. Then again, if you give a ship Maxims, I guess you want it to be a long-range fighter, so this might be good for you. Dunno. :nervous:
'Violence is the last refuge of the incompetent'  -Salvor Hardin, "Foundation"

So don't take a hammer to your computer. ;-)

 

Offline bigchunk1

  • bigchunk1 = Awesome²
  • 29
  • ...and by awesome I mean Jerk!
Re: Forcing AI to fight at range
What about using the ai-keep-safe-distance SEXP? Never used it myself, don't know if it works... and how it works. It claims that the ai will keep a safe distance from all enemy ships, so this might not be what you want. Then again, if you give a ship Maxims, I guess you want it to be a long-range fighter, so this might be good for you. Dunno. :nervous:

Unfortunately, this does not work. The AI will not 'keep-safe-distance' and attack an enemy target at the same time. Depending on what the priority is, the AI will choose to run or attack, but won't fight at range.

If your convoy is gonna be in motion, you could simply have your fighter attack from the rear of it, give it orders to follow the convoy's waypoint and cap its speed to match the convoy ships.  That way, it'll never get closer than a certain distance.  I'm not sure however, if a fighter will fire its weapons at a hostile that crosses its path while following waypoints.

Is it possible to change the maximum speed in runtime? I could just cap their speed at 0 when they get too close. I don't how to do this though. Are you talking about set velocity in the ships editor? That only works for the first frame of the mission before the AI takes over. I also want them to be able to move later in the mission, so I need to be able to allow them to go full speed after fighting at range. If somehow you can change the maximum speed in runtime with an event I think you solved my problem, but again I still don't know how to do this.


BP Multi
The Antagonist
Zacam: Uh. No, using an effect is okay. But you are literally using the TECHROOM ani as the weapon effect.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Forcing AI to fight at range
If they're running waypoints, use cap-waypoint-speed. It's a SEXP.

 

Offline Sushi

  • Art Critic
  • 211
Re: Forcing AI to fight at range
By default, the AI will actually do what you want (maintain a distance and continuous fire instead of doing looping/strafing attacks) under two conditions:

1. No hostile fighters get within 600m or so of them.
2. Their target isn't shooting back.


 

Offline Trivial Psychic

  • 212
  • Snoop Junkie
Re: Forcing AI to fight at range
I think he wants the fighters to fight from just within the maximum range of the maxim, which is significant, and I believe that the stop-moving-and-fire-continuously range is much closer than that.
The Trivial Psychic Strikes Again!

 

Offline headdie

  • i don't use punctuation lol
  • 212
  • Lawful Neutral with a Chaotic outook
    • Skype
    • Twitter
    • Headdie on Deviant Art
Re: Forcing AI to fight at range
how difficult would it be for SCP to code an AI order to attack seeking to maintain minimum distance to target and inversely attack within a maximum range, could be useful to mimic attack patterns and make using the attack order for cap ships look a little better forcing them to keep to big gun ranges
Minister of Interstellar Affairs Sol Union - Retired
quote General Battuta - "FRED is canon!"
Contact me at [email protected]
My Release Thread, Old Release Thread, Celestial Objects Thread, My rubbish attempts at art

 

Offline Trivial Psychic

  • 212
  • Snoop Junkie
Re: Forcing AI to fight at range
Would probably be done in ai_profiles.tbl or scripting.
The Trivial Psychic Strikes Again!

 

Offline bigchunk1

  • bigchunk1 = Awesome²
  • 29
  • ...and by awesome I mean Jerk!
Re: Forcing AI to fight at range
If they're running waypoints, use cap-waypoint-speed. It's a SEXP.
Having them fly behind the target convoy using cap-waypoint-speed does not work. When a fighter is on waypoints, it does not fire its weapons. The fighters only started attacking when they were being fired upon themselves, which I am pretty sure was them acting in self defense and not as a result of waypoints. Good idea though Trivial Psychic, I was almost sure it would work before I tested it.

I am still pretty surprised there is only a ‘cap-waypoint-speed’ and not a ‘cap-speed’ SEXP. I wonder why volition restricted such a potentially useful SEXP.

By default, the AI will actually do what you want (maintain a distance and continuous fire instead of doing looping/strafing attacks) under two conditions:

1. No hostile fighters get within 600m or so of them.
2. Their target isn't shooting back.
That is quite interesting. The reason why the AI was going within flak range was because I made their default load out Maxim/Prometheus R I think they were getting within range to use the Prometheus when the flak started firing. I will have to force their load out to be double Maxims to get them to work properly but all things considered I am ok with that. Their secondary load out consists of Trebuchets, Stiletto II warheads and Piranhas; works as intended with this configuration.  One thing to note though, they close to roughly 2000 meters with this setup and the range of the Maxim is much longer than that. If not an ideal solution, it is a workable one. Thanks.


BP Multi
The Antagonist
Zacam: Uh. No, using an effect is okay. But you are literally using the TECHROOM ani as the weapon effect.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Forcing AI to fight at range
Be aware they won't fire their Trebuchets without using Fury AI, good-secondary-time, or otherwise customized AI.

 

Offline bigchunk1

  • bigchunk1 = Awesome²
  • 29
  • ...and by awesome I mean Jerk!
Re: Forcing AI to fight at range
Be aware they won't fire their Trebuchets without using Fury AI, good-secondary-time, or otherwise customized AI.

Good catch, I'll take note of that

BP Multi
The Antagonist
Zacam: Uh. No, using an effect is okay. But you are literally using the TECHROOM ani as the weapon effect.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Forcing AI to fight at range
Bear in mind that there are SEXPs to allow you to change the weapons loaded on a ship so you can set the ships to have a Maxim for the capship attack and then give them the Proms back when it comes to time to attack something else.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline headdie

  • i don't use punctuation lol
  • 212
  • Lawful Neutral with a Chaotic outook
    • Skype
    • Twitter
    • Headdie on Deviant Art
Re: Forcing AI to fight at range
Would probably be done in ai_profiles.tbl or scripting.

SEXPs would have more flexibility for fredders
Minister of Interstellar Affairs Sol Union - Retired
quote General Battuta - "FRED is canon!"
Contact me at [email protected]
My Release Thread, Old Release Thread, Celestial Objects Thread, My rubbish attempts at art