Page 1 of 1

Fixing Units

Posted: Fri Jul 08, 2016 12:51 am
by Paul59
Hi guys,

I want to fix in place the AI team 2, until turn 6. What code do I put into the .bsf file?

Many thanks!


Paul

Re: Fixing Units

Posted: Fri Jul 08, 2016 7:25 am
by rbodleyscott
Paul59 wrote:Hi guys,

I want to fix in place the AI team 2, until turn 6. What code do I put into the .bsf file?

Many thanks!


Paul
Internally, AI turns are numbered 1,3,5,7,8,11, so their 6th turn is turn 11

Code: Select all

if (side == 1)
  {
    if (GetTurn() < 11)
    {
        MoveTeamCoord(1,2,-1,-1,64);
    }
}
in StartTurnPost().

64 will stop them doing any moves except turning to face nearby enemy.

Change the 64 to 8 if you want them to react normally to enemy who come close (including charging them if appropriate), 136 if you want them to react only to non-light enemy.

Re: Fixing Units

Posted: Fri Jul 08, 2016 9:19 pm
by Paul59
Thanks Richard,

That worked a treat!

Cheers


Paul

Re: Fixing Units

Posted: Tue Jul 12, 2016 11:00 am
by Paul59
Hi Richard,

I also need to know how to fix Player Team 1 indefinitely. I tied to do it by adapting the code given above, but I cannot get it to work. It might be because I have switched sides for this scenario, and that always seems to cause problems.


Cheers

Re: Fixing Units

Posted: Tue Jul 12, 2016 11:43 am
by rbodleyscott
Paul59 wrote:Hi Richard,

I also need to know how to fix Player Team 1 indefinitely. I tied to do it by adapting the code given above, but I cannot get it to work. It might be because I have switched sides for this scenario, and that always seems to cause problems.


Cheers
You can't fix player teams like this. They don't use AI code to move, so giving them the 64 "aggression" order has no effect.

You can simply give them 0 AP each turn if you like, which would allow them to turn 45 degrees but do nothing else. Or you could allow the player no control of them whatsoever, as I did for the Saxons in the First Battle of Breitenfeld scenario.

If you tell me what exactly you are trying to achieve, I may be able to give you a snippet of code to do it.

Re: Fixing Units

Posted: Tue Jul 12, 2016 12:43 pm
by Paul59
Thanks Richard,

The 0 AP option will work just fine I think.


regards

Paul

Re: Fixing Units

Posted: Tue Jul 12, 2016 12:51 pm
by rbodleyscott
Paul59 wrote:Thanks Richard,

The 0 AP option will work just fine I think.


regards

Paul
Can you figure out how to do that yourself or need a snippet of code from me?

Re: Fixing Units

Posted: Tue Jul 12, 2016 12:55 pm
by Paul59
You mean put a zero in column O of the Squads.csv file, right? I am very happy modifying that file, its this all coding in the .bsf files that I have no clue about!

Re: Fixing Units

Posted: Tue Jul 12, 2016 2:06 pm
by rbodleyscott
Paul59 wrote:You mean put a zero in column O of the Squads.csv file, right? I am very happy modifying that file, its this all coding in the .bsf files that I have no clue about!
Well it is a bit of a hack, but if it does the job for you, fine.

Re: Fixing Units

Posted: Mon Jul 18, 2016 9:20 pm
by Paul59
Paul59 wrote:Thanks Richard,

That worked a treat!

Cheers


Paul
Actually, it worked once, and then I made changes to the scenario and I have been unable to get it to work since!

I am working on another scenario now, and currently I can get the script to stop the team from advancing, but they never get released.

I have fiddled with the code endlessly, and this is what I have got at the moment;

FUNCTION StartTurnPost(side)
{
// Scenario-specific AI code goes here - you can look at some of the historical scenarios for examples.
if (side == 1)
{
if (GetTurn() < 3)
{
MoveTeamCoord(1,1,-1,-1,8);
}
// AI_Masterplan() can be used to provide automated AI for encounter battles where Side 0 is on the left side of the map and Side 1 is on the right side of the map.
// Be warned that it may not cope well with unusual AI deployments.
// If used, PreBattleSetup() must include AI_ReassignTeams(1);
// The parameter is the turn on which the AI side will start to advance its infantry if it has not done so already. (Turn 0 is side 0's first turn, Turn 1 is Side 1's first turn, and so on).
// If the value is set at -1 the infantry will only ever advance if the tactical situation merits it.

// AI_Masterplan(15);

// If you want to use AI_Masterplan() in a scenario where the AI foot is defending fortifications you need to use the following code here
// SetUniversalVar("SkirmishGame",1);
// SetUniversalVar("ScenarioType",0);
// AI_Masterplan(-1);
// SetUniversalVar("SkirmishGame",0);
// You would also need to set the position of the fortification line in PreBattleSetup(), using
// SetUniversalVar("FootMinX", 24); // X-coordinate of bottom end of fortifications line
// SetUniversalVar("FootMaxX", 28); // X-coordinate of upper end of fortifications line
// SetUniversalVar("FrontLine", 26); // Y-coordinate of fortifications line


// Otherwise insert any custom AI code here
}

// Set up MP scenario to use adjusted MP victory conditions:
// SetMPForceRatio();
}

Please can you tell me where I am going wrong with this?

