Author Topic: Outpost 2 Coding 101: Week 9  (Read 15330 times)

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Outpost 2 Coding 101: Week 9
« on: March 17, 2010, 10:01:15 PM »
Week 9
Intro to AI - Doing Stupid Stuff Since '97

You ever wonder why the AI always starts with much more stuff than you do?  Because it sucks at playing OP2.  If you were to write a simple AI that started with a default LoS setup and fought you, 1-on-1, in a fair fight, it would lose.  Wouldn't even be much of a challenge, really.  But I'll do my best to help you write a somewhat decent AI.  Ready?  Let's start with the basics: setting up groups, building its base and mining ore.

AI Groups
For the AI to function at all, you need to organize its units into specialized groups for construction, repairing, mining ore, (re)building mines, attacking, defending, etc.  Here are some important functions common to all unit groups:
Code: [Select]

[code]// Manipulating the group itself
Disable();  // Disables the group (I'm assuming this prevents it from doing anything or being rebuilt, but I don't know for sure)
Enable();  // Enables the group (Only needed if previously disabled)
IsInitialized(); // No idea, though I'd guess it checks if you've actually created the group/specified what type of group it should be (see below)
Destroy();  // Destroys the group.  OP2 can no longer reference this group.  The units in the group are freed up and can be put in another group now

// Initializing the group (note: I'll explain what each type of group does below)
CreateBuildingGroup(Player[Owner]); // Initializes this group as a building group
CreateMiningGroup(Player[Owner]): // Initializes this group as a mining group
CreateFightGroup(Player[Owner]): // Initializes this group as a fight group
// Note that each group MUST be one of these three types.  There is no "generic" group type.

// Manipulating the units in the group
TakeUnit(Unit Handle);    // Takes the specified unit and adds it to the group
TakeAllUnits(Unit Group);   // Takes all units in the specified group and adds them to this group
SetLights(0 = off, 1 = on);   // Turn on/off lights for all units in the group
SetTargCount(Unit Type, Cargo, Amount);  // Used to tell a Vehicle Factory how many units of type X this group needs
ClearTargCount();    // Erases any data set by SetTargCount.  Useful for changing the type of units a group uses.
RemoveUnit(Unit Handle);   // Removes the specified unit from the group
HasBeenAttacked();    // Checks if the group has been attacked by enemy units
SetDeleteWhenEmpty(0 = false, 1 = true); // Deletes the group if all units in it have been destroyed (assumed?)

Now, some examples of how you would use some of those functions:
Code: [Select]
// Example

// Create a group to defend our base
FightGroup BaseDefense;   // Note: For now, this should be a global variable

...

(in InitProc)
// Initialize it
BaseDefense = CreateFightGroup(Player[playerAI]);

// Create some units for it
Unit Unit1;

TethysGame::CreateUnit(Unit1, mapLynx, ... );
BaseDefense.TakeUnit(Unit1);
TethysGame::CreateUnit(Unit1, mapLynx, ... );
BaseDefense.TakeUnit(Unit1);
TethysGame::CreateUnit(Unit1, mapLynx, ... );
BaseDefense.TakeUnit(Unit1);

// Do some stuff to the group
BaseDefense.SetLights(1);
BaseDefense.SetTargCount(mapLynx, mapLaser, 3);

...

// If we research Rail Gun, replace the Lasers with Rail Guns
SCRIPT_API void RailGunResearched()
{
    BaseDefense.ClearTargCount();
    BaseDefense.SetTargCount(mapLynx, mapRailGun, 3);
}

...

// If we get Thor's Hammer, destroy this group
SCRIPT_API void ThorsResearched()
{
    BaseDefense.Destroy();
}

Now let's talk about the special functions available to the different types of groups

Bulding Groups
Despite the name, building groups don't necessarily deal with construction.  There are four sub-types of the building group:
1) Building Construction
2) Building Repair
3) Mine Construction
4) Vehicle (Re)Building
5) Walls and Tubes

