Fixed bug of hitting wrong front/aft shield of player when hit by laser-beam from a NPC ship-subentity.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2583 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Eric Walch 2009-09-23 19:37:24 +00:00
parent 3a35a277ed
commit d1316acfb6

View File

@ -3294,9 +3294,10 @@ static PlayerEntity *sSharedPlayer = nil;
- (void) takeEnergyDamage:(double)amount from:(Entity *)ent becauseOf:(Entity *)other
{
Vector rel_pos;
Vector rel_pos = kZeroVector;
double d_forward;
BOOL internal_damage = NO; // base chance
Entity* attacker = nil;
OOLog(@"player.ship.damage", @"Player took damage from %@ becauseOf %@", ent, other);
@ -3306,10 +3307,23 @@ static PlayerEntity *sSharedPlayer = nil;
[[ent retain] autorelease];
[[other retain] autorelease];
rel_pos = (ent != nil) ? [ent position] : kZeroVector;
// rel_pos = (ent != nil) ? [ent position] : kZeroVector;
if(ent)
{
if([ent isSubEntity])
{
attacker = [[[ent owner] retain] autorelease];
rel_pos = [attacker position];
}
else
{
attacker = ent;
rel_pos = [attacker position];
}
}
rel_pos = vector_subtract(rel_pos, position);
[self doScriptEvent:@"shipBeingAttacked" withArgument:ent];
[self doScriptEvent:@"shipBeingAttacked" withArgument:attacker];
d_forward = dot_product(rel_pos, v_forward);