ADemo3

From OPU Wiki


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

See also:

ADemo3.cpp


/*

File:        ADemo3.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 #3";
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
};


UnitRecord enemy[]=
{
  { mapLynx, 68,30,0,orW, mapRailGun,    16,0,0 },
  { mapLynx, 72,30,0,orW, mapRailGun,    16,0,0 },
  { mapTiger,70,30,0,orW, mapThorsHammer,16,0,0 },
  { mapLynx, 57,45,0,orW, mapRailGun,    16,0,0 },
  { mapLynx, 57,47,0,orW, mapRailGun,    16,0,0 },
  { mapLynx, 57,49,0,orW, mapRailGun,    16,0,0 },

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

// this MAP_RECT is used in Setup for fGrp

MAP_RECT rect(61,38,73,52);

// the attacking fight group
// stored globally, so it can be accessed anywhere in the code

FightGroup fGrp;

// the spaceport structure
// stored globally, so it can be accessed anywhere in the code

Unit spaceport;

Trigger trigSpace;

// this UnitBlock is EXPORTED (=can be accessed from outside this DLL)
// to access it, use it exactly as typed (including Capitals)

EXPORT UnitBlock Group1(enemy); 


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

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



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

EXPORT void BuildIt()
{
  // instruct the spaceport to build an EMP missile
  spaceport.DoDevelop(mapEMPMissile);

  // call "LaunchIt" every 30 ticks
  // the second param=0 means indefinately
  // save the returned trigger, so we can disable it later
  trigSpace=CreateTimeTrigger(1,0,30,"LaunchIt");
}

EXPORT void LaunchIt()
{
  // check if spaceport is done building the missile
  if (!spaceport.IsBusy())
  {
    // prevent trigger from being called again
    trigSpace.Disable();

    // launch the missile
    spaceport.DoLaunch(0,0,0);
  }
}

EXPORT void Towers_Gone()
{
  // have them attack the spaceport now
  fGrp.SetAttackType(mapSpaceport);
}

void Setup()
{
  Unit u;

  // some tubes to connect the base buildings
  TethysGame::CreateWallOrTube(71,43,2,mapTube);
  TethysGame::CreateWallOrTube(73,45,2,mapTube);

  // create base
  TethysGame::CreateUnit(u,mapCommandCenter,LOCATION(73,43),2,mapNone,0);
  TethysGame::CreateUnit(u,mapAdvancedLab,LOCATION(73,47),2,mapNone,0);
  TethysGame::CreateUnit(u,mapMHDGenerator,LOCATION(67,52),2,mapNone,0);
  TethysGame::CreateUnit(u,mapCommonStorage,LOCATION(76,43),2,mapNone,0);
  TethysGame::CreateUnit(u,mapRareStorage,LOCATION(78,43),2,mapNone,0);

  // create guardposts
  TethysGame::CreateUnit(u,mapGuardPost,LOCATION(62,49),2,mapRailGun,0);
  TethysGame::CreateUnit(u,mapGuardPost,LOCATION(62,45),2,mapRailGun,0);
  TethysGame::CreateUnit(u,mapGuardPost,LOCATION(68,39),2,mapRailGun,0);
  TethysGame::CreateUnit(u,mapGuardPost,LOCATION(73,39),2,mapRailGun,0);
  TethysGame::CreateUnit(u,mapGuardPost,LOCATION(70,52),2,mapRailGun,0);
  TethysGame::CreateUnit(u,mapGuardPost,LOCATION(73,52),2,mapRailGun,0);

  // create the space port
  TethysGame::CreateUnit(spaceport,mapSpaceport,LOCATION(67,46),2,mapNone,0);

  // and connect it
  TethysGame::CreateWallOrTube(71,46,2,mapTube);

  // create attackers
  fGrp=CreateFightGroup(Player[1]);
  fGrp.DoAttackEnemy();
  fGrp.SetRect(rect);
  fGrp.SetAttackType(mapGuardPost);
  fGrp.AddUnits(Group1);
  fGrp.SetLights(1);
}


// ----------------------
// == 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();

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

  // set initial stuff
  Player[2].SetOre(9000);
  Player[2].SetRareOre(5000);
  Player[2].SetFoodStored(4000);
  Player[2].SetWorkers(35);
  Player[2].SetScientists(27);
  Player[2].SetKids(38);

  // set level 3 technologies
  Player[2].MarkResearchComplete(3000);
  Player[2].MarkResearchComplete(techHighTemperatureSuperconductivity);

  // set level 5 technologies
  Player[2].MarkResearchComplete(5000);
  Player[2].MarkResearchComplete(techAdvancedLab);
  Player[2].MarkResearchComplete(techIndependentTurretPowerSystems);
  Player[2].MarkResearchComplete(techHeatDissipationSystemsPlymouth);

  // set level 8 technologies
  Player[2].MarkResearchComplete(8000);
  Player[2].MarkResearchComplete(techEfficiencyEngineeringEden);

  Setup();

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

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

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

  // wait 65 ticks, then call "BuildIt"
  CreateTimeTrigger(1,1,65,"BuildIt");

  // wait until player2 has no more guardposts, then call "Towers_Gone"
  CreateCountTrigger(1,1,2,mapGuardPost,mapNone,0,cmpEqual,"Towers_Gone");

  return 1;
}

Personal tools