Let's start at the top.  You may have already figured this out, but building construction groups are what you use to tell the AI to build structures.  Such a group consists of three things:
1) ConVecs
2) A Structure Factory
3) A list of buildings to build (and rebuild if they get destroyed.  This should include any buildings the AI starts the game with)

Repair groups are simple.  You just need a ConVec (can reuse one from the build group), a Repair Vehicle, or a Spider.  I'll explain using them below.

Mine construction is basically the same as construction, except you need:
1) Robo-Miner
2) A list of all mines to be built/rebuilt

Rebuilding vehicles is easy.  You need:
1) At least one Vehicle Factory
2) A list of all unit groups, with an assigned priority

Building walls and tubes are just like structures.  You need:
1) Earthworker(s)
2) List of tubes to build/rebuild
3) List of Normal Walls to build/rebuild
4) List of Lava Walls to build/rebuild (optional)
5) List of Microbe Walls to build/rebuild (optional)

All Building Group Functions:
Code: [Select]
// Construction
RecordBuilding(LOCATION(x, y), Unit Type, Cargo Type);  // Tells the AI what type of building should be at the specified location.  More info below.
RecordTube(LOCATION(x, y) );     // Tells the AI that a tube needs to be at the specified location.
RecordWall(LOCATION(x, y), Wall Type);    // Tells the AI that a wall of the specified type must be at the specified location.

// Building Vehicles
RecordVehReinforceGroup(Group, Priority);   // Tells the VF(s) to build units for the specified group until it's target count is reached
UnRecordVehGroup(Group);     // Tells the VF(s) to stop reinforcing the specified group

// Generic functions
SetRect(Region);      // Specifies where the units will wait when they're idle.

Examples:
Code: [Select]
// Demonstrating how to build a base and setup vehicle rebuilding
BuildingGroup Construction;
BuildingGroup RebuildMines;
BuildingGroup Reinforce;

...

// Create the Construction building group
Construction = CreateBuildingGroup(Player[1]);

// Add the units to the group
MAP_RECT ConVecBox(225+31, 71-1, 232+31, 79-1);
Construction.SetRect(ConVecBox);
Construction.TakeUnit(SFact);
Construction.TakeUnit(ConVec1);
Construction.TakeUnit(ConVec2);
Construction.TakeUnit(ConVec3);
Construction.SetTargCount(mapConVec, mapNone, 3);

// Record buildings to the list
Construction.RecordBuilding(LOCATION(233+31,  74-1), mapCommandCenter,       mapNone);     // How are we going to rebuild the CC?
Construction.RecordBuilding(LOCATION(229+31,  73-1), mapStructureFactory,    mapNone);
...

// New buildings
Construction.RecordBuilding(LOCATION(252+31, 116-1), mapMHDGenerator, mapNone);

// Create the RebuildMines building group
RebuildMines = CreateBuildingGroup(Player[1]);

// Add the units to the group
MAP_RECT MinerBox(240+31, 78-1, 244+31, 81-1);
RebuildMines.SetRect(MinerBox);
RebuildMines.TakeUnit(Miner);
RebuildMines.TakeUnit(COreMine);
RebuildMines.TakeUnit(ROreMine);
RebuildMines.SetTargCount(mapRoboMiner, mapNone, 1);
RebuildMines.SetTargCount(mapCommonOreMine, mapNone, 2);

// Record the mines
RebuildMines.RecordBuilding(LOCATION(241+31,  89-1), mapCommonOreMine, mapNone);
RebuildMines.RecordBuilding(LOCATION(245+31, 112-1), mapCommonOreMine, mapNone);

// Setup the Reinforce building group
Reinforce = CreateBuildingGroup(Player[1]);

// Assign the Vehicle Factories and Arachnid Factory to the group
Reinforce.TakeUnit(VFact1);
Reinforce.TakeUnit(VFact2);
Reinforce.TakeUnit(VFact3);
Reinforce.TakeUnit(AFact);

