Author Topic: Ai Problems, Please Help  (Read 2864 times)

Offline Angellus Mortis

  • Full Member
  • ***
  • Posts: 138
Ai Problems, Please Help
« 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();
}
« Last Edit: August 01, 2017, 11:44:06 AM by leeor_net »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Ai Problems, Please Help
« Reply #1 on: July 30, 2009, 12:36:47 AM »
Perhaps you should ask a question if you're seeking help.
 

Offline Hidiot

  • Hero Member
  • *****
  • Posts: 1018
Ai Problems, Please Help
« Reply #2 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.
« Last Edit: July 30, 2009, 02:58:08 AM by Hidiot »
"Nothing from nowhere, I'm no one at all"

Offline Angellus Mortis

  • Full Member
  • ***
  • Posts: 138
Ai Problems, Please Help
« Reply #3 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.

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Ai Problems, Please Help
« Reply #4 on: August 03, 2009, 09:40:44 AM »
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

Offline Hidiot

  • Hero Member
  • *****
  • Posts: 1018
Ai Problems, Please Help
« Reply #5 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.
« Last Edit: August 03, 2009, 09:47:27 AM by Hidiot »
"Nothing from nowhere, I'm no one at all"