I dont understand the parameters of a script...

Have modding questions or discovered something new? Post here.
User avatar
{RaheeXF}
Map Maker
Map Maker
Posts: 169
Joined: Tue Jun 15, 2021 6:45 am
Virgin Islands (USA)

I dont understand the parameters of a script...

Post by {RaheeXF} »

Code: Select all

CreateObjectType("random_units","Objective")
{
  GameObj();
  ObjectiveObj()
  {
    Condition("Timer")
    {
      Time(120, 180);
    }
    Action()
    {
      NewRandomObjective()
      {
        Add("type1", 25);
        Add("type2", 25);
        Add("type3", 25);
        Add("type4", 25);
        Add("type5", 25);
        Add("type6", 25);
        Add("type7", 25);
      }
    }
  }
}

CreateObjectType("type1", "Objective")
{
  GameObj();
  ObjectiveObj()
  {
    Condition("Timer")
    {
      Time(15, 30);
    }
    Action()
    {
      ExecuteScript("type1*", "squad.move.typebasetotrail", 1000, 3)
      {
        Op("%.types", "=", "type1");
        Op("%.base", "=", "Tan");
        Op("%.trail", "=", "base-base");
        Op("%.attack", "=", 1);
        Op("%.acceptInsufficient", "=", 1);
      }

      NewObjective("random_units");
    }
  }
}
Can somebody please explain how ExecuteScript(), Op() and CreateObjectType() works? I just need a manual file or something...
By the way, I am back after a long time! :PB
*RaheeXF*
User avatar
TommyCD1
Moderator
Moderator
Posts: 1146
Joined: Tue Jun 04, 2013 8:55 am
Location: East Coast
Contact:
United States of America

Re: I dont understand the parameters of a script...

Post by TommyCD1 »

From my Custom Campaigns \ Missions Add-on Support. You are free to extract the files from the demonstration campaign and see what I've done. I've left a load of comments in the code to help you figure out what's going on.
TommyCD1 wrote:// In order to have some variance between waves, we can use random wave setups. To do this, we
// use a single parent objective that will be repeated indefinitely, which will call upon
// a random child which is then responsible for actually executing the attack script.
CreateObjectType("obj_tan-l_random_low_infantry", "Objective")
{
Condition("Timer")
{
// A timer can have two different numbers. If it does, it will randomly pick any value that is between
// the highest and lowest numbers inclusive. So ANY time from 30 to 200 seconds can be chosen.
Time(30, 200);
}

Action()
{
// This will call on a new objective just like the NewObjective function. However, this will pick
// one of the objectives from the list randomly based on their weight. Their weight is the number
// after the comma. Weight is relative, not based out of 100 or anything like that. So for example:
// Add("example_1", 60);
// Add("example_2", 30);
// In this instance, example 2 has a weight of 30. This does not mean it is 30% likely. Instead,
// since example 1 has a weight of 60, that makes example 1 twice as likely as example 2. This means
// that example 1 will be chosen 2/3 of the time, while example 2 will be chosen 1/3 of the time.
NewRandomObjective()
{
// Both variations are equally as likely to happen.
Add("obj_tan-l_loworder-1", 25);
Add("obj_tan-l_loworder-2", 25);
}

// Now call the parent objective once again to repeat the 90 second wait and the random wave logic.
NewObjective("obj_tan-l_low_infantry");
}
}
TommyCD1 wrote:// When you use an ExecuteScript function, its block will always look something like this:
// ExecuteScript("tan_attack", "squad.move.tagtotrail")
// {
// Op("%.var1", "=", "squad");
// Op("%.var2", "=", "trail");
// Op("%.var3", "=", 1);
// Op("%.var4", "=", 0);
// }
// In the function itself, there are two parameters. The first is the ID name of the script. This is used to
// refer to this script again at a later date, usually to abort it. It is also helpful for debugging; you can
// see which scripts are currently running, and can identify them by their name. In this example, our name is
// "tan_attack". Keep in mind that only one name can be in use at a time. The second parameter is the type of
// script it is. In this case, it is the "squad.move.tagtotrail" script, which is defined by the
// squad_move_tagtotrail.cfg file which was included from strategic.cfg.

