Author Topic: Storage Bays, Multiplayer Dificulty, And Cargo  (Read 3819 times)

Fire Plague

  • Guest
Storage Bays, Multiplayer Dificulty, And Cargo
« on: January 01, 2010, 12:02:02 PM »
I would greatly apretiate help with this one...

I know that you can fill bays with structure kits, trucks and convecs as well.
I needed to place kits and caro in trucks and the stucture factory baced on the "difficulty" or "resorces" that the host asigned to each player before the game starts.
(not the dificulty for a single player which I think I was using back when I rememberd how.)

How do you fill a specific cargo bay in a struture factory for a given player and rare or common cargo (the 1000 unit bars) into trucks at the start of the game? I can get the convecs filled well enough, but turrets will not work for some reason.

then I need to know how to access the correct "dificulty" or "resorces" settings for each player so that I can place the correct number and type of kits for each setting (low resorces, medium resorces, and high resorces; placed by the game host at the game setup time.)

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Storage Bays, Multiplayer Dificulty, And Cargo
« Reply #1 on: January 01, 2010, 03:24:24 PM »
Use Player[0].Difficulty() to find out the difficulty/resource setting. It should range from 0..2, I believe.

I've recently added some tutorial code to the SVN that sets cargo truck cargo. Use Unit.SetTruckCargo for cargo trucks, Unit.SetCargo for ConVecs, and Unit.SetFactoryCargo for structure factories and Spaceports.

Remeber that when specifying military units, like Lynxes or GPs, you need to specify both the base type, and the weapon type.

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Storage Bays, Multiplayer Dificulty, And Cargo
« Reply #2 on: January 02, 2010, 10:49:59 AM »
Alternatively, you could just set (most) units' cargo at creation time.
TethysGame::CreateUnit(Unit1, mapConVec, LOCATION(129, 43), 0, mapCommandCenter, 0);
TethysGame::CreateUnit(AI.AG1_3, mapTiger, LOCATION(36, 4), AI.numAI1, mapThorsHammer, 1);
TethysGame::CreateUnit(AI.GP7, mapGuardPost, LOCATION(94, 8), 5, mapLaser, 0);

Doing it for trucks is weird though.  Create a truck with no cargo:
TethysGame::CreateUnit(Unit1, mapCargoTruck, LOCATION(40, 12), 0, mapNone, 0);

Now:
Unit1.SetTruckCargo(truckCommonMetal, 1000);
Where the first argument is the truck's cargo (here, truckCommonMetal), and the second argument is the amount (here, 1000).

Here's a list of all truck cargoes:
truckEmpty (why you'd need to set it to empty is beyond me, but just in case...)
truckCommonMetal
truckRareMetal
truckFood
truckCommonOre
truckRareOre
truckCommonRubble
truckRareRubble
truckSpaceport (Starship modules.  Explained below in more detail.)
truckGarbage (Starship wreckage.  Explained below in more detail.)
truckUnit (Dunno, but it seems to act like truckSpaceport.)

About truckSpaceport and truckGarbage:
The cargo amount corresponds to the unit ID of the starship part/tech ID of the wreckage.  This info can be found in MapIdEnum.h and EnumTechID (or the techtree file you're using) respectively.  Make sure you use proper values when you do this.  I'm not sure how OP2 would react if you try to launch a Command Center into space, but if you use bad tech ID values for wreckage the game will crash if you try to unload them at the Spaceport.

One final note:  There's probably a different way to do this, but if you want a Gene Bank in a cargo truck, set its cargo to be the Ion Drive Module.  I say there must be a better way because amount is always set to 5...

Edit: Why can't I bold things inside code tags?  I kinda wanted to emphasize the part where the cargo gets set...

PS: By the way, if you want a Garage to start with units, check out this thread.
« Last Edit: January 02, 2010, 10:57:54 AM 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

Fire Plague

  • Guest
Storage Bays, Multiplayer Dificulty, And Cargo
« Reply #3 on: January 22, 2010, 01:24:50 PM »
Well, it seems to be working but visual studio 2008 on my XP keeps screwing up the build. I can't see the game long enough to see if it's done everything before it tells me that I've won. I know it's the compilation process because the thing keeps displaying two names to start for each .dll. It clearly hasn't put into effect some of my changes in the last two builds eather.
If someone could access the site to setup codeblocks or knows how to correctly get visual studio to run (it ran fine the first time only and has been screwed up since) I might be able to finish my project and have something for you.

Offline AmIMeYet

  • Full Member
  • ***
  • Posts: 128
Storage Bays, Multiplayer Dificulty, And Cargo
« Reply #4 on: January 22, 2010, 03:33:26 PM »
Hm.. well you might want to check if your settings match those from this tutorial. Or actually, I think the version on the new wiki is better.
If that doesn't work, you could always check the codeblocks setup here.

What do you mean with "because the thing keeps displaying two names to start for each .dll"? If you mean what I think it is, have you checked if there aren't any duplicate dll's?

Fire Plague

  • Guest
Storage Bays, Multiplayer Dificulty, And Cargo
« Reply #5 on: January 23, 2010, 11:13:20 AM »
Yes it is doubling the entry for every, I also setup a brand new sdk from scratch and set the progect up and ran it, but that did the same thing. Codeblocks is next, but i think it would be worth looking into if the build solution, build op2script, or op2script only -> build op2script; if using one is causing the error and not the others. Not to mention rebuilding each. All I know is that I have gotten it to display only one name twice and I can't repeat it for the life of me.

EDIT: well the doubleing of the name is due to a glitch. Each new mission dll had a different filename but the same name inisde the dll. The game was remembering the previously erased dll and listing it as an option even though a new dll with a new filename was placed ther in it's place.

     SO:
my code gives me a mission failed for player two and I assume would for any players higher. It seems like it's not creating the players even though it's creating the actual buildings.   here is the test code i used:

int InitProc()
{
   // **TODO**: Add your own code here.
    Unit unit;

TethysGame::CreateUnit(unit, mapCommandCenter, LOCATION(10,10), 0, mapNone, 0);
   Player[0].SetOre(5000);
   Player[0].SetFoodStored(3000);
   Player[0].SetWorkers(28);
   Player[0].SetScientists(13);
   Player[0].SetKids(15);
   Player[0].GoHuman();

TethysGame::CreateUnit(unit, mapCommandCenter, LOCATION(20,20), 1, mapNone, 0);
                    Player[1].SetOre(5000);
   Player[1].SetFoodStored(3000);
   Player[1].SetWorkers(28);
   Player[1].SetScientists(13);
   Player[1].SetKids(15);
   Player[1].GoHuman();

   CreateLastOneStandingVictoryCondition();
   CreateNoCommandCenterFailureCondition();

   return 1; // return 1 if OK; 0 on failure
}
 
« Last Edit: January 27, 2010, 07:21:26 PM by Fire Plague »