Page 12 of 13

Needs suggestion to fix coded problematic behaviors

Posted: Sat Feb 24, 2018 12:57 am
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");
        }
      }
    }
  }

How to write brver offensive AIs

Posted: Mon Mar 12, 2018 6:41 pm
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");
          }
        }
      }
    }
  }
  

Advanced Terror AI personality

Posted: Sun Mar 03, 2019 7:25 am
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.)

Re: AI mod suggestions.

Posted: Sat May 11, 2019 3:42 pm
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.

Re: AI mod suggestions.

Posted: Sun May 12, 2019 3:04 am
by j3rry
Yes. This AI is focused on DumDums and Mines, also it builds quite a bit of AA Guns and Pillboxes.

Re: AI mod suggestions.

Posted: Thu May 16, 2019 4:48 pm
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...

Re: AI mod suggestions.

Posted: Thu May 16, 2019 10:34 pm
by j3rry
Advanced Vehcles AI personality. AI player produces large amount of various vehicles: tanks, half-tracks, dumdums, choppers.

Re: AI mod suggestions.

Posted: Thu Jun 13, 2019 3:24 am
by HarrickGreen_TRB
Hey, can we combine those personality?

Re: AI mod suggestions.

Posted: Thu Jun 13, 2019 11:55 am
by j3rry
Sure, you can. They will not conflict with each other.

Re: AI mod suggestions.

Posted: Fri Jun 28, 2019 7:16 am
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