Officers
Moderators: Slitherine Core, BA Moderators
-
junk2drive
- BA Moderator

- Posts: 1478
- Joined: Sun May 23, 2010 4:47 pm
- Location: Arizona USA -7GMT
Officers
I'd like to see Merr's commanders with rally action combined with Amaris' officer range effect.
Thoughts?
Thoughts?
You can call me junk - and type that with one hand.
Junk,
Incorporating Amaris' officer range to a scenario that includes my commanders should be easy to do ....
Look in Amaris' scenario BSF called ST-MERE.bsf ...
There are several functions he created that need to be in your scenario BSF .... called ;
FUNCTION MoraleCheck()
FUNCTION OfficerBonus(unit)
FUNCTION GetUnitLonely(unit)
FUNCTION AjustMoral(unit)
There is only one FUNCTION that needs to be changed that would allow my commanders this ability...FUNCTION MoraleCheck()
Change the condition that reads ;
to read ;
So, the entire function should look like this ;
Hope that helps 
Incorporating Amaris' officer range to a scenario that includes my commanders should be easy to do ....
Look in Amaris' scenario BSF called ST-MERE.bsf ...
There are several functions he created that need to be in your scenario BSF .... called ;
FUNCTION MoraleCheck()
FUNCTION OfficerBonus(unit)
FUNCTION GetUnitLonely(unit)
FUNCTION AjustMoral(unit)
There is only one FUNCTION that needs to be changed that would allow my commanders this ability...FUNCTION MoraleCheck()
Change the condition that reads ;
Code: Select all
if (IsUnitType(unit, "US_Officier") == 1)Code: Select all
if ( GetAttrib (unit, "RallySkill") == 1)Code: Select all
FUNCTION MoraleCheck()
{
int i ;
int unit ;
for(i=0;i<GetUnitCount(0);i++)
{
unit = GetUnitID(0, i) ;
if ( GetAttrib (unit, "RallySkill") == 1)
{
OfficerBonus(unit);
}
else
{
if(GetUnitLonely(unit) == 1)
{
AjustMoral(unit);
}
}
}
}
-
junk2drive
- BA Moderator

- Posts: 1478
- Joined: Sun May 23, 2010 4:47 pm
- Location: Arizona USA -7GMT
You know ... I just realized that I "helped" you mess with the code again ...junk2drive wrote:Sure it helps but I'm lazy and want someone to do it for me![]()
Seems passive enough ... In this case, you could add conditions (or dupe functions) to run side (1) ... Currently, his code is only setup to check side(0).Is Amaris code passive enough for the AI to use it?
Duplicate functions could be called ...
FUNCTION MoraleCheckAI()
FUNCTION OfficerBonusAI(unit)
FUNCTION GetUnitLonelyAI(unit)
FUNCTION AjustMoralAI(unit)
Oh, by the way ... in his startturn he also has the check to run his functions ... shown as ;
Code: Select all
if(side == 0)
{
MoraleCheck();
}-
junk2drive
- BA Moderator

- Posts: 1478
- Joined: Sun May 23, 2010 4:47 pm
- Location: Arizona USA -7GMT
We can mess with this later ....junk2drive wrote:Messing with the code means me breaking it and you fixing it I think.
So we can model C&C differences for either player. We can have Germans with it and French and Soviet without.
The biggest problem is the AI Commanders ... The AI won't know how to use them properly like a human. Sure, it will work for the AI, but the AI commander might just move around like a normal unit and get himself killed.
Building the logic for the AI Commander is possible, but a big task... several ways to do it. An easy way would be placing the AI commander on a seperate team by himself and use AI Points to keep him out of trouble and manage it's movement to other units that need help. This would require the team aggression logic to be "dynamic" ... sometimes you want him to stay put (64), other times you want him to move around and avoid the enemy (4), etc.
-
pipfromslitherine
- Site Admin

- Posts: 9937
- Joined: Wed Mar 23, 2005 10:35 pm
Taking the AI script and adding special casing for a given unit type would not be that hard. You would just catch the office type at the top of the main functions.
Hmmm - looking the AI isn't documented, sorry! Basically it works like this:
1 - At the start of the AI turn we call AI_REBUILD - this can be used to build any state data you want for the turn
2 - Call AI_TEAM for each AI team
3 - Begin the normal turn
4 - For each unit in turn, call AI_UNIT until it returns -1, at which point move to the next one
I'll document it better once France is done!
Thanks
Pip
Hmmm - looking the AI isn't documented, sorry! Basically it works like this:
1 - At the start of the AI turn we call AI_REBUILD - this can be used to build any state data you want for the turn
2 - Call AI_TEAM for each AI team
3 - Begin the normal turn
4 - For each unit in turn, call AI_UNIT until it returns -1, at which point move to the next one
I'll document it better once France is done!
Thanks
Pip
-
Amaris
- Captain - Heavy Cruiser

- Posts: 929
- Joined: Fri Jul 23, 2010 11:08 am
- Location: France
- Contact:
In the first version, there was an error in function OfficerBonus(unit) ! Indeed, the bonus applied to the officer and not to the troops near...
Good version (included in version 3 of my campaign):
Good version (included in version 3 of my campaign):
Code: Select all
FUNCTION OfficerBonus(unit)
{
int i ;
int id ;
int distance;
int moral;
for(i=0;i<GetUnitCount(0);i++)
{
id = GetUnitID(0, i) ;
if ((id != unit) && (GetUnitActive(id) != 0))
{
distance = GetDistanceBetween(unit, id);
if (distance < 3)
{
AddVizUnitText(id, "IDS_UNIT_OfficerBonus", "FFCC00") ;
moral = GetAttrib(id, "Morale");
if (moral < 101)
{
moral = moral + 20;
SetAttrib (id, "Morale", moral) ;
}
}
}
}
}-
junk2drive
- BA Moderator

- Posts: 1478
- Joined: Sun May 23, 2010 4:47 pm
- Location: Arizona USA -7GMT
-
Amaris
- Captain - Heavy Cruiser

- Posts: 929
- Joined: Fri Jul 23, 2010 11:08 am
- Location: France
- Contact:
True, it is in:
Code: Select all
FUNCTION MoraleCheck()
{
int i ;
int unit ;
for(i=0;i<GetUnitCount(0);i++)
{
unit = GetUnitID(0, i) ;
if (IsUnitType(unit, "US_Officier") == 1)
{
OfficerBonus(unit);
}
else
{
if(GetUnitLonely(unit) == 1) //see if the unit is isolated
{
AjustMoral(unit); //the call function AjustMoral(unit) to reduce moral
}
}
}
}