AI Cloak Patrols for Mission Map

I have had some trouble with AI and cloaking. I am listing my troubles and then my solution below. Curious how others deal with it and if anyone has ideas to improve.

TROUBLES:

  1. Ai cloaks as soon as ship is hypered in. However after the initial cloak wears off they re-cloak the moment they have any recharge. The affect is like 10 seconds of cloak and off again, repeat.
  2. Vaygr CPU Player cloaked carriers do not cloak surrounding ships like human player’s cloaked ships do in multi player. Not sure if this if a CPU thing or a Single Player thing… not tested my own cloaked ships yet in Mission. (Was avoiding let human cloak versus AI for… figured that would be best)

SOLUTION I came up with

  1. Hyper carrier in cloaked.
  2. Right after hypered in I override the CPU player AI and control ship with script. It stays cloaked for over 2 minutes with what ever i want it to do.
  3. Set function to let the CPU player take back control for a few seconds when the cloak has worn off and I have adequate recharge of cloak.

BONUS: I also set some random behavior for the CPU Player Carrier to move to or hyper to many different locations on the map… randomly. This should make it more difficult for the Human Player to predict where the patrol is going to be and when and where the strike craft will be coming from.

REPEAT BELOW WITH CODE

  1. Hyper carrier in cloaked.

SobGroup_ExitHyperSpace(“VPatrolSOB_1”, “PatrolVOL_1”) --WFB Bring patrol
Rule_AddInterval ( “Patrol_Human_1”, 10 ) --WFB Give control to Human after CPU player cloaks

  1. Right after hypered in I override the CPU player AI and control ship with script. It stays cloaked for over 2 minutes with what ever i want it to do. Random Patrol set.

function Patrol_Human_1() --WFB Human Takes control makes a ships
if (SobGroup_Empty(“VPatrolSOB_1”) == 1) then
Rule_Remove (“Patrol_Human_1”)
else
CPU_RemoveSobGroup( 4, “VPatrolSOB_1” ) --WFB Remove control from CPU player
i = RandomIntMax(4) --WFB Set random patrol to fool human
if (i == 0) then
SobGroup_Move(4, “VPatrolSOB_1”, “PatrolVOL_1”) --Move to VOL1 cloaked
elseif (i == 1) then
SobGroup_Move(4, “VPatrolSOB_1”, “PatrolVOL_2”) --Move to VOL2 cloaked
elseif (i == 2) then
SobGroup_EnterHyperSpaceOffMap(“VPatrolSOB_1”) --Hyperspace to VOL1 cloaked
Rule_AddInterval ( “Patrol_AIHyper_1”, 30 )
elseif (i == 3) then
–Subtitle_Message(“Do Nothing”, 3)
SobGroup_EnterHyperSpaceOffMap(“VPatrolSOB_3”) --Hyperspace to VOl3 cloaked
Rule_AddInterval ( “Patrol_AIHyper_1”, 30 ) --WFB Delayed Hyper, time for animation
end
end
SobGroup_CreateShip( “VPatrolSOB_1”, “Vgr_Bomber” ) --WFB Create bomber for attack
SobGroup_CreateShip( “VPatrolSOB_1”, “Vgr_Bomber” )
Rule_AddInterval ( “Patrol_AI_1”, 300 ) --WFB Give control back to AI when Cloak is done and charged to recloak
Rule_AddInterval ( “Patrol_HumanAttack_1”, 20 ) --WFB Attack Human player with bombers
Rule_Remove (“Patrol_Human_1”)
end

  1. Set function to let the CPU player take back control for a few seconds when the cloak has worn off and I have adequate recharge. When I take control again LONG cloak time.

function Patrol_AI_1() --WFB Ai takes control to go CLOAK then gives back to human
if (SobGroup_Empty(“VPatrolSOB_1”) == 1) then
Rule_Remove (“Patrol_AI_1”)
else
–Subtitle_Message(“Ai Control”, 3)
CPU_AddSobGroup(4, “VPatrolSOB_1”)
Rule_AddInterval ( “Patrol_Human_1”, 20 )
end
end

  1. Hyperspace Carrier after animation has played to hyper out. Part of random patrol path.

function Patrol_AIHyper_1() --WFB Delayed exit hyperspace for Patrol
SobGroup_ExitHyperSpace(“VPatrolSOB_1”, “PatrolVOL_1”) --WFB Exit Hyper
Rule_Remove (“Patrol_AIHyper_1”)
end

  1. Attack Human Player with strike-craft. Sending out peridoic waves of strike-craft from many differant angles.

function Patrol_HumanAttack_1() --WFB Attack with Units
Player_FillShipsByType(“KillFriendSOB2”, 4, “Vgr_Bomber”) --WFB Fill SOB with units to attack
CPU_RemoveSobGroup( 4, “KillFriendSOB2” ) --WFB Remove control from CPU player
SobGroup_SetROE(“KillFriendSOB2”, OffensiveROE)
SobGroup_Attack( 4, “KillFriendSOB2”, “Player_Ships0” ) --WFB Attack Human
Rule_Remove (“Patrol_HumanAttack_1”)
end

There is one thing left to code I did not post. Plotting different targets based on some data collection and sending the strike-craft out on the target that makes the most sense.

Anyway… took me whole afternoon to test all this out to my satisfaction (my final code is far more involved then the pieces above to make the CPU player seem more human like. I just did not want to post a larger wall of text then I needed to :). I thought I would post so some genius could tell me how I could have done the whole thing with 1 line of code instead. :stuck_out_tongue:

-B8factor - having fun figuring this stuff out!

2 Likes