December 22, 2024, 02:39:14

Author Topic: [Fixed] TargetWeapon command and AI behaviour  (Read 5282 times)

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
[Fixed] TargetWeapon command and AI behaviour
« on: March 18, 2011, 22:48:19 »
When issuing a ship's weapons the "targetWeapon" command, the ship will inmediately target those weapons to the given target, but the minute it fires it will find an other target and so on.

For the past weeks I've been working on a very versatile AI of my making, completely mod-free and with plenty of functionality, except for that annoying problem that really messes with the concept of a "smart" ai, where each ship will concentrate their fire and not just firing to the first thing that crosses their crosshairs...

So, anyone knows a why to force a ship to ONLY fire their weapons at an specific target?
Specially using the TargetWeapons command (the tFireTo one doesn't always work)
And if that solution doesn't involve re-aiming the same weapon after it finishes firing it'd be best...

What I tried and didn't work:
-disabling the AI (messes up with movement and default commands)
-Using forbid flags (weapons won't fire or will not use the weapons properly)
-using the tFireTo command (only works at times, and it doesn't let you fire two purposes at the same time (device disabling and hull damaging, in example)
-setting all ships under the ai in focused focused Behaviour (didn't change a thing)

I've included my AI, to use it, all you have to do is include it inside your mission inside a machine, like this:

Code: [Select]
Machine "AI"
#include "defaultAI.mach"
END

The usage is explained inside the file, but it basically has 3 states: Battle, CleanUp and Update.
Battle is the initial state, it should only be called in first instance or after you've called the CleanUp one. Use the Update state if you want to let the AI know new ships have arrived.
« Last Edit: April 05, 2011, 04:30:06 by Mularac »

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
Re: TargetWeapon command and AI behaviour
« Reply #1 on: April 05, 2011, 04:29:08 »
Fixed by requesting a fire event every time one the AI's ship fires and storing the target as a new attribute in the Ship's variable.

Here's the code: Default AI
Feedback is welcome