- Timestamp:
- 06/09/11 19:01:01 (14 years ago)
- Location:
- ps/trunk/binaries/data/mods/public/simulation
- Files:
-
- 2 edited
-
components/UnitAI.js (modified) (1 diff)
-
helpers/Player.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
r9601 r9602 2007 2007 UnitAI.prototype.LeaveFoundation = function(target) 2008 2008 { 2009 // TODO: we should verify this is a friendly foundation, otherwise2010 // there's no reason we should let them build here2011 2012 2009 // If we're already being told to leave a foundation, then 2013 2010 // ignore this new request so we don't end up being too indecisive -
ps/trunk/binaries/data/mods/public/simulation/helpers/Player.js
r9532 r9602 192 192 } 193 193 194 /** 195 * Returns true if the entity 'target' is owned by an ally of 196 * the owner of 'entity'. 197 */ 194 198 function IsOwnedByAlly(entity, target) 195 199 { 196 //figure out which player controls us 197 var cmpOwnership = Engine.QueryInterface(entity, IID_Ownership); 198 var owner = 0; 199 if (cmpOwnership) 200 owner = cmpOwnership.GetOwner(); 201 202 var playerMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 203 var player = Engine.QueryInterface(playerMan.GetPlayerByID(owner), IID_Player); 204 // Get our diplomacy array 205 var diplomacy = player.GetDiplomacy(); 206 207 //figure out which player controls the foundation being built 208 var cmpOwnershipTarget = Engine.QueryInterface(target, IID_Ownership); 209 var targetOwner = 0; 210 if (cmpOwnershipTarget) 211 targetOwner = cmpOwnershipTarget.GetOwner(); 212 213 //If we don't like the guy with the building, ignore their request to move 214 return owner==targetOwner || diplomacy[targetOwner - 1] > 0; 200 // Figure out which player controls us 201 var owner = 0; 202 var cmpOwnership = Engine.QueryInterface(entity, IID_Ownership); 203 if (cmpOwnership) 204 owner = cmpOwnership.GetOwner(); 205 206 // Figure out which player controls the foundation being built 207 var targetOwner = 0; 208 var cmpOwnershipTarget = Engine.QueryInterface(target, IID_Ownership); 209 if (cmpOwnershipTarget) 210 targetOwner = cmpOwnershipTarget.GetOwner(); 211 212 // Players are always implicitly their own ally 213 if (owner == targetOwner) 214 return true; 215 216 // Get our diplomacy array 217 var playerMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 218 var player = Engine.QueryInterface(playerMan.GetPlayerByID(owner), IID_Player); 219 var diplomacy = player.GetDiplomacy(); 220 221 // Check for allied diplomacy status 222 if (diplomacy[targetOwner - 1] > 0) 223 return true; 224 225 return false; 215 226 } 216 227
Note:
See TracChangeset
for help on using the changeset viewer.