I have set the release turn as 3 because I have been play testing to see if it works, and did not want to go through several turns to find out that it did not work. Ideally I would like AI Team 1 to be released on turn 17.


Cheers


Paul

Re: Fixing Units

Posted: Tue Jul 19, 2016 6:03 am
by rbodleyscott
They aren't automatically released, you have to code the change of orders.

Code: Select all

if (GetTurn() < 3)
  {
    MoveTeamCoord(1,1,-1,-1,8);
  }
else
  {
    MoveTeamCoord(1,1,-1,-1,16); 
  }
Unless you want them to go anywhere in particular in which case replace the -1, -1 in the second MoveTeamCoord() with a destination, although they will deviate from this if any enemy are near

Re: Fixing Units

Posted: Tue Jul 19, 2016 7:44 pm
by Paul59
Thanks Richard, that has worked.

Re: Fixing Units

Posted: Fri Nov 18, 2016 11:48 am
by edward77
Paul, Trying to design a scenario with the normal P&S unit set for Fontenoy 1745 is not very good so I had a go at using your squad.csv from Blenheim and its working ok so far. However before proceeding any further I need your permission to use the file. The only major problem I have encounted is finding and switching the sideicons which currently are the wrong way around (Henry leading the French!).
BTW is there any way of switching the editor to and from the background whilst editing the text1 or squad files?

Re: Fixing Units

Posted: Fri Nov 18, 2016 2:03 pm
by rbodleyscott
edward77 wrote:BTW is there any way of switching the editor to and from the background whilst editing the text1 or squad files?
ALT_TAB should work.

Re: Fixing Units

Posted: Fri Nov 18, 2016 3:09 pm
by Paul59
edward77 wrote:Paul, Trying to design a scenario with the normal P&S unit set for Fontenoy 1745 is not very good so I had a go at using your squad.csv from Blenheim and its working ok so far. However before proceeding any further I need your permission to use the file. The only major problem I have encounted is finding and switching the sideicons which currently are the wrong way around (Henry leading the French!).
BTW is there any way of switching the editor to and from the background whilst editing the text1 or squad files?
Blenheim is not my scenario, it was designed by Odenathus.

The Sideicons (and Uniticons, Flags etc) are numbered to match the SIDENAME. The standard list of SIDENAMEs are as follows;

IDS_SIDENAME0,"Anti-Imperial", // Default
IDS_SIDENAME1,"Pro-Imperial", // Default
IDS_SIDENAME2,"Protestant", // TYW German
IDS_SIDENAME3,"Catholic", // TYW German
IDS_SIDENAME4,"French", // TYW
IDS_SIDENAME5,"Spanish", // TYW
IDS_SIDENAME6,"Swedish", // TYW
IDS_SIDENAME7,"Transylvanian", // TYW
IDS_SIDENAME8,"Polish", // TYW
IDS_SIDENAME9,"Ottoman", // TYW
IDS_SIDENAME10,"Danish", // TYW
IDS_SIDENAME11,"Weimarian", // TYW
IDS_SIDENAME12,"Royalist", // ECW
IDS_SIDENAME13,"Parliamentarian", // ECW
IDS_SIDENAME14,"Scots", // ECW
IDS_SIDENAME15,"Swiss", // Italian Wars
IDS_SIDENAME16,"Italian", // Italian Wars
IDS_SIDENAME17,"Spanish/Imperial", // Italian Wars
IDS_SIDENAME18,"French", // Italian Wars
IDS_SIDENAME19,"Bohemian", // TYW
IDS_SIDENAME20,"French Huguenot",
IDS_SIDENAME21,"Dutch",
IDS_SIDENAME22,"Russian",
IDS_SIDENAME23,"Hungarian-Bohemian",

You can create and use your own sideicons to replace the standard ones, they need to be put in the DATA/UI/TEXTURES folder of your scenario.

It sounds like you have copied Odenathus' Blenheim scenario and have tried to change the player side to the French. All you need to do is change the Side IDs in the editor to what you require (presumably French for Side 0 and British for Side 1? Creating your own appropriate 18th Century sideicons is a little more difficult, and requires some graphical skills, but maybe you could borrow some from existing scenarios, such as my own Nine Years War battles or Odenathus' Jacobite scenarios? They will not be ideal, but would be better than the standard pictures.

Re: Flags

Posted: Tue Mar 07, 2017 9:01 pm
by edward77
Paul, I think flag3 is Austrian but is not linked to a side icon. How do I get the AI to use that flag?

Re: Flags

Posted: Wed Mar 08, 2017 9:42 am
by Paul59
edward77 wrote:Paul, I think flag3 is Austrian but is not linked to a side icon. How do I get the AI to use that flag?
I'm a bit confused about what you mean. Are you talking about a particular mod or scenario? In the main game side 3 is Catholic (although the Austrian army lists do use it), and it certainly has a sideicon.

Re: Fixing Units

Posted: Thu Mar 09, 2017 10:51 am
by edward77
Ah! You have answered the question! I did not twig the Catholic-Austrian connection. Thank you

Re: Fixing Units

Posted: Sat Apr 08, 2017 12:36 am
by ReinerAllen
Just downloaded "Labositz" . Nice mod.

Re: Fixing Units

Posted: Sun Apr 09, 2017 9:34 pm
by edward77
The credit for the mods goes to Odenathus who kindly allowed me to use them.