// Setup the reinforcement info
Reinforce.RecordVehReinforceGroup(CommonMining1,     1500);
Reinforce.RecordVehReinforceGroup(CommonMining2,     1500);

Reinforce.RecordVehReinforceGroup(Construction,      1000);
Reinforce.RecordVehReinforceGroup(EWorker,            500);
Reinforce.RecordVehReinforceGroup(RebuildMines,      3000);

You should give that code a try.  Go make a quick little colony game demo where the AI just builds a little base and some vehicles.  Might want to give it unlimited resources for now.  Also, keep in mind that the order you record a building to the build list is the order it will be rebuilt in.

Okay, go write that little AI demo!  I'll be waiting when you get back, and we'll move on to mining and combat.
« Last Edit: March 17, 2010, 10:02:22 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 Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Outpost 2 Coding 101: Week 9
« Reply #1 on: March 17, 2010, 10:02:45 PM »
Okay, I hope everything went well.  Let's talk about mining next (easy) and then combat (a bit trickier).  We'll wrap it up by talking about repairing damaged structures.

Mining Groups:
Mining groups do what you expect.  You assign a Smelter, a Mine, and several trucks and they do their thing.  Just some things to keep in mind:
1) Several groups can use the same mine.  Groups can also share trucks and smelters, but why?
2) Make sure you don't accidentally assign a Rare Ore Mine and a Common Ore Smelter to the same group (or vice-versa).
3) Remember: Never create a Rare Ore Mine in your code!  Tell OP2 to create a Common Ore Mine and it will automatically create a Rare Ore Mine instead.  Rare Ore Mines generated by your DLL do not work properly.

Here are the functions:
Code: [Select]
// There are three different Setup functions.  Only one is worth using.
Setup(Mine Unit Handle, Smelter Unit Handle, Idle Region);  // Grabs the mine and smelter you want to use as well as the region idle trucks should wait (should be near the Smelter or Mine)

Example code:
Code: [Select]
// Sets up the first mining group and assigns it to player 1
CommonMining1 = CreateMiningGroup(Player[1]);

// Sets up the mining location and adds the necessary units to the group.
MAP_RECT CommonBox1(230+31, 81-1, 242+31, 90-1);
CommonMining1.Setup(COreMine, COreSmelter1, CommonBox1);
CommonMining1.TakeUnit(CargoTruck1);
CommonMining1.TakeUnit(CargoTruck2);

CommonMining1.SetTargCount(mapCargoTruck, mapNone, 2);

// Mining Group 2
CommonMining2 = CreateMiningGroup(Player[1]);
MAP_RECT CommonBox2(230+31, 81-1, 242+31, 90-1);

CommonMining2.Setup(COreMine, COreSmelter2, CommonBox2);
CommonMining2.TakeUnit(CargoTruck3);
CommonMining2.TakeUnit(CargoTruck4);

CommonMining2.SetTargCount(mapCargoTruck, mapNone, 2);

I told you mining was simple.  Let's look at offense and defense now, though.

Fight Groups:
We'll look into fight groups a lot more next week.  For now I'll just walk you through the basics.

Code: [Select]
// Basic Fight Group Stuff
SetRect(Region);  // Specifies an area for this group to wait at when idle OR defend.
DoGuardRect();   // Orders the fight group to defend the region designated with SetRect to the bitter end.
SetTargetUnit(Unit Handle); // Specifies a unit for this group to attack or protect.
DoAttackUnit();   // Orders the group to attack the unit specified with SetTargetUnit
DoGuardUnit();   // Orders the group to defend the unit specified with SetTargetUnit
SetAttackType(Unit Type); // Specifies a unit type for this group to target
DoAttackEnemy();  // Orders this group to attack the enemy, paying special attention to all units of the type specified by SetAttackType

