Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: How to use CombatTaskManagerAPI.giveAssignment?  (Read 1871 times)

Zaphide

  • Admiral
  • *****
  • Posts: 799
    • View Profile
How to use CombatTaskManagerAPI.giveAssignment?
« on: January 22, 2016, 08:40:51 PM »

Does anyone have any info or examples on using fleet assignments in combat? At the moment I have this:
Code
// Get fleet manager for target ship
CombatFleetManagerAPI combatFleetManagerAPI = Global.getCombatEngine().getFleetManager(ship.getOwner());

// Create a light escort order on target ship
CombatFleetManagerAPI.AssignmentInfo assignmentInfo = combatFleetManagerAPI.getTaskManager(true).createAssignment(CombatAssignmentType.LIGHT_ESCORT, (AssignmentTargetAPI)this.getDeployedFleetMemberAPI(ship), false);

// Assign other ship to the light escort order
combatFleetManagerAPI.getTaskManager(true).giveAssignment(this.getDeployedFleetMemberAPI(otherShip), this.assignmentInfo, false);

But it doesn't seem to work (the LIGHT_ESCORT assignment doesn't appear to be created nor is it followed by otherShip).

Also tried testing with this:
Code
// Create waypoint for assignment
AssignmentTargetAPI assignmentTargetAPI = combatFleetManagerAPI.createWaypoint(ship.getLocation(), false);

// Create assignment
CombatFleetManagerAPI.AssignmentInfo assignmentInfo = combatFleetManagerAPI.getTaskManager(true).createAssignment(CombatAssignmentType.DEFEND, assignmentTargetAPI, false);
           
// Assign other ship to assignment
combatFleetManagerAPI.getTaskManager(true).giveAssignment(this.getDeployedFleetMemberAPI(otherShip), assignmentInfo, false);

In this case, the waypoint is created (I can see it in the tactical map) but it does not get the DEFEND assignment and then the otherShip does not get the defend order.

Am I missing a step somewhere? :)
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24126
    • View Profile
Re: How to use CombatTaskManagerAPI.giveAssignment?
« Reply #1 on: January 22, 2016, 08:56:54 PM »

I think you want:
combatFleetManagerAPI.getTaskManager(false)

Passing true there gives you the task managed for allied forces (for an ongoing battle), not the player's.
Logged

Zaphide

  • Admiral
  • *****
  • Posts: 799
    • View Profile
Re: How to use CombatTaskManagerAPI.giveAssignment?
« Reply #2 on: January 22, 2016, 09:20:40 PM »

I think you want:
combatFleetManagerAPI.getTaskManager(false)

Passing true there gives you the task managed for allied forces (for an ongoing battle), not the player's.

Huh yep that was it :D I was sure I had tried that...  :P

Thanks very much! Now waypoints and ship assignments work as expected!
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24126
    • View Profile
Re: How to use CombatTaskManagerAPI.giveAssignment?
« Reply #3 on: January 22, 2016, 09:24:57 PM »

Excellent :)
Logged