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
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();
}
I don't get what you mean, but this should work:
Declare FightGroup grp1; below your DescBlock. Like so:
//Your descblock here!
FightGroup grp1;
Then, above IntProc, put this:
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:
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
Okay..
i will teach you 1 more powerful C++ command: switch
Syntax:
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:- you can only use each case number once;
- you MUST end a case block with a break command;
- you can use default for any value that isn't included in any of the other cases
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:
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++
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
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
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
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);
}
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.
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;
}
}