Modding Movement through units - Robosturm/Commander_Wars GitHub Wiki

This is something a lot of people have asked or requested. After some thinking through. I came up with a solution that will/is possible with Beta Release 19

Step by steup walk through:

  1. Give a unit the ability to ignore unit collision. See oozium-code for an example.
  2. Change the movement cost function signature to:
this.getMovementpoints = function(terrain, unit, currentTerrain, trapChecking = false)
  1. Go to the movement table used by the given unit and add the following code:
var currentUnit = terrain.getUnit();
if ((currentUnit !== null) &&
    (unit.getOwner().isEnemy(currentUnit .getOwner())))
{
    if (!currentUnit.isStealthed(unit.getOwner()) || trapChecking)
    {
        if (unit should not cross this currentUnit condition)
        {
            return -1;
        }
    }
}
  1. Replace the pseudo code for when a unit should not cross through the other unit. E.g. an air unit should cross another air unit or a sea unit another sea unit etc. Be creative.