How to calculate if party is in friendly territory?

Users who are viewing this thread

I want to create a function that will return whether the party is in friendly/neutral/enemy territory.
It seems I can get party's position, but that doesn't seems to help me much. I guess I could iterate through all settlements and get the kingdom from the closest settlement and check the relationship between the kingdom and party's kingdom. But that seems to cause a lot of calculations. Any easier ways to calculate whether a party is in friendly territory or not?
 
Have a look in the SettlementHelper class; you can call FindNearestSettlementToPoint and pass in the party's current position and then all you have to do is check relations with the settlement's faction. Be warned though, this method does iterate over all settlements so it could have a performance impact if you're planning to call it every tick or something (I would hope not).
 
Thanks MitchPTI.

After reading a bit, it seems I could use _currentSettlement in MobileParty class. I assume this will return the closest settlement for the party, as shown in the encyclepedia. I'll give this a try to see if I can use this `_currentSettlement` to help me figure out if a party is in friendly territory or not.
 
It seems currentSettlement property only contains value when the party is at a settlement in the campaign map. It looks like I have to use FindNearestSettlementToPoint.

Regarding to the performance, I might have to calculate this once for all points in the map can cache it in the memory.
 
Back
Top Bottom