Author Topic: Added outpost functionality  (Read 1837 times)

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Added outpost functionality
« on: May 01, 2005, 12:02:40 PM »
By now, you've probably all figured out i've implemented Hooman's findings -i should mention i did do a lot of work towards this, but i got Hooman to thank for helping me in the right direction- anyway: i've implemented those findings into a shared library: op2extra.zip. It includes a new Unit structure for use with the extended unit-functions, which i've dubbed IUnit (I as in "Internal", since it uses the internal OP2-unit structure, rather then the one exported). It is derived from the exported Unit class, and as so inherits ALL the Unit's members.
To add to this: it uses some of the hacks that we (Hooman and i) found to issue commandPackets right into the core of the outpost game engine. Some remarks about this are in place here:
  • You all know the hacks are windows-dependend, which means they could become useless, if MicroSoft decides to change the way executables are loaded. On the other hand; putting everything into a shared dll makes updating pretty easy, so IF Windows changes we can patch the dll and others wouldn't even have to recompile their projects to use the new dll version.
  • Not all member functions have been tested to this date. If anyone feels compelled to this: be my guest and let me know :)
  • Some of the commandPackets that i've used are meant to be used on a group of units (like Scatter), but since i've added them as a member-function to the IUnit class, they refer to only one unit. As such: the scatter command is not supported, since obviously scattering a single unit makes no sense.
  • I've tried to insert code that will verify certain things, so the code won't backfire on you, if used in a wrong way. Like trying to use IUnit::Research(..) on a non-lab unit. IMPORTANT: with the current version, there will not be any warning if you try to use a wrong method, it will simply return from the subroutine -doing nothing- In time, i'm going to change this to either displaying a clean error-msg or using a standard windows exception
Added IUnit methods:
Code: [Select]
void Doze(MAP_RECT region);  // use with RoboDozer only
void Dock();       // to be used when a unit in on a docking pad
void DockGarage();     // to be used when a unit in on a docking pad of a garage
void Build(LOCATION location); // use when there's a kit inside a convec, or when this is a miner/geocon
void Produce(enum map_id itemToProduce,enum map_id weaponType);
void TransferCargo(short bay); // to be used when a unit in on a docking pad
void LoadCargo();      // to be used when a unit in on a docking pad
void UnloadCargo();     // to be used when a unit in on a docking pad
void DumpCargo();
void Research(short techID,short numScientists); // use only with labs
void TrainScientists(short numTrained);    // use only with university
void Salvage(MAP_RECT region,IUnit gorf);
void Poof();
void Repair(IUnit target);   // use with convec or repait vehicle
void Reprogram(IUnit target);  // use with spider only
void Dismantle(IUnit target);  // use with convec

command_type GetBusy();    // returns what this unit is doing (0=not busy)
void GetFactoryCargo(int bay, enum map_id &unitType, enum map_id &weaponType);
void GetCargo(map_id &cargoType,map_id &weaponType); // works for convecs
int GetTruckCargo(Truck_Cargo &cargoType);    // returns amount of cargo
int GetDamage();      // 0=no damage

bool IsInRect(MAP_RECT rect);  // returns true if the unit is in the rect

Some remarks:
There is a difference between Build and Produce: Build is to be used on a vehicle that can build something, like a convec, geocon or miner: you only supply the location where the new building has to be built. Produce can be used on buildings that produce either units or kits; eg. SF, VF, Aracnid F, Consumer F and SpacePort

TransferCargo hasn't been tested yet, so i honestly don't know if it should be used on the building or the vehicle. Either way: the unit MUST be already on the pad! Same goes for LoadCargo and UnloadCargo.

Poof() will make the unit exit the gamemap at the nearest exit point - the unit will first move to the side of the map, then "poof". Be advised, somehow, this will cause a graphics bug - the game doesnt repaint its DC after the unit poofs!

Repair/Reprogram/Dismantle all use the same internal structure - but i've included them seperately.


Then, i've added some other methods, that i've used before (succesfully i might add):
  • GetFactoryCargo  -- does just that
  • GetCargo -- retrieves the cargo PLUS its weapontype (original GetCargo doesn't do this). I've included the original GetCargo as an overloaded method (C++ allows this). Depending the number of arguments IUnit will use either the new or old method.
  • GetTruckCargo -- use this to get the cargo (as with the old GetCargo) but it also returns the amount held in the truck!
  • GetDamage -- obvious: there IS a SetDamage, so why isn't there a GetDamage ?? go figure!
  • IsInRect -- a handy method, to find out if a unit is in your specified rect.
Have fun !



Next addition to this library: events!!   YES - i WILL get it to work (MAJOR hack required though  :blush: )
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz