You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the map editor, when you click on any character, first you will be able to give them proper order / behavior like: stationary, on guard, seek enemy and others. This works fine with all kind of human characters because there is a code for that.
Unfortunately creators gave animals only code for one behavior which is "MAX_ROAMING_RANGE", which corresponds to the function "seek enemy". That's why they are running whenever and wherever they want.
Is it possible to improve the code a bit and at least give bloodcats and crepitus the ability to behave the way we want them to in modifications?
I think the base code for that is in file "Game / Tactical / AIUtils.cc" in line 1933. For humans there are "Cases" with all kind of orders but not for the mentioned animals.
Would it take a lot of changes to give these animals these "cases" also with this "switch" function for all the behaviors?
Regards
JA2S version
Game version
Vanilla bug?
Used to work?
0.21.0
JA2 Gold 1.12 ENG
YES
NO
INT16 RoamingRange(SOLDIERTYPE *pSoldier, INT16 * pusFromGridNo)
{
if ( CREATURE_OR_BLOODCAT( pSoldier ) )
{
if ( pSoldier->bAlertStatus == STATUS_BLACK )
{
*pusFromGridNo = pSoldier->sGridNo; // from current position!
return(MAX_ROAMING_RANGE);
}
}
if ( pSoldier->bOrders == POINTPATROL || pSoldier->bOrders == RNDPTPATROL )
{
// roam near NEXT PATROL POINT, not from where merc starts out
*pusFromGridNo = pSoldier->usPatrolGrid[pSoldier->bNextPatrolPnt];
}
else
{
// roam around where mercs started
//*pusFromGridNo = pSoldier->sInitialGridNo;
*pusFromGridNo = pSoldier->usPatrolGrid[0];
}
switch (pSoldier->bOrders)
{
// JA2 GOLD: give non-NPCs a 5 tile roam range for cover in combat when being shot at
case STATIONARY:
if (pSoldier->ubProfile != NO_PROFILE || (pSoldier->bAlertStatus < STATUS_BLACK && !(pSoldier->bUnderFire)))
{
return( 0 );
}
else
{
return( 5 );
}
case ONGUARD:
return( 5 );
case CLOSEPATROL:
return( 15 );
case RNDPTPATROL:
case POINTPATROL:
return(10 ); // from nextPatrolGrid, not whereIWas
case FARPATROL:
if (pSoldier->bAlertStatus < STATUS_RED)
{
return( 25 );
}
else
{
return( 50 );
}
case ONCALL:
if (pSoldier->bAlertStatus < STATUS_RED)
{
return( 10 );
}
else
{
return( 30 );
}
case SEEKENEMY:
*pusFromGridNo = pSoldier->sGridNo; // from current position!
return(MAX_ROAMING_RANGE);
default:
return(0);
}
}
The text was updated successfully, but these errors were encountered:
Would it take a lot of changes? If you really just want to change the behavior of RoamingRange(), then all it takes would be to disable the first if block. One could do that by just removing the block, but we prefer not to change vanilla behavior unconditionally.
That means you would have to add a new game option. If you're interested in implementing this yourself (your best path forward if you need this feature urgently) then start by looking at the following files:
For your mod you could then advise players to set this new option in game.json.
The other approach to allow mods to override default game behavior are Lua scripts, which means you would have to add an Obervable callback for RoamingRange(). This is more flexible but also a bit more complex to implement.
Hello
In the map editor, when you click on any character, first you will be able to give them proper order / behavior like: stationary, on guard, seek enemy and others. This works fine with all kind of human characters because there is a code for that.
Unfortunately creators gave animals only code for one behavior which is "MAX_ROAMING_RANGE", which corresponds to the function "seek enemy". That's why they are running whenever and wherever they want.
Is it possible to improve the code a bit and at least give bloodcats and crepitus the ability to behave the way we want them to in modifications?
I think the base code for that is in file "Game / Tactical / AIUtils.cc" in line 1933. For humans there are "Cases" with all kind of orders but not for the mentioned animals.
Would it take a lot of changes to give these animals these "cases" also with this "switch" function for all the behaviors?
Regards
The text was updated successfully, but these errors were encountered: