Author Topic: Second Ai Colony  (Read 11816 times)

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3237
Second Ai Colony
« Reply #25 on: September 09, 2010, 08:08:29 AM »
Set up a new Building Group once the new SF is running.  Make sure to assign it ConVecs and a build list.
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline Ecke100

  • Newbie
  • *
  • Posts: 36
Second Ai Colony
« Reply #26 on: September 09, 2010, 11:38:33 AM »
Here is my code.

Code: [Select]
Unit ConVec3, ConVec4;

TethysGame::CreateUnit(ConVec3, mapConVec, LOCATION(15+31, 113-1), 1, mapCommandCenter, 3);
x.DoSetLights(1);
TethysGame::CreateUnit(ConVec4, mapConVec, LOCATION(17+31, 113-1), 1, mapStructureFactory, 3);
x.DoSetLights(1);

First, they wait in the main base

Code: [Select]
buildGroup2 = CreateBuildingGroup(Player[1]);
buildGroup2.SetRect(MAP_RECT(12+31, 108-1, 28+31, 114-1));
buildGroup2.TakeUnit(ConVec3);
buildGroup2.TakeUnit(ConVec4);

Then after, they will go to the next area.

Code: [Select]
SCRIPT_API void Base2()
{
    buildGroup2b = CreateBuildingGroup(Player[1]);
    buildGroup2b.SetRect(MAP_RECT(185+31, 19-1, 194+31, 28-1));
    buildGroup2b.TakeAllUnits(buildGroup2);
    buildGroup2b.RecordBuilding(LOCATION(191+31, 23-1), mapCommandCenter, mapNone);
    buildGroup2b.RecordBuilding(LOCATION(191+31, 26-1), mapStructureFactory, mapNone);
    buildGroup2b.RecordBuilding(LOCATION(197+31, 22-1), mapVehicleFactory, mapNone);
}

They build Command Center and Structure Factory, but ConVecs will not record Structure Factory and build next building on the list.
« Last Edit: May 17, 2018, 09:55:25 PM by leeor_net »

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3237
Second Ai Colony
« Reply #27 on: September 09, 2010, 05:55:56 PM »
I don't trust TakeAllUnits.  Try doing that manually somehow.  Also make sure to remove the units from the old group first.

On second thought, why are you even making a "group 2b"?  Just change group 2 as needed.
« Last Edit: September 09, 2010, 05:56:30 PM by Sirbomber »
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline Ecke100

  • Newbie
  • *
  • Posts: 36
Second Ai Colony
« Reply #28 on: April 22, 2011, 08:13:01 AM »
Someone who has been running the AI ​​to build more separate bases?

Offline Ecke100

  • Newbie
  • *
  • Posts: 36
Second Ai Colony
« Reply #29 on: June 28, 2011, 07:26:46 AM »
Now i got it, it works now at last! :D

Code: [Select]
SD.buildGroup2 = CreateBuildingGroup(Player[1]);
SD.buildGroup2.SetRect(MAP_RECT(12+31, 108-1, 28+31, 114-1));
SD.buildGroup2.TakeUnit(SD.ConVec3);
SD.buildGroup2.TakeUnit(SD.ConVec4);
SD.buildGroup2.SetDeleteWhenEmpty(1);

CreateTimeTrigger(1, 1, 1000, "Base2a");
CreateTimeTrigger(1, 1, 13000, "Base2");

SD.CheckSecondSF = CreateTimeTrigger(1, 0, 10, "AI_SFCheck");

SCRIPT_API void Base2a()
{
Unit ConVec3 ,ConVec4, SF2;
SD.buildGroup2b = CreateBuildingGroup(Player[1]);
SD.buildGroup2b.SetRect(MAP_RECT(185+31, 19-1, 194+31, 28-1));
SD.buildGroup2b.RecordBuilding(LOCATION(191+31, 23-1), mapCommandCenter, mapNone);
SD.buildGroup2b.RecordBuilding(LOCATION(191+31, 26-1), mapStructureFactory, mapNone);
SD.buildGroup2b.TakeAllUnits(SD.buildGroup2);
SD.buildGroup2b.TakeUnit(SD.SF2);
}

SCRIPT_API void Base2()
{
Unit ConVec3 ,ConVec4, SF2;
SD.buildGroup2c = CreateBuildingGroup(Player[1]);
SD.buildGroup2c.SetRect(MAP_RECT(185+31, 19-1, 194+31, 28-1));
SD.buildGroup2c.TakeAllUnits(SD.buildGroup2b);
SD.buildGroup2c.TakeUnit(SD.SF2);
SD.buildGroup2c.RecordBuilding(LOCATION(196+31, 22-1), mapVehicleFactory, mapNone);
}

SCRIPT_API void AI_SFCheck()
{
    // Let's use an enumerator
    Unit SF2;
    PlayerBuildingEnum unitEnum(1, mapNone);
    while (unitEnum.GetNext(SF2) )
    {
        // Check if this is the unit we want (make sure it's an SF and in the right spot)
        if ( (SF2.GetType() == mapStructureFactory) && (SF2.Location().x == 191+31) && (SF2.Location().y == 26-1) )
        {
            // We've found it!  Record it and destroy this trigger.
            SD.SF2 = SF2;
            SD.CheckSecondSF.Destroy();
        }
    }
}

You need to Create a group after the StructureFactory is done with a TimeTrigger.
« Last Edit: May 17, 2018, 09:55:55 PM by leeor_net »

Offline Hidiot

  • Hero Member
  • *****
  • Posts: 1018
Second Ai Colony
« Reply #30 on: June 28, 2011, 10:49:41 AM »
What?

You should be able to create a group anywhere before first being used. Only the record unit part needs to assign a handle to an actually existing entity.
"Nothing from nowhere, I'm no one at all"

Offline Ecke100

  • Newbie
  • *
  • Posts: 36
Second Ai Colony
« Reply #31 on: August 18, 2011, 05:05:09 PM »
Here is my map :) Beta 1.1

Offline Ecke100

  • Newbie
  • *
  • Posts: 36
Second Ai Colony
« Reply #32 on: August 18, 2011, 05:06:40 PM »
Map file

Offline Highlander

  • Hero Member
  • *****
  • Posts: 780
  • Outpost 2 Elder
Second Ai Colony
« Reply #33 on: August 19, 2011, 01:15:31 AM »
I get an error message when trying your game - "Game could not initialize"
There can be Only one. Wipe Them out. All of Them.

Old player still playing. Visit Spark for a game of Outpost 2

Offline Flashy

  • Sr. Member
  • ****
  • Posts: 391
Second Ai Colony
« Reply #34 on: August 19, 2011, 07:06:32 PM »
Same with me.
Praise the mighty light towers!!!

Offline Savant_Ace

  • Full Member
  • ***
  • Posts: 102
    • http://www.spitfire-sa.com/
Second Ai Colony
« Reply #35 on: August 20, 2011, 12:06:42 AM »
+1 (Could not Initialize)

Offline Ecke100

  • Newbie
  • *
  • Posts: 36
Second Ai Colony
« Reply #36 on: August 21, 2011, 12:05:22 PM »
Can not understand why you get the error, did not find anything wrong yet

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Second Ai Colony
« Reply #37 on: August 22, 2011, 03:03:14 AM »
The mapName field of the DescBlock points to the string "bad allocation". There are also similar problems with the levelDesc and techTreeName fields not pointing to valid strings.
 

Offline Ecke100

  • Newbie
  • *
  • Posts: 36
Second Ai Colony
« Reply #38 on: August 24, 2011, 07:24:39 PM »
I can play the map with no problems.

Offline Savant_Ace

  • Full Member
  • ***
  • Posts: 102
    • http://www.spitfire-sa.com/
Second Ai Colony
« Reply #39 on: August 24, 2011, 08:18:29 PM »
That much seems obvious. Try making a fresh installation of OP2 in a different directory and installing your map there, then see if you run into the same problem that we do.

Offline Ecke100

  • Newbie
  • *
  • Posts: 36
Second Ai Colony
« Reply #40 on: November 19, 2011, 09:28:39 AM »
Now i have installed on a another computer and it work.

Note: I use (Outpost 2 Version 1.35 Beta 2) and when you download the map, remove the underscore in Bana_2.map and write it to Bana 2.map (Scenario 2.map in English) :)

Sorry i dont try test download my map from this site, i should have seen it but i dont.
« Last Edit: December 03, 2011, 06:28:20 PM by Eke100 »

Offline Ecke100

  • Newbie
  • *
  • Posts: 36
Second Ai Colony
« Reply #41 on: May 25, 2013, 03:09:26 PM »
Quote
What?

You should be able to create a group anywhere before first being used. Only the record unit part needs to assign a handle to an actually existing entity.
Has found a way that you meant, a code that works that way, thx to Sirbomber, Flashy and more. from various topics i got a combination of codes that works.  :)

Here is the solution.

Code: [Select]
SCRIPT_API void Red_SFCheck()
{
    // Let's use an enumerator
    IUnit RSF1;
    PlayerBuildingEnum unitEnum(2, mapNone);
    while (unitEnum.GetNext(RSF1) )
    {
        // Check if this is the unit we want (make sure it's an SF and in the right spot)
        if ( (RSF1.GetType() == mapStructureFactory) && (RSF1.Location().x == 28+31) && (RSF1.Location().y == 31-1) )
              {
             switch(RSF1.GetBusy())
                {
                    case ctMoDevelop:
                    case ctMoUnDevelop:
                    case ctMoDismantle:
                        break;
                default:
                // We've found it!  Record it and destroy this trigger.
                SD.RSF1 = RSF1;
                CreateTimeTrigger(1, 1, 50, "RedBase1");
                SD.CheckFirstSF.Destroy();
            }
        }
    }
}
« Last Edit: May 25, 2013, 05:09:19 PM by Eke100 »

Offline Ecke100

  • Newbie
  • *
  • Posts: 36
Second Ai Colony
« Reply #42 on: June 14, 2013, 01:35:57 PM »
Beta 1.4

Offline Ecke100

  • Newbie
  • *
  • Posts: 36
Second Ai Colony
« Reply #43 on: June 14, 2013, 01:37:17 PM »
Map file