News:

We've upgraded the forum software.
You may need to log in again or reset your password!

Main Menu

Ai Problems, Please Help

Started by Angellus Mortis, July 29, 2009, 06:50:26 PM

Angellus Mortis

Okay, I am trying to simulate my AI to research. They start when the lab is build. TimtTriggers control when something is researched. It show no sign of them getting the techs. Here is the related code (NOTE: I am using survtech):

//Research orders and times for labs (times in ticks)
int BasicLabOrder[] = {2701, 2702, 2703, 2704, 2705, 2707, 2708};
int BasicLabTime[] = {1200, 1200, 1200, 1200, 1200, 1200, 1900};
int StandardLabOrder[] = {3304, 3305, 3401, 5051, 3408, 3405, 3302, 5310, 3851, 7206, 5202, 3901, 7102, 5317, 5116, 8319, 7103, 8203, 8320, 3201, 3202, 8306, 3878};
int StandardLabTime[] ={700, 1500, 1600, 1700, 1800, 2400, 1700, 1400, 1800, 2200, 2200, 2000, 1600, 1300, 1800, 1700, 2100, 1700, 2100, 2000, 1800, 2100, 1900};
int AdvancedLabOrder[] = {3402, 5601, 5110, 5111, 5405, 5201, 5508, 12201, 7104, 10204, 7212, 7405, 5701, 8201, 10303, 8407, 5599, 8309, 8321, 10306, 11999};
int AdvancedLabTime[] = {1500, 3300, 2200, 2100, 3900, 2400, 1800, 4900, 2100, 3100, 3800, 1800, 1400, 2900, 2900, 2100, 3300, 1500, 1700, 3100, 6500};

//Currents tech for each lab
scriptGlobal.CBasicLab = 0;
scriptGlobal.CStanLab = 0;
scriptGlobal.CAdvLab = 0;

//Bulid Basic Lab at start
scriptGlobal.Build1.RecordBuilding(LOCATION(17-1, 37-1), mapBasicLab, mapNone); 

//Builds Standard Lab after "Earth Scientific Database"
scriptGlobal.StanLab = CreateResearchTrigger(1 , 1, 2708, 1, "BuildStandardLab");

SCRIPT_API void BuildStandardLab()
{
    scriptGlobal.Build1.RecordBuilding(LOCATION(12-1, 39-1), mapStandardLab, mapNone);
    scriptGlobal.StanLab.Destroy();
}

//Builds University and Advanced Lab after "Research Training Programs"
scriptGlobal.UniAdv = CreateResearchTrigger(1 , 1, 3305, 1, "BuildUniAdv");

SCRIPT_API void BuildUniAdv()
{
    scriptGlobal.Build1.RecordBuilding(LOCATION(22-1, 42-1), mapUniversity, mapNone);
    scriptGlobal.Build1.RecordBuilding(LOCATION(32-1, 16-1), mapAdvancedLab, mapNone);
    for (scriptGlobal.j=19; scriptGlobal.j<21; scriptGlobal.j++)
        scriptGlobal.Tuber1.RecordTube(LOCATION(scriptGlobal.j-1, 42-1));
    for (scriptGlobal.j=13; scriptGlobal.j<31; scriptGlobal.j++)
        scriptGlobal.Tuber1.RecordTube(LOCATION(scriptGlobal.j-1, 16-1));
    scriptGlobal.UniAdv.Destroy();
}

//Checks for operational labs
scriptGlobal.HaveBasicLab = CreateOperationalTrigger(1, 1, 1, mapBasicLab, 1, cmpGreaterEqual, "BasicLab");        
scriptGlobal.HaveStanLab = CreateOperationalTrigger(1, 1, 1, mapStandardLab, 1, cmpGreaterEqual, "StanLab");   
scriptGlobal.HaveAdvLab = CreateOperationalTrigger(1, 1, 1, mapAdvancedLab, 1, cmpGreaterEqual, "AdvLab"); 


//creates the TimeTriggers for the techs
SCRIPT_API void BasicLab()
{
    scriptGlobal.RBasicLab = CreateTimeTrigger(1, 0, BasicLabTime[scriptGlobal.CBasicLab], "BasicLabResearch");
}

SCRIPT_API void AdvLab()
{
    scriptGlobal.RAdvLab = CreateTimeTrigger(1, 0, AdvancedLabTime[scriptGlobal.CAdvLab], "AdvLabResearch");
}

SCRIPT_API void StanLab()
{
    scriptGlobal.RStanLab = CreateTimeTrigger(1, 0, StandardLabTime[scriptGlobal.CStanLab], "StanLabResearch");
}


//Marks the research complete after a certain time
SCRIPT_API void BasicLabResearch()
{
    Player[1].MarkResearchComplete(BasicLabOrder[scriptGlobal.CBasicLab]);
    scriptGlobal.CBasicLab +=1;

    if (scriptGlobal.CBasicLab = 7)
        scriptGlobal.RBasicLab.Destroy();
}

SCRIPT_API void StanLabResearch()
{
    Player[1].MarkResearchComplete(StandardLabOrder[scriptGlobal.CStanLab]);
    scriptGlobal.CStanLab +=1;

    if (scriptGlobal.CStanLab = 23)
        scriptGlobal.RStanLab.Destroy();
}


SCRIPT_API void AdvLabResearch()
{
    Player[1].MarkResearchComplete(AdvancedLabOrder[scriptGlobal.CStanLab]);
    scriptGlobal.CAdvLab +=1;

    if (scriptGlobal.CAdvLab = 21)
        scriptGlobal.RAdvLab.Destroy();
}


Hooman

Perhaps you should ask a question if you're seeking help.

Hidiot

#2
QuoteIt show no sign of them getting the techs.
What I suspect is that the trigger only launches once and is not re-enabled afterward.

Which is true.

Code: cpp
SCRIPT_API void BasicLabResearch()
{
Player[1].MarkResearchComplete(BasicLabOrder[scriptGlobal.CBasicLab]);
scriptGlobal.CBasicLab +=1;

if (scriptGlobal.CBasicLab = 7)
scriptGlobal.RBasicLab.Destroy();
}


Should be:

Code: cpp
SCRIPT_API void BasicLabResearch()
{
Player[1].MarkResearchComplete(BasicLabOrder[scriptGlobal.CBasicLab]);
scriptGlobal.CBasicLab +=1;
scriptGlobal.RBasicLab.Destroy();
if (scriptGlobal.CBasicLab < 7)
   scriptGlobal.RBasicLab = CreateTimeTrigger(1, 0, BasicLabTime[scriptGlobal.CBasicLab], "BasicLabResearch");
}


What I did was make it destroy the research handle as one research has been marked complete, so as to set it as a trigger handle for the next time it should fire.

I only did it to the Basic Lab research, just apply to the other two.
"Nothing from nowhere, I'm no one at all"

Angellus Mortis

Quote
QuoteIt show no sign of them getting the techs.
What I suspect is that the trigger only launches once and is not re-enabled afterward.

Which is true.

Thanks, Hidiot it works.

Eddy-B

Looks like you guys don't need me anymore :P
Hidiot's doing fine without me!
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

Hidiot

#5
I detect sarcasm.

Really, now... I'm not that good, I'm just trying to help while I'm still active. I do fumble, you know.
"Nothing from nowhere, I'm no one at all"