// Each script has its own variables that can be adjusted on startup through the ExecuteScript function.
// Inside the block, you'll use the Op function to do this. Normally each variable has a more descriptive name,
// but in this example we'll ignore that for now. There are three different types of variables: Integers, Strings,
// and Floats. The Op function takes in three parameters: The variable being changed, the arithmetic being applied,
// and the value the variable is changing to. 90% of the time, the arithmetic you'll be using is "=" which sets the
// variable to the given input regardless of its value beforehand. For String variables, the third parameters MUST be
// inclosed within "" quotation marks. Otherwise, if the variable being changed is an Integer or a Float, then don't
// use the quotation marks.
I may not make the best maps, or be the best player, but I put a lot of time, effort, and care into my stuff. That counts for something, right? No.
Image
"Can we order a pizza?"
GameRanger ID: 913974
User avatar
{RaheeXF}
Map Maker
Map Maker
Posts: 169
Joined: Tue Jun 15, 2021 6:45 am
Virgin Islands (USA)

Re: I dont understand the parameters of a script...

Post by {RaheeXF} »

I cannot make the hills smooth using the brush (Smooth not Bell or Flat). The hills are sharp as hell......
Last edited by {RaheeXF} on Sat Mar 11, 2023 7:31 am, edited 1 time in total.
*RaheeXF*
User avatar
{RaheeXF}
Map Maker
Map Maker
Posts: 169
Joined: Tue Jun 15, 2021 6:45 am
Virgin Islands (USA)

Re: I dont understand the parameters of a script...

Post by {RaheeXF} »

I am really sorry to say that I still didnt understand what is CreateBase:Orderer(), CreateBase(), Orderers(), Manifest(), Placement(), Random(), CanBuild(), AddBase(), AssignBaseConstructors() and AssignBaseUnits(). These functions are sooo complicated. I am dying to figure these out. Oof! :S:
*RaheeXF*
User avatar
{RaheeXF}
Map Maker
Map Maker
Posts: 169
Joined: Tue Jun 15, 2021 6:45 am
Virgin Islands (USA)

Re: I dont understand the parameters of a script...

Post by {RaheeXF} »

Objective_Tan.cfg

Code: Select all

// Tan AI Starts Working

CreateObjectType("Tan_Start","Objective")
{
  Condition("TRUE"); // No Condition
  Action()
  {
      AddBase("Tan", "army") // "army" Is Defined In base_army.cfg
      {
        Orientation(120);
      }
      AssignBaseConstructors("Tan")
      {
        Tag("tan-base"); // Tag In Game
      }
      AssignBaseUnits("Tan")
      {
        Tag("tan-base"); // Tag In Game
      }

      NewObjective("Recruit_Random"); // Go To The Recruit_Random Objective
  }
}

// Recruit_Random Objective Which Will Select What To Recruit

CreateObjectType("Recruit_Random","Objective")
{
  GameObj();
  ObjectiveObj()
  {
    Condition("Timer") // Condtion Is A Timer
    {
      Time(1, 2); // Time(C,B) - Selects A Time Between C and B
    }
    Action()
    {
      NewRandomObjective()
      {
        // Select Any One Of These
        // The Second Value Is Weight
        Add("Infantry1", 25);
      }
    }
  }
}

// Infantry1 Objective Which Will Recruit And Send Units

CreateObjectType("Infantry1", "Objective")
{
  GameObj();
  ObjectiveObj()
  {
    Condition("Timer") // Condtion Is A Timer
    {
      Time(1, 2); // Time(C,B) - Selects A Time Between C and B
    }
    Action()
    {
      ExecuteScript("Infantry1", "squad.move.typebasetotrail") // ExecuteScript("Name", "Script Type")
      {
        Op("%.types", "=", "Infantry1"); // Defined In Recruit Types CFG File
        Op("%.base", "=", "Tan"); // Defined Above: AddBase("Tan", "army");
        Op("%.trail", "=", "barracks-trail-01"); // Trail Name In Studio/Editor
        Op("%.attack", "=", 1); // Just Go And Attack
        Op("%.acceptInsufficient", "=", 1); // It Will Attack What It Has If It Is Set To 1
      }

      // Go To Recruit_Random Objective Again
      // NewObjective("Recruit_Random"); 
    }
  }
}
Recruit_Types.cfg

Code: Select all

