370 lines
9.8 KiB
Plaintext
370 lines
9.8 KiB
Plaintext
/*
|
|
* Cam1-2-AI.slo
|
|
*
|
|
* Opposition AI
|
|
*
|
|
*/
|
|
|
|
|
|
// enemy1 variables
|
|
private GROUP enemy1Build, enemy1Attack, enemy1Start, enemy1Fin, enemy1Force1, enemy1Force2;
|
|
private GROUP enemy2Build, enemy2Attack, enemy2Start, enemy2Fin, enemy2Force1, enemy2Force2;
|
|
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;
|
|
|
|
/* Enemy Tactics */
|
|
public TEMPLATE trike;
|
|
public TEMPLATE buggy;
|
|
public TEMPLATE bloke;
|
|
public TEMPLATE jeep;
|
|
public TEMPLATE rktJeep;
|
|
|
|
/* enemy1 */
|
|
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;
|
|
private bool enm2Fact1Destroyed;
|
|
|
|
trigger enemy1AttackPause( every, 3000 ); //5 mins
|
|
|
|
/* triggers for build lists start here */
|
|
/* Triggers: Enemy Tactics */
|
|
trigger enm1Start1Trig(droidInRange(player, enm1.x, enm1.y, 2000),10);
|
|
trigger enm1Fact1Trig(every,150);
|
|
|
|
//trigger enm2Start1Trig(droidInRange(player, enm2.x, enm2.y, 2000),10);
|
|
trigger enm2Start1Trig(wait, 300); //triggered after 30 seconds
|
|
trigger enm2Fact1Trig(every,100);
|
|
|
|
// event prototypes
|
|
event enemy1AttackBase;
|
|
|
|
|
|
event startup(init)
|
|
{
|
|
//setass here since factory might be dead if done later!!!
|
|
setAssemblyPoint (enm1, enm1Ass1X, enm1Ass1Y);
|
|
setAssemblyPoint (enm2, enm2Ass1X, enm2Ass1Y);
|
|
|
|
//set up of positions now done in VLO
|
|
|
|
// whether the oil well has been cleared
|
|
oilWellClear = FALSE;
|
|
ld=75; //enemy2 leadership (change to higher when fixed!)
|
|
//set retreat stuff for non grouped units
|
|
setRetreatPoint(enemy1, enm1Ret1X, enm1Ret1Y); //retreat to base1 by rocket pit
|
|
setRetreatForce(enemy1, 50); //set morale to 50%
|
|
setRetreatLeadership(enemy1, 50); //set leadership chance (small=more likely?)
|
|
|
|
//make up starting forces
|
|
//groupAddArea(enemy1Force1, enemy1, 4288, 9024, 5568, 9920);
|
|
//groupAddArea(enemy1Force2, enemy1, 1600, 10048, 2624, 10816);
|
|
//groupAddArea(enemy1Force1, enemy1, 448, 960, 1472, 1728); //lots of blokes round back
|
|
groupAddArea(enemy1Force1, enemy1, 2496, 5824, 3136, 6336); //4 Jeeps (West door)
|
|
//set retreat point
|
|
setGroupRetreatPoint(enemy1Force1, enm1Ret1X, enm1Ret1Y); //retreat to base1 by rocket pit
|
|
setGroupRetreatForce(enemy1Force1, 80); //set morale to 10%
|
|
setGroupRetreatLeadership(enemy1Force1, 50); //set leadership chance (small=more likely?)
|
|
|
|
|
|
//groupAddArea(enemy1Force2, enemy1, 5312, 960, 6336, 1984); //lots of blokes near base1
|
|
groupAddArea(enemy1Force2, enemy1, 3904, 4032, 5312, 4928); //4 Jeeps 2 blokes (east door)
|
|
|
|
//set retreat point enemy2
|
|
setGroupRetreatPoint(enemy1Force2, enm2Ret1X, enm2Ret1Y); //retreat to base2
|
|
setGroupRetreatForce(enemy1Force2, 75); //set morale to 25%
|
|
setGroupRetreatLeadership(enemy1Force2, ld); //set leadership chance (small=more likely?)
|
|
|
|
}
|
|
|
|
|
|
// deal with a droid being built by enemy1
|
|
event enemy1build(CALL_NEWDROID, enemy1, ref newDroid, ref newDroidFactory)
|
|
{
|
|
if (newDroidFactory == enm1) //and (idleGroup(enemy1Force1) >= enemy1Force1.members/2)) //only for 1st factory and idle
|
|
{
|
|
// see if there are any enemy droids near the base
|
|
if (droidInRange(player, enm1Ass1X, enm1Ass1Y, 9 * 128))
|
|
{
|
|
//set Morale to stubborn
|
|
setGroupRetreatPoint(enemy1Force1, enm1Ret2X, enm1Ret2Y); //retreat to base
|
|
//setRetreatForce(enemy1, 50); //set morale to 50%
|
|
//setRetreatLeadership(enemy1, 50); //set leadership chance (small=more likely?)
|
|
groupAddDroid(enemy1Force1, newDroid);
|
|
// get all the droids back to base
|
|
orderGroupLoc(enemy1Force1, DORDER_SCOUT, enm1Ass1X, enm1Ass1Y);
|
|
}
|
|
else
|
|
{
|
|
groupAddDroid(enemy1Build, newDroid);
|
|
if (enemy1Build.members >= 4)
|
|
{
|
|
groupAddGroup(enemy1Force1, enemy1Build);
|
|
if (droidInRange(player, rBlkX,rBlkY, 8 * 128))
|
|
{
|
|
// in the canyon go get em
|
|
moveX = rBlkX; moveY = rBlkY;
|
|
}
|
|
else
|
|
{
|
|
if (oilWellClear)
|
|
{
|
|
// go attack the base
|
|
moveX = playerX;
|
|
moveY = playerY;
|
|
}
|
|
else
|
|
{
|
|
// go and have a look at the derek
|
|
moveX = oilPatchX; moveY = oilPatchY;
|
|
//setEventTrigger(enemy1AttackBase, enemy1AttackPause);
|
|
}
|
|
|
|
}
|
|
|
|
orderGroupLoc(enemy1Force1, 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(enemy1Force1, 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) // and (idleGroup(enemy1Force2) >= enemy1Force2.members/2)) //only for 2nd factory and group idle
|
|
{
|
|
// see if there are any player droids near enemy2 base1
|
|
if (droidInRange(player, enm2Ass1X, enm2Ass1Y, 9 * 128))
|
|
{
|
|
groupAddDroid(enemy1Force2, newDroid);
|
|
//Set Morale to stubborn
|
|
setGroupRetreatPoint(enemy1Force2, enm2Ret2X, enm2Ret2Y); //retreat to base2
|
|
//setRetreatForce(enemy2, 50); //set morale to 50%
|
|
//setRetreatLeadership(enemy2, ld); //set leadership chance (small=more likely?)
|
|
|
|
// get all the droids back to base
|
|
orderGroupLoc(enemy1Force2, DORDER_SCOUT, enm2Ass1X, enm2Ass1Y);
|
|
}
|
|
else
|
|
{
|
|
groupAddDroid(enemy2Build, newDroid);
|
|
|
|
if (enemy2Build.members >= 4)
|
|
{
|
|
groupAddGroup(enemy1Force2, 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?)
|
|
|
|
if (droidInRange(player, rBlkX,rBlkY, 8 * 128))
|
|
{
|
|
// in the canyon go get em
|
|
moveX = rBlkX; moveY = rBlkY;
|
|
}
|
|
else
|
|
{
|
|
if (oilWellClear)
|
|
{
|
|
// go attack the base
|
|
moveX = playerX;
|
|
moveY = playerY;
|
|
}
|
|
else
|
|
{
|
|
// go and have a look at the derek
|
|
moveX = oilPatchX; moveY = oilPatchY;
|
|
setEventTrigger(enemy1AttackBase, enemy1AttackPause);
|
|
}
|
|
}
|
|
orderGroupLoc(enemy1Force2, DORDER_SCOUT, moveX,moveY);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* events for build lists start here */
|
|
/* Enemy 1 */
|
|
//build list
|
|
event enm1Fact1Evnt(inactive)
|
|
{
|
|
enm1Fact1Destroyed = buildingDestroyed (enm1ID, enemy1);
|
|
if (enm1Fact1Destroyed)
|
|
{
|
|
setEventTrigger(enm1Fact1Evnt, inactive);
|
|
}
|
|
else if (structureIdle(enm1) and (enemy1Build.members+enemy1Force1.members)<enemy1Tot)
|
|
{
|
|
if (enm1Fact1State == 0)
|
|
{
|
|
buildDroid (bloke, enm1, enemy1, 3);
|
|
enm1Fact1State = 1;
|
|
}
|
|
else if (enm1Fact1State == 1)
|
|
{
|
|
buildDroid (buggy, enm1, enemy1, 3);
|
|
enm1Fact1State = 2;
|
|
}
|
|
else if (enm1Fact1State == 2)
|
|
{
|
|
buildDroid (jeep, enm1, enemy1, 2);
|
|
enm1Fact1State = 3;
|
|
}
|
|
else
|
|
{
|
|
buildDroid (rktJeep, 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 25%
|
|
//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, playerX, playerY);
|
|
|
|
buildDroid (bloke, enm1, enemy1, 3); //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+enemy1Force2.members)<enemy2Tot)
|
|
{
|
|
|
|
if (enm2Fact1State == 0)
|
|
{
|
|
buildDroid (bloke, enm2, enemy2, 3);
|
|
enm2Fact1State = 1;
|
|
}
|
|
else if (enm2Fact1State == 1)
|
|
{
|
|
buildDroid (buggy, enm2, enemy2, 2);
|
|
enm2Fact1State = 2;
|
|
}
|
|
else if (enm2Fact1State == 2)
|
|
{
|
|
buildDroid (jeep, enm2, enemy2, 1);
|
|
enm2Fact1State = 3;
|
|
}
|
|
else
|
|
{
|
|
buildDroid (rktJeep, enm2, enemy2, 1);
|
|
enm2Fact1State = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
event enm2Start1Evnt(enm2Start1Trig)
|
|
{
|
|
|
|
//build first ones to Trigger AI
|
|
buildDroid (trike, enm2, enemy2, 1);
|
|
orderGroupLoc(enemy1Force2, DORDER_SCOUT, playerX, playerY);
|
|
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 (enm1Fact1Destroyed) //(not anyStructButWallsLeft(enemy1))
|
|
{
|
|
groupAddArea(enemy1Fin, enemy1, 0, 0, 64*128, 64*128);
|
|
//go to LZ if base dead
|
|
orderGroupLoc(enemy1Fin, DORDER_SCOUT, 52*128, 55*128);
|
|
//setEventTrigger(lastAttack1, inactive);
|
|
}
|
|
}
|
|
|
|
event lastAttack2(every, 50)
|
|
{
|
|
//make enemy easier to find if all his buildings destroyed
|
|
if (not anyStructButWallsLeft(enemy2))
|
|
{
|
|
groupAddArea(enemy2Fin, enemy1, 0, 0, 64*128, 64*128);
|
|
orderGroupLoc(enemy2Fin, DORDER_SCOUT, 52*128, 55*128);
|
|
//setEventTrigger(lastAttack2, inactive);
|
|
}
|
|
}
|