warzone2100/data/script/text/cam1b-ai.slo

447 lines
12 KiB
Plaintext

/*
* Cam1B-AI.slo
*
* Opposition AI
*
*/
// enemy1 variables
private GROUP enemy1Build, enemy1Attack, enemy1Start, enemy1Fin, enemy1Force1, enemy1Force2;
private GROUP enemy2Build, enemy2Attack, enemy2Start, enemy2Fin, hillGroup;
public INT rBlkX,rBlkY;
public INT oilPatchX,oilPatchY;
public INT playerX,playerY;
private BOOL oilWellClear;
private STRUCTURE attackedStruct;
private BASEOBJ attacker;
private STRUCTURE newDroidFactory;
// temporary variables
private DROID newDroid;
private INT moveX,moveY;
private INT xdiff,ydiff;
private INT ld; //default leadership for enemy2
/* values for build lists start here */
/* General Values */
public int player;
public int enemy1;
public int enemy2;
public int enemy1Tot; //limit build to this number
public int enemy2Tot; //limit build to this number
public int pow1, pow2; //starting power
/* Enemy Tactics */
public TEMPLATE trike;
public TEMPLATE buggy;
public TEMPLATE bloke;
public TEMPLATE jeep;
/* enemy1 */
public STRUCTURE enm0;
public STRUCTUREID enm0ID;
public int enm0Ass1X, enm0Ass1Y;
private int enm0Fact1State;
private bool enm0Fact1Destroyed;
public STRUCTURE enm1;
public STRUCTUREID enm1ID;
public int enm1Ass1X, enm1Ass1Y;
public int enm1Ret1X, enm1Ret1Y;
public int enm1Ret2X, enm1Ret2Y;
private int enm1Fact1State;
private bool enm1Fact1Destroyed;
/* enemy2 */
public STRUCTURE enm2;
public STRUCTUREID enm2ID;
public int enm2Ass1X, enm2Ass1Y;
public int enm2Ret1X, enm2Ret1Y;
public int enm2Ret2X, enm2Ret2Y;
private int enm2Fact1State, atkTot;
private bool enm2Fact1Destroyed;
/* hill attack */
public int hillX[4], hillY[4], hillNum;
private int temp;
trigger enemy1AttackPause( every, 3000 ); //5 mins
/* triggers for build lists start here */
/* Triggers: Enemy Tactics */
trigger enm0Fact1Trig(every,400); //40 second build rate
//no start trigger for hill factory, produces from start of level!
//trigger enm1Start1Trig(droidInRange(player, enm1.x, enm1.y, 2000),10);
trigger enm1Start1Trig(droidInArea(player, 4032, 8000, 5440, 9024),10); //firing range of bunkers
trigger enm1Fact1Trig(every,400); //40 second build rate
trigger attackPlayer1Trig(wait, 1800); //wait 3 mins before building for attack
//trigger enm2Start1Trig(droidInRange(player, enm2.x, enm2.y, 2000),10);
//trigger enm2Start1Trig(droidInArea(player, 320, 11712, 6720, 13120),10); //cross south of radar hill
trigger enm2Start1Trig(droidInArea(player, 320, 9792, 6720, 13120),10); //at 1st base?
trigger enm2Fact1Trig(every,400); //40 second build rate
trigger attackPlayer2Trig(wait, 3600); //wait 6 mins before building for attack
trigger hillAttackTrig(every, 200); //20 second delay between hill attacks, keep moving
// event prototypes
event enemy1AttackBase;
event startup(CALL_GAMEINIT)
{
atkTot = 4; //set number req'd for player base attack
//setassembly points here, since can't do later in case factory destroyed!!
setAssemblyPoint (enm0, enm0Ass1X, enm0Ass1Y);
setAssemblyPoint (enm1, enm1Ass1X, enm1Ass1Y);
setAssemblyPoint (enm2, enm2Ass1X, enm2Ass1Y);
//set up of positions now done in VLO
//make scavengers allies
createAlliance(enemy1, enemy2);
// whether the oil well has been cleared
oilWellClear = FALSE;
//set starting power
setPowerLevel(pow1, enemy1);
setPowerLevel(pow2, enemy2);
ld=75; //enemy2 leadership (change to higher when fixed!)
//make all droids left part of build group
// groupAddArea(enemy1Start, enemy1, 128, 7744, 7744, 16000);
// groupAddGroup(enemy1Build, enemy1Start);
// groupAddArea(enemy2Start, enemy2, 128, 7744, 7744, 16000);
// groupAddGroup(enemy2Build, enemy2Start);
//make up starting forces
groupAddArea(enemy1Force1, enemy1, 4288, 9024, 5568, 9920);
groupAddArea(enemy1Force2, enemy1, 1600, 10048, 2624, 10816);
//set retreat point
setGroupRetreatPoint(enemy1Force1, enm1Ret1X, enm1Ret1Y); //retreat to road block
setGroupRetreatForce(enemy1Force1, 90); //set morale to 10%
setGroupRetreatLeadership(enemy1Force1, 50); //set leadership chance (small=more likely?)
setGroupRetreatPoint(enemy1Force2, enm1Ret1X, enm1Ret1Y); //retreat to road block
setGroupRetreatForce(enemy1Force2, 90); //set morale to 10%
setGroupRetreatLeadership(enemy1Force2, 50); //set leadership chance (small=more likely?)
//set retreat point enemy2
setRetreatPoint(enemy2, enm2Ret1X, enm2Ret1Y); //retreat to base2
setRetreatForce(enemy2, 75); //set morale to 25%
setRetreatLeadership(enemy2, ld); //set leadership chance (small=more likely?)
//start hill attack
groupAddArea(hillGroup, enemy2, 1088, 8891, 1600, 9536);
temp = random(hillNum);
orderGroupLoc(hillGroup, DORDER_MOVE, hillX[temp],hillY[temp]);
}
// deal with a droid being built by enemy1
event enemy1build(CALL_NEWDROID, enemy1, ref newDroid,ref newDroidFactory)
{
// see if there are any enemy droids near the base
if (droidInRange(player, enm1Ass1X, enm1Ass1Y, 9 * 128))
{
//set Morale to stubborn
setRetreatPoint(enemy1, enm1Ret2X, enm1Ret2Y); //retreat to base
setRetreatForce(enemy1, 75); //set morale to 75%
setRetreatLeadership(enemy1, 50); //set leadership chance (small=more likely?)
groupAddDroid(enemy1Attack, newDroid);
// get all the droids back to base
orderGroupLoc(enemy1Attack, DORDER_SCOUT, enm1Ass1X, enm1Ass1Y);
}
else
{
groupAddDroid(enemy1Build, newDroid);
if (enemy1Build.members >= 4)
{
groupAddGroup(enemy1Attack, enemy1Build);
if (droidInRange(player, rBlkX,rBlkY, 8 * 128))
{
// in the canyon go get em
moveX = rBlkX; moveY = rBlkY;
}
else
{
// go attack the base
moveX = playerX;
moveY = playerY;
}
orderGroupLoc(enemy1Attack, DORDER_SCOUT, moveX,moveY);
}
}
}
// send the droids to the player base if there is nothing at
// the oil derek
event enemy1AttackBase( inactive )
{
if (not objectInRange(player, oilPatchX, oilPatchY, 8*128))
{
orderGroupLoc(enemy1Attack, DORDER_SCOUT, playerX,playerY);
orderGroupLoc(enemy2Attack, DORDER_SCOUT, playerX,playerY);
oilWellClear = TRUE;
}
else
{
oilWellClear = FALSE;
}
}
// deal with a droid being built by enemy2
event enemy2build(CALL_NEWDROID, enemy2, ref newDroid,ref newDroidFactory)
{
if (newDroidFactory == enm2) //only for southern factory!
{
// see if there are any player droids near enemy2 base1 (protect base!)
if (droidInRange(player, enm2Ass1X, enm2Ass1Y, 9 * 128)) //9 squares of assembly point
{
groupAddDroid(enemy2Attack, newDroid);
//Set Morale to stubborn
setRetreatPoint(enemy2, enm2Ret2X, enm2Ret2Y); //retreat to base2
setRetreatForce(enemy2, 75); //set morale to 75%
setRetreatLeadership(enemy2, ld); //set leadership chance (small=more likely?)
// get all the droids back to base
orderGroupLoc(enemy2Attack, DORDER_SCOUT, enm2Ass1X, enm2Ass1Y);
}
else
{
groupAddDroid(enemy2Build, newDroid);
if (enemy2Build.members >= atkTot)
{
atkTot = atkTot + 1; //increase for next attack!
groupAddGroup(enemy2Attack, enemy2Build);
//set Morale low
setRetreatPoint(enemy2, enm2Ret2X, enm2Ret2Y); //retreat to base2
setRetreatForce(enemy2, 75); //set morale to 25%
setRetreatLeadership(enemy2, ld); //set leadership chance (small=more likely?)
/* don't bother now on SCOUT orders!!!
if (droidInRange(player, rBlkX,rBlkY, 8 * 128))
{
// in the canyon go get em
moveX = rBlkX; moveY = rBlkY;
}
else
{
// go attack the base
moveX = playerX;
moveY = playerY;
}
*/
// go attack the base
moveX = playerX;
moveY = playerY;
orderGroupLoc(enemy2Attack, DORDER_SCOUT, moveX,moveY);
}
}
}
}
event hillGroupEvnt(hillAttackTrig)
{
//group around assembly point (always, so limit how many built)
//groupAddArea(hillGroup, enemy2, 1088, 8891, 1600, 9536);
groupAddArea(hillGroup, enemy2, 960, 8640, 1984, 9664);
}
event hillAttackEvnt(hillAttackTrig)
{
//order to random cliff edge hillX, hillY
temp = random(4);
orderGroupLoc(hillGroup, DORDER_MOVE, hillX[temp],hillY[temp]);
}
/* events for build lists start here */
/* Enemy 1 */
//build list
event enm0Fact1Evnt(enm1Fact1Trig)
{
enm0Fact1Destroyed = buildingDestroyed (enm0ID, enemy2);
if (enm0Fact1Destroyed)
{
setEventTrigger(enm0Fact1Evnt, inactive);
}
else if (structureIdle(enm0) and (hillGroup.members <= 10)) //limit total to 10?
{
if (enm0Fact1State == 0)
{
buildDroid (bloke, enm0, enemy2, 2); //produce blokes until other base attacked
//enm0Fact1State = 1;
}
else if (enm0Fact1State == 1)
{
buildDroid (trike, enm0, enemy2, 1);
enm0Fact1State = 2;
}
else if (enm0Fact1State == 2)
{
buildDroid (buggy, enm0, enemy2, 1);
enm0Fact1State = 3;
}
else
{
buildDroid (bloke, enm0, enemy2, 2);
enm0Fact1State = 1;
}
}
}
event enm1Fact1Evnt(inactive)
{
enm1Fact1Destroyed = buildingDestroyed (enm1ID, enemy1);
if (enm1Fact1Destroyed)
{
//get hill factory to change production from blokes to vehicles
//and turn off random attack stuff?
enm0Fact1State = 1;
orderGroupLoc(hillGroup, DORDER_MOVE, enm0Ass1X, enm0Ass1Y); //protect base
setEventTrigger(hillAttackEvnt, inactive);
setEventTrigger(enm1Fact1Evnt, inactive);
}
else if (structureIdle(enm1) and (enemy1Build.members+enemy1Attack.members)<enemy1Tot)
{
if (enm1Fact1State == 0)
{
buildDroid (trike, enm1, enemy1, 1);
enm1Fact1State = 1;
}
else if (enm1Fact1State == 1)
{
buildDroid (bloke, enm1, enemy1, 2);
enm1Fact1State = 2;
}
else if (enm1Fact1State == 2)
{
buildDroid (buggy, enm1, enemy1, 1);
enm1Fact1State = 3;
}
else
{
buildDroid (bloke, enm1, enemy1, 2);
enm1Fact1State = 0;
}
}
}
event enm1Start1Evnt(enm1Start1Trig)
{
//set Morale to low
setRetreatPoint(enemy1, enm1Ret2X, enm1Ret2Y); //retreat to base
setRetreatForce(enemy1, 75); //set morale to 75%
setRetreatLeadership(enemy1, 50); //set leadership chance (small=more likely?)
//order guys around bunker to get into position behind when player near
orderGroupLoc(enemy1Force1, DORDER_SCOUT, rBlkX, rBlkY);
buildDroid (buggy, enm1, enemy1, 1); //build first ones so AI triggered
setEventTrigger(enm1Fact1Evnt, enm1Fact1Trig);
setEventTrigger(enm1Start1Evnt, inactive);
}
/* Enemy 2 */
//build list
event enm2Fact1Evnt(inactive)
{
enm2Fact1Destroyed = buildingDestroyed (enm2ID, enemy2);
if (enm2Fact1Destroyed)
{
setEventTrigger(enm2Fact1Evnt, inactive);
}
else if (structureIdle(enm2) and (enemy2Build.members+enemy2Attack.members)<enemy2Tot)
{
if (enm2Fact1State == 0)
{
buildDroid (trike, enm2, enemy2, 1);
enm2Fact1State = 1;
}
else if (enm2Fact1State == 1)
{
buildDroid (bloke, enm2, enemy2, 3);
enm2Fact1State = 2;
}
else if (enm2Fact1State == 2)
{
buildDroid (buggy, enm2, enemy2, 1);
enm2Fact1State = 3;
}
else
{
buildDroid (jeep, enm2, enemy2, 1);
enm2Fact1State = 0;
}
}
}
event enm2Start1Evnt(enm2Start1Trig)
{
//build first ones to Trigger AI
buildDroid (trike, enm2, enemy2, 1);
setEventTrigger(enm2Fact1Evnt, enm2Fact1Trig);
setEventTrigger(enm2Start1Evnt, inactive);
}
event enemy1Atk1(every, 20)
{
if (enm1Fact1Destroyed)
{
//order guys around village to attack player near enemy1 base when factory destroyed
orderGroupLoc(enemy1Force2, DORDER_SCOUT, rBlkX, rBlkY);
setEventTrigger(enemy1Atk1, inactive);
}
}
event lastAttack1(every, 50)
{
//make enemy easier to find if all his buildings destroyed
if (not anyStructButWallsLeft(enemy1))
{
groupAddArea(enemy1Fin, enemy1, 0, 0, 8191, 16383);
orderGroupLoc(enemy1Fin, DORDER_SCOUT, enm1Ass1X, enm1Ass1Y);
//setEventTrigger(lastAttack1, inactive);
}
}
event lastAttack2(every, 50)
{
//make enemy easier to find if all his buildings destroyed
if (not anyStructButWallsLeft(enemy2))
{
groupAddArea(enemy2Fin, enemy2, 0, 0, 8191, 16383);
orderGroupLoc(enemy2Fin, DORDER_SCOUT, enm2Ass1X, enm2Ass1Y);
//setEventTrigger(lastAttack2, inactive);
}
}
//Timed attacks if player dawdles
event attackPlayer1(attackPlayer1Trig)
{
setEventTrigger(enm1Fact1Evnt, enm1Fact1Trig);
setEventTrigger(attackPlayer1, inactive);
}
event attackPlayer2(attackPlayer2Trig)
{
setEventTrigger(enm2Fact1Evnt, enm2Fact1Trig);
setEventTrigger(attackPlayer2, inactive);
}