// A Amount Of Specific Units or Vehicles To Recruit
CreateRecruitType("Infantry1")
{
  Type("army.unit.grunt", 3);
}
Base_Army.cfg

Code: Select all

CreateBase("army")
{
  InitialState("army.units");

  State("army.units")
  {
    Orderers()
    {
      Add("army.units.infantry", 2000);
      //Add("army.units.vehicles", 2000);
    }
  }
}
Base_Army_Orderers.cfg

Code: Select all

CreateBase::Orderer("army.bulldozers")
{
  Manifest("Level")
  {
    Placement("army.units");
    Types()
    {
      Add("army.unit.bulldozer");
    }
  }
}
CreateBase::Orderer("army.units.infantry")
{
  Manifest("BaseLevel")
  {
    Placement("army.units");
    Types()
    {
      Add("army.unit.grunt", 20);
    }
    Random(1);
  }
}
I have given you the coding I have done. It does not work properly. It just recruits 20 grunts following the army.units.infantry Orderer....... I don't know what the hell is wrong here. Please send me a manual type of thing. I am getting lost...
*RaheeXF*
User avatar
TommyCD1
Moderator
Moderator
Posts: 1146
Joined: Tue Jun 04, 2013 8:55 am
Location: East Coast
Contact:
United States of America

Re: I dont understand the parameters of a script...

Post by TommyCD1 »

{RaheeXF} wrote: Sat Mar 11, 2023 6:14 amI cannot make the hills smooth using the brush (Smooth not Bell or Flat). The hills are sharp as hell......
Make sure you have both Deform and Raise selected before trying to use it. Also your brush strength may be too low. The strength of the brush is determined by the slider directly under the listbox of deform types. On a scale of 0 to 1, 1 being maximum strength, meaning it takes less time to get drastic results. A lower strength is good for very fine tunements.
Also keep in mind that this game is still very limited. Each cell is only so complex, so no matter what the ground may still look blocky, especially when using a heightmap. In some cases it may be better to simply create your hills from scratch using the Bell deform mode. Or you can also use the Flat deform brush, then smooth the edges of the created plateaus.
{RaheeXF} wrote: Sat Mar 11, 2023 6:23 amI am really sorry to say that I still didnt understand what is CreateBase:Orderer(), CreateBase(), Orderers(), Manifest(), Placement(), Random(), CanBuild(), AddBase(), AssignBaseConstructors() and AssignBaseUnits(). These functions are sooo complicated. I am dying to figure these out. Oof! :S:
From what I can see so far in your code, there is only one problem. You stated that your base is in fact building the 20 grunts you are requesting, correct? Assuming "Tan_Start" is called immediately when the game is started, then your script is being executed too soon. "Tan_Start" calls "Recruit_Random" immediately, and "Recruit_Random" calls "Infantry1" after 1 to 2 seconds. Then, after another 1 to 2 seconds, "Infantry1" will execute your attacking script, which again seems to be coded correctly. The problem now, is that the tan base doesn't have enough time to build any units. Only at most 4 seconds have passed before the script is being executed, which is not even enough time to build one Grunt, which takes 10 seconds. Also because you have set %.acceptInsufficient, to 1 this means that the script will not wait to be filled out, instead it will take whatever it can take, even nothing, and continue like normal.

My recommendation is to try increasing your time between objectives drastically, for a simple grunt script, anywhere between 30 to 90 seconds can work. A good rule of thumb for random attack scripts: take each possible squad formation and add up the entire construction time of all units. Then, make your Time() function using the lowest and highest construction times. For example, the fastest squad could be two grunts and three grenadiers, which takes 65 seconds to build. The slowest squad could be four grunts, two grenadiers, and a minesweeper, which takes 80 seconds to build. Therefore, you could make your Time() scope between the values of 65 - 80 seconds.

Another possible problem I can see is that your "Infantry1" script doesn't call anything upon completion. That means your script is only ever run once. I would recommend uncommenting the line

Code: Select all

      // Go To Recruit_Random Objective Again
      // NewObjective("Recruit_Random"); 
This will repeat your script repeatedly. Although you may have to adjust your Time() function so it isn't repeating every 5 seconds.

Lastly, your objectives have unnecessary nesting in them.

Code: Select all

  GameObj();
  ObjectiveObj()
  {
  }
