AI mod suggestions.

Mods that are being worked on. You can post your teaser here.
User avatar
Secg
Half Track L2
Half Track L2
Posts: 200
Joined: Sat Jun 10, 2017 12:28 am
United States of America

Needs suggestion to fix coded problematic behaviors

Post by Secg »

For some strange reasons, the Medic which is supposedly assigned to heal its team's Sarge decides to meet other Medics at the center of the map. Maybe it's confused about which tagged units to follow?

I put the code lines from personality_default_scripts.cfg here:

Code: Select all

  // Sarge
  CreateRecruitType("personality.default.recruit.sarge")
  {
    Type("army.unit.sarge", 1);
  }
  
  // Sarge script
  CreateScript("personality.default.defense.sarge")
  {
    InitialState("Recruit");

    CreateVarString("%.types", "");
    CreateVarFloat("%.range", 100.0);
    CreateVarInteger("%.acceptInsufficient", 0);
    CreateVarInteger("%.cluster.target");
    CreateVarString("%.base");
    CreateVarString("%.tag", "");

    State("Recruit")
    {
      Action("Recruit", "TypeBase")
      {
        Config("%.types");
        Location()
        {
          Base("Base", "%.base");
        }
        Range("%.range");
        AcceptInsufficient("%.acceptInsufficient");
        Base("%.base");
      }
      Conditions()
      {
        Condition("ObjectiveCondition")
        {
          Condition("Timer")
          {
            Time(10);  // Wait 10 seconds. If we don't have a sarge then abort.
          }
          Transition()
          {
            GoToState("HaveSarge");
          }
        }
      }
    }

    // Do I have a Sarge?
    State("HaveSarge")
    {
      Settings()
      {
        Setting("Tag")
        {
          Tag("%.tag");
          Append(1);
        }
      }
      Conditions()
      {
        Condition("Count")
        {
          Amount(0);
          Operator(">");
          Transition()
          {
            GoToState("DefendBase");
          }
        }
        Condition("Count")
        {
          Amount(0);
          Operator("<=");
          Transition()
          {
            GoToState("Abort");
          }
        }
      }
    }

    //State("Find")
    //{
      //Action("ApplyRule")
      //{
        //Rule("FindUndefendedCluster");
        //Var("%.cluster.target");
        //DangerRatio("%.danger");
      //}
      //Conditions()
      //{
        //Condition("Count")
        //{
          //Amount(0);
          //Operator("<=");
          //Transition()
          //{
            //GoToState("Abort");
          //}
        //}
        //Condition("HitPoints")
        //{
          //Operator("<");
          //Amount(500);
          //Transition()
          //{
            //GoToState("ReturnToBase");
          //}
        //}
        //Status("Completed")
        //{
          //GoToState("Move");
        //}
        //Status("Failed")
        //{
          //GoToState("DefendBase");
        //}
      //}
    //}

    State("DefendBase")
    {
      Action("ApplyRule")
      {
        Rule("FindProtectBase");
        ArmourClass("structure");
        Var("%.cluster.target");
        Base("%.base");
      }
      Conditions()
      {
        Condition("Count")
        {
          Amount(0);
          Operator("<=");
          Transition()
          {
            GoToState("Abort");
          }
        }
        Condition("HitPoints")
        {
          Operator("<");
          Amount(199);
          Transition()
          {
            GoToState("Run");
          }
        }
        Status("Completed")
        {
          GoToState("Move");
        }
        Status("Failed")
        {
          GoToState("ReturnToBase");
        }
      }
    }

    State("Move")
    {
      Action("Move")
      {
        Attack(1);
        Location()
        {
          Base("VarCluster", "%.cluster.target");
        }
      }
      Conditions()
      {
        Condition("Count")
        {
          Amount(0);
          Operator("<=");
          Transition()
          {
            GoToState("Abort");
          }
        }
        Condition("HitPoints")
        {
          Operator("<");
          Amount(199);
          Transition()
          {
            GoToState("Run");
          }
        }
        Condition("ObjectiveCondition")
        {
          Condition("Timer")
          {
            Time(30);
          }
          Transition()
          {
            GoToState("DefendBase");
          }
        }
        Status("Completed")
        {
          GoToState("DefendBase");
        }
      }
    }

    State("Run")
    {
      Action("Move")
      {
        Attack(0);
        Location()
        {
          Base("Base", "%.base");
        }
      }
      Conditions()
      {
        Condition("Count")
        {
          Amount(0);
          Operator("<=");
          Transition()
          {
            GoToState("Abort");
          }
        }
        Status("Completed")
        {
          GoToState("Wait");
        }
      }
    }

    State("ReturnToBase")
    {
      Action("Move")
      {
        Attack(1);
        Location()
        {
          Base("Base", "%.base");
        }
      }
      Conditions()
      {
        Condition("Count")
        {
          Amount(0);
          Operator("<=");
          Transition()
          {
            GoToState("Abort");
          }
        }
        Condition("HitPoints")
        {
          Operator("<");
          Amount(199);
          Transition()
          {
            GoToState("Run");
          }
        }
        Status("Completed")
        {
          GoToState("Wait");
        }
      }
    }

    State("Wait")
    {
      Conditions()
      {
        Condition("Count")
        {
          Amount(0);
          Operator("<=");
          Transition()
          {
            GoToState("Abort");
          }
        }
        Condition("HitPoints")
        {
          Operator(">=");
          Amount(900);
          Transition()
          {
            GoToState("DefendBase");
          }
        }
      }
    }

    State("Abort")
    {
      Action("Discharge");
      Conditions()
      {
        Status("Completed")
        {
          End();
        }
      }
    }
  }
  
  // Sarge heal
  CreateScript("personality.default.sargeheal")
  {
    InitialState("Start");

    CreateVarString("%.tag", "");

    State("Start")
    {
      Conditions()
      {
        Condition("ObjectiveCondition")
        {
          Condition("Timer")
          {
            Time(180);
          }
          Transition()
          {
            GoToState("Move");
          }
        }
      }
    }

    State("Move")
    {
      Action("FollowTag")
      {
        Attack(1);
        Tag("%.tag");
      }
      Conditions()
      {
        Status("Completed")
        {
          GoToState("Move");
        }
        Status("Failed")
        {
          GoToState("Move");
        }
      }
    }
  }
ImageImage
User avatar
Secg
Half Track L2
Half Track L2
Posts: 200
Joined: Sat Jun 10, 2017 12:28 am
United States of America

How to write brver offensive AIs

Post by Secg »

The "Offensive" scripts, which operates according to the "FindUndefendedCluster" rule is often too cowardly to attack structures which have units or towers placed nearby . Is there any way to program the AI so that it will simply attack the structure even if there were defening troops & tower nearby?

Code: Select all

  
  CreateScript("personality.default.offense.advinfantry")
  {
    InitialState("Start");

    CreateVarFloat("%.danger", 0.2);
    CreateVarInteger("%.cluster.target");
    CreateVarString("%.base");

    State("Start")
    {
      Conditions()
      {
        Condition("ObjectiveCondition")
        {
          Condition("Timer")
          {
            Time(360);
          }
          Transition()
          {
            GoToState("Wait");
          }
        }
      }
    }

    State("Find")
    {
      Action("ApplyRule")
      {
        Rule("FindUndefendedCluster");
        Var("%.cluster.target");
        DangerRatio("%.danger");
      }
      Conditions()
      {
        Condition("HitPoints")
        {
          Operator("<");
          Percentage(80%);
          Transition()
          {
            GoToState("HeavyFire");
          }
        }
        Status("Completed")
        {
          GoToState("Move");
        }
        Status("Failed")
        {
          GoToState("DefendBase");
        }
      }
    }

    State("Move")
    {
      Action("Move")
      {
        Attack(1);
        Location()
        {
          Base("VarCluster", "%.cluster.target");
        }
      }
      Conditions()
      {
        Condition("HitPoints")
        {
          Operator("<");
          Percentage(90%);
          Transition()
          {
            GoToState("HeavyFire");
          }
        }
        Condition("ObjectiveCondition")
        {
          Condition("Timer")
          {
            Time(30);
          }
          Transition()
          {
            GoToState("Wait");
          }
        }
        Status("Completed")
        {
          GoToState("Wait");
        }
      }
    }

    State("HeavyFire")
    {
      Conditions()
      {
        Condition("Threat")
        {
          Amount(10%);
          Operator(">");
          Transition()
          {
            GoToState("SeekShelter");
          }
        }
        Condition("ObjectiveCondition")
        {
          Condition("Timer")
          {
            Time(30);
          }
          Transition()
          {
            GoToState("Wait");
          }
        }
      }
    }

    State("SeekShelter")
    {
      Action("ApplyRule")
      {
        Rule("FindShelteredCluster");
        Var("%.cluster.target");
        MaxDistance(150);
      }
      Conditions()
      {
        Status("Completed")
        {
          GoToState("Run");
        }
        Status("Failed")
        {
          GoToState("ReturnToBase");
        }
      }
    }
	
    State("Run")
    {
      Action("Move")
      {
        Attack(0);
        Location()
        {
          Base("VarCluster", "%.cluster.target");
        }
      }
      Conditions()
      {
        Condition("ObjectiveCondition")
        {
          Condition("Timer")
          {
            Time(30);
          }
          Transition()
          {
            GoToState("Wait");
          }
        }
        Status("Completed")
        {
          GoToState("Wait");
        }
      }
    }
	
    State("ReturnToBase")
    {
      Action("Move")
      {
        Attack(0);
        Location()
        {
          Base("Base", "%.base");
        }
      }
      Conditions()
      {
        Condition("ObjectiveCondition")
        {
          Condition("Timer")
          {
            Time(30);
          }
          Transition()
          {
            GotoState("Wait");
          }
        }
        Status("Completed")
        {
          GoToState("Wait");
        }
      }
    }

    State("DefendBase")
    {
      Action("ApplyRule")
      {
        Rule("FindProtectBase");
        ArmourClass("structure");
        Var("%.cluster.target");
        Base("%.base");
      }
      Conditions()
      {
        Status("Completed")
        {
          GoToState("Move");
        }
        Status("Failed")
        {
          GoToState("Find");
        }
      }
    }

    State("Wait")
    {
      Conditions()
      {
        Condition("HitPoints")
        {
          Operator("<");
          Percentage(90%);
          Transition()
          {
            GoToState("HeavyFire");
          }
        }
        Condition("And")
        {
          Condition("ObjectiveCondition")
          {
            Condition("Timer")
            {
              Time(10);
            }
          }
          Condition("Count")
          {
            Amount(13);
            Operator(">");
          }
          Transition()
          {
            GoToState("Find");
          }
        }
      }
    }
  }
  
