Turret fixes

NPC turrets should track properly, and OXP ships using the old style
of subentity declaration with the core turret entity should now work.
This commit is contained in:
cim 2015-05-16 09:06:26 +01:00
parent 2cc3a9f561
commit b70c555743
3 changed files with 22 additions and 1 deletions

View File

@ -316,6 +316,7 @@ Bug fixes:
* Bug making tutorial extremely difficult to complete if player obtained a
bounty fixed.
* Fix error with cargo dumping when reloading save after death
* Fix NPC turret aim
-------------------------------------------------------------------------------

View File

@ -10205,13 +10205,23 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
vector_to_target = HPVectorToVector(HPvector_subtract([target position], my_position));
// this is in absolute coordinates, so now rotate it
OOLog(@"turret.debug",@"abs:[%f %f %f], vector:[%f %f %f]",my_position.x,my_position.y,my_position.z,vector_to_target.x,vector_to_target.y,vector_to_target.z);
Entity *last = nil;
Entity *father = [self parentEntity];
Quaternion q = kIdentityQuaternion;
while ((father)&&(father != last) && (father != NO_TARGET))
{
q = quaternion_multiply(q,quaternion_conjugate([father orientation]));
/* Fix orientation */
Quaternion fo = [father normalOrientation];
fo.w = -fo.w;
/* The below code works for player turrets where the
* orientation is different, but not for NPC turrets. Taking
* the normal orientation with -w works: there is probably a
* neater way which someone who understands quaternions can
* find, but this works well enough for 1.82 - CIM */
q = quaternion_multiply(q,quaternion_conjugate(fo));
last = father;
if (![last isSubEntity]) break;
father = [father owner];
@ -10220,6 +10230,9 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
// q now contains the rotation to the turret's reference system
vector_to_target = quaternion_rotate_vector(q,vector_to_target);
OOLog(@"turret.debug",@"adjvector:[%f %f %f]",vector_to_target.x,vector_to_target.y,vector_to_target.z);
leading = quaternion_rotate_vector(q,leading);
// rotate the vector to target and its velocity

View File

@ -1660,6 +1660,13 @@ static NSString * const kVisualEffectDataCacheKey = @"visual effect data";
if ([[ScanTokensFromString(action) objectAtIndex:0] isEqualToString:@"initialiseTurret"]) return YES;
}
if ([shipKey isEqualToString:@"ballturret"])
{
// compatibility for OXPs using old subentity declarations and the
// core turret entity
return YES;
}
return NO;
}