View Single Post
Old 03-03-10, 04:14 AM   #54
CCIP
Navy Seal
 
Join Date: Apr 2005
Location: Waterloo, Canada
Posts: 8,700
Downloads: 29
Uploads: 2


Default

I've started looking into scripts and indeed at least in theory there is a lot that can be done with the AI using this language. Take a look at this for example:


This is a chunk of the script for AI escort tactics. It allows the AI's response to a submarine contact to be coordinated, currently with 3 special tactics that ships could use. One of them is Operation Plaster.

Quote:
strategy OperationPlaster(Ship)
{
precond
{
Ship:GetCurrentTacticID() == OPERATION_PLASTER and Ship:ContactDetected()
}
strategies
{
Role_OP_Plaster,
Role_OP_Directing
}
}

strategy Role_OP_Plaster(Ship)
{
precond
{
Ship:GetRole() == ROLE_PLASTER
}
action
{
# this step is necesary in order to give the ships time to allign themselsves before starting the first plaster pass
# during the plaster passes (between StartFiringDCs and StopFiringDCs the ship cannot turn right/left
# and because of this it might miss its destination and never stop going forward -- actually until the ship looses contact)
Ship:SetGotoDestRelToContact(-800);
Ship:GotoAction(0, true, 100);
Ship:WaitForFormation();

# ready the ship for the first plaster pass
Ship:SetGotoDestRelToContact(-150);
Ship:GotoAction(0, true, 100);
Ship:WaitForFormation();

# throw first round of DCs while passing over the contact
Ship:SetGotoDestRelToContactKeepFormationOrientati on(200);
Ship:StartFiringDCs();
Ship:GotoAction(0, false, 100);
Ship:StopFiringDCs();
Ship:WaitForFormation();

# go further away in order to have room to turn
Ship:SetGotoDestRelToContact(-1000);
Ship:GotoAction(0, true, 100);
Ship:WaitForFormation();

#Ship:TurnToHeading(Ship:GetCurrentFormationHeadin g() - 180, 1.0);

# come back and turn towards contact in the process
Ship:SetGotoDestRelToContact(-500);
Ship:GotoAction(0, true, 100);
Ship:WaitForFormation();

# ready the ships for the second plaster pass (all ships should have the same orientation at this point)
Ship:SetGotoDestRelToContact(-150);
Ship:GotoAction(0, false, 100);
Ship:WaitForFormation();

# throw second round of DCs on the way back
Ship:SetGotoDestRelToContactKeepFormationOrientati on(200);
Ship:StartFiringDCs();
Ship:GotoAction(0, false, 100);
Ship:StopFiringDCs();
Ship:WaitForFormation();

Ship:SetGotoDestRelToContact(-1000);
Ship:GotoAction(0, true, 100);
Ship:WaitForFormation();

#Ship:TurnToHeading(Ship:GetCurrentFormationHeadin g() - 180, 1.0);

Ship:SetGotoDestRelToContact(-500);
Ship:GotoAction(0, true, 100);
Ship:WaitForFormation();


Ship:EndCurrentTactic();
}
}

strategy Role_OP_Directing(Ship)
{
precond
{
Ship:GetRole() == ROLE_DIRECTING
}
action
{
Ship:SetGotoDestRelToContact(-1500);
Ship:GotoAction(0, true, 100);
Ship:WaitAction(15.0);
}
}
Looking through it carefully, you can see a whole number of features programmed in - the pre-conditions for when such an attack would be executed, the assignment of two different roles to escorts, and a whole bunch of parameters for the execution determining how the ship will move, where it will drop its charges, and how it will behave afterwards. You can't count on them just dropping this stuff on your last known position anymore!

How actually effective this is... I'm not sure. But in theory this is now all part of the game and can be edited and added onto very easily by modders, needing nothing more than the notepad and some understanding of the game's commands.
__________________

There are only forty people in the world and five of them are hamburgers.
-Don Van Vliet
(aka Captain Beefheart)
CCIP is offline   Reply With Quote