Now, an example:
Code: [Select]
// Create a fight group that will Micro Rush the enemy
MicroRush1 = CreateFightGroup(Player[AI]);
MAP_RECT FightIdle(231+31, 60-1, 238+31, 65-1);
MicroRush1.SetRect(FightIdle);
MicroRush1.SetTargCount(mapLynx, mapMicrowave, 14);

...

// If the group is ready, attack
if (MicroRush1.TotalUnitCount() == 14)
{
    MicroRush1.SetAttackType(mapCommandCenter);
    MicroRush1.DoAttackEnemy();
}

That's it for Fight Groups today.  We'll talk about them more next week.

Repairing Damaged Structures:
Okay, we've got two ways to do this.  One involves some extra stuff and lots of code, and the other involves blatant cheating.  Let's start with the second option.

Cheating Method (only recommended if the AI has Tokamaks):
1) In AIProc, use a Player Building Enumeartor to search through all buildings.  Specify some specific criteria if you want?
2) For each building, use SetDamage(0) to restore them to full health, no matter what.

IUnit Method:
1) IUnit is an add-on to OP2's functionality made by Eddy-B.  It allows you even more control over units, but it doesn't come standard with the SDK.
2) Go here.

Really, though, repairing isn't all that important.  If the AI needs to repair anything it's probably already lost anyways, right?  Okay, maybe not...  But I don't think there's a way to do it with the normal tools available to us.

Well, see you next week for the second to last tutorial: Your First Colony Game with an AI!
"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 Flashy

  • Sr. Member
  • ****
  • Posts: 391
Outpost 2 Coding 101: Week 9
« Reply #2 on: April 27, 2010, 11:22:59 AM »
I followed your instructions, but i observed some odd behaviour:
The Ai can build buildings, but it can't REbuild buildings.
BuildingGroup Construction; is a global variable.
Code: [Select]
Unit Convec1;
Unit Convec2;
Unit Convec3;
Unit SFactory;

TethysGame::CreateUnit(SFactory, mapStructureFactory, LOCATION(69+31, 64-1), 1, mapNone, 0);

TethysGame::CreateUnit(Convec1, mapConVec, LOCATION(66+31, 68-1), 1, mapNone, 0);
Convec1.DoSetLights(1);
TethysGame::CreateUnit(Convec2, mapConVec, LOCATION(67+31, 68-1), 1, mapNone, 0);
Convec2.DoSetLights(1);
TethysGame::CreateUnit(Convec3, mapConVec, LOCATION(68+31, 68-1), 1, mapNone, 0);
Convec3.DoSetLights(1);


Construction = CreateBuildingGroup(Player[1]);
MAP_RECT ConVecBox(67+31, 66-1, 71+31, 70-1);
Construction.SetRect(ConVecBox);
Construction.TakeUnit(SFactory);
Construction.TakeUnit(Convec1);
Construction.TakeUnit(Convec1);
Construction.TakeUnit(Convec1);
Construction.SetTargCount(mapConVec, mapNone, 3);
Construction.RecordBuilding(LOCATION(61+31, 64-1), mapCommonStorage, mapNone);
The AI builds the storage correctly, but after it is destroyed, nothing happens. The Ai had a working MiningGroup, a working structure factory and a (working) cc. What am I doing wrong? :blink:  
Praise the mighty light towers!!!

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Outpost 2 Coding 101: Week 9
« Reply #3 on: April 27, 2010, 12:52:08 PM »
Maybe it no longer has any ore after its only storage facility gets destroyed?  :P  
"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 Flashy

  • Sr. Member
  • ****
  • Posts: 391
Outpost 2 Coding 101: Week 9
« Reply #4 on: April 27, 2010, 01:22:10 PM »
No, the MiningGroup includes an active smelter. I made a few screenshots:
EDIT:Picture removed

EDIT:Picture removed

