The function GetUnitLonely(unit) is being called to run in the function MoraleCheck(), MoraleCheck() even called in the function StartTurn(side).
I do that for optimisation : my function MoraleCheck() use a single loop to go through the player's units, or is an officer and call the function OfficerBonus(unit), or I look if the unit is isolated (with function GetUnitLonely(unit)) and call the function AjustMoral(unit).
D-DAY SF Campaign : Sainte-Mere-Eglise
Moderators: Slitherine Core, BA Moderators
Amaris wrote:The function GetUnitLonely(unit) is being called to run in the function MoraleCheck(), MoraleCheck() even called in the function StartTurn(side).
I do that for optimisation : my function MoraleCheck() use a single loop to go through the player's units, or is an officer and call the function OfficerBonus(unit), or I look if the unit is isolated (with function GetUnitLonely(unit)) and call the function AjustMoral(unit).
hmm ... I'm sorry I haven't ran the scenario to check this ... I can see the check(for lonelyunit) in the MoraleCheck() ....
Code: Select all
else
{
if(GetUnitLonely(unit) == 1)
{
AjustMoral(unit);
}
}
Code: Select all
else
{
GetUnitLonely(unit) ;
if(GetUnitLonely(unit) == 1)
{
AjustMoral(unit);
}
}
-
- BA Moderator
- Posts: 1478
- Joined: Sun May 23, 2010 4:47 pm
- Location: Arizona USA -7GMT
-
- Captain - Heavy Cruiser
- Posts: 929
- Joined: Fri Jul 23, 2010 11:08 am
- Location: France
- Contact:
Well I'll try to explain :
Indeed the function GetUnitLonely(unit) return a value of 0 or 1 when it called.
The Syntax of if is :
The call of GetUnitLonely(unit) :
The (conditional) of if is : GetUnitLonely(unit) == 1. So the program call the function GetUnitLonely(unit), return 0 or 1 as follows and finally the (conditional) is 0 == 1 or 1 == 1 as follows.
Indeed the function GetUnitLonely(unit) return a value of 0 or 1 when it called.
The Syntax of if is :
Code: Select all
if(conditional)
{
//code
}
else
{
//code
}
Code: Select all
...
if(GetUnitLonely(unit) == 1)
{
AjustMoral(unit);
}
...