These functions / blocks are simply leftovers from early development. They appear in Dark Reign 2's code, as well as some code in Army Men RTS. But they are completely unnecessary. Either they are assumed by the code already, or they do nothing. It is safe to remove these.
I may not make the best maps, or be the best player, but I put a lot of time, effort, and care into my stuff. That counts for something, right? No.
Image
"Can we order a pizza?"
GameRanger ID: 913974
User avatar
{RaheeXF}
Map Maker
Map Maker
Posts: 169
Joined: Tue Jun 15, 2021 6:45 am
Virgin Islands (USA)

Re: I dont understand the parameters of a script...

Post by {RaheeXF} »

Hello Tommy! Thanks a lot for your reply. I have another question, are you saying that the AI will recruit army.units.infantry first then take some units from them (army.units.infantry) to attack? Like, does the Infantry1 script tell the AI to recruit units or does it just tells the AI to take some units from army.units.infantry which the AI makes? Also, the AI stops after making 20 grunt...... That means the AI can just attack 6 times (6*3 = 18 Grunts).......
*RaheeXF*
User avatar
{RaheeXF}
Map Maker
Map Maker
Posts: 169
Joined: Tue Jun 15, 2021 6:45 am
Virgin Islands (USA)

Re: I dont understand the parameters of a script...

Post by {RaheeXF} »

I don't only want the AI to recruit 20 grunts..... I also want the AI to attack with Tanks, Half-Tracks, Bazooka Man, etc. What should I do?
*RaheeXF*
User avatar
TommyCD1
Moderator
Moderator
Posts: 1146
Joined: Tue Jun 04, 2013 8:55 am
Location: East Coast
Contact:
United States of America

Re: I dont understand the parameters of a script...

Post by TommyCD1 »

{RaheeXF} wrote: Sat Mar 11, 2023 4:17 pmHello Tommy! Thanks a lot for your reply. I have another question, are you saying that the AI will recruit army.units.infantry first then take some units from them (army.units.infantry) to attack? Like, does the Infantry1 script tell the AI to recruit units or does it just tells the AI to take some units from army.units.infantry which the AI makes? Also, the AI stops after making 20 grunt...... That means the AI can just attack 6 times (6*3 = 18 Grunts).......
Yes! That is how it works. The base will produce the units according to the orderers it receives. Then, the actual script that is executed will recruit any units it needs from the base and uses them. And yes, while the base will only make 20 grunts, this does not mean that you are limited to using a total of 20 grunts. This is because the base will not only produce its orderers, it will also try to maintain the orderers. That is, should it ever at any reason have less than 20 grunts, it will resume building until it does. This means that, once the script recruits the units it needs, they are no longer considered as within the base, therefore they will immediately be rebuilt by the base for the next attack script(s). This is also the reason why it is recommended that AI bases be given a large amount of resources to build units with.
{RaheeXF} wrote: Sat Mar 11, 2023 4:20 pmI don't only want the AI to recruit 20 grunts..... I also want the AI to attack with Tanks, Half-Tracks, Bazooka Man, etc. What should I do?
You can simply give the base more orderers. Keep in mind that the only reason you'd want more than one orderer is to prioritize some set of units over another. If all you want is for you AI to make units however it can, then a single orderer is good enough.
Also, orderers can have more than one unit type. And these units do not have to be related in any way, such as by constructor. If you want an orderer, say like this

Code: Select all

CreateBase::Orderer("army.allunits")
{
  Manifest("BaseLevel")
  {
    Types()
    {
      Add("army.unit.grunt", 4);
      Add("army.unit.sniper", 2);
      Add("army.unit.tank", 1);
      Add("army.unit.chopper", 2);
    }
  }
}
Then that is perfectly acceptable for the game to use.
I may not make the best maps, or be the best player, but I put a lot of time, effort, and care into my stuff. That counts for something, right? No.
Image
"Can we order a pizza?"
GameRanger ID: 913974
User avatar
{RaheeXF}
Map Maker
Map Maker
Posts: 169
Joined: Tue Jun 15, 2021 6:45 am
Virgin Islands (USA)

Re: I dont understand the parameters of a script...

Post by {RaheeXF} »

Thank you so much! Also, gonna come back with a new single player map soon! Make sure to play and stream it as soon as I upload it! The new map is gonna be interesting....... :GAME:
*RaheeXF*
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest