groupAttackTarget is not working with script added ships.

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

groupAttackTarget is not working with script added ships.

Post by Eric Walch »

I was working on the AI of the thargoid carrier (Together with McLane). I noticed the defenders didn't react on the groupAttackTarget command. McLane reported me the same for his sentinal asteroid defenders.

With the new AI debugging tool I logged all the messages. I noticed the mother is sending and receiving them. The defenders however never get it. So i looked into the code of the command and saw that if the carrier has no groupID itself, it never sends anything to its members. And again with the debuggingtool I noticed that the carrier groupID is 0. (=NO_GROUP). This means there is a bug in the ship-adding routine. The populator sets groupID but ships added by script don't have it.

Code needs a fix. Or in the adding it should check if it is an carrier or in the launching of defenders there must be a check for the groupID of the mother. The defenders itself have a groupID set.

For the time being I added a sendScriptMessage that sends a "GROUP_ATTACK_TARGET" to all group members. Now the group members act as intended and abort their docking and go into attack mode.

Code: Select all

ATTACKED = (setTargetToPrimaryAggressor, groupAttackTarget, "sendScriptMessage: groupAttack"); 

Code: Select all

this.groupAttack = function() 
{ 
   // create an array of all defense_ships in a radius of 30000 m around the ship 
   let thargoidDefenders = system.shipsWithPrimaryRole("defense_ship", this.ship, 30000); 
   // send message to those defenseShips that are group members. 
   for (let i=0; i<thargoidDefenders.length; i++) 
   { 
      // if the ship is a groupmember
      if(thargoidDefenders[i].groupID == this.ship.ID) 
      // send the message to the AI 
      thargoidDefenders[i].reactToAIMessage("GROUP_ATTACK_TARGET")
   } 
}
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Thanks for the fix! Already implemented. :D

@ Selezen: With Eric's gorgeous help the work on the Thargoid Carrier is almost done! :D
Post Reply