Outpost Universe Forums

Projects & Development => Outpost 2 Programming & Development => Topic started by: spirit1flyer on February 22, 2006, 12:08:03 AM

Title: Hardness Levels?
Post by: spirit1flyer on February 22, 2006, 12:08:03 AM
with the colony mission I just released as a beta, I was thinking it would be nice to set how many enemy attacks for the hardness level,
5 for easy 7 for normal and so on.

How do I do it?    
I have seen two types of code that talk about doing this but they are a little vague and I don't know how to use them can someone clarify for me?

spirit
Title: Hardness Levels?
Post by: Mcshay on February 22, 2006, 07:12:07 AM
Without any idea on how to do this either, but with an understanding c++, I think this outline might work:

Code: [Select]
if(Player[0].Difficulty() == 0)
{
  //Easy units go here
}

if(Player[0].Difficulty() == 1)
{
  //Normal units go here
}

if(Player[0].Difficulty() == 2)
{
  //Hard units go here
}

I'm assuming that Player[0].Difficulty() is the games difficulty.

The only problem is that I don't know if 0 really is easy, or if 1 really is normal, ect, there are no notes in the headers to explain difficulty.  
Title: Hardness Levels?
Post by: Sirbomber on February 22, 2006, 08:19:25 AM
0 = Easy(SP)/High Res(MP)
1 = Normal/Med Res
2 = Hard/Low Res
Title: Hardness Levels?
Post by: spirit1flyer on February 22, 2006, 10:32:59 AM
this might be able to do it in basedata but I am trying to get it to work for this code

Any idea how I can get that working?
I just tried the code you posted right above fightgroup grp1;  and that did not work


Code: [Select]
FightGroup grp1;

SCRIPT_API void CreateTanks1()
{
  Unit u;

  grp1=CreateFightGroup(Player[1]);
  grp1.SetRect(MAP_RECT(30,8,34,12));
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,2),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,3),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,1),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
   TethysGame::CreateUnit(u,mapLynx,LOCATION(158,1),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
}
SCRIPT_API void CreateTanks2()
{
  Unit u;

  grp1=CreateFightGroup(Player[1]);
  grp1.SetRect(MAP_RECT(30,8,34,12));
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,2),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,3),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapTiger,LOCATION(158,1),1,mapEMP,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
   TethysGame::CreateUnit(u,mapTiger,LOCATION(158,1),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
}
SCRIPT_API void CreateTanks3()
{
  Unit u;

  grp1=CreateFightGroup(Player[1]);
  grp1.SetRect(MAP_RECT(30,8,34,12));
  TethysGame::CreateUnit(u,mapPanther,LOCATION(158,2),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,3),1,mapStickyfoam,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapPanther,LOCATION(158,1),1,mapEMP,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
   TethysGame::CreateUnit(u,mapPanther,LOCATION(158,1),1,mapEMP,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
}


SCRIPT_API void Attack()
{
  grp1.DoAttackEnemy();
}
Title: Hardness Levels?
Post by: Mcshay on February 22, 2006, 11:43:59 AM
I don't get what you mean, but this should work:

Declare FightGroup grp1; below your DescBlock. Like so:

Code: [Select]

//Your descblock here!

FightGroup grp1;

Then, above IntProc, put this:

Code: [Select]
SCRIPT_API void CreateTanksWave1() // Wave 1
{
Unit u;

if(Player[0].Difficulty() == 0) // Wave 1: Easy
{
TethysGame::CreateUnit(u,mapLynx,LOCATION(158,2),1,mapMicrowave,SouthWest);
 grp1.TakeUnit(u);
 TethysGame::CreateUnit(u,mapLynx,LOCATION(158,3),1,mapMicrowave,SouthWest);
 grp1.TakeUnit(u);
 TethysGame::CreateUnit(u,mapLynx,LOCATION(158,1),1,mapMicrowave,SouthWest);
 grp1.TakeUnit(u);
 TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
 grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,1),1,mapMicrowave,SouthWest);
 grp1.TakeUnit(u);
 TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
 grp1.TakeUnit(u);
}

if(Player[0].Difficulty() == 1) // Wave 1: Normal
{
TethysGame::CreateUnit(u,mapLynx,LOCATION(158,2),1,mapMicrowave,SouthWest);
 grp1.TakeUnit(u);
 TethysGame::CreateUnit(u,mapLynx,LOCATION(158,3),1,mapMicrowave,SouthWest);
 grp1.TakeUnit(u);
 TethysGame::CreateUnit(u,mapTiger,LOCATION(158,1),1,mapEMP,SouthWest);
 grp1.TakeUnit(u);
 TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
 grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapTiger,LOCATION(158,1),1,mapMicrowave,SouthWest);
 grp1.TakeUnit(u);
 TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
 grp1.TakeUnit(u);
}

