Page 1 of 1
Officers
Posted: Sun Dec 12, 2010 5:45 pm
by junk2drive
I'd like to see Merr's commanders with rally action combined with Amaris' officer range effect.
Thoughts?
Posted: Mon Dec 13, 2010 2:41 pm
by Merr
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 ;
Code: Select all
if (IsUnitType(unit, "US_Officier") == 1)
to read ;
Code: Select all
if ( GetAttrib (unit, "RallySkill") == 1)
So, the entire function should look like this ;
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);
}
}
}
}
Hope that helps

Posted: Mon Dec 13, 2010 2:54 pm
by junk2drive
Sure it helps but I'm lazy and want someone to do it for me
Is Amaris code passive enough for the AI to use it?
Posted: Mon Dec 13, 2010 3:40 pm
by Merr
junk2drive wrote:Sure it helps but I'm lazy and want someone to do it for me
You know ... I just realized that I "helped" you mess with the code again ...

Is this a good thing?
Is Amaris code passive enough for the AI to use it?
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).
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 ;
This starts the whole process off and running!
Posted: Mon Dec 13, 2010 3:49 pm
by junk2drive
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.
Posted: Mon Dec 13, 2010 5:01 pm
by Merr
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.
We can mess with this later ....
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.
Posted: Mon Dec 13, 2010 8:42 pm
by pipfromslitherine
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
Posted: Tue Dec 14, 2010 5:10 pm
by Amaris
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):
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) ;
}
}
}
}
}
Posted: Tue Dec 14, 2010 5:37 pm
by junk2drive
I assume then that the malus for isolation is a separate function?
Posted: Tue Dec 14, 2010 6:00 pm
by Amaris
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
}
}
}
}