diff --git a/msu/hooks/entity/tactical/tactical_entity_manager.nut b/msu/hooks/entity/tactical/tactical_entity_manager.nut index c39a206d..be90f425 100644 --- a/msu/hooks/entity/tactical/tactical_entity_manager.nut +++ b/msu/hooks/entity/tactical/tactical_entity_manager.nut @@ -35,6 +35,27 @@ } return ret; } + + q.getAdjacentActors <- function( _tile ) + { + if (_tile.ID == 0) + { + ::logError("The ID of _tile is 0 which means that the actor this tile was fetched from is not placed on map."); + throw ::MSU.Exception.InvalidValue(_tile); + } + + local ret = []; + for (local i = 0; i < 6; i++) + { + if (!_tile.hasNextTile(i)) + continue; + + local nextTile = _tile.getNextTile(i); + if (nextTile.IsOccupiedByActor) + ret.push(nextTile.getEntity()); + } + return ret; + } q.getAlliedActors <- function( _faction, _tile = null, _distance = null, _atDistance = false ) { @@ -44,6 +65,14 @@ throw ::MSU.Exception.InvalidValue(_tile); } + if (_distance == 1) + { + local ret = this.getAdjacentActors(_tile); + if (!_atDistance && _tile.IsOccupiedByActor) + ret.push(_tile.getEntity()); + return ret.filter(@(_, _a) _a.isAlliedWith(_faction)); + } + return this.getActorsByFunction(function(_actor) { if (!_actor.isAlliedWith(_faction)) return false; if (_tile != null) @@ -64,6 +93,14 @@ throw ::MSU.Exception.InvalidValue(_tile); } + if (_distance == 1) + { + local ret = this.getAdjacentActors(_tile); + if (!_atDistance && _tile.IsOccupiedByActor) + ret.push(_tile.getEntity()); + return ret.filter(@(_, _a) !_a.isAlliedWith(_faction)); + } + return this.getActorsByFunction(function(_actor) { if (_actor.isAlliedWith(_faction)) return false; if (_tile != null) @@ -87,6 +124,14 @@ ::logError("The ID of _tile is 0 which means that the actor this tile was fetched from is not placed on map."); throw ::MSU.Exception.InvalidValue(_tile); } + + if (_distance == 1) + { + local ret = this.getAdjacentActors(_tile); + if (!_atDistance && _tile.IsOccupiedByActor) + ret.push(_tile.getEntity()); + return ret.filter(@(_, _a) _a.getFaction() == _faction); + } local actors = this.getInstancesOfFaction(_faction); local ret = []; @@ -108,6 +153,14 @@ throw ::MSU.Exception.InvalidValue(_tile); } + if (_distance == 1) + { + local ret = this.getAdjacentActors(_tile); + if (!_atDistance && _tile.IsOccupiedByActor) + ret.push(_tile.getEntity()); + return ret.filter(@(_, _a) _a.isAlliedWith(_faction) && _a.getFaction() != _faction); + } + return this.getActorsByFunction(function(_actor) { if (!_actor.isAlliedWith(_faction) || _actor.getFaction() == _faction) return false; if (_tile != null)