if(Player[0].Difficulty() == 2) // Wave 1: Hard
{
TethysGame::CreateUnit(u,mapPanther,LOCATION(158,2),1,mapMicrowave,SouthWest);
 grp1.TakeUnit(u);
 TethysGame::CreateUnit(u,mapLynx,LOCATION(158,3),1,mapStickyfoam,SouthWest);
 grp1.TakeUnit(u);
 TethysGame::CreateUnit(u,mapPanther,LOCATION(158,1),1,mapEMP,SouthWest);
 grp1.TakeUnit(u);
 TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
 grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapPanther,LOCATION(158,1),1,mapEMP,SouthWest);
 grp1.TakeUnit(u);
 TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
 grp1.TakeUnit(u);
}
}

And finaly, put this below the bases in IntProc:

Code: [Select]
grp1=CreateFightGroup(Player[1]);
grp1.SetRect(MAP_RECT(30,8,34,12));

CreateTimeTrigger(1, 1, 6000, "CreateTanksWave1"); // I think that should call the first wave at mark 60

Disclamer: I don't have a working compiler on this computer to test this code
Title: Hardness Levels?
Post by: Eddy-B on February 22, 2006, 11:50:00 AM
Okay..
i will teach you 1 more powerful C++ command:  switch

Syntax:
Code: [Select]
switch ( variable )
{
   case 1:
     // stuff ..
     break;

   case 2:
     // stuff ..
     break;

   case 3:
     // stuff ..
     break;
}
You can add as many case statements as you like - but the rules are:When a value is matched in 1 of the cases, the code from the case statement until the break statement is executed. Once it reaches break program execution will continue again at the end if the switch block.
If no default is used, a value that doesn't match any of the cases, won't execute any of the code.


In your case, you can make something like this:

Code: [Select]
SCRIPT_API void CreateTanks1()
{
  Unit u;

  grp1=CreateFightGroup(Player[1]);
  grp1.SetRect(MAP_RECT(30,8,34,12));


  // specific difficulties:
  switch ( Player[0].Difficulty )
  {
    case 0:   // easy
      TethysGame::CreateUnit(u,mapPanther,LOCATION(158,2),1,mapMicrowave,SouthWest);
      grp1.TakeUnit(u);
      TethysGame::CreateUnit(u,mapPanther,LOCATION(158,1),1,mapEMP,SouthWest);
      grp1.TakeUnit(u);
      TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
      grp1.TakeUnit(u);
      TethysGame::CreateUnit(u,mapPanther,LOCATION(158,1),1,mapEMP,SouthWest);
      grp1.TakeUnit(u);
      TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
      grp1.TakeUnit(u);
      break;

    case 1:
    
// etc... etc...
  }
}

There are other ways to make it even easier, but that would require more knowledge of C++
Title: Hardness Levels?
Post by: spirit1flyer on February 22, 2006, 01:05:45 PM
Okay I just tried it and I got over seven errors so I still don't have a clue how to do what I want.
Now I have below the code in the format I would like, but I don't know if it can be done.  


Easy


Code: [Select]
FightGroup grp1;

SCRIPT_API void CreateTanks1()
{
  Unit u;



  grp1=CreateFightGroup(Player[1]);
  grp1.SetRect(MAP_RECT(30,8,34,12));
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,2),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,3),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,1),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
   TethysGame::CreateUnit(u,mapLynx,LOCATION(158,1),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
}
SCRIPT_API void CreateTanks2()
{
  Unit u;

  grp1=CreateFightGroup(Player[1]);
  grp1.SetRect(MAP_RECT(30,8,34,12));
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,2),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,3),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapTiger,LOCATION(158,1),1,mapEMP,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
   TethysGame::CreateUnit(u,mapTiger,LOCATION(158,1),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
}
SCRIPT_API void CreateTanks3()
{
  Unit u;

  grp1=CreateFightGroup(Player[1]);
  grp1.SetRect(MAP_RECT(30,8,34,12));
  TethysGame::CreateUnit(u,mapPanther,LOCATION(158,2),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,3),1,mapStickyfoam,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapPanther,LOCATION(158,1),1,mapEMP,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
   TethysGame::CreateUnit(u,mapPanther,LOCATION(158,1),1,mapEMP,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
}

normal

Code: [Select]

FightGroup grp1;

SCRIPT_API void CreateTanks1()
{
  Unit u;



  grp1=CreateFightGroup(Player[1]);
  grp1.SetRect(MAP_RECT(30,8,34,12));
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,2),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,3),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,1),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
   TethysGame::CreateUnit(u,mapLynx,LOCATION(158,1),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
}
SCRIPT_API void CreateTanks2()
{
  Unit u;

  grp1=CreateFightGroup(Player[1]);
  grp1.SetRect(MAP_RECT(30,8,34,12));
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,2),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,3),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapTiger,LOCATION(158,1),1,mapEMP,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
   TethysGame::CreateUnit(u,mapTiger,LOCATION(158,1),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
}
SCRIPT_API void CreateTanks3()
{
  Unit u;

  grp1=CreateFightGroup(Player[1]);
  grp1.SetRect(MAP_RECT(30,8,34,12));
  TethysGame::CreateUnit(u,mapPanther,LOCATION(158,2),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,3),1,mapStickyfoam,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapPanther,LOCATION(158,1),1,mapEMP,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
   TethysGame::CreateUnit(u,mapPanther,LOCATION(158,1),1,mapEMP,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
}


Hard

Code: [Select]
FightGroup grp1;

SCRIPT_API void CreateTanks1()
{
  Unit u;



  grp1=CreateFightGroup(Player[1]);
  grp1.SetRect(MAP_RECT(30,8,34,12));
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,2),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,3),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,1),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
   TethysGame::CreateUnit(u,mapLynx,LOCATION(158,1),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
}
SCRIPT_API void CreateTanks2()
{
  Unit u;

  grp1=CreateFightGroup(Player[1]);
  grp1.SetRect(MAP_RECT(30,8,34,12));
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,2),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,3),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapTiger,LOCATION(158,1),1,mapEMP,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
   TethysGame::CreateUnit(u,mapTiger,LOCATION(158,1),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
}
SCRIPT_API void CreateTanks3()
{
  Unit u;

  grp1=CreateFightGroup(Player[1]);
  grp1.SetRect(MAP_RECT(30,8,34,12));
  TethysGame::CreateUnit(u,mapPanther,LOCATION(158,2),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,3),1,mapStickyfoam,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapPanther,LOCATION(158,1),1,mapEMP,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
   TethysGame::CreateUnit(u,mapPanther,LOCATION(158,1),1,mapEMP,SouthWest);
  grp1.TakeUnit(u);
  TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
  grp1.TakeUnit(u);
}
Title: Hardness Levels?
Post by: omagaalpha on March 05, 2006, 08:42:49 PM
spirit1flyer might want to post the erros you been geting ,so he know where your trouble is the compiler.
Title: Hardness Levels?
Post by: spirit1flyer on March 05, 2006, 09:39:49 PM
I will do that as soon as I get my computer reformated  
Title: Hardness Levels?
Post by: Eddy-B on March 06, 2006, 06:25:57 AM
From what you posted i assume you've created an enormous amount of source code, where you can suffice with just a tiny routine to your initialising.
I'll give you an example that resambles your code... since yours is just too long to look through in a quick go.

Code: [Select]
SCRIPT_API void CreateTanks()
{
   int i;
   Unit u;

   // create 3 micro lynx, no matter what
   for (i=0; i<3; ++i)
     TethysGame::CreateUnit(u,mapLynx,LOCATION(158,1+i),1,mapMicrowave,SouthWest);

   // create other units depending difficulty
   switch (Player[0].Difficulty)
   {
   case 0:       // easy:  3 more micro lynx
     for (i=0; i<3; ++i)
       TethysGame::CreateUnit(u,mapLynx,LOCATION(159,1+i),1,mapMicrowave,SouthWest);
     break;

   case 1:       // medium
     TethysGame::CreateUnit(u,mapPanther,LOCATION(159,1),1,mapMicrowave,SouthWest);
     TethysGame::CreateUnit(u,mapPanther,LOCATION(159,2),1,mapMicrowave,SouthWest);
     TethysGame::CreateUnit(u,mapTiger,LOCATION(159,3),1,mapEMP,SouthWest);
     break;

   case 2:       // hard
     TethysGame::CreateUnit(u,mapTiger,LOCATION(159,1),1,mapStickyfoam,SouthWest);
     TethysGame::CreateUnit(u,mapTiger,LOCATION(159,2),1,mapEMP,SouthWest);
     TethysGame::CreateUnit(u,mapTiger,LOCATION(159,3),1,mapEMP,SouthWest);
     break;
   }
}