ImageImage
User avatar
j3rry
Map Maker
Map Maker
Posts: 121
Joined: Thu Oct 11, 2018 5:43 am
Location: Central Russia
Russia

Advanced Terror AI personality

Post by j3rry »

Advanced Terror AI personality, made by me.

Forces Computer Player to produce a lot of DumDums and plant various Mines around of its base and occupy resources with Pillboxes. This personality especially useful when playing in team. With DumDum AI could become very dangerous and pretty annoying. (Though it mostly depends on a map.)
Last edited by j3rry on Thu Jan 06, 2022 7:13 am, edited 2 times in total.
User avatar
Rarefy (R.SX)
Half Track
Half Track
Posts: 60
Joined: Tue Aug 02, 2016 9:04 pm
Location: United States
Contact:
Mexico

Re: AI mod suggestions.

Post by Rarefy (R.SX) »

So the AI basically plays competitively but additionally deploys a whole lot of dumdums and mines around its base?... :COFE:
j3rry wrote: Sun Mar 03, 2019 7:25 am Advanced Terror AI personality, made by me.

Forces AI player to produce a lot of dumdums, also plant various mines around of its base and occupy resources with pillboxes.
This personality is useful when playing in team, acting great as teammate. With dumdums AI could become very dangerous and pretty annoying (mostly depends on map).

Installation: just unpack the file into your game directory.
Also tested in multiplayer, but every player must have this persona.
User avatar
j3rry
Map Maker
Map Maker
Posts: 121
Joined: Thu Oct 11, 2018 5:43 am
Location: Central Russia
Russia

Re: AI mod suggestions.

Post by j3rry »

Yes. This AI is focused on DumDums and Mines, also it builds quite a bit of AA Guns and Pillboxes.
Last edited by j3rry on Thu Jan 06, 2022 7:11 am, edited 1 time in total.
User avatar
Rarefy (R.SX)
Half Track
Half Track
Posts: 60
Joined: Tue Aug 02, 2016 9:04 pm
Location: United States
Contact:
Mexico

Re: AI mod suggestions.

Post by Rarefy (R.SX) »

hey if you can see this TommyCD1 i was going to ask if you could try making an AI personality that focuses on consistency and strategy... more so.. they produce anykind of unit... and they also use their heroes.. and plant mines :GAME: ... Almost as if its being played by a Human just as nearly... 8)

Id like to use this in certain maps and face an AI that has a bit of strategy thinking where it defends its base and it sends all types of units accordingly in any given time (as scouts or as groups) where it senses attacks or when it wants to attack.. if you get what i mean?.. :ROCK: :GAME:

This could be a perfect AI personality for normal maps if it comes out right... ya know? .. im asking you because you seem to have tremendous skill doing this as i overlooked this forum =D> ... (i should really start making maps and mods myself but i dont know where to start) lol...
User avatar
j3rry
Map Maker
Map Maker
Posts: 121
Joined: Thu Oct 11, 2018 5:43 am
Location: Central Russia
Russia

Re: AI mod suggestions.

Post by j3rry »

Advanced Vehcles AI personality. AI player produces large amount of various vehicles: tanks, half-tracks, dumdums, choppers.
Last edited by j3rry on Thu Jan 06, 2022 7:06 am, edited 1 time in total.
User avatar
HarrickGreen_TRB
Tank
Tank
Posts: 97
Joined: Fri Dec 28, 2018 2:20 am
Location: D.F.S.P
Vietnam

Re: AI mod suggestions.

Post by HarrickGreen_TRB »

Hey, can we combine those personality?
User avatar
j3rry
Map Maker
Map Maker
Posts: 121
Joined: Thu Oct 11, 2018 5:43 am
Location: Central Russia
Russia

Re: AI mod suggestions.

Post by j3rry »

Sure, you can. They will not conflict with each other.
Last edited by j3rry on Thu Jan 06, 2022 7:06 am, edited 2 times in total.
User avatar
HarrickGreen_TRB
Tank
Tank
Posts: 97
Joined: Fri Dec 28, 2018 2:20 am
Location: D.F.S.P
Vietnam

Re: AI mod suggestions.

Post by HarrickGreen_TRB »

j3rry wrote: Thu Jun 13, 2019 11:55 am
HarrickGreen_TRB wrote: Thu Jun 13, 2019 3:24 am
Sure, you can. They won't conflict with each other.
How cool that would be hmm
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests