I did add Reseach(...) to my IUnit, but had never tested it.
When i did test it, it caused an exception..
So, i looked into it:
----
OP2 does not take the techID# as a param for the research-cmdPacket, instead it wants an array entry within it's tech array. I'll explain:
When the mission loads, after reading the techfile, op2 sorts the entire file, and stores all those techs into an array located at 015208C0. I've already added the proper address to my "DataStructure Technology.txt". When sending a cmdPacket of type ctMoResearch, it takes 3 params in its Data property:
struct ResearchData
{
unsigned short labID;
unsigned short techEntry;
unsigned short numScientists;
};
The techEntry is NOT the techID what you'd expect, but the array item number (=item offset). The list is sorted according to techID, so if you'd create a techfile with these entries (and in this order):
BEGIN_TECH "Cybernetic Teleoperation" 03401
...
BEGIN_TECH "Emergency Response Systems" 03301
...
BEGIN_TECH "Focused Microwave Projection" 03408
...
It will get sorted like this:
entry content-tech
0x00 03301
0x01 03401
0x02 03408
Note that the order is different: the lowest techID is first!
Now, to have Cybernetic Teleoperation researched, you'd use 0x01 for the techEntry property of the ResearchData struct.
Since ANY person can modify the techfiles, it is pretty useless using those numbers, because if one tech is removed or added, it might not be correct anymore...
So, i was looking for a function that "translates" the techID into a techEntry as i've dubbed it. And i found one at memory location OUTPOST2: 00472D90
It does something that shocked me: a Quicksearch - this would certainly prove that sections of code are written by different people. Compare this with what i found out about the victory/failure checking (in this same forum).
Anyway: i've updated my IUnit class, v1.2 to include this new Research function. Coders can now send a techID (as declared in EnumTechID.h) to the IUnit::Research member function. As a side-note: when starting a research in your InitProc, it won't work, because at that point the labs are still offline. They'll be put online during the first game-cycle (4 game ticks, i believe).
1 minor change to the IUnit.h
IUnit::Research now takes an
int as techID, instead of a short