EDIT:Picture removed
After 80 marks:
EDIT:Picture removed
« Last Edit: April 28, 2010, 12:17:41 PM by Flashy »
Praise the mighty light towers!!!

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Outpost 2 Coding 101: Week 9
« Reply #5 on: April 27, 2010, 01:26:41 PM »
Upload your .cpp file and I'll take a look.
"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 Flashy

  • Sr. Member
  • ****
  • Posts: 391
Outpost 2 Coding 101: Week 9
« Reply #6 on: April 27, 2010, 01:41:33 PM »
OK.
« Last Edit: April 27, 2010, 02:13:20 PM by Flashy »
Praise the mighty light towers!!!

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Outpost 2 Coding 101: Week 9
« Reply #7 on: April 27, 2010, 01:59:44 PM »
Uhhh... It works perfectly...

Did you try just waiting a few seconds?  The AI needs some time to do its thing you know...
« Last Edit: April 27, 2010, 02:00:01 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 Flashy

  • Sr. Member
  • ****
  • Posts: 391
Outpost 2 Coding 101: Week 9
« Reply #8 on: April 27, 2010, 02:21:29 PM »
I waited for 50 marks. Maybe Visual C++ 2008 Express Edition hates me.  :'(

Edit: Strange, after I destroyed my last starflare lynx, the AI worked! It looks like it doesn't build anything while enemy units are somewhere around the colony. But thank you for looking at the .cpp file.
« Last Edit: April 27, 2010, 03:18:35 PM by Flashy »
Praise the mighty light towers!!!

Offline Kayedon

  • Sr. Member
  • ****
  • Posts: 378
Outpost 2 Coding 101: Week 9
« Reply #9 on: April 27, 2010, 05:56:20 PM »
Quote
I waited for 50 marks. Maybe Visual C++ 2008 Express Edition hates me.  :'(

Edit: Strange, after I destroyed my last starflare lynx, the AI worked! It looks like it doesn't build anything while enemy units are somewhere around the colony. But thank you for looking at the .cpp file.
I have to say that's odd, as in singleplayer they seem to love rebuilding in front of you.
"Trust me, I'm crazy."

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Outpost 2 Coding 101: Week 9
« Reply #10 on: April 27, 2010, 06:53:09 PM »
Yeah, I've never noticed that...
"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 Flashy

  • Sr. Member
  • ****
  • Posts: 391
Outpost 2 Coding 101: Week 9
« Reply #11 on: April 28, 2010, 07:29:12 AM »
Maybe you need starflares.
Praise the mighty light towers!!!

Offline Ecke100

  • Newbie
  • *
  • Posts: 36
Outpost 2 Coding 101: Week 9
« Reply #12 on: May 12, 2010, 08:21:34 AM »
Hi, i have problem with Robo-Miner will be built in Vehicle Factory even if AI has Common mine and Rare ore mine.

This is my code

Code: [Select]
/* Add the units to the group */
MAP_RECT MinerBox(100+31, 25-1, 103+31, 23-1);
Unit COreMine;
Unit ROreMine;
Unit Miner;
TethysGame::CreateUnit(COreMine, mapCommonOreMine, LOCATION(102+31, 24-1), 1, mapNone, 2);
RebuildMines.SetRect(MinerBox);
RebuildMines.TakeUnit(Miner);
RebuildMines.TakeUnit(COreMine);
RebuildMines.TakeUnit(ROreMine);
RebuildMines.SetTargCount(mapRoboMiner, mapNone, 1);
RebuildMines.SetTargCount(mapCommonOreMine, mapNone, 2);

/* Record the mines */
RebuildMines.RecordBuilding(LOCATION(102+31, 24-1), mapCommonOreMine, mapNone);
RebuildMines.RecordBuilding(LOCATION(97+31, 45-1), mapCommonOreMine, mapNone);

MiningGroup CommonMining1;

/* Sets up the first mining group and assigns it to player 1 */
CommonMining1 = CreateMiningGroup(Player[1]);

/* Sets up the mining location and adds the necessary units to the group. */
MAP_RECT CommonBox1(89+31, 24-1, 98+31, 31-1);
Unit CargoTruck1;
Unit CargoTruck2;
Unit CargoTruck3;
Unit COreSmelter1;
TethysGame::CreateUnit(CargoTruck1, mapCargoTruck, LOCATION(95+31, 25-1), 1, mapNone, 1);
CargoTruck1.DoSetLights(1);
TethysGame::CreateUnit(CargoTruck2, mapCargoTruck, LOCATION(91+31, 25-1), 1, mapNone, 1);
CargoTruck2.DoSetLights(1);
TethysGame::CreateUnit(CargoTruck3, mapCargoTruck, LOCATION(89+31, 27-1), 1, mapNone, 1);
CargoTruck3.DoSetLights(1);
TethysGame::CreateUnit(COreSmelter1, mapCommonOreSmelter, LOCATION(94+31, 29-1), 1, mapNone, 0);
CommonMining1.Setup(COreMine, COreSmelter1, CommonBox1);
CommonMining1.TakeUnit(CargoTruck1);
CommonMining1.TakeUnit(CargoTruck2);
CommonMining1.TakeUnit(CargoTruck3);
CommonMining1.TakeUnit(COreSmelter1);
CommonMining1.SetTargCount(mapCargoTruck, mapNone, 5);

What is wrong with my code if they build Robo-Miner even after they have build Mine platform
« Last Edit: May 17, 2018, 09:58:38 PM by leeor_net »

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Outpost 2 Coding 101: Week 9
« Reply #13 on: May 12, 2010, 12:09:50 PM »
Nothing is wrong with it.  You've designated it to always have at least one Robo-Miner with this line:
Code: [Select]
RebuildMines.SetTargCount(mapRoboMiner, mapNone, 1);
 While you may not like it, telling the AI to always keep a spare Robo-Miner laying around is much easier than ordering it to build a new one as needed.  But if you really want it, you could probably run a check inside AIProc to see if:
1) The AI needs a new Robo-Miner
2) The AI is not already building a Robo-Miner
If these conditions are met, you could then add a Robo-Miner to the reinforce list (give it a really high priority).  Once the Robo-Miner has been built, remove it from the list of units the AI needs to build.

Note: Since doing this is not really important to the AI working correctly, I'm not going to write the code for you.
"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 Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Outpost 2 Coding 101: Week 9
« Reply #14 on: May 13, 2010, 12:51:46 AM »
I think you might be able to record the mine, and it will know to rebuild it (using a Robo-Miner), if it gets destroyed. I'm quite possibly wrong on that, but I believe I've seen the AI rebuild mines before, and not have spare Robo-Miners lying around, so I think it's possible somehow and that seems like the most likely way.
 

Offline CK9

  • Administrator
  • Hero Member
  • *****
  • Posts: 6226
    • http://www.outpost2.net/~ck9
Outpost 2 Coding 101: Week 9
« Reply #15 on: May 13, 2010, 09:23:14 AM »
colony games --> plymouth starship II, blow up eden mine without devistating the base, and the mine will be rebuilt
CK9 in outpost
Iamck in runescape (yes, I still play...sometimes...)
srentiln in minecraft (I like legos, and I like computer games...it was only a matter of time...) and youtube...
xdarkinsidex on deviantart

yup, I have too many screen names

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Outpost 2 Coding 101: Week 9
« Reply #16 on: May 13, 2010, 09:58:00 AM »
That... really doesn't prove anything, CK9...
"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 CK9

  • Administrator
  • Hero Member
  • *****
  • Posts: 6226
    • http://www.outpost2.net/~ck9
Outpost 2 Coding 101: Week 9
« Reply #17 on: May 13, 2010, 11:47:54 AM »
yes it does, it shows that the ai can be told to rebuild the mine without having an extra robominer pre-built.  As to if it's cheating or not for that, I have no idea, heh
CK9 in outpost
Iamck in runescape (yes, I still play...sometimes...)
srentiln in minecraft (I like legos, and I like computer games...it was only a matter of time...) and youtube...
xdarkinsidex on deviantart

yup, I have too many screen names

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Outpost 2 Coding 101: Week 9
« Reply #18 on: May 13, 2010, 02:14:42 PM »
No, Hooman was saying that the AI will automatically build a Robo-Miner if it needs a Mine.  I think...
"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 CK9

  • Administrator
  • Hero Member
  • *****
  • Posts: 6226
    • http://www.outpost2.net/~ck9
Outpost 2 Coding 101: Week 9
« Reply #19 on: May 13, 2010, 03:19:44 PM »
hmm...from what he's saying, here's what I get:

1) the mine is built
2) the mine is put in a list of things to watch
3) the mine is destroyed
4) the ai finds the mine is destroyed
5) the ai builds a new robominer
6) the mine is replaced

which is what the ai seems to do on plym ss 2
CK9 in outpost
Iamck in runescape (yes, I still play...sometimes...)
srentiln in minecraft (I like legos, and I like computer games...it was only a matter of time...) and youtube...
xdarkinsidex on deviantart

yup, I have too many screen names

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Outpost 2 Coding 101: Week 9
« Reply #20 on: May 13, 2010, 06:43:09 PM »
Yes, that is what you'd need to do to make it work.  That's not what I was saying.  I was... Never mind.
"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 CK9

  • Administrator
  • Hero Member
  • *****
  • Posts: 6226
    • http://www.outpost2.net/~ck9
Outpost 2 Coding 101: Week 9
« Reply #21 on: May 13, 2010, 07:54:36 PM »
you were saying that you wonder if there are built-in measures to the game to where it will already do that?
CK9 in outpost
Iamck in runescape (yes, I still play...sometimes...)
srentiln in minecraft (I like legos, and I like computer games...it was only a matter of time...) and youtube...
xdarkinsidex on deviantart

yup, I have too many screen names

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Outpost 2 Coding 101: Week 9
« Reply #22 on: May 13, 2010, 10:42:26 PM »
I think CK9 kind of picked up on what I was saying. The game is obviously capable of doing it. How is another question entirely.
 

Offline Angellus Mortis

  • Full Member
  • ***
  • Posts: 138
Outpost 2 Coding 101: Week 9
« Reply #23 on: August 08, 2010, 02:16:35 AM »
Yes, if you add a Vehicle Factory to the build group and Record a mine, the Vehicle WILL  build a Robo-Miner and automatically build the mine. It is how I build all my mines except the first :D

Offline jcj94

  • Sr. Member
  • ****
  • Posts: 407
    • http://techfusion-279.com
Outpost 2 Coding 101: Week 9
« Reply #24 on: March 15, 2011, 09:03:34 PM »
How would you set an ATTACK ALL UNITS WITHIN RANGE IF WRECKAGE PIECE IS HERE 65+31, 66-1 (not actual code, just giving intended purpose)  How would I tell if its there for one, and two something that would accomplish that goal.. just an (generalized) SetAttackUnit(unit handle) or SetAttackUnit(Unit type 1, unit type 2, unit type 3) or SetAttackUnit(Vehichles)


I'm working on La Corrida for modded tiger and AI With Thor's Hammers surrounding it, so people can't rush for it.. but i want them to attack (seeing as they are guard posts).  I know i know, I have a lot of problems, but if any of you guys (Sir Bomber, CK9, Hooman... any GOOD coder actually) was On irc when I was (stupid time zones) It'd probably go a lot smoother.  

Another quetion I've run into is is there a way to WIDEN the daynight band, as it looks on the Eden and Plymouth unit demos?

Attached here is my source code( using the mapper, supposed to be using map ml4_01
, i basicly added things here in the though of transfering them over I KNOW ITS A MESS.. just.. see if you can help. Pleeeaase)
« Last Edit: March 16, 2011, 03:36:53 PM by jcj94 »