Outpost Universe Forums

Projects & Development => Outpost 2 Programming & Development => Topic started by: Angellus Mortis on July 29, 2009, 06:50:26 PM

Title: Ai Problems, Please Help
Post by: Angellus Mortis on July 29, 2009, 06:50:26 PM
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):

Code: [Select]
//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();
}
Title: Ai Problems, Please Help
Post by: Hooman on July 30, 2009, 12:36:47 AM
Perhaps you should ask a question if you're seeking help.
 
Title: Ai Problems, Please Help
Post by: Hidiot on July 30, 2009, 02:55:14 AM
Quote
It 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: [Select]
SCRIPT_API void BasicLabResearch()
{
Player[1].MarkResearchComplete(BasicLabOrder[scriptGlobal.CBasicLab]);
scriptGlobal.CBasicLab +=1;

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

Should be:

Code: [Select]
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.
Title: Ai Problems, Please Help
Post by: Angellus Mortis on July 30, 2009, 04:09:17 PM
Quote
Quote
It 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.
Title: Ai Problems, Please Help
Post by: Eddy-B on August 03, 2009, 09:40:44 AM
Looks like you guys don't need me anymore :P
Hidiot's doing fine without me!
Title: Ai Problems, Please Help
Post by: Hidiot on August 03, 2009, 09:46:46 AM
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.