to bring sources up to Oolite r675
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@51 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
b355b7a2ec
commit
d7eae4e657
@ -132,6 +132,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
if (translucent)
|
||||
{
|
||||
Entity* player = [universe entityZero];
|
||||
glEnable(GL_FOG);
|
||||
glFogi(GL_FOG_MODE, GL_LINEAR);
|
||||
glFogfv(GL_FOG_COLOR, fogcolor);
|
||||
@ -150,7 +151,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
offset = [[universe entityZero] getPosition];
|
||||
offset = (player)? player->position: position;
|
||||
|
||||
if (!warp_stars)
|
||||
{
|
||||
@ -197,4 +198,3 @@ Your fair use and other rights are in no way affected by the above.
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
36
Entity.m
36
Entity.m
@ -108,6 +108,13 @@ static Universe *data_store_universe;
|
||||
//
|
||||
usingVAR = NO;
|
||||
//
|
||||
isParticle = NO;
|
||||
isRing = NO;
|
||||
isShip = NO;
|
||||
isStation = NO;
|
||||
isPlanet = NO;
|
||||
isPlayer = NO;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -251,7 +258,7 @@ static Universe *data_store_universe;
|
||||
|
||||
- (NSComparisonResult) compareZeroDistance:(Entity *)otherEntity;
|
||||
{
|
||||
if (zero_distance > [otherEntity getZeroDistance])
|
||||
if ((otherEntity)&&(zero_distance > otherEntity->zero_distance))
|
||||
return NSOrderedAscending;
|
||||
else
|
||||
return NSOrderedDescending;
|
||||
@ -408,7 +415,7 @@ static Universe *data_store_universe;
|
||||
// int fi,vi;
|
||||
int ti;
|
||||
GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 };
|
||||
GLfloat mat_no[] = { 0.0, 0.0, 0.0, 1.0 };
|
||||
GLfloat mat_no[] = { 0.0, 0.0, 0.0, 1.0 };
|
||||
if (is_smooth_shaded)
|
||||
glShadeModel(GL_SMOOTH);
|
||||
else
|
||||
@ -494,11 +501,12 @@ static Universe *data_store_universe;
|
||||
|
||||
- (void) drawSubEntity:(BOOL) immediate :(BOOL) translucent
|
||||
{
|
||||
if ((owner != NO_TARGET)&&(universe))
|
||||
Entity* my_owner = [universe entityForUniversalID:owner];
|
||||
if (my_owner)
|
||||
{
|
||||
// this test provides an opportunity to do simple LoD culling
|
||||
//
|
||||
zero_distance = [[universe entityForUniversalID:owner] getZeroDistance];
|
||||
zero_distance = my_owner->zero_distance;
|
||||
if (zero_distance > no_draw_distance)
|
||||
{
|
||||
//NSLog(@"DEBUG - sub entity '%@' too far away to draw", self);
|
||||
@ -529,14 +537,13 @@ static Universe *data_store_universe;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector abspos; // STATUS_ACTIVE means it is in control of it's own orientation
|
||||
abspos = position;
|
||||
Entity* father = [self owner];
|
||||
Vector abspos = position; // STATUS_ACTIVE means it is in control of it's own orientation
|
||||
Entity* father = my_owner;
|
||||
GLfloat* r_mat = [father rotationMatrix];
|
||||
while (father)
|
||||
{
|
||||
mult_vector_gl_matrix(&abspos, r_mat);
|
||||
Vector pos = [father getPosition];
|
||||
Vector pos = father->position;
|
||||
abspos.x += pos.x; abspos.y += pos.y; abspos.z += pos.z;
|
||||
father = [father owner];
|
||||
r_mat = [father rotationMatrix];
|
||||
@ -567,7 +574,7 @@ static Universe *data_store_universe;
|
||||
if ((faces[fi].texName == 0)&&(faces[fi].textureFile))
|
||||
{
|
||||
// load texture into Universe texturestore
|
||||
//NSLog(@"Off to load %@",faces[fi].textureFile);
|
||||
// NSLog(@"Off to load %@",faces[fi].textureFile);
|
||||
if (universe)
|
||||
{
|
||||
faces[fi].texName = [[universe textureStore] getTextureNameFor:faces[fi].textureFile];
|
||||
@ -597,7 +604,7 @@ static Universe *data_store_universe;
|
||||
if (displayListName != 0)
|
||||
{
|
||||
glNewList(displayListName, GL_COMPILE);
|
||||
[self drawEntity:YES:NO];
|
||||
[self drawEntity:YES:NO]; // immediate YES translucent NO
|
||||
glEndList();
|
||||
}
|
||||
}
|
||||
@ -607,7 +614,7 @@ static Universe *data_store_universe;
|
||||
Entity* player = [universe entityZero];
|
||||
if (player)
|
||||
{
|
||||
Vector p0 = [player getPosition];
|
||||
Vector p0 = player->position;
|
||||
relative_position = make_vector( position.x - p0.x, position.y - p0.y, position.z - p0.z);
|
||||
zero_distance = magnitude2(relative_position);
|
||||
}
|
||||
@ -626,7 +633,7 @@ static Universe *data_store_universe;
|
||||
track[track_index].q_rotation = q_rotation;
|
||||
track[track_index].timeframe = track_time;
|
||||
track_index = (track_index + 1 ) & 0xff;
|
||||
// if ([self isKindOfClass:[PlayerEntity class]])
|
||||
// if (isPlayer)
|
||||
// NSLog(@"Saving frame %d %.2f", track_index, track_time);
|
||||
}
|
||||
}
|
||||
@ -1009,7 +1016,7 @@ static Universe *data_store_universe;
|
||||
[self fakeTexturesWithImageFile:@"metal.png" andMaxSize:NSMakeSize(256.0,256.0)];
|
||||
|
||||
// dump out data for ships with faked textures
|
||||
//if ([self isKindOfClass:[ShipEntity class]])
|
||||
//if (isShip)
|
||||
// //NSLog(@"Faked Texture coordinates for this model :\n\n%@\n\n", [self toString]);
|
||||
}
|
||||
|
||||
@ -1216,7 +1223,7 @@ static Universe *data_store_universe;
|
||||
{
|
||||
Vector pv, rv;
|
||||
Vector rpos = position;
|
||||
Vector opv = [other getPosition];
|
||||
Vector opv = (other)? other->position : rpos;
|
||||
rpos.x -= opv.x; rpos.y -= opv.y; rpos.z -= opv.z;
|
||||
rv.x = dot_product(_i,rpos);
|
||||
rv.y = dot_product(_j,rpos);
|
||||
@ -1742,4 +1749,3 @@ static Universe *data_store_universe;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
@ -334,7 +334,7 @@ static BOOL hostiles;
|
||||
GLfloat police_color2[4] = {1.0, 0.0, 0.5, alpha}; // purpley-red
|
||||
GLfloat col[4]; // can be manipulated
|
||||
|
||||
position = [player getPosition];
|
||||
position = player->position;
|
||||
gl_matrix_into_matrix([player rotationMatrix], rotMatrix);
|
||||
|
||||
// NSLog(@"drawing grid size %.1f x %.1f", siz.width, siz.height);
|
||||
@ -356,15 +356,15 @@ static BOOL hostiles;
|
||||
// BOOL sent_a_message = NO;
|
||||
|
||||
drawthing = (Entity *)[entityList objectAtIndex:i];
|
||||
int drawClass = [drawthing scanClass];
|
||||
int drawClass = drawthing->scan_class;
|
||||
if (drawClass == CLASS_PLAYER) drawClass = CLASS_NO_DRAW;
|
||||
|
||||
// consider large bodies for mass_lock
|
||||
if ([drawthing isKindOfClass:[PlanetEntity class]])
|
||||
if (drawthing->isPlanet)
|
||||
{
|
||||
PlanetEntity* planet = (PlanetEntity *)drawthing;
|
||||
double dist = [planet getZeroDistance];
|
||||
double rad = [planet collisionRadius];
|
||||
double dist = planet->zero_distance;
|
||||
double rad = planet->collision_radius;
|
||||
double factor = ([planet getPlanetType] == PLANET_TYPE_SUN) ? 2.0 : 4.0;
|
||||
if (dist < rad*rad*factor)
|
||||
{
|
||||
@ -377,7 +377,7 @@ static BOOL hostiles;
|
||||
GLfloat x1,y1,y2;
|
||||
float ms_blip = 0.0;
|
||||
|
||||
if ([drawthing getZeroDistance] <= mass_lock_range2)
|
||||
if (drawthing->zero_distance <= mass_lock_range2)
|
||||
{
|
||||
switch (drawClass)
|
||||
{
|
||||
@ -397,12 +397,12 @@ static BOOL hostiles;
|
||||
}
|
||||
[player setAlert_flag:ALERT_FLAG_MASS_LOCK :mass_locked];
|
||||
|
||||
if ((isnan([drawthing getZeroDistance]))||([drawthing getZeroDistance] > max_scanner_range2))
|
||||
if ((isnan(drawthing->zero_distance))||(drawthing->zero_distance > max_scanner_range2))
|
||||
continue;
|
||||
|
||||
// has it snt a recent message
|
||||
//
|
||||
if ([drawthing isKindOfClass:[ShipEntity class]])
|
||||
if (drawthing->isShip)
|
||||
ms_blip = 2.0 * [(ShipEntity *)drawthing message_time];
|
||||
if (ms_blip > max_blip)
|
||||
{
|
||||
@ -423,10 +423,10 @@ static BOOL hostiles;
|
||||
y2 = y1 + y_factor * relativePosition.y;
|
||||
|
||||
isHostile = NO;
|
||||
if ([drawthing isKindOfClass:[ShipEntity class]])
|
||||
if (drawthing->isShip)
|
||||
{
|
||||
double wr = [(ShipEntity *)drawthing weapon_range];
|
||||
isHostile = (([(ShipEntity *)drawthing hasHostileTarget])&&([(ShipEntity *)drawthing getPrimaryTarget] == player)&&([(ShipEntity *)drawthing getZeroDistance] < wr*wr));
|
||||
isHostile = (([(ShipEntity *)drawthing hasHostileTarget])&&([(ShipEntity *)drawthing getPrimaryTarget] == player)&&(drawthing->zero_distance < wr*wr));
|
||||
// sent_a_message = (([(ShipEntity *)drawthing message_time] > 0.0)&&(flicker));
|
||||
}
|
||||
|
||||
@ -448,7 +448,7 @@ static BOOL hostiles;
|
||||
col[0] = hostile_color[0]; col[1] = hostile_color[1]; col[2] = hostile_color[2]; col[3] = hostile_color[3];
|
||||
}
|
||||
foundHostiles = YES;
|
||||
// NSLog(@"DEBUG found Thargoid %.0f %.0f", [drawthing getZeroDistance], max_scanner_range2);
|
||||
// NSLog(@"DEBUG found Thargoid %.0f %.0f", drawthing->zero_distance, max_scanner_range2);
|
||||
break;
|
||||
case CLASS_MISSILE :
|
||||
col[0] = missile_color[0]; col[1] = missile_color[1]; col[2] = missile_color[2]; col[3] = missile_color[3];
|
||||
@ -502,9 +502,9 @@ static BOOL hostiles;
|
||||
{
|
||||
drawSpecialOval( x1 - 0.5, y2 + 1.5, z1, NSMakeSize(16.0 * (1.0 - ms_blip), 8.0 * (1.0 - ms_blip)), 30, col);
|
||||
}
|
||||
if ([drawthing isKindOfClass:[ParticleEntity class]]&&(drawClass == CLASS_MINE))
|
||||
if ((drawthing->isParticle)&&(drawClass == CLASS_MINE))
|
||||
{
|
||||
double r1 = 2.5 + [drawthing collisionRadius] * upscale;
|
||||
double r1 = 2.5 + drawthing->collision_radius * upscale;
|
||||
double l2 = r1*r1 - relativePosition.y*relativePosition.y;
|
||||
double r0 = (l2 > 0)? sqrt(l2): 0;
|
||||
if (r0 > 0)
|
||||
@ -550,7 +550,7 @@ static BOOL hostiles;
|
||||
- (void) refreshLastTransmitter
|
||||
{
|
||||
Entity* lt = [[player universe] entityForUniversalID:last_transmitter];
|
||||
if ((lt == nil)||(![lt isKindOfClass:[ShipEntity class]]))
|
||||
if ((lt == nil)||(!(lt->isShip)))
|
||||
return;
|
||||
ShipEntity* st = (ShipEntity*)lt;
|
||||
// NSLog(@"DEBUG Last Transmitter (%d) == %@ %d", last_transmitter, [st name], [st universal_id]);
|
||||
@ -590,47 +590,58 @@ static BOOL hostiles;
|
||||
alpha = [(NSNumber *)[info objectForKey:ALPHA_KEY] doubleValue];
|
||||
// draw the compass
|
||||
Matrix rotMatrix;
|
||||
Vector position = [player getPosition];
|
||||
Vector position = player->position;
|
||||
gl_matrix_into_matrix([player rotationMatrix], rotMatrix);
|
||||
//
|
||||
[compassSprite blitCentredToX:x Y:y Z:z1 Alpha:alpha];
|
||||
//
|
||||
if (([[player universe] viewDir] != VIEW_DOCKED)&&([[player universe] sun]))
|
||||
PlanetEntity* the_sun = [[player universe] sun];
|
||||
PlanetEntity* the_planet = [[player universe] planet];
|
||||
StationEntity* the_station = [[player universe] station];
|
||||
Entity* the_target = [player getPrimaryTarget];
|
||||
Entity* the_next_beacon = [[player universe] entityForUniversalID:[player nextBeaconID]];
|
||||
if (([[player universe] viewDir] != VIEW_DOCKED)&&(the_sun)&&(the_planet))
|
||||
{
|
||||
Vector relativePosition;
|
||||
if ([player compass_mode] == COMPASS_MODE_BASIC)
|
||||
{
|
||||
relativePosition = [[[player universe] planet] getPosition];
|
||||
if ([player checkForAegis] != AEGIS_NONE)
|
||||
relativePosition = [[[player universe] station] getPosition];
|
||||
relativePosition = the_planet->position;
|
||||
if (([player checkForAegis] != AEGIS_NONE)&&(the_station))
|
||||
relativePosition = the_station->position;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch ([player compass_mode])
|
||||
{
|
||||
case COMPASS_MODE_PLANET:
|
||||
relativePosition = [[[player universe] planet] getPosition];
|
||||
relativePosition = the_planet->position;
|
||||
break;
|
||||
case COMPASS_MODE_STATION:
|
||||
relativePosition = [[[player universe] station] getPosition];
|
||||
relativePosition = the_station->position;
|
||||
break;
|
||||
case COMPASS_MODE_SUN:
|
||||
relativePosition = [[[player universe] sun] getPosition];
|
||||
relativePosition = the_sun->position;
|
||||
break;
|
||||
case COMPASS_MODE_TARGET:
|
||||
if ([player getPrimaryTarget])
|
||||
relativePosition = [[player getPrimaryTarget] getPosition];
|
||||
if (the_target)
|
||||
relativePosition = the_target->position;
|
||||
else
|
||||
{
|
||||
[player setCompass_mode:COMPASS_MODE_PLANET];
|
||||
relativePosition = [[[player universe] planet] getPosition];
|
||||
relativePosition = the_planet->position;
|
||||
}
|
||||
break;
|
||||
case COMPASS_MODE_WITCHPOINT:
|
||||
relativePosition = [[player universe] getWitchspaceExitPosition];
|
||||
break;
|
||||
case COMPASS_MODE_BEACONS:
|
||||
relativePosition = [[[player universe] entityForUniversalID:[player nextBeaconID]] getPosition];
|
||||
if (the_next_beacon)
|
||||
relativePosition = the_next_beacon->position;
|
||||
else
|
||||
{
|
||||
[player setCompass_mode:COMPASS_MODE_PLANET];
|
||||
relativePosition = the_planet->position;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -674,7 +685,7 @@ static BOOL hostiles;
|
||||
case COMPASS_MODE_BEACONS:
|
||||
// [self drawCompassBeaconBlip:[(ShipEntity*)[[player universe] entityForUniversalID:[player nextBeaconID]] beaconChar] At:relativePosition Size:sz Alpha:alpha];
|
||||
[self drawCompassBeaconBlipAt:relativePosition Size:sz Alpha:alpha];
|
||||
drawString( [NSString stringWithFormat:@"%c", [(ShipEntity*)[[player universe] entityForUniversalID:[player nextBeaconID]] beaconChar]],
|
||||
drawString( [NSString stringWithFormat:@"%c", [(ShipEntity*)the_next_beacon beaconChar]],
|
||||
x - 2.5 * sz.width, y - 3.0 * sz.height, z1, NSMakeSize(sz.width * 2, sz.height * 2));
|
||||
break;
|
||||
}
|
||||
@ -965,7 +976,7 @@ static BOOL hostiles;
|
||||
NSSize dial_size = NSMakeSize(siz.width,qy - 2);
|
||||
int cy = y - (n_bars - 1) * qy / 2;
|
||||
double energy = [player dial_energy]*n_bars;
|
||||
[player setAlert_flag:ALERT_FLAG_ENERGY :((energy < 1.0)&&([player getStatus]==STATUS_IN_FLIGHT))];
|
||||
[player setAlert_flag:ALERT_FLAG_ENERGY :((energy < 1.0)&&(player->status == STATUS_IN_FLIGHT))];
|
||||
int i;
|
||||
for (i = 0; i < n_bars; i++)
|
||||
{
|
||||
@ -1096,7 +1107,7 @@ static BOOL hostiles;
|
||||
glColor4fv(red_color);
|
||||
if ((flash)&&(temp > .90))
|
||||
glColor4fv(redplus_color);
|
||||
[player setAlert_flag:ALERT_FLAG_TEMP :((temp > .90)&&([player getStatus]==STATUS_IN_FLIGHT))];
|
||||
[player setAlert_flag:ALERT_FLAG_TEMP :((temp > .90)&&(player->status == STATUS_IN_FLIGHT))];
|
||||
hudDrawBarAt( x, y, z1, siz, temp);
|
||||
}
|
||||
|
||||
@ -1149,7 +1160,7 @@ static BOOL hostiles;
|
||||
glColor4fv(red_color);
|
||||
if ((flash)&&(alt < .10))
|
||||
glColor4fv(redplus_color);
|
||||
[player setAlert_flag:ALERT_FLAG_ALT :((alt < .10)&&([player getStatus]==STATUS_IN_FLIGHT))];
|
||||
[player setAlert_flag:ALERT_FLAG_ALT :((alt < .10)&&(player->status == STATUS_IN_FLIGHT))];
|
||||
hudDrawBarAt( x, y, z1, siz, alt);
|
||||
}
|
||||
|
||||
@ -1349,7 +1360,7 @@ static BOOL hostiles;
|
||||
|
||||
// draw the direction cue
|
||||
Matrix rotMatrix;
|
||||
Vector position = [player getPosition];
|
||||
Vector position = player->position;
|
||||
gl_matrix_into_matrix([player rotationMatrix], rotMatrix);
|
||||
//
|
||||
if ([[player universe] viewDir] != VIEW_DOCKED)
|
||||
@ -1357,7 +1368,7 @@ static BOOL hostiles;
|
||||
GLfloat siz1 = CROSSHAIR_SIZE * (1.0 - ONE_EIGHTH);
|
||||
GLfloat siz0 = CROSSHAIR_SIZE * ONE_EIGHTH;
|
||||
GLfloat siz2 = CROSSHAIR_SIZE * (1.0 + ONE_EIGHTH);
|
||||
Vector rpn = [target getPosition];
|
||||
Vector rpn = target->position;
|
||||
// translate the view
|
||||
rpn.x -= position.x; rpn.y -= position.y; rpn.z -= position.z;
|
||||
// rotate the view
|
||||
@ -1612,8 +1623,9 @@ void hudDrawReticleOnTarget(Entity* target, PlayerEntity* player1, GLfloat z1)
|
||||
//GLfloat z1 = [(MyOpenGLView *)[[player1 universe] gameView] display_z];
|
||||
ShipEntity* target_ship = (ShipEntity *)target;
|
||||
NSString* legal_desc = nil;
|
||||
|
||||
switch ([target_ship scanClass])
|
||||
if ((!target)||(!player1))
|
||||
return;
|
||||
switch (target_ship->scan_class)
|
||||
{
|
||||
case CLASS_NEUTRAL :
|
||||
{
|
||||
@ -1648,18 +1660,17 @@ void hudDrawReticleOnTarget(Entity* target, PlayerEntity* player1, GLfloat z1)
|
||||
if ([player1 gui_screen] != GUI_SCREEN_MAIN) // don't draw on text screens
|
||||
return;
|
||||
|
||||
if (target == nil)
|
||||
if (!target)
|
||||
return;
|
||||
|
||||
gl_matrix back_mat;
|
||||
Quaternion back_q = [player1 QRotation];
|
||||
Quaternion back_q = player1->q_rotation;
|
||||
back_q.w = -back_q.w; // invert
|
||||
// Vector p0 = [player1 getPosition];
|
||||
Vector p0 = [player1 getViewpointPosition];
|
||||
Vector p1 = [target getPosition];
|
||||
Vector p1 = target->position;
|
||||
p1.x -= p0.x; p1.y -= p0.y; p1.z -= p0.z;
|
||||
double rdist = sqrt(magnitude2(p1));
|
||||
double rsize = [target collisionRadius];
|
||||
double rsize = target->collision_radius;
|
||||
|
||||
if (rsize < rdist * ONE_SIXTYFOURTH)
|
||||
rsize = rdist * ONE_SIXTYFOURTH;
|
||||
@ -1727,10 +1738,10 @@ void hudDrawReticleOnTarget(Entity* target, PlayerEntity* player1, GLfloat z1)
|
||||
glEnd();
|
||||
|
||||
// add text for reticle here
|
||||
float range = sqrt([target getZeroDistance])/1000;
|
||||
float range = sqrt(target->zero_distance)/1000;
|
||||
NSSize textsize = NSMakeSize( rdist * ONE_SIXTYFOURTH, rdist * ONE_SIXTYFOURTH);
|
||||
float line_height = rdist * ONE_SIXTYFOURTH;
|
||||
NSString *info1 = [NSString stringWithFormat:@"%@", [(ShipEntity *)target name], [(ShipEntity *)target universal_id]];
|
||||
NSString *info1 = [(ShipEntity *)target name];
|
||||
NSString *info2 = (legal_desc == nil)? [NSString stringWithFormat:@"%0.3f km", range] : [NSString stringWithFormat:@"%0.3f km (%@)", range, legal_desc];
|
||||
// no need to set color - tis green already!
|
||||
drawString( info1, rs0, 0.5 * rs2, 0, textsize);
|
||||
@ -1901,4 +1912,3 @@ void drawSpecialOval( double x, double y, double z, NSSize siz, int step, GLfloa
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
@ -228,7 +228,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
if ([gameController universe])
|
||||
{
|
||||
Vector sun_pos = [[[gameController universe] sun] getPosition];
|
||||
Entity* the_sun = [[gameController universe] sun];
|
||||
Vector sun_pos = (the_sun)? the_sun->position : make_vector(0,0,0);
|
||||
sun_center_position[0] = sun_pos.x;
|
||||
sun_center_position[1] = sun_pos.y;
|
||||
sun_center_position[2] = sun_pos.z;
|
||||
@ -356,6 +357,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
//- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
|
||||
//{
|
||||
// return NO;
|
||||
//
|
||||
// if ([gameController inFullScreenMode])
|
||||
// {
|
||||
// NSLog(@"DEBUG [gameController inFullScreenMode] MyOpenGLView trying to performKeyEquivalent:%@", [theEvent description]);
|
||||
@ -367,7 +370,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
// return [super performKeyEquivalent: theEvent];
|
||||
// }
|
||||
//}
|
||||
|
||||
//
|
||||
- (void) keyUp:(NSEvent *)theEvent
|
||||
{
|
||||
int key = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
|
||||
@ -615,4 +618,3 @@ Your fair use and other rights are in no way affected by the above.
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
169
ParticleEntity.m
169
ParticleEntity.m
@ -84,17 +84,22 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
circleVertex[i].z = 0.0;
|
||||
}
|
||||
//
|
||||
isParticle = YES;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initLaserFromShip:(ShipEntity *) ship view:(int) view
|
||||
{
|
||||
self = [super init];
|
||||
//
|
||||
if (!ship)
|
||||
return self;
|
||||
//
|
||||
status = STATUS_EFFECT;
|
||||
position = [ship getPosition];
|
||||
q_rotation = [ship QRotation];
|
||||
if ([ship isKindOfClass:[PlayerEntity class]])
|
||||
position = ship->position;
|
||||
q_rotation = ship->q_rotation;
|
||||
if ((ship)&&(ship->isPlayer))
|
||||
q_rotation.w = -q_rotation.w; //reverse view direction for the player
|
||||
Vector v_up = vector_up_from_quaternion(q_rotation);
|
||||
Vector v_forward = vector_forward_from_quaternion(q_rotation);
|
||||
@ -124,7 +129,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
}
|
||||
quaternion_into_gl_matrix(q_rotation, rotMatrix);
|
||||
//
|
||||
if ([ship isKindOfClass:[PlayerEntity class]])
|
||||
if ((ship)&&(ship->isPlayer))
|
||||
{
|
||||
position.x -= WEAPON_OFFSET_DOWN * v_up.x; position.y -= WEAPON_OFFSET_DOWN * v_up.y; position.z -= WEAPON_OFFSET_DOWN * v_up.z; // offset below the view line
|
||||
}
|
||||
@ -141,6 +146,8 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
//
|
||||
collision_radius = [ship weapon_range];
|
||||
//
|
||||
isParticle = YES;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -176,6 +183,8 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
//
|
||||
collision_radius = [self findCollisionRadius];
|
||||
//
|
||||
isParticle = YES;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -223,17 +232,21 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
//
|
||||
collision_radius = [self findCollisionRadius];
|
||||
//
|
||||
isParticle = YES;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initECMMineFromShip:(ShipEntity *) ship
|
||||
{
|
||||
self = [super init];
|
||||
if (!ship)
|
||||
return self;
|
||||
//
|
||||
time_counter = 0.0;
|
||||
activation_time = 0.5;
|
||||
duration = 2.0;
|
||||
[self setPosition:[ship getPosition]];
|
||||
position = ship->position;
|
||||
//
|
||||
status = STATUS_EFFECT;
|
||||
scan_class = CLASS_NO_DRAW;
|
||||
@ -243,7 +256,9 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
particle_type = PARTICLE_ECM_MINE;
|
||||
//
|
||||
[self setOwner:ship];
|
||||
//
|
||||
//
|
||||
isParticle = YES;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -251,10 +266,12 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
{
|
||||
self = [super init];
|
||||
//
|
||||
if (!ship)
|
||||
return self;
|
||||
//
|
||||
time_counter = 0.0;
|
||||
duration = 20.0;
|
||||
[self setPosition:[ship getPosition]];
|
||||
position = ship->position;
|
||||
//
|
||||
[self setVelocity:make_vector( 0, 0, 0)];
|
||||
//
|
||||
@ -271,7 +288,9 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
particle_type = PARTICLE_ENERGY_MINE;
|
||||
//
|
||||
[self setOwner:[ship owner]];
|
||||
//
|
||||
//
|
||||
isParticle = YES;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -281,12 +300,17 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
//
|
||||
time_counter = 0.0;
|
||||
duration = 2.0;
|
||||
size.width = [ship collisionRadius] * 0.5;
|
||||
if (!ship)
|
||||
{
|
||||
NSLog(@"ERROR - initHyperringFromShip:NULL");
|
||||
return self;
|
||||
}
|
||||
size.width = ship->collision_radius * 0.5;
|
||||
size.height = size.width * 1.25;
|
||||
ring_inner_radius = size.width;
|
||||
ring_outer_radius = size.height;
|
||||
[self setPosition:[ship getPosition]];
|
||||
[self setQRotation:[ship QRotation]];
|
||||
position = ship->position;
|
||||
[self setQRotation:ship->q_rotation];
|
||||
[self setVelocity:[ship getVelocity]];
|
||||
//
|
||||
status = STATUS_EFFECT;
|
||||
@ -302,7 +326,9 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
}
|
||||
//
|
||||
[self setOwner:ship];
|
||||
//
|
||||
//
|
||||
isParticle = YES;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -342,7 +368,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
return YES;
|
||||
if (other == [self owner])
|
||||
return NO;
|
||||
return ![other isKindOfClass:[ParticleEntity class]];
|
||||
return !(other->isParticle);
|
||||
}
|
||||
|
||||
|
||||
@ -414,7 +440,6 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
- (void) update:(double) delta_t
|
||||
{
|
||||
// NSLog(@"DEBUG update for %@",self);
|
||||
|
||||
[super update:delta_t];
|
||||
|
||||
time_counter += delta_t;
|
||||
@ -432,11 +457,17 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
case PARTICLE_FLASHER :
|
||||
case PARTICLE_SHOT_PLASMA :
|
||||
case PARTICLE_EXPLOSION :
|
||||
if (!texName)
|
||||
[self initialiseTexture: textureNameString];
|
||||
q_rotation = [[universe entityZero] QRotation];
|
||||
q_rotation.w = -q_rotation.w;
|
||||
quaternion_into_gl_matrix(q_rotation, rotMatrix);
|
||||
{
|
||||
Entity* player = [universe entityZero];
|
||||
if (!texName)
|
||||
[self initialiseTexture: textureNameString];
|
||||
if (player)
|
||||
{
|
||||
q_rotation = player->q_rotation;
|
||||
q_rotation.w = -q_rotation.w;
|
||||
quaternion_into_gl_matrix(q_rotation, rotMatrix);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (particle_type)
|
||||
@ -518,7 +549,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
for (i = 0; i < [targets count]; i++)
|
||||
{
|
||||
Entity *e2 = [targets objectAtIndex:i];
|
||||
if ([e2 isKindOfClass:[ShipEntity class]])
|
||||
if (e2->isShip)
|
||||
[[(ShipEntity *)e2 getAI] reactToMessage:@"ECM"];
|
||||
}
|
||||
}
|
||||
@ -531,8 +562,9 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
- (void) updateEnergyMine:(double) delta_t
|
||||
{
|
||||
// new billboard routine (working at last!)
|
||||
Entity* player = [universe entityZero];
|
||||
Vector v0 = position;
|
||||
Vector p0 = [[universe entityZero] getPosition];
|
||||
Vector p0 = (player)? player->position : make_vector(0,0,0);
|
||||
v0.x -= p0.x; v0.y -= p0.y; v0.z -= p0.z; // vector from player to position
|
||||
|
||||
v0 = unit_vector(&v0);
|
||||
@ -587,7 +619,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
{
|
||||
Entity * e = (Entity *)[collidingEntities objectAtIndex:i];
|
||||
[e takeEnergyDamage:energy from:self becauseOf:[self owner]];
|
||||
// if ([e isKindOfClass:[ShipEntity class]])
|
||||
// if (e->isShip)
|
||||
// {
|
||||
// ShipEntity* s = (ShipEntity*)e;
|
||||
// NSLog(@"DEBUG ENERGY BOMB Doing %.3f energy damage to %@ %d", energy, [s name], [s universal_id]);
|
||||
@ -711,34 +743,52 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
|
||||
- (void) drawSubEntity:(BOOL) immediate :(BOOL) translucent
|
||||
{
|
||||
// if (particle_type == PARTICLE_EXHAUST)
|
||||
// {
|
||||
// [super drawSubEntity:immediate :translucent];
|
||||
// return;
|
||||
// }
|
||||
if (particle_type == PARTICLE_EXHAUST)
|
||||
{
|
||||
[super drawSubEntity:immediate :translucent];
|
||||
if (translucent)
|
||||
{
|
||||
glPushMatrix();
|
||||
|
||||
// position and orientation is relative to owner
|
||||
|
||||
//NSLog(@"DEBUG drawing passive subentity at %.3f, %.3f, %.3f", position.x, position.y, position.z);
|
||||
|
||||
glTranslated( position.x, position.y, position.z);
|
||||
glMultMatrixf(rotMatrix);
|
||||
|
||||
[self drawExhaust:immediate];
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ((owner != NO_TARGET)&&(universe))
|
||||
Entity* my_owner = [universe entityForUniversalID:owner];
|
||||
|
||||
if (my_owner)
|
||||
{
|
||||
// this test provides an opportunity to do simple LoD culling
|
||||
//
|
||||
zero_distance = [[universe entityForUniversalID:owner] getZeroDistance];
|
||||
zero_distance = my_owner->zero_distance;
|
||||
if (zero_distance > no_draw_distance)
|
||||
{
|
||||
//NSLog(@"DEBUG - sub entity '%@' too far away to draw", self);
|
||||
return; // TOO FAR AWAY
|
||||
}
|
||||
return; // TOO FAR AWAY TO DRAW
|
||||
}
|
||||
|
||||
if ((particle_type == PARTICLE_FLASHER)&&(status != STATUS_INACTIVE))
|
||||
{
|
||||
Vector abspos; // in control of it's own orientation
|
||||
abspos = position;
|
||||
Entity* father = [self owner];
|
||||
Vector abspos = position; // in control of it's own orientation
|
||||
Entity* father = my_owner;
|
||||
GLfloat* r_mat = [father rotationMatrix];
|
||||
while (father)
|
||||
{
|
||||
mult_vector_gl_matrix(&abspos, r_mat);
|
||||
Vector pos = [father getPosition];
|
||||
Vector pos = father->position;
|
||||
abspos.x += pos.x; abspos.y += pos.y; abspos.z += pos.z;
|
||||
if ([father owner] != father)
|
||||
father = [father owner];
|
||||
@ -862,7 +912,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
{
|
||||
GLfloat flat_ambdiff[4] = {1.0, 1.0, 1.0, 1.0}; // for alpha
|
||||
GLfloat lase_ambdiff[4] = {0.0, 0.0, 0.0, 1.0}; // for alpha
|
||||
GLfloat lase_zero[4] = {0.0, 0.0, 0.0, 1.0}; // nothing
|
||||
GLfloat mat_no[4] = {0.0, 0.0, 0.0, 1.0}; // nothing
|
||||
double lase_alpha = 0.75;
|
||||
|
||||
color_fv[3] = lase_alpha; // set alpha
|
||||
@ -870,13 +920,26 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
|
||||
glDisable(GL_CULL_FACE); // face culling
|
||||
|
||||
//NSLog(@"drawing laser from %3.1f distant to %3.1f distant with alphas (%3.1f, %3.1f)", sqrt(d0), sqrt(d1), alpha0, alpha1);
|
||||
// NSLog(@"drawing laser %.0f long with lase_ambdiff (%0.3f, %0.3f, %0.3f, %0.3f) color_fv (%0.3f, %0.3f, %0.3f, %0.3f)", collision_radius,
|
||||
// lase_ambdiff[0], lase_ambdiff[1], lase_ambdiff[2], lase_ambdiff[3],
|
||||
// color_fv[0], color_fv[1], color_fv[2], color_fv[3]);
|
||||
|
||||
// //state check
|
||||
// NSLog(@"DEBUG OpenGL state check: GL_COLOR_MATERIAL : %@",
|
||||
// (glIsEnabled(GL_COLOR_MATERIAL) == GL_TRUE)? @"YES":@"NO");
|
||||
|
||||
// movies:
|
||||
// draw data required collision_radius, color_fv[0], color_fv[1], color_fv[2]
|
||||
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, lase_ambdiff);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color_fv);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
glEnable( GL_COLOR_MATERIAL);
|
||||
glColorMaterial( GL_FRONT_AND_BACK, GL_EMISSION);
|
||||
glColor4fv( color_fv);
|
||||
|
||||
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_no);
|
||||
glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, mat_no);
|
||||
// glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color_fv);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
@ -891,9 +954,14 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
glVertex3f(0.0, -0.25, 0.0);
|
||||
|
||||
glEnd();
|
||||
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, lase_zero);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, flat_ambdiff);
|
||||
|
||||
glDisable( GL_COLOR_MATERIAL);
|
||||
|
||||
glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, mat_no);
|
||||
glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, mat_no);
|
||||
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, flat_ambdiff);
|
||||
|
||||
glEnable( GL_LIGHTING);
|
||||
|
||||
glEnable(GL_CULL_FACE); // face culling
|
||||
}
|
||||
@ -902,10 +970,10 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
{
|
||||
int fi, vi;
|
||||
|
||||
GLfloat flat_ambdiff[4] = {1.0, 1.0, 1.0, 1.0}; // flat
|
||||
GLfloat ex_ambdiff[4] = {0.0, 0.0, 0.0, 1.0}; // pale blue
|
||||
GLfloat flat_ambdiff[4] = {1.0, 1.0, 1.0, 1.0}; // flat white
|
||||
GLfloat ex_ambdiff[4] = {0.0, 0.0, 0.0, 1.0}; // flat black
|
||||
GLfloat ex_emissive[4] = {0.6, 0.8, 1.0, 0.9}; // pale blue
|
||||
GLfloat ex_zero[4] = {0.0, 0.0, 0.0, 1.0}; // nothing
|
||||
GLfloat no_mat[4] = {0.0, 0.0, 0.0, 1.0}; // flat black
|
||||
|
||||
ShipEntity *ship =(ShipEntity *)[universe entityForUniversalID:owner];
|
||||
int dam = [ship damage];
|
||||
@ -946,12 +1014,12 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
// movies:
|
||||
// draw data required flare_factor, red_factor, green_factor, flare_length
|
||||
|
||||
glDisable(GL_CULL_FACE); // face culling
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
if (basefile)
|
||||
{
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, ex_zero);
|
||||
glDisable(GL_CULL_FACE); // face culling
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
// glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, ex_zero); // causes TIGER BLACK TEXTURE PROBLEM?
|
||||
glBegin(GL_TRIANGLES);
|
||||
for (fi = 0; fi < n_faces; fi++)
|
||||
{
|
||||
@ -970,11 +1038,11 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
|
||||
}
|
||||
glEnd();
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, ex_zero);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, flat_ambdiff);
|
||||
}
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, no_mat);
|
||||
|
||||
glEnable(GL_CULL_FACE); // face culling
|
||||
glEnable(GL_CULL_FACE); // face culling
|
||||
}
|
||||
}
|
||||
|
||||
- (void) drawHyperring
|
||||
@ -1045,4 +1113,3 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
@ -132,7 +132,9 @@ static GLuint vertex_index_array[3*(20+80+320+1280+5120+20480)];
|
||||
amb_polar_sea[1] = 1.0;
|
||||
amb_polar_sea[2] = 1.0;
|
||||
amb_polar_sea[3] = 1.0;
|
||||
|
||||
//
|
||||
isPlanet = YES;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -211,6 +213,8 @@ static GLuint vertex_index_array[3*(20+80+320+1280+5120+20480)];
|
||||
for (i = 0; i < 729; i++)
|
||||
rvalue[i] = randf();
|
||||
//
|
||||
isPlanet = YES;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -222,9 +226,15 @@ static GLuint vertex_index_array[3*(20+80+320+1280+5120+20480)];
|
||||
//
|
||||
self = [super init];
|
||||
//
|
||||
position = [planet getPosition];
|
||||
q_rotation = [planet QRotation];
|
||||
collision_radius = [planet collisionRadius] + ATMOSPHERE_DEPTH; // atmosphere is 500m deep only
|
||||
if (!planet)
|
||||
{
|
||||
NSLog(@"ERROR Planetentity initAsAtmosphereForPlanet:NULL");
|
||||
return self;
|
||||
}
|
||||
//
|
||||
position = planet->position;
|
||||
q_rotation = planet->q_rotation;
|
||||
collision_radius = planet->collision_radius + ATMOSPHERE_DEPTH; // atmosphere is 500m deep only
|
||||
//
|
||||
shuttles_on_ground = 0;
|
||||
last_launch_time = 0.0;
|
||||
@ -292,7 +302,8 @@ static GLuint vertex_index_array[3*(20+80+320+1280+5120+20480)];
|
||||
if (usingVAR)
|
||||
[self OGL_AssignVARMemory:sizeof(VertexData) :(void *)&vertexdata :0];
|
||||
//
|
||||
|
||||
isPlanet = YES;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -300,9 +311,15 @@ static GLuint vertex_index_array[3*(20+80+320+1280+5120+20480)];
|
||||
{
|
||||
self = [super init];
|
||||
//
|
||||
position = [planet getPosition];
|
||||
if (!planet)
|
||||
{
|
||||
NSLog(@"ERROR Planetentity initAsCoronaForPlanet:NULL");
|
||||
return self;
|
||||
}
|
||||
//
|
||||
position = planet->position;
|
||||
quaternion_set_identity(&q_rotation);
|
||||
collision_radius = [planet collisionRadius] + ATMOSPHERE_DEPTH * 2; // atmosphere is 5000m deep only
|
||||
collision_radius = planet->collision_radius + ATMOSPHERE_DEPTH * 2; // atmosphere is 5000m deep only
|
||||
//
|
||||
shuttles_on_ground = 0;
|
||||
last_launch_time = 0.0;
|
||||
@ -320,7 +337,9 @@ static GLuint vertex_index_array[3*(20+80+320+1280+5120+20480)];
|
||||
atmosphere = nil;
|
||||
|
||||
[self setOwner:planet];
|
||||
|
||||
//
|
||||
isPlanet = YES;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -476,7 +495,9 @@ static GLuint vertex_index_array[3*(20+80+320+1280+5120+20480)];
|
||||
if (usingVAR)
|
||||
[self OGL_AssignVARMemory:sizeof(VertexData) :(void *)&vertexdata :0];
|
||||
//
|
||||
|
||||
//
|
||||
isPlanet = YES;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -517,12 +538,14 @@ static GLuint vertex_index_array[3*(20+80+320+1280+5120+20480)];
|
||||
- (BOOL) checkCloseCollisionWith:(Entity *)other
|
||||
{
|
||||
//NSLog(@"PLANET Collision!");
|
||||
if ([other isKindOfClass:[ShipEntity class]])
|
||||
if (!other)
|
||||
return NO;
|
||||
if (other->isShip)
|
||||
{
|
||||
if ([(ShipEntity *)other reportAImessages])
|
||||
{
|
||||
ShipEntity *ship = (ShipEntity *)other;
|
||||
Vector p1 = [ship getPosition];
|
||||
Vector p1 = ship->position;
|
||||
NSLog(@"%@ %d collided with planet at (%.1f,%.1f,%.1f)",[ship name], [ship universal_id], p1.x,p1.y,p1.z);
|
||||
}
|
||||
}
|
||||
@ -561,7 +584,7 @@ static GLuint vertex_index_array[3*(20+80+320+1280+5120+20480)];
|
||||
{
|
||||
[atmosphere update:delta_t];
|
||||
double alt = sqrt_zero_distance - collision_radius;
|
||||
double atmo = 10.0 * ([atmosphere collisionRadius] - collision_radius); // effect starts at 10x the height of the clouds
|
||||
double atmo = 10.0 * (atmosphere->collision_radius - collision_radius); // effect starts at 10x the height of the clouds
|
||||
|
||||
if ((alt > 0)&&(alt <= atmo))
|
||||
{
|
||||
@ -589,8 +612,9 @@ static GLuint vertex_index_array[3*(20+80+320+1280+5120+20480)];
|
||||
case PLANET_TYPE_SUN :
|
||||
{
|
||||
// new billboard routine (working at last!)
|
||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
||||
Vector v0 = position;
|
||||
Vector p0 = [[universe entityZero] getPosition];
|
||||
Vector p0 = (player)? player->position: make_vector(0,0,0);
|
||||
v0.x -= p0.x; v0.y -= p0.y; v0.z -= p0.z; // vector from player to position
|
||||
|
||||
v0 = unit_vector(&v0);
|
||||
@ -616,8 +640,8 @@ static GLuint vertex_index_array[3*(20+80+320+1280+5120+20480)];
|
||||
|
||||
if (planet_type == PLANET_TYPE_CORONA)
|
||||
{
|
||||
Vector v_sun = [[universe sun] getPosition];
|
||||
Vector v_p = [[universe entityZero] getPosition];
|
||||
Vector v_sun = [universe sun]->position;
|
||||
Vector v_p = (player)? player->position: make_vector(0,0,0);
|
||||
v_sun.x -= v_p.x; v_sun.y -= v_p.y; v_sun.z -= v_p.z;
|
||||
v_sun = unit_vector(&v_sun);
|
||||
polar_color_factor = dot_product( v_sun, v0);
|
||||
@ -833,13 +857,14 @@ static GLuint vertex_index_array[3*(20+80+320+1280+5120+20480)];
|
||||
case PLANET_TYPE_CORONA :
|
||||
if (!translucent)
|
||||
{
|
||||
Entity* my_owner = [universe entityForUniversalID:owner];
|
||||
GLfloat bri = 1.0 + polar_color_factor;
|
||||
GLfloat r = 0.42 * bri;
|
||||
GLfloat g = 0.42 * bri;
|
||||
GLfloat b = 0.5 * bri;
|
||||
|
||||
GLfloat amb_1[4] = {1.0, 1.0, 1.0, 1.0 };
|
||||
double r0 = [[universe entityForUniversalID:owner] collisionRadius];
|
||||
double r0 = (my_owner)? my_owner->collision_radius: 5000;
|
||||
// GLfloat col1[4] = { amb_land[0], amb_land[1], amb_land[2], 1.0};
|
||||
// GLfloat col2[4] = { amb_land[0], amb_land[1], amb_land[2], 0.0};
|
||||
GLfloat col1[4] = { r, g, b, 1.0};
|
||||
@ -1371,4 +1396,3 @@ int baseVertexIndexForEdge(int va, int vb)
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
@ -1121,7 +1121,7 @@ NSMutableDictionary* currentShipyard;
|
||||
[ship setUniverse:universe];
|
||||
[ship setUpShipFromDictionary:shipDict];
|
||||
|
||||
double cr = [ship collisionRadius];
|
||||
double cr = ship->collision_radius;
|
||||
if (debug)
|
||||
NSLog(@"::::: showShipModel:'%@'.", [ship name]);
|
||||
[ship setQRotation: q2];
|
||||
@ -1303,4 +1303,3 @@ NSMutableDictionary* currentShipyard;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@ -1110,23 +1110,26 @@ static int shipsFound;
|
||||
quaternion_rotate_about_axis(&q2,vector_right_from_quaternion(q2), 0.5 * PI);
|
||||
|
||||
ship = [universe getShipWithRole: shipKey]; // retain count = 1
|
||||
double cr = [ship collisionRadius];
|
||||
if (debug)
|
||||
NSLog(@"::::: showShipModel:'%@' (%@) (%@)", shipKey, ship, [ship name]);
|
||||
[ship setQRotation: q2];
|
||||
pos.x += 3.6 * cr * v_forward.x;
|
||||
pos.y += 3.6 * cr * v_forward.y;
|
||||
pos.z += 3.6 * cr * v_forward.z;
|
||||
|
||||
[ship setStatus: STATUS_DEMO];
|
||||
[ship setPosition: pos];
|
||||
[ship setScanClass: CLASS_NO_DRAW];
|
||||
[ship setRoll: PI/5.0];
|
||||
[ship setPitch: PI/10.0];
|
||||
[universe addEntity: ship];
|
||||
[[ship getAI] setStateMachine: @"nullAI.plist"];
|
||||
if (ship)
|
||||
{
|
||||
double cr = ship->collision_radius;
|
||||
if (debug)
|
||||
NSLog(@"::::: showShipModel:'%@' (%@) (%@)", shipKey, ship, [ship name]);
|
||||
[ship setQRotation: q2];
|
||||
pos.x += 3.6 * cr * v_forward.x;
|
||||
pos.y += 3.6 * cr * v_forward.y;
|
||||
pos.z += 3.6 * cr * v_forward.z;
|
||||
|
||||
[ship setStatus: STATUS_DEMO];
|
||||
[ship setPosition: pos];
|
||||
[ship setScanClass: CLASS_NO_DRAW];
|
||||
[ship setRoll: PI/5.0];
|
||||
[ship setPitch: PI/10.0];
|
||||
[universe addEntity: ship];
|
||||
[[ship getAI] setStateMachine: @"nullAI.plist"];
|
||||
|
||||
[ship release];
|
||||
[ship release];
|
||||
}
|
||||
//
|
||||
}
|
||||
|
||||
@ -1186,9 +1189,9 @@ static int shipsFound;
|
||||
for (i = 1; i < [ents count]; i++)
|
||||
{
|
||||
Entity* e1 = [ents objectAtIndex:i];
|
||||
if ([e1 isKindOfClass:[ShipEntity class]])
|
||||
if (e1->isShip)
|
||||
{
|
||||
int e_class = [e1 scanClass];
|
||||
int e_class = e1->scan_class;
|
||||
if ((e_class == CLASS_NEUTRAL)||(e_class == CLASS_POLICE)||(e_class == CLASS_THARGOID))
|
||||
{
|
||||
[[(ShipEntity*)e1 getAI] setStateMachine:@"exitingTraderAI.plist"];
|
||||
@ -1295,4 +1298,3 @@ static int shipsFound;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
@ -96,21 +96,22 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
#define WEAPON_COOLING_FACTOR 6.0
|
||||
#define ENERGY_RECHARGE_FACTOR energy_recharge_rate
|
||||
#define SHIELD_RECHARGE_FACTOR 2.0
|
||||
#define SHIELD_RECHARGE_FACTOR (2.0 + shield_enhancer)
|
||||
#define ECM_ENERGY_DRAIN_FACTOR 20.0
|
||||
#define ECM_DURATION 2.5
|
||||
|
||||
#define ROLL_DAMPING_FACTOR 1.0
|
||||
#define PITCH_DAMPING_FACTOR 1.0
|
||||
|
||||
#define PLAYER_MAX_FORWARD_SHIELD 128.0
|
||||
#define PLAYER_MAX_AFT_SHIELD 128.0
|
||||
#define PLAYER_MAX_FORWARD_SHIELD (128.0 * (shield_booster + shield_enhancer))
|
||||
#define PLAYER_MAX_AFT_SHIELD (128.0 * (shield_booster + shield_enhancer))
|
||||
#define PLAYER_MAX_WEAPON_TEMP 256.0
|
||||
#define PLAYER_MAX_CABIN_TEMP 256.0
|
||||
#define PLAYER_MAX_FUEL 70.0
|
||||
#define PLAYER_MAX_MISSILES 4
|
||||
#define PLAYER_STARTING_MISSILES 3
|
||||
#define PLAYER_DIAL_MAX_ALTITUDE 40000.0
|
||||
#define PLAYER_SUPER_ALTITUDE2 10000000000.0
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~ = 40km
|
||||
|
||||
#define ALERT_CONDITION_DOCKED 0
|
||||
@ -341,6 +342,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
// has_energy_bomb; // BOOL - from ShipEntity
|
||||
BOOL has_energy_unit;
|
||||
int energy_unit;
|
||||
int shield_booster, shield_enhancer;
|
||||
BOOL has_docking_computer;
|
||||
BOOL has_galactic_hyperdrive;
|
||||
// has_escape_pod; // BOOL - from ShipEntity
|
||||
|
140
PlayerEntity.m
140
PlayerEntity.m
@ -739,6 +739,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
//
|
||||
[self set_flags_from_extra_equipment];
|
||||
forward_shield = PLAYER_MAX_FORWARD_SHIELD;
|
||||
aft_shield = PLAYER_MAX_AFT_SHIELD;
|
||||
//
|
||||
|
||||
// things...
|
||||
@ -774,6 +776,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
drawDebugParticle = [[ParticleEntity alloc] init];
|
||||
[drawDebugParticle setParticleType:PARTICLE_MARKER];
|
||||
//
|
||||
isPlayer = YES;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -998,6 +1002,9 @@ static BOOL galactic_witchjump;
|
||||
has_escape_pod = NO;
|
||||
has_fuel_injection = NO;
|
||||
|
||||
shield_booster = 1;
|
||||
shield_enhancer = 0;
|
||||
|
||||
// set up missiles
|
||||
missiles = PLAYER_STARTING_MISSILES;
|
||||
max_missiles = PLAYER_MAX_MISSILES;
|
||||
@ -1432,7 +1439,7 @@ static BOOL galactic_witchjump;
|
||||
if (missile_status == MISSILE_STATUS_TARGET_LOCKED)
|
||||
{
|
||||
Entity* e = [universe entityForUniversalID:primaryTarget];
|
||||
if ((e == nil)||([e getZeroDistance] > SCANNER_MAX_RANGE2)||([e scanClass] == CLASS_NO_DRAW)) // checking scanClass checks for cloaked ships
|
||||
if ((e == nil)||(e->zero_distance > SCANNER_MAX_RANGE2)||(e->scan_class == CLASS_NO_DRAW)) // checking scanClass checks for cloaked ships
|
||||
{
|
||||
[universe addMessage:[universe expandDescription:@"[target-lost]" forSystem:system_seed] forCount:3.0];
|
||||
#ifdef HAVE_SOUND
|
||||
@ -1457,7 +1464,7 @@ static BOOL galactic_witchjump;
|
||||
if ((missile_entity[i])&&([missile_entity[i] getPrimaryTargetID] != NO_TARGET))
|
||||
{
|
||||
ShipEntity* target_ship = (ShipEntity *)[missile_entity[i] getPrimaryTarget];
|
||||
if ((!target_ship)||([target_ship getZeroDistance] > SCANNER_MAX_RANGE2))
|
||||
if ((!target_ship)||(target_ship->zero_distance > SCANNER_MAX_RANGE2))
|
||||
{
|
||||
[universe addMessage:[universe expandDescription:@"[target-lost]" forSystem:system_seed] forCount:3.0];
|
||||
#ifdef HAVE_SOUND
|
||||
@ -1500,6 +1507,7 @@ static BOOL galactic_witchjump;
|
||||
//
|
||||
double speed_delta = 5.0 * thrust;
|
||||
//
|
||||
PlanetEntity* sun = [universe sun];
|
||||
// if (weapon_temp > 0.0)
|
||||
// {
|
||||
// weapon_temp -= WEAPON_COOLING_FACTOR * delta_t;
|
||||
@ -1617,11 +1625,11 @@ static BOOL galactic_witchjump;
|
||||
}
|
||||
}
|
||||
|
||||
if ([universe sun])
|
||||
if (sun)
|
||||
{
|
||||
// do Revised sun-skimming check here...
|
||||
double sun_zd = [[universe sun] getZeroDistance]; // square of distance
|
||||
double sun_cr = [[universe sun] collisionRadius];
|
||||
double sun_zd = sun->zero_distance; // square of distance
|
||||
double sun_cr = sun->collision_radius;
|
||||
double alt1 = sun_cr * sun_cr / sun_zd;
|
||||
double external_temp = SUN_TEMPERATURE * alt1;
|
||||
if ([[universe sun] goneNova])
|
||||
@ -2007,17 +2015,16 @@ static BOOL galactic_witchjump;
|
||||
}
|
||||
- (double) dial_altitude
|
||||
{
|
||||
// are we trapped in witch space?
|
||||
if(![universe planet])
|
||||
return 1.0;
|
||||
|
||||
PlanetEntity *planet = [universe planet];
|
||||
PlanetEntity *sun = [universe sun];
|
||||
double planet_zd = [planet getZeroDistance];
|
||||
double sun_zd = [sun getZeroDistance];
|
||||
double alt = (planet_zd < sun_zd) ? (sqrt(planet_zd) - [planet collisionRadius]) : (sqrt(sun_zd) - [sun collisionRadius]);
|
||||
alt /= PLAYER_DIAL_MAX_ALTITUDE;
|
||||
double planet_zd = (planet)? planet->zero_distance : PLAYER_SUPER_ALTITUDE2;
|
||||
double sun_zd = (sun)? sun->zero_distance : PLAYER_SUPER_ALTITUDE2;
|
||||
double planet_cr = (planet)? planet->collision_radius : 0;
|
||||
double sun_cr = (sun)? sun->collision_radius : 0;
|
||||
double alt = (planet_zd < sun_zd) ? (sqrt(planet_zd) - planet_cr) : (sqrt(sun_zd) - sun_cr);
|
||||
|
||||
alt /= PLAYER_DIAL_MAX_ALTITUDE;
|
||||
|
||||
if (alt > 1.0)
|
||||
alt = 1.0;
|
||||
if (alt < 0.0)
|
||||
@ -2163,7 +2170,7 @@ static BOOL galactic_witchjump;
|
||||
- (NSString *) dial_target_name
|
||||
{
|
||||
Entity* target_entity = [universe entityForUniversalID:primaryTarget];
|
||||
if ([target_entity isKindOfClass:[ShipEntity class]])
|
||||
if ((target_entity)&&(target_entity->isShip))
|
||||
return [(ShipEntity*)target_entity name];
|
||||
else
|
||||
return @"No target";
|
||||
@ -2718,7 +2725,8 @@ static BOOL cloak_pressed;
|
||||
//
|
||||
if (([gameView isDown:key_autopilot_target])&&(has_docking_computer)&&(![beepSound isPlaying])) // look for the 'c' key
|
||||
{
|
||||
if ([[self getPrimaryTarget] isKindOfClass:[StationEntity class]])
|
||||
Entity* primeTarget = [self getPrimaryTarget];
|
||||
if ((primeTarget)&&(primeTarget->isStation))
|
||||
{
|
||||
targetStation = primaryTarget;
|
||||
primaryTarget = NO_TARGET;
|
||||
@ -4267,7 +4275,7 @@ static BOOL toggling_music;
|
||||
}
|
||||
//
|
||||
// keep music playing
|
||||
if (autopilot_engaged && (docking_music_on)&&(!ootunes_on))
|
||||
if ((docking_music_on)&&(!ootunes_on))
|
||||
{
|
||||
#ifndef GNUSTEP
|
||||
if (IsMovieDone ([dockingMusic QTMovie]))
|
||||
@ -4563,7 +4571,7 @@ static BOOL toggling_music;
|
||||
start.y = boundingBox.min_y - 4.0; // 4m below bounding box
|
||||
start.z = boundingBox.max_z + 1.0; // 1m ahead of bounding box
|
||||
double throw_speed = 250.0;
|
||||
Quaternion q1 = [self QRotation];
|
||||
Quaternion q1 = q_rotation;
|
||||
q1.w = -q1.w; // player view is reversed remember!
|
||||
Entity *target = [self getPrimaryTarget];
|
||||
|
||||
@ -4601,8 +4609,10 @@ static BOOL toggling_music;
|
||||
|
||||
- (BOOL) launchMine:(ShipEntity*) mine
|
||||
{
|
||||
if (!mine)
|
||||
return NO;
|
||||
// [self setSpeed: max_flight_speed];
|
||||
double start = collision_radius + [mine collisionRadius];
|
||||
double start = collision_radius + mine->collision_radius;
|
||||
double eject_speed = -500.0;
|
||||
Quaternion random_direction;
|
||||
Vector vel;
|
||||
@ -4661,7 +4671,7 @@ static BOOL toggling_music;
|
||||
for (i = 0; i < [targets count]; i++)
|
||||
{
|
||||
Entity *e2 = [targets objectAtIndex:i];
|
||||
if ([e2 isKindOfClass:[ShipEntity class]])
|
||||
if (e2->isShip)
|
||||
[(ShipEntity *)e2 takeEnergyDamage:1000 from:self becauseOf:self];
|
||||
}
|
||||
}
|
||||
@ -4813,7 +4823,7 @@ static BOOL toggling_music;
|
||||
|
||||
[ent retain];
|
||||
[other retain];
|
||||
rel_pos = [ent getPosition];
|
||||
rel_pos = (ent)? ent->position: make_vector(0,0,0);
|
||||
|
||||
rel_pos.x -= position.x;
|
||||
rel_pos.y -= position.y;
|
||||
@ -4874,7 +4884,7 @@ static BOOL toggling_music;
|
||||
|
||||
if (energy <= 0.0)
|
||||
{
|
||||
if ([other isKindOfClass:[ShipEntity class]])
|
||||
if ((other)&&(other->isShip))
|
||||
{
|
||||
ShipEntity* hunter = (ShipEntity *)other;
|
||||
[hunter collectBountyFor:self];
|
||||
@ -4901,7 +4911,7 @@ static BOOL toggling_music;
|
||||
return;
|
||||
|
||||
[ent retain];
|
||||
rel_pos = [ent getPosition];
|
||||
rel_pos = (ent)? ent->position : make_vector(0,0,0);
|
||||
|
||||
rel_pos.x -= position.x;
|
||||
rel_pos.y -= position.y;
|
||||
@ -4947,7 +4957,7 @@ static BOOL toggling_music;
|
||||
energy -= amount;
|
||||
if (energy <= 0.0)
|
||||
{
|
||||
if ([ent isKindOfClass:[ShipEntity class]])
|
||||
if ((ent)&&(ent->isShip))
|
||||
{
|
||||
ShipEntity* hunter = (ShipEntity *)ent;
|
||||
[hunter collectBountyFor:self];
|
||||
@ -4971,7 +4981,7 @@ static BOOL toggling_music;
|
||||
int result;
|
||||
//double start = 10.0;
|
||||
//double throw_speed = 20.0;
|
||||
Quaternion q1 = [self QRotation];
|
||||
Quaternion q1 = q_rotation;
|
||||
|
||||
status = STATUS_ESCAPE_SEQUENCE; // firstly
|
||||
ship_clock_adjust += 43200 + 5400 * (ranrot_rand() & 127); // add up to 8 days until rescue!
|
||||
@ -5061,8 +5071,10 @@ static BOOL toggling_music;
|
||||
|
||||
- (void) collectBountyFor:(ShipEntity *)other
|
||||
{
|
||||
if (!other)
|
||||
return;
|
||||
int score = 10 * [other getBounty];
|
||||
int killClass = [other scanClass]; // **tgape** change (+line)
|
||||
int killClass = other->scan_class; // **tgape** change (+line)
|
||||
int kill_award = 1;
|
||||
//
|
||||
if ([[other roles] isEqual:@"police"]) // oops, we shot a copper!
|
||||
@ -5144,7 +5156,7 @@ static BOOL toggling_music;
|
||||
for (i = 0; i < [entList count] ; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if ([thing isKindOfClass:[ShipEntity class]])
|
||||
if (thing->isShip)
|
||||
{
|
||||
ShipEntity* ship = (ShipEntity *)thing;
|
||||
if (self == [ship getPrimaryTarget])
|
||||
@ -5192,24 +5204,24 @@ static BOOL toggling_music;
|
||||
|
||||
[self loseTargetStatus];
|
||||
|
||||
Vector launchPos = [docked_station getPosition];
|
||||
position = launchPos;
|
||||
|
||||
q_rotation = [docked_station QRotation];
|
||||
q_rotation.w = -q_rotation.w; // need this as a fix...
|
||||
|
||||
// rotate 90 degrees
|
||||
quaternion_rotate_about_z(&q_rotation, PI * 0.5);
|
||||
|
||||
// [self setPosition:[docked_station getPosition]];
|
||||
// [self setQRotation:[docked_station QRotation]];
|
||||
if (docked_station)
|
||||
{
|
||||
Vector launchPos = docked_station->position;
|
||||
position = launchPos;
|
||||
|
||||
q_rotation = docked_station->q_rotation;
|
||||
q_rotation.w = -q_rotation.w; // need this as a fix...
|
||||
|
||||
// rotate 90 degrees
|
||||
quaternion_rotate_about_z(&q_rotation, PI * 0.5);
|
||||
|
||||
v_forward = vector_forward_from_quaternion(q_rotation);
|
||||
v_right = vector_right_from_quaternion(q_rotation);
|
||||
v_up = vector_up_from_quaternion(q_rotation);
|
||||
|
||||
v_forward = vector_forward_from_quaternion(q_rotation);
|
||||
v_right = vector_right_from_quaternion(q_rotation);
|
||||
v_up = vector_up_from_quaternion(q_rotation);
|
||||
|
||||
q_rotation.w = -q_rotation.w; // need this as a fix...
|
||||
quaternion_into_gl_matrix(q_rotation, rotMatrix);
|
||||
q_rotation.w = -q_rotation.w; // need this as a fix...
|
||||
quaternion_into_gl_matrix(q_rotation, rotMatrix);
|
||||
}
|
||||
|
||||
flight_roll = 0.0;
|
||||
flight_pitch = 0.0;
|
||||
@ -5596,13 +5608,16 @@ static BOOL toggling_music;
|
||||
[universe setViewDirection:VIEW_DOCKED];
|
||||
|
||||
docked_station = [universe station];
|
||||
[self setPosition:[docked_station getPosition]];
|
||||
[self setQRotation:[docked_station QRotation]];
|
||||
v_forward = vector_forward_from_quaternion(q_rotation);
|
||||
v_right = vector_right_from_quaternion(q_rotation);
|
||||
v_up = vector_up_from_quaternion(q_rotation);
|
||||
|
||||
q_rotation.w = -q_rotation.w; // need this as a fix...
|
||||
if (docked_station)
|
||||
{
|
||||
position = docked_station->position;
|
||||
[self setQRotation:docked_station->q_rotation];
|
||||
v_forward = vector_forward_from_quaternion(q_rotation);
|
||||
v_right = vector_right_from_quaternion(q_rotation);
|
||||
v_up = vector_up_from_quaternion(q_rotation);
|
||||
|
||||
q_rotation.w = -q_rotation.w; // need this as a fix...
|
||||
}
|
||||
|
||||
flight_roll = 0.0;
|
||||
flight_pitch = 0.0;
|
||||
@ -6330,7 +6345,7 @@ static int last_outfitting_index;
|
||||
|
||||
// NSLog(@"DEBUG EquipShipScreen missiles = %d", missiles);
|
||||
|
||||
// if skip == -1 then use the last recorded index
|
||||
// if skip < 0 then use the last recorded index
|
||||
if (skip < 0)
|
||||
{
|
||||
if (last_outfitting_index >= 0)
|
||||
@ -6635,8 +6650,7 @@ static int last_outfitting_index;
|
||||
|
||||
if (gui)
|
||||
gui_screen = GUI_SCREEN_INTRO1;
|
||||
|
||||
|
||||
|
||||
if (themeMusic)
|
||||
{
|
||||
#ifndef GNUSTEP
|
||||
@ -7184,6 +7198,11 @@ static int last_outfitting_index;
|
||||
[self add_extra_equipment:@"EQ_DOCK_COMP"];
|
||||
if (has_galactic_hyperdrive)
|
||||
[self add_extra_equipment:@"EQ_GAL_DRIVE"];
|
||||
|
||||
if (shield_booster > 1)
|
||||
[self add_extra_equipment:@"EQ_SHIELD_BOOSTER"];
|
||||
if (shield_enhancer)
|
||||
[self add_extra_equipment:@"EQ_NAVAL_SHIELD_BOOSTER"];
|
||||
}
|
||||
|
||||
- (void) set_flags_from_extra_equipment
|
||||
@ -7212,7 +7231,9 @@ static int last_outfitting_index;
|
||||
compass_mode = COMPASS_MODE_PLANET;
|
||||
else
|
||||
compass_mode = COMPASS_MODE_BASIC;
|
||||
|
||||
|
||||
shield_booster = ([self has_extra_equipment:@"EQ_SHIELD_BOOSTER"])? 2:1;
|
||||
shield_enhancer = ([self has_extra_equipment:@"EQ_NAVAL_SHIELD_BOOSTER"])? 1:0;
|
||||
}
|
||||
|
||||
|
||||
@ -7407,8 +7428,15 @@ NSString* GenerateDisplayString(int inModeWidth, int inModeHeight, int inModeRef
|
||||
{
|
||||
// NSLog(@"DEBUG checking per poly collision %@ %d versus particle", name, universal_id);
|
||||
|
||||
|
||||
// This is not currently working so...
|
||||
//
|
||||
return YES;
|
||||
//
|
||||
////
|
||||
|
||||
if (!other)
|
||||
return NO;
|
||||
|
||||
Quaternion q_actual = q_rotation;
|
||||
q_actual.w = -q_actual.w;
|
||||
@ -7419,9 +7447,9 @@ NSString* GenerateDisplayString(int inModeWidth, int inModeHeight, int inModeRef
|
||||
// check bounding boxes ...
|
||||
//
|
||||
// get position relative to this ship's orientation
|
||||
Vector o_pos = [other getPosition];
|
||||
Vector o_pos = other->position;
|
||||
o_pos.x -= position.x; o_pos.y -= position.y; o_pos.z -= position.z;
|
||||
double cr = [other collisionRadius];
|
||||
double cr = other->collision_radius;
|
||||
|
||||
int f;
|
||||
BOOL all_clear = YES;
|
||||
|
@ -173,6 +173,20 @@
|
||||
<string>EQ_QC_MINE</string>
|
||||
<string>Tyley-Feynman Quirium cascade mine. Mounts in place of a missile, but deploys to the rear of your craft. Capable of massive destruction and triggering chain reactions in the witchdrives of ships caught in its blast range.</string>
|
||||
</array>
|
||||
<array>
|
||||
<integer>10</integer>
|
||||
<integer>147500</integer>
|
||||
<string>Shield Boosters</string>
|
||||
<string>EQ_SHIELD_BOOSTER</string>
|
||||
<string>Shield boosting technology dramatically increases the capability of standard defensive shields.</string>
|
||||
</array>
|
||||
<array>
|
||||
<integer>13</integer>
|
||||
<integer>475500</integer>
|
||||
<string>Military Shield Enhancement</string>
|
||||
<string>EQ_NAVAL_SHIELD_BOOSTER</string>
|
||||
<string>Military technology, used in conjunction with ordinary shields and shield boosting technology, further increases the capability of standard defensive shields.</string>
|
||||
</array>
|
||||
<!-- next item was a test item -->
|
||||
<!--
|
||||
-->
|
||||
|
@ -276,7 +276,9 @@
|
||||
<key>has_escape_pod</key>
|
||||
<false/>
|
||||
<key>has_fuel_injection</key>
|
||||
<true/>
|
||||
<real>0.5</real>
|
||||
<key>has_shield_booster</key>
|
||||
<real>0.5</real>
|
||||
<key>has_scoop</key>
|
||||
<true/>
|
||||
<key>likely_cargo</key>
|
||||
@ -1053,6 +1055,8 @@
|
||||
<true/>
|
||||
<key>has_scoop</key>
|
||||
<true/>
|
||||
<key>has_shield_booster</key>
|
||||
<real>0.25</real>
|
||||
<key>likely_cargo</key>
|
||||
<integer>3</integer>
|
||||
<key>max_cargo</key>
|
||||
@ -1293,6 +1297,10 @@
|
||||
<false/>
|
||||
<key>has_scoop</key>
|
||||
<true/>
|
||||
<key>has_fuel_injection</key>
|
||||
<real>0.25</real>
|
||||
<key>has_shield_booster</key>
|
||||
<real>0.25</real>
|
||||
<key>likely_cargo</key>
|
||||
<integer>2</integer>
|
||||
<key>max_cargo</key>
|
||||
@ -1642,7 +1650,11 @@
|
||||
<key>has_escape_pod</key>
|
||||
<false/>
|
||||
<key>has_fuel_injection</key>
|
||||
<true/>
|
||||
<real>0.75</real>
|
||||
<key>has_shield_booster</key>
|
||||
<real>0.5</real>
|
||||
<key>has_shield_enhancer</key>
|
||||
<real>0.5</real>
|
||||
<key>has_scoop</key>
|
||||
<true/>
|
||||
<key>likely_cargo</key>
|
||||
@ -1733,6 +1745,8 @@
|
||||
<false/>
|
||||
<key>has_scoop</key>
|
||||
<true/>
|
||||
<key>has_shield_booster</key>
|
||||
<real>0.4</real>
|
||||
<key>likely_cargo</key>
|
||||
<integer>0</integer>
|
||||
<key>max_cargo</key>
|
||||
@ -1875,7 +1889,11 @@
|
||||
<key>has_escape_pod</key>
|
||||
<false/>
|
||||
<key>has_fuel_injection</key>
|
||||
<true/>
|
||||
<real>0.65</real>
|
||||
<key>has_shield_booster</key>
|
||||
<real>0.5</real>
|
||||
<key>has_shield_enhancer</key>
|
||||
<real>0.25</real>
|
||||
<key>has_scoop</key>
|
||||
<true/>
|
||||
<key>likely_cargo</key>
|
||||
@ -1929,6 +1947,8 @@
|
||||
<false/>
|
||||
<key>has_scoop</key>
|
||||
<true/>
|
||||
<key>has_shield_booster</key>
|
||||
<real>0.25</real>
|
||||
<key>likely_cargo</key>
|
||||
<integer>0</integer>
|
||||
<key>max_cargo</key>
|
||||
@ -2076,6 +2096,8 @@
|
||||
<false/>
|
||||
<key>has_scoop</key>
|
||||
<true/>
|
||||
<key>has_shield_booster</key>
|
||||
<real>0.5</real>
|
||||
<key>likely_cargo</key>
|
||||
<integer>0</integer>
|
||||
<key>max_cargo</key>
|
||||
@ -2248,6 +2270,8 @@
|
||||
<true/>
|
||||
<key>has_scoop</key>
|
||||
<true/>
|
||||
<key>has_shield_booster</key>
|
||||
<real>0.75</real>
|
||||
<key>likely_cargo</key>
|
||||
<integer>10</integer>
|
||||
<key>max_cargo</key>
|
||||
|
@ -23,6 +23,7 @@
|
||||
<string>EQ_SCANNER_SHOW_MISSILE_TARGET</string>
|
||||
<string>EQ_MULTI_TARGET</string>
|
||||
<string>EQ_GAL_DRIVE</string>
|
||||
<string>EQ_SHIELD_BOOSTER</string>
|
||||
</array>
|
||||
<key>price</key>
|
||||
<integer>65000</integer>
|
||||
@ -63,6 +64,7 @@
|
||||
<string>EQ_MULTI_TARGET</string>
|
||||
<string>EQ_GAL_DRIVE</string>
|
||||
<string>EQ_ADVANCED_COMPASS</string>
|
||||
<string>EQ_SHIELD_BOOSTER</string>
|
||||
</array>
|
||||
<key>price</key>
|
||||
<integer>650000</integer>
|
||||
@ -98,6 +100,8 @@
|
||||
<string>EQ_FUEL_INJECTION</string>
|
||||
<string>EQ_GAL_DRIVE</string>
|
||||
<string>EQ_ADVANCED_COMPASS</string>
|
||||
<string>EQ_SHIELD_BOOSTER</string>
|
||||
<string>EQ_NAVAL_SHIELD_BOOSTER</string>
|
||||
</array>
|
||||
<key>price</key>
|
||||
<integer>375000</integer>
|
||||
@ -141,6 +145,7 @@
|
||||
<string>EQ_MULTI_TARGET</string>
|
||||
<string>EQ_GAL_DRIVE</string>
|
||||
<string>EQ_ADVANCED_COMPASS</string>
|
||||
<string>EQ_SHIELD_BOOSTER</string>
|
||||
</array>
|
||||
<key>price</key>
|
||||
<integer>450000</integer>
|
||||
@ -181,6 +186,8 @@
|
||||
<string>EQ_MULTI_TARGET</string>
|
||||
<string>EQ_GAL_DRIVE</string>
|
||||
<string>EQ_ADVANCED_COMPASS</string>
|
||||
<string>EQ_SHIELD_BOOSTER</string>
|
||||
<string>EQ_NAVAL_SHIELD_BOOSTER</string>
|
||||
</array>
|
||||
<key>price</key>
|
||||
<integer>495000</integer>
|
||||
@ -222,6 +229,8 @@
|
||||
<string>EQ_MULTI_TARGET</string>
|
||||
<string>EQ_GAL_DRIVE</string>
|
||||
<string>EQ_ADVANCED_COMPASS</string>
|
||||
<string>EQ_SHIELD_BOOSTER</string>
|
||||
<string>EQ_NAVAL_SHIELD_BOOSTER</string>
|
||||
</array>
|
||||
<key>price</key>
|
||||
<integer>150000</integer>
|
||||
@ -261,6 +270,7 @@
|
||||
<string>EQ_SCANNER_SHOW_MISSILE_TARGET</string>
|
||||
<string>EQ_MULTI_TARGET</string>
|
||||
<string>EQ_GAL_DRIVE</string>
|
||||
<string>EQ_SHIELD_BOOSTER</string>
|
||||
</array>
|
||||
<key>price</key>
|
||||
<integer>100000</integer>
|
||||
@ -292,6 +302,7 @@
|
||||
<string>EQ_WEAPON_MINING_LASER</string>
|
||||
<string>EQ_WEAPON_MILITARY_LASER</string>
|
||||
<string>EQ_GAL_DRIVE</string>
|
||||
<string>EQ_NAVAL_SHIELD_BOOSTER</string>
|
||||
</array>
|
||||
<key>price</key>
|
||||
<integer>485000</integer>
|
||||
@ -309,6 +320,7 @@
|
||||
<string>EQ_FUEL_INJECTION</string>
|
||||
<string>EQ_MULTI_TARGET</string>
|
||||
<string>EQ_DOCK_COMP</string>
|
||||
<string>EQ_SHIELD_BOOSTER</string>
|
||||
</array>
|
||||
<key>forward_weapon_type</key>
|
||||
<string>EQ_WEAPON_BEAM_LASER</string>
|
||||
@ -343,6 +355,8 @@
|
||||
<string>EQ_MULTI_TARGET</string>
|
||||
<string>EQ_GAL_DRIVE</string>
|
||||
<string>EQ_ADVANCED_COMPASS</string>
|
||||
<string>EQ_SHIELD_BOOSTER</string>
|
||||
<string>EQ_NAVAL_SHIELD_BOOSTER</string>
|
||||
</array>
|
||||
<key>price</key>
|
||||
<integer>125000</integer>
|
||||
@ -384,6 +398,7 @@
|
||||
<string>EQ_MULTI_TARGET</string>
|
||||
<string>EQ_GAL_DRIVE</string>
|
||||
<string>EQ_ADVANCED_COMPASS</string>
|
||||
<string>EQ_SHIELD_BOOSTER</string>
|
||||
</array>
|
||||
<key>price</key>
|
||||
<integer>145000</integer>
|
||||
@ -424,6 +439,7 @@
|
||||
<string>EQ_SCANNER_SHOW_MISSILE_TARGET</string>
|
||||
<string>EQ_MULTI_TARGET</string>
|
||||
<string>EQ_GAL_DRIVE</string>
|
||||
<string>EQ_SHIELD_BOOSTER</string>
|
||||
</array>
|
||||
<key>price</key>
|
||||
<integer>200000</integer>
|
||||
|
@ -67,6 +67,6 @@
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<string>OoliteApp</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@ -106,7 +106,9 @@ Ringdata ringentity;
|
||||
velocity.x = 0.0;
|
||||
velocity.y = 0.0;
|
||||
velocity.z = 1.0;
|
||||
|
||||
//
|
||||
isRing = YES;
|
||||
//
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -190,4 +192,3 @@ Ringdata ringentity;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
@ -270,7 +270,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
// inform our old target of our new target
|
||||
//
|
||||
if ([[universe entityForUniversalID:primaryTarget] isKindOfClass:[ShipEntity class]])
|
||||
Entity* primeTarget = [universe entityForUniversalID:primaryTarget];
|
||||
if ((primeTarget)&&(primeTarget->isShip))
|
||||
{
|
||||
ShipEntity* currentShip = (ShipEntity*)[universe entityForUniversalID:primaryTarget];
|
||||
[[currentShip getAI] message:[NSString stringWithFormat:@"%@ %d %d", AIMS_AGGRESSOR_SWITCHED_TARGET, universal_id, primaryAggressor]];
|
||||
@ -296,16 +297,16 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count] ; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if (([thing isKindOfClass:[ShipEntity class]])&&(thing != (Entity *)self))
|
||||
if ((thing->isShip)&&(thing != (Entity *)self))
|
||||
{
|
||||
ShipEntity* ship = (ShipEntity *)thing;
|
||||
if ((([[ship roles] isEqual:@"trader"])||([ship isKindOfClass:[PlayerEntity class]]))&&([ship getStatus] != STATUS_DEAD)&&([ship getStatus] != STATUS_DOCKED))
|
||||
if ((([[ship roles] isEqual:@"trader"])||(ship->isPlayer))&&(ship->status != STATUS_DEAD)&&(ship->status != STATUS_DOCKED))
|
||||
{
|
||||
double d2;
|
||||
Vector delta = [ship getPosition];
|
||||
Vector delta = ship->position;
|
||||
delta.x -= position.x; delta.y -= position.y; delta.z -= position.z;
|
||||
d2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
|
||||
if (([roles isEqual:@"pirate"])&&(d2*d2 < desired_range)&&([ship isKindOfClass:[PlayerEntity class]])&&(PIRATES_PREFER_PLAYER))
|
||||
if (([roles isEqual:@"pirate"])&&(d2*d2 < desired_range)&&(ship->isPlayer)&&(PIRATES_PREFER_PLAYER))
|
||||
d2 = 0.0;
|
||||
if (d2 < found_d2)
|
||||
{
|
||||
@ -335,13 +336,13 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count] ; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if (([thing isKindOfClass:[ShipEntity class]])&&(thing != (Entity *)self))
|
||||
if ((thing->isShip)&&(thing != (Entity *)self))
|
||||
{
|
||||
ShipEntity* ship = (ShipEntity *)thing;
|
||||
if ((([[ship roles] isEqual:@"trader"])||([ship isKindOfClass:[PlayerEntity class]]))&&([ship getStatus] != STATUS_DEAD)&&([ship getStatus] != STATUS_DOCKED))
|
||||
if ((([[ship roles] isEqual:@"trader"])||(ship->isPlayer))&&(ship->status != STATUS_DEAD)&&(ship->status != STATUS_DOCKED))
|
||||
{
|
||||
double d2;
|
||||
Vector delta = [ship getPosition];
|
||||
Vector delta = ship->position;
|
||||
delta.x -= position.x; delta.y -= position.y; delta.z -= position.z;
|
||||
d2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
|
||||
if (d2 < found_d2)
|
||||
@ -367,7 +368,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
- (void) scanForLoot
|
||||
{
|
||||
/*-- Locates the nearest debris in range --*/
|
||||
if ((![self isKindOfClass:[StationEntity class]])&&(!has_scoop))
|
||||
if ((!isStation)&&(!has_scoop))
|
||||
{
|
||||
[shipAI message:@"NOTHING_FOUND"]; //can't collect loot if you have no scoop!
|
||||
return;
|
||||
@ -380,13 +381,13 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count]; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if ([thing isKindOfClass:[ShipEntity class]])
|
||||
if (thing->isShip)
|
||||
{
|
||||
ShipEntity *other = (ShipEntity *)thing;
|
||||
if (([other scanClass] == CLASS_CARGO)&&([other getCargoType] != CARGO_NOT_CARGO))
|
||||
if ((other->scan_class == CLASS_CARGO)&&([other getCargoType] != CARGO_NOT_CARGO))
|
||||
{
|
||||
double d2;
|
||||
Vector delta = [thing getPosition];
|
||||
Vector delta = thing->position;
|
||||
delta.x -= position.x; delta.y -= position.y; delta.z -= position.z;
|
||||
d2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
|
||||
if (d2 < found_d2)
|
||||
@ -413,7 +414,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
// double found_d2 = desired_range*desired_range;
|
||||
double found_d2 = scanner_range * scanner_range;
|
||||
found_target = NO_TARGET;
|
||||
if ((![self isKindOfClass:[StationEntity class]])&&(!has_scoop))
|
||||
if ((!isStation)&&(!has_scoop))
|
||||
{
|
||||
[shipAI message:@"NOTHING_FOUND"]; //can't collect loot if you have no scoop!
|
||||
return;
|
||||
@ -422,13 +423,13 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; (i < [entList count])&&(things_found < 16) ; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if ([thing isKindOfClass:[ShipEntity class]])
|
||||
if (thing->isShip)
|
||||
{
|
||||
ShipEntity *other = (ShipEntity *)thing;
|
||||
if (([other scanClass] == CLASS_CARGO)&&([other getCargoType] != CARGO_NOT_CARGO))
|
||||
if ((other->scan_class == CLASS_CARGO)&&([other getCargoType] != CARGO_NOT_CARGO))
|
||||
{
|
||||
double d2;
|
||||
Vector delta = [thing getPosition];
|
||||
Vector delta = thing->position;
|
||||
delta.x -= position.x; delta.y -= position.y; delta.z -= position.z;
|
||||
d2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
|
||||
if (d2 < found_d2)
|
||||
@ -480,8 +481,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
{
|
||||
/*- requests coordinates from the nearest station it can find (which may be a rock hermit) -*/
|
||||
StationEntity* station = nil;
|
||||
|
||||
if ([[universe entityForUniversalID:targetStation] isKindOfClass:[StationEntity class]])
|
||||
Entity* targStation = [universe entityForUniversalID:targetStation];
|
||||
if ((targStation)&&(targStation->isStation))
|
||||
{
|
||||
station = (StationEntity*)[universe entityForUniversalID:targetStation];
|
||||
}
|
||||
@ -494,9 +495,9 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count]; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if ([thing isKindOfClass:[StationEntity class]])
|
||||
if (thing->isStation)
|
||||
{
|
||||
Vector p2 = [thing getPosition];
|
||||
Vector p2 = thing->position;
|
||||
p2.x -= p1.x; p2.y -= p1.y; p2.z -= p1.z;
|
||||
double range2 = (p2.x * p2.x + p2.y * p2.y + p2.z * p2.z);
|
||||
if (range2 < nearest2)
|
||||
@ -542,9 +543,9 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count]; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if ([thing isKindOfClass:[StationEntity class]])
|
||||
if (thing->isStation)
|
||||
{
|
||||
Vector p2 = [thing getPosition];
|
||||
Vector p2 = thing->position;
|
||||
p2.x -= p1.x; p2.y -= p1.y; p2.z -= p1.z;
|
||||
double range2 = (p2.x * p2.x + p2.y * p2.y + p2.z * p2.z);
|
||||
if (range2 < nearest2)
|
||||
@ -557,8 +558,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
[entList release];
|
||||
if (station)
|
||||
{
|
||||
coordinates = [station getPosition];
|
||||
Vector vr = vector_right_from_quaternion([station QRotation]);
|
||||
coordinates = station->position;
|
||||
Vector vr = vector_right_from_quaternion(station->q_rotation);
|
||||
coordinates.x += 10000 * vr.x; // 10km from station
|
||||
coordinates.y += 10000 * vr.y;
|
||||
coordinates.z += 10000 * vr.z;
|
||||
@ -604,7 +605,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; (i < [entList count])&&(missile == nil); i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if ([thing scanClass] == CLASS_MISSILE)
|
||||
if (thing->scan_class == CLASS_MISSILE)
|
||||
{
|
||||
if ([(ShipEntity *)thing getPrimaryTarget] == self)
|
||||
missile = (ShipEntity *)thing;
|
||||
@ -683,11 +684,11 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count]; i++)
|
||||
{
|
||||
Entity *thing = (Entity *)[entList objectAtIndex:i];
|
||||
if ([thing isKindOfClass:[PlanetEntity class]])
|
||||
if (thing->isPlanet)
|
||||
{
|
||||
if ([(PlanetEntity *)thing getPlanetType] == PLANET_TYPE_GREEN)
|
||||
{
|
||||
Vector p2 = [thing getPosition];
|
||||
Vector p2 = thing->position;
|
||||
p2.x -= p1.x; p2.y -= p1.y; p2.z -= p1.z;
|
||||
double range2 = (p2.x * p2.x + p2.y * p2.y + p2.z * p2.z);
|
||||
if ((!the_planet)||(range2 < nearest2))
|
||||
@ -708,8 +709,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
PlanetEntity *the_planet = [self findNearestPlanet];
|
||||
if (the_planet)
|
||||
{
|
||||
destination = [the_planet getPosition];
|
||||
desired_range = [the_planet collisionRadius] + 100.0; // 100m from the surface
|
||||
destination = the_planet->position;
|
||||
desired_range = the_planet->collision_radius + 100.0; // 100m from the surface
|
||||
}
|
||||
}
|
||||
|
||||
@ -719,8 +720,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
PlanetEntity *the_planet = [self findNearestPlanet];
|
||||
if (the_planet)
|
||||
{
|
||||
destination = [the_planet getPosition];
|
||||
desired_range = [the_planet collisionRadius] + 10000.0; // 10km from the surface
|
||||
destination = the_planet->position;
|
||||
desired_range = the_planet->collision_radius + 10000.0; // 10km from the surface
|
||||
}
|
||||
else
|
||||
NSLog(@"***** Ackk!! planet not found!!!");
|
||||
@ -780,7 +781,9 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
- (void) setDestinationToTarget
|
||||
{
|
||||
destination = [[universe entityForUniversalID:primaryTarget] getPosition];
|
||||
Entity* the_target = [universe entityForUniversalID:primaryTarget];
|
||||
if (the_target)
|
||||
destination = the_target->position;
|
||||
}
|
||||
|
||||
- (void) checkCourseToDestination
|
||||
@ -810,10 +813,10 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count] ; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if (([thing isKindOfClass:[ShipEntity class]])&&([thing scanClass] != CLASS_CARGO))
|
||||
if ((thing->isShip)&&(thing->scan_class != CLASS_CARGO))
|
||||
{
|
||||
ShipEntity* ship = (ShipEntity *)thing;
|
||||
if (([ship getStatus] != STATUS_DEAD)&&([ship getStatus] != STATUS_DOCKED))
|
||||
if ((ship->status != STATUS_DEAD)&&(ship->status != STATUS_DOCKED))
|
||||
{
|
||||
double d2;
|
||||
BOOL is_thargoid = [[ship roles] isEqual:@"thargoid"];
|
||||
@ -821,7 +824,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
if (is_thargoid)
|
||||
legal_factor += 500;
|
||||
int random_factor = ranrot_rand() & 255; // 25% chance of spotting a fugitive in 15s
|
||||
Vector delta = [ship getPosition];
|
||||
Vector delta = ship->position;
|
||||
delta.x -= position.x; delta.y -= position.y; delta.z -= position.z;
|
||||
d2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
|
||||
if ((d2 < found_d2)&&(random_factor < legal_factor)&&(legal_factor > worst_legal_factor))
|
||||
@ -891,16 +894,16 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count] ; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if ([thing isKindOfClass:[ShipEntity class]])
|
||||
if (thing->isShip)
|
||||
{
|
||||
Vector delta = [thing getPosition];
|
||||
Vector delta = thing->position;
|
||||
delta.x -= position.x; delta.y -= position.y; delta.z -= position.z;
|
||||
d2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
|
||||
if (d2 < found_d2)
|
||||
{
|
||||
ShipEntity *ship = (ShipEntity *)thing;
|
||||
// tell it! //
|
||||
if ([ship isKindOfClass:[PlayerEntity class]])
|
||||
if (ship->isPlayer)
|
||||
{
|
||||
if ((primaryAggressor == [ship universal_id])&&(energy < 0.375 * max_energy)&&(!is_buoy))
|
||||
{
|
||||
@ -914,7 +917,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
//
|
||||
thanked_ship_id = NO_TARGET;
|
||||
}
|
||||
if ([ship isKindOfClass:[StationEntity class]])
|
||||
if (ship->isStation)
|
||||
[ship acceptDistressMessageFrom:self];
|
||||
if ([[ship roles] isEqual:@"police"])
|
||||
[ship acceptDistressMessageFrom:self];
|
||||
@ -986,11 +989,11 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count] ; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if ([thing isKindOfClass:[ShipEntity class]])
|
||||
if (thing->isShip)
|
||||
{
|
||||
double d2;
|
||||
ShipEntity *ship = (ShipEntity *)thing;
|
||||
Vector delta = [thing getPosition];
|
||||
Vector delta = thing->position;
|
||||
delta.x -= position.x; delta.y -= position.y; delta.z -= position.z;
|
||||
d2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
|
||||
if (([[ship roles] isEqual:@"thargoid"])&&(d2 < found_d2))
|
||||
@ -1016,7 +1019,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count] ; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if ([thing isKindOfClass:[ShipEntity class]])
|
||||
if (thing->isShip)
|
||||
{
|
||||
ShipEntity* other = (ShipEntity*)thing;
|
||||
if (([other getPrimaryTarget] == self)&&([other hasHostileTarget]))
|
||||
@ -1039,17 +1042,17 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count] ; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if ([thing isKindOfClass:[ShipEntity class]])
|
||||
if (thing->isShip)
|
||||
{
|
||||
double d2;
|
||||
NSString *shiproles = [(ShipEntity *)thing roles];
|
||||
Vector delta = [thing getPosition];
|
||||
Vector delta = thing->position;
|
||||
delta.x -= position.x; delta.y -= position.y; delta.z -= position.z;
|
||||
d2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
|
||||
if (([thing scanClass] != CLASS_CARGO)&&([thing getStatus] != STATUS_DOCKED)&&(![shiproles hasPrefix:@"tharg"])&&(d2 < found_d2))
|
||||
if ((thing->scan_class != CLASS_CARGO)&&(thing->status != STATUS_DOCKED)&&(![shiproles hasPrefix:@"tharg"])&&(d2 < found_d2))
|
||||
{
|
||||
found_target = [thing universal_id];
|
||||
if ([thing isKindOfClass:[PlayerEntity class]]) d2 = 0.0; // prefer the player
|
||||
if (thing->isPlayer) d2 = 0.0; // prefer the player
|
||||
found_d2 = d2;
|
||||
}
|
||||
}
|
||||
@ -1090,13 +1093,13 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count] ; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if ([thing isKindOfClass:[ShipEntity class]])
|
||||
if (thing->isShip)
|
||||
{
|
||||
double d2;
|
||||
Vector delta = [thing getPosition];
|
||||
Vector delta = thing->position;
|
||||
delta.x -= position.x; delta.y -= position.y; delta.z -= position.z;
|
||||
d2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
|
||||
if ((([thing scanClass] == CLASS_THARGOID)||(([(ShipEntity *)thing getPrimaryTarget] == self)&&([(ShipEntity *)thing hasHostileTarget])))&&(d2 < found_d2))
|
||||
if (((thing->scan_class == CLASS_THARGOID)||(([(ShipEntity *)thing getPrimaryTarget] == self)&&([(ShipEntity *)thing hasHostileTarget])))&&(d2 < found_d2))
|
||||
{
|
||||
found_target = [thing universal_id];
|
||||
found_d2 = d2;
|
||||
@ -1275,7 +1278,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count] ; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if (([thing isKindOfClass:[ShipEntity class]])&&(thing != (Entity *)self))
|
||||
if ((thing->isShip)&&(thing != (Entity *)self))
|
||||
{
|
||||
ShipEntity* ship = (ShipEntity *)thing;
|
||||
pair_okay = ([roles isEqual:@"escort"]&&[[ship roles] isEqual:@"trader"]);
|
||||
@ -1284,7 +1287,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
if (pair_okay)
|
||||
{
|
||||
double d2;
|
||||
Vector delta = [ship getPosition];
|
||||
Vector delta = ship->position;
|
||||
delta.x -= position.x; delta.y -= position.y; delta.z -= position.z;
|
||||
d2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
|
||||
if (d2 < found_d2)
|
||||
@ -1329,11 +1332,15 @@ Your fair use and other rights are in no way affected by the above.
|
||||
{
|
||||
// NSLog(@"DEBUG patrol ship %@ %d has reached patrol check point... %d", name, universal_id, patrol_counter);
|
||||
//
|
||||
Vector sun_pos = [[universe sun] getPosition];
|
||||
Vector stn_pos = [[universe station] getPosition];
|
||||
Entity* the_sun = [universe sun];
|
||||
Entity* the_station = [universe station];
|
||||
if ((!the_sun)||(!the_station))
|
||||
return;
|
||||
Vector sun_pos = the_sun->position;
|
||||
Vector stn_pos = the_station->position;
|
||||
Vector sun_dir = make_vector( sun_pos.x - stn_pos.x, sun_pos.y - stn_pos.y, sun_pos.z - stn_pos.z);
|
||||
Vector vSun = unit_vector( &sun_dir);
|
||||
Vector v0 = vector_forward_from_quaternion([[universe station] QRotation]);
|
||||
Vector v0 = vector_forward_from_quaternion(the_station->q_rotation);
|
||||
Vector v1 = cross_product( v0, vSun);
|
||||
Vector v2 = cross_product( v0, v1);
|
||||
switch (patrol_counter)
|
||||
@ -1402,8 +1409,11 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
- (void) setSunSkimExitCoordinates
|
||||
{
|
||||
Entity* the_sun = [universe sun];
|
||||
if (!the_sun)
|
||||
return;
|
||||
Vector v1 = [universe getSunSkimEndPositionForShip:self];
|
||||
Vector vs = [[universe sun] getPosition];
|
||||
Vector vs = the_sun->position;
|
||||
Vector vout = make_vector( v1.x - vs.x, v1.y - vs.y, v1.z - vs.z);
|
||||
vout = unit_vector(&vout);
|
||||
v1.x += 10000 * vout.x; v1.y += 10000 * vout.y; v1.z += 10000 * vout.z;
|
||||
@ -1418,13 +1428,14 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
- (void) checkForMotherStation
|
||||
{
|
||||
if (![[self owner] isKindOfClass:[StationEntity class]])
|
||||
Entity* my_owner = [self owner];
|
||||
if ((!my_owner) || (!(my_owner->isStation)))
|
||||
{
|
||||
[shipAI message:@"NOTHING_FOUND"];
|
||||
return;
|
||||
}
|
||||
StationEntity* motherStation = (StationEntity*)[self owner];
|
||||
Vector v0 = [motherStation getPosition];
|
||||
Vector v0 = motherStation->position;
|
||||
Vector rpos = make_vector( position.x - v0.x, position.y - v0.y, position.z - v0.z);
|
||||
double found_d2 = scanner_range * scanner_range;
|
||||
if (magnitude2(rpos) > found_d2)
|
||||
@ -1438,7 +1449,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
- (void) sendTargetCommsMessage:(NSString*) message
|
||||
{
|
||||
ShipEntity* ship = (ShipEntity*)[self getPrimaryTarget];
|
||||
if ((!ship)||([ship getStatus] == STATUS_DEAD)||([ship getStatus] == STATUS_DOCKED))
|
||||
if ((!ship)||(ship->status == STATUS_DEAD)||(ship->status == STATUS_DOCKED))
|
||||
{
|
||||
primaryTarget = NO_TARGET;
|
||||
[shipAI reactToMessage:@"TARGET_LOST"];
|
||||
@ -1450,7 +1461,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
- (void) markTargetForFines
|
||||
{
|
||||
ShipEntity* ship = (ShipEntity*)[self getPrimaryTarget];
|
||||
if ((!ship)||([ship getStatus] == STATUS_DEAD)||([ship getStatus] == STATUS_DOCKED))
|
||||
if ((!ship)||(ship->status == STATUS_DEAD)||(ship->status == STATUS_DOCKED))
|
||||
{
|
||||
primaryTarget = NO_TARGET;
|
||||
[shipAI reactToMessage:@"TARGET_LOST"];
|
||||
@ -1470,13 +1481,13 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count] ; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if ([thing isKindOfClass:[ShipEntity class]])
|
||||
if (thing->isShip)
|
||||
{
|
||||
NSString* ship_role = [(ShipEntity *)thing roles];
|
||||
if ([ship_role isEqual:@"boulder"])
|
||||
{
|
||||
double d2;
|
||||
Vector delta = [thing getPosition];
|
||||
Vector delta = thing->position;
|
||||
delta.x -= position.x; delta.y -= position.y; delta.z -= position.z;
|
||||
d2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
|
||||
if (d2 < found_d2)
|
||||
@ -1492,13 +1503,13 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count] ; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if ([thing isKindOfClass:[ShipEntity class]])
|
||||
if (thing->isShip)
|
||||
{
|
||||
NSString* ship_role = [(ShipEntity *)thing roles];
|
||||
if ([ship_role isEqual:@"asteroid"])
|
||||
{
|
||||
double d2;
|
||||
Vector delta = [thing getPosition];
|
||||
Vector delta = thing->position;
|
||||
delta.x -= position.x; delta.y -= position.y; delta.z -= position.z;
|
||||
d2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
|
||||
if (d2 < found_d2)
|
||||
@ -1524,9 +1535,10 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
- (void) setDestinationToDockingAbort
|
||||
{
|
||||
Entity* the_target = [self getPrimaryTarget];
|
||||
double bo_distance = 8000; // 8km back off
|
||||
Vector v0 = position;
|
||||
Vector d0 = [[self getPrimaryTarget] getPosition];
|
||||
Vector d0 = (the_target)? the_target->position : make_vector(0,0,0);
|
||||
v0.x += (randf() - 0.5)*collision_radius; v0.y += (randf() - 0.5)*collision_radius; v0.z += (randf() - 0.5)*collision_radius;
|
||||
v0.x -= d0.x; v0.y -= d0.y; v0.z -= d0.z;
|
||||
v0 = unit_vector(&v0);
|
||||
@ -1560,14 +1572,14 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < [entList count] ; i++)
|
||||
{
|
||||
Entity* thing = (Entity *)[entList objectAtIndex:i];
|
||||
if ([thing isKindOfClass:[ShipEntity class]])
|
||||
if (thing->isShip)
|
||||
{
|
||||
double d2;
|
||||
double e1 = [thing getEnergy];
|
||||
Vector delta = [thing getPosition];
|
||||
Vector delta = thing->position;
|
||||
delta.x -= position.x; delta.y -= position.y; delta.z -= position.z;
|
||||
d2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
|
||||
if ((([thing scanClass] == CLASS_THARGOID)||(([(ShipEntity *)thing getPrimaryTarget] == mother)&&([(ShipEntity *)thing hasHostileTarget])))&&(d2 < found_d2))
|
||||
if (((thing->scan_class == CLASS_THARGOID)||(([(ShipEntity *)thing getPrimaryTarget] == mother)&&([(ShipEntity *)thing hasHostileTarget])))&&(d2 < found_d2))
|
||||
{
|
||||
if (e1 > max_e)
|
||||
{
|
||||
@ -1587,4 +1599,3 @@ Your fair use and other rights are in no way affected by the above.
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
452
ShipEntity.m
452
ShipEntity.m
File diff suppressed because it is too large
Load Diff
@ -459,9 +459,9 @@ Your fair use and other rights are in no way affected by the above.
|
||||
{
|
||||
if (usingVAR)
|
||||
[self OGL_UpdateVAR];
|
||||
|
||||
Entity* player = [universe entityZero];
|
||||
zero_distance = MAX_CLEAR_DEPTH * MAX_CLEAR_DEPTH;
|
||||
position = [[universe entityZero] getPosition];
|
||||
position = (player)? player->position : position;
|
||||
}
|
||||
|
||||
- (BOOL) canCollide
|
||||
@ -611,4 +611,3 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
@ -310,11 +310,14 @@ Your fair use and other rights are in no way affected by the above.
|
||||
int ship_id = [ship universal_id];
|
||||
NSString* shipID = [NSString stringWithFormat:@"%d", ship_id];
|
||||
|
||||
if (([ship isKindOfClass:[PlayerEntity class]])&&([ship legal_status] > 50))
|
||||
if (!ship)
|
||||
return position;
|
||||
|
||||
if ((ship->isPlayer)&&([ship legal_status] > 50))
|
||||
{
|
||||
[[ship getAI] message:@"DOCKING_REFUSED"];
|
||||
[self sendExpandedMessage:@"[station-docking-refused-to-fugitive]" toShip:ship];
|
||||
return [ship getPosition]; // hold position
|
||||
return ship->position; // hold position
|
||||
}
|
||||
|
||||
|
||||
@ -328,7 +331,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
{
|
||||
// NSLog(@"DEBUG %@ %d refusing because of no docking while launching", name, universal_id);
|
||||
[[ship getAI] message:@"TRY_AGAIN_LATER"];
|
||||
return [ship getPosition]; // hold position
|
||||
return ship->position; // hold position
|
||||
}
|
||||
|
||||
if ((magnitude2(velocity) > 1.0)||
|
||||
@ -337,7 +340,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
// NSLog(@"DEBUG %@ %d refusing docking to %@ because of motion", name, universal_id, [ship name]);
|
||||
[shipAI message:@"DOCKING_REQUESTED"]; // note the request.
|
||||
[[ship getAI] message:@"HOLD_POSITION"];// send HOLD
|
||||
return [ship getPosition]; // hold position
|
||||
return ship->position; // hold position
|
||||
}
|
||||
|
||||
if (![shipsOnApproach objectForKey:shipID])
|
||||
@ -385,7 +388,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
c1.x -= offset2*v_off.x;
|
||||
c1.y -= offset2*v_off.y;
|
||||
c1.z -= offset2*v_off.z;
|
||||
if (distance2(c0,[ship getPosition]) < distance2(c1,[ship getPosition]))
|
||||
if (distance2(c0,ship->position) < distance2(c1,ship->position))
|
||||
{
|
||||
coords = c0;
|
||||
}
|
||||
@ -431,7 +434,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
if ([coordinatesStack count] == 0)
|
||||
{
|
||||
[[ship getAI] message:@"HOLD_POSITION"]; // not docked - try again
|
||||
return [ship getPosition];
|
||||
return ship->position;
|
||||
}
|
||||
|
||||
NSMutableDictionary* nextCoords = (NSMutableDictionary *)[coordinatesStack objectAtIndex:0];
|
||||
@ -449,7 +452,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
Vector vk = v_forward;
|
||||
if (scan_class == CLASS_STATION)
|
||||
{
|
||||
Vector v0 = [[universe sun] getPosition];
|
||||
Entity* the_sun = [universe sun];
|
||||
Vector v0 = (the_sun)? the_sun->position : make_vector(1,0,0);
|
||||
vi = cross_product(vk,v0);
|
||||
vj = cross_product(vk,vi);
|
||||
}
|
||||
@ -458,9 +462,9 @@ Your fair use and other rights are in no way affected by the above.
|
||||
coords.y += rel_coords.x * vi.y + rel_coords.y * vj.y + rel_coords.z * vk.y;
|
||||
coords.z += rel_coords.x * vi.z + rel_coords.y * vj.z + rel_coords.z * vk.z;
|
||||
|
||||
double allowed_range = 100.0 + [ship collisionRadius];
|
||||
double allowed_range = 100.0 + ship->collision_radius;
|
||||
|
||||
Vector ship_position = [ship getPosition];
|
||||
Vector ship_position = ship->position;
|
||||
Vector delta = coords;
|
||||
delta.x -= ship_position.x; delta.y -= ship_position.y; delta.z -= ship_position.z;
|
||||
|
||||
@ -532,7 +536,8 @@ Your fair use and other rights are in no way affected by the above.
|
||||
Vector vk = v_forward;
|
||||
if (scan_class == CLASS_STATION)
|
||||
{
|
||||
Vector v0 = [[universe sun] getPosition];
|
||||
Entity* the_sun = [universe sun];
|
||||
Vector v0 = (the_sun)? the_sun->position : make_vector(1,0,0);
|
||||
vi = cross_product(vk,v0);
|
||||
vj = cross_product(vk,vi);
|
||||
}
|
||||
@ -648,7 +653,9 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
Vector result = vector_right_from_quaternion( quaternion_multiply( port_qrotation, q_rotation));
|
||||
|
||||
// NSLog(@"portUpVector = [%.3f, %.3f, %.3f] v_up = [%.3f, %.3f, %.3f]",
|
||||
result.x = - result.x; result.y = - result.y; result.z = - result.z;
|
||||
|
||||
// NSLog(@"DEBUG %@ portUpVector = [%.3f, %.3f, %.3f] v_up = [%.3f, %.3f, %.3f]", self,
|
||||
// result.x, result.y, result.z, v_up.x, v_up.y, v_up.z);
|
||||
|
||||
return result;
|
||||
@ -699,6 +706,9 @@ Your fair use and other rights are in no way affected by the above.
|
||||
last_patrol_report_time = 0.0;
|
||||
patrol_launch_interval = 300.0; // 5 minutes
|
||||
last_patrol_report_time -= patrol_launch_interval;
|
||||
//
|
||||
isShip = YES;
|
||||
isStation = YES;
|
||||
|
||||
return self;
|
||||
}
|
||||
@ -733,6 +743,9 @@ Your fair use and other rights are in no way affected by the above.
|
||||
police_launched = 0;
|
||||
last_launch_time = 0.0;
|
||||
no_docking_while_launching = NO;
|
||||
//
|
||||
isShip = YES;
|
||||
isStation = YES;
|
||||
}
|
||||
|
||||
- (id) initWithDictionary:(NSDictionary *) dict
|
||||
@ -777,6 +790,9 @@ Your fair use and other rights are in no way affected by the above.
|
||||
for (i = 0; i < MAX_DOCKING_STAGES; i++)
|
||||
id_lock[i] = NO_TARGET;
|
||||
|
||||
isShip = YES;
|
||||
isStation = YES;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -899,28 +915,22 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
- (BOOL) checkCloseCollisionWith:(Entity *)other
|
||||
{
|
||||
// BOOL standard_port = ![roles isEqual:@"rockhermit"];
|
||||
if (!other)
|
||||
return NO;
|
||||
//
|
||||
// check if other is within docking corridor
|
||||
//
|
||||
//NSLog(@"Checking Station CloseContact...");
|
||||
//
|
||||
if ([universe strict]&&(self != [universe station])&&[other isKindOfClass:[PlayerEntity class]])
|
||||
if ([universe strict]&&(self != [universe station])&&(other->isPlayer))
|
||||
{
|
||||
// in a strict universe the player can only dock with the main station
|
||||
return [super checkCloseCollisionWith:other];
|
||||
}
|
||||
//
|
||||
if ([other isKindOfClass:[ShipEntity class]])
|
||||
if (other->isShip)
|
||||
{
|
||||
Vector rel_pos, delta, prt_pos;
|
||||
// // port dimensions..
|
||||
// double ww = (standard_port)? 32: 69;
|
||||
// double hh = (standard_port)? 96: 69;
|
||||
// double dd = (standard_port)? 250: 250;
|
||||
// // reduced dimensions for fudging..
|
||||
// double w1 = (standard_port)? 24: 51;
|
||||
// double h1 = (standard_port)? 72: 51;
|
||||
// port dimensions..
|
||||
double ww = port_dimensions.x;
|
||||
double hh = port_dimensions.y;
|
||||
@ -929,7 +939,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
double w1 = ww * 0.75;
|
||||
double h1 = hh * 0.75;
|
||||
ShipEntity* ship = (ShipEntity *) other;
|
||||
double radius = [ship collisionRadius];
|
||||
double radius = ship->collision_radius;
|
||||
|
||||
// check if the ship is too big for the port and fudge things accordingly
|
||||
BoundingBox shipbb = [ship getBoundingBox];
|
||||
@ -940,7 +950,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
|
||||
//NSLog(@"DEBUG Checking docking corridor...");
|
||||
prt_pos = [self getPortPosition];
|
||||
rel_pos = [ship getPosition];
|
||||
rel_pos = ship->position;
|
||||
rel_pos.x -= prt_pos.x;
|
||||
rel_pos.y -= prt_pos.y;
|
||||
rel_pos.z -= prt_pos.z;
|
||||
@ -1003,7 +1013,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
delta.x = 0;
|
||||
if ((arbb.max_y > 96)&&(arbb.min_x > - 96))
|
||||
delta.y = 0;
|
||||
Vector pos = [ship getPosition];
|
||||
Vector pos = ship->position;
|
||||
pos.x -= delta.y * v_up.x + delta.x * v_right.x;
|
||||
pos.y -= delta.y * v_up.y + delta.x * v_right.y;
|
||||
pos.z -= delta.y * v_up.z + delta.x * v_right.z;
|
||||
@ -1580,7 +1590,7 @@ Your fair use and other rights are in no way affected by the above.
|
||||
{
|
||||
// launch docked ships if possible
|
||||
PlayerEntity* player = (PlayerEntity*)[universe entityZero];
|
||||
if (([player getStatus] == STATUS_DOCKED)&&([player docked_station] == self))
|
||||
if ((player)&&(player->status == STATUS_DOCKED)&&([player docked_station] == self))
|
||||
{
|
||||
// undock the player!
|
||||
[player leaveDock:self];
|
||||
@ -1640,4 +1650,3 @@ Your fair use and other rights are in no way affected by the above.
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
461
Universe.m
461
Universe.m
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user