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:
parent
2cc3a9f561
commit
b70c555743
@ -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
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user