ADemo2

From OPU Wiki

(Redirected from Ademo2.dll)


Below is a source file that, when compiled, will create the "mission" ADemo2.dll

See also:

ADemo2.cpp


/*

File:        ADemo2.cpp
Author:      Dynamix/Sierra Online
Description: Original AutoDemo file

Source extracted by Eddy-B

*/

#include <windows.h>
#include "Outpost2DLL.h"



#define EXPORT extern "C" __declspec(dllexport)

EXPORT char MapName[]      = "eden04.map";
EXPORT char LevelDesc[]    = "AutoDemo Mission #2"; 
EXPORT char TechtreeName[] = "PLY_TEK.TXT";
EXPORT SDescBlock DescBlock= { AutoDemo, 3, 8, false };


// Orientation constants for use with UnitRecords
// the values inbetween can also be used; eg. 0x10= ESE

enum Orientation
{
  orE  =0x00,
  orSE =0x20,
  orS  =0x40,
  orSW =0x60,
  orW  =0x80,
  orNW =0xA0,
  orN  =0xC0,
  orNE =0xE0
};



// a UnitRecord is a set of units (buildings and/or vehicles)
// that are predefined, and can be used mroe then once.
// to create them, use a UnitBlock (see below)

UnitRecord units1[]=
{
  { mapLynx,      69,16,0,orW, mapLaser,    16,0,0 },
  { mapLynx,      69,19,0,orW, mapLaser,    16,0,0 },
  { mapCargoTruck,71,18,0,orW, mapNone,     16,0,0 },
  { mapCargoTruck,73,18,0,orW, mapNone,     16,0,0 },
  { mapCargoTruck,75,18,0,orW, mapNone,     16,0,0 },
  { mapLynx,      77,16,0,orW, mapLaser,    16,0,0 },

  // a line of zeroes ends the list
  { mapNone,       0, 0,0,  0, mapNone,      0,0,0 }
};

UnitRecord units2[]=
{
  { mapLynx,      65,10,0,orN, mapEMP,      16,0,0 },
  { mapLynx,      67,10,0,orN, mapEMP,      16,0,0 },
  { mapLynx,      69,10,0,orN, mapEMP,      16,0,0 },
  { mapSpider,    63,10,0,orE, mapNone,     16,0,0 },
  { mapSpider,    66,10,0,orE, mapNone,     16,0,0 },
  { mapSpider,    70,10,0,orE, mapNone,     16,0,0 },
  { mapSpider,    68,25,0,orE, mapNone,     16,0,0 },
  { mapSpider,    69,25,0,orE, mapNone,     16,0,0 },
  { mapSpider,    64,25,0,orE, mapNone,     16,0,0 },

  // a line of zeroes ends the list
  { mapNone,       0, 0,0,  0, mapNone,      0,0,0 }
};

UnitRecord units3[]=
{
  { mapLynx,      60,15,0,orN, mapMicrowave,16,0,0 },
  { mapLynx,      59,16,0,orN, mapMicrowave,16,0,0 },
  { mapLynx,      60,19,0,orN, mapMicrowave,16,0,0 },

  // a line of zeroes ends the list
  { mapNone,       0, 0,0,  0, mapNone,      0,0,0 }
};

// these MAP_RECTs are used in SetupGroups

MAP_RECT rect1(32,16,34,18);
MAP_RECT rect2(80,16,82,18);

// the attacking fight groups
// stored globally, so they can be accessed anywhere in the code

FightGroup fGrp1,fGrp2;

// these UnitBlocks are EXPORTED (=can be accessed from outside this DLL)
// to access them, use them exactly as typed (including Capitals)

EXPORT UnitBlock Group1(units1);
EXPORT UnitBlock Group2(units2);
EXPORT UnitBlock Group3(units3);


// ------------------------
// == Module entry point ==
// ------------------------

BOOL APIENTRY DllMain(HANDLE,DWORD,LPVOID)
{
  return TRUE;
}



// ---------------------
// == Other functions ==
// ---------------------

EXPORT void LightsOn()
{
  // turn on attacker's lights
  fGrp1.SetLights(1);
  fGrp2.SetLights(1);
}

EXPORT void LightsOn2()
{
  // turn on attacker's "default group" light
  ScGroup grp=Player[2].GetDefaultGroup();
  grp.SetLights(1);
}

// create the 3 fight groups
void SetupGroups()
{
  FightGroup grp;

  // create the targets
  // these are laser lynx and a few cargo trucks
  grp=CreateFightGroup(Player[1]);
  grp.DoGuardRect();        // the lynx will guard rect1
  grp.SetRect(rect1);
  grp.AddUnits(Group1);
  grp.SetLights(1);

  // create 1 fight group that targets the trucks
  // this group contains the EMP lynx and the spiders
  fGrp1=CreateFightGroup(Player[2]);
  fGrp1.DoAttackEnemy();    // attack closest enemy
  fGrp1.SetRect(rect2);     // when no more enemies, move to rect2
  fGrp1.SetAttackType(mapCargoTruck);
  fGrp1.AddUnits(Group2);

  // create a second group that targets the enemy lynx
  // this group contains only microwave lynx
  fGrp2=CreateFightGroup(Player[2]);
  fGrp2.DoAttackEnemy();
  fGrp2.SetRect(rect2);
  fGrp2.SetAttackType(mapLynx);
  fGrp2.AddUnits(Group3);

  // "DefaultGroup" is the group in which all captured units will be put
  // these 2 lines will send all captured units towards rect2
  grp=*((FightGroup *)&(Player[2].GetDefaultGroup()));
  grp.SetRect(rect2);

  // the following 3 lines are not found in the original code
  // it's safe to assume Dynamix coders just forgot about them
  // turn off the lights of the attack groups
  fGrp1.SetLights(0);
  fGrp2.SetLights(0);

  // turn off the attacker's "default group" lights
  grp.SetLights(0);
}



// ----------------------
// == Required exports ==
// ----------------------

EXPORT void AIProc()
{
}

EXPORT int  StatusProc()
{
  return 0;
}

EXPORT void NoResponseToTrigger()
{
}



// --------------
// == InitProc ==
// --------------

EXPORT int InitProc()
{
  // Player[0] is the human player; Player[1] is the first "AI" player
  Player[0].GoPlymouth();
  Player[1].GoEden();
  Player[2].GoPlymouth();

  SetupGroups();

  // this is a demo. make sure we can see everything
  Player[0].CenterViewOn(65,16);

  // make everything dark
  TethysGame::SetDaylightEverywhere(0);

  // disable cheats (they don't work anyway)
  TethysGame::SetCheatFastUnits(0);
  TethysGame::SetCheatFastProduction(0);
  TethysGame::SetCheatUnlimitedResources(0);
  TethysGame::SetCheatProduceAll(0);

  // wait 900 ticks (=9 marks), then call the VictoryCondition
  Trigger trig=CreateTimeTrigger(1,1,900,"NoResponseToTrigger");
  CreateVictoryCondition(1,1,trig,
    "    Outpost 2 demo mode.\n\nPress any key to return to the Main Menu.");

  CreateTimeTrigger(1,1,80,"LightsOn");

  CreateTimeTrigger(1,1,700,"LightsOn2");

  return 1;
}

Personal tools