So far what i have done is:
- indicators for all entities inside scanner range with distance to them displayed - no extra data, this just makes targetting easier, and something like this could go into an EQ_
- in addition all cargo containers show their contents when they're targetted OR in combination with the previous EQ_ which makes picking of cargo easier. Both of these are written into addReticleToTarget.
- And if you get near (1km.) radioactive cargo it has 25% of exploding with a energy of 200 (takes most of a full improved shield) which seems similar to a missile, to a range of 2.56km, which would also take some other containers in that range. I copied the code of the energy bomb and put it in a pair of functions + a pair of booleans in ShipEntity.
I didn't knew about weapon_energy so i put it into a new function instead of the way you suggest... hmm
What i'm missing is all the EQ_ implementation that should go into the equimpent.plist and another places.
And i'm not sure about the 25%, does the get_rnd_number function returns a random number between 0-255? it seems like less than 25% of them explode. (i tried this buying some radioactives and jettisoning them, and found a bug in the jettisoning proccess in the way).
You can test it if you want, apply this patch to current SVN (rev. 366, "cat stuff.patch | patch -p0" in the trunk root, it applies clean even if it says 364 in the patch) and recompile.
Code: Select all
Index: src/Core/HeadUpDisplay.m
===================================================================
--- src/Core/HeadUpDisplay.m (revision 364)
+++ src/Core/HeadUpDisplay.m (working copy)
@@ -56,6 +56,7 @@
GLfloat red_color[4] = {1.0, 0.0, 0.0, 1.0};
GLfloat redplus_color[4] = {1.0, 0.0, 0.5, 1.0};
GLfloat yellow_color[4] = {1.0, 1.0, 0.0, 1.0};
+GLfloat darkyellow_color[4] = {0.75, 0.75, 0.0, 1.0};
GLfloat green_color[4] = {0.0, 1.0, 0.0, 1.0};
GLfloat darkgreen_color[4] ={0.0, 0.75, 0.0, 1.0};
GLfloat blue_color[4] = {0.0, 0.0, 1.0, 1.0};
@@ -486,6 +487,12 @@
foundHostiles = YES;
break;
}
+ // adds reticles to all stuff inside max_scanner_range2
+ // to do: "if player_has_advanced_scanner_item"
+ if ((drawthing->isShip) && (drawthing->zero_distance <= max_scanner_range2))
+ {
+ hudDrawReticleOnTarget(drawthing, player, z1);
+ }
// exit if it's off-scanner
if (drawthing->zero_distance > max_zoomed_range2)
continue;
@@ -1973,8 +1980,12 @@
//rotate to face player1
glMultMatrixf(back_mat);
// draw the reticle
- glColor4fv(green_color);
- glBegin(GL_LINES);
+
+ if (target == [player1 getPrimaryTarget])
+ {
+ glColor4fv(green_color);
+
+ glBegin(GL_LINES);
glVertex2f(rs0,rs2); glVertex2f(rs0,rs0);
glVertex2f(rs0,rs0); glVertex2f(rs2,rs0);
@@ -1986,6 +1997,12 @@
glVertex2f(-rs0,-rs2); glVertex2f(-rs0,-rs0);
glVertex2f(-rs0,-rs0); glVertex2f(-rs2,-rs0);
+ } else {
+ glColor4fv(darkyellow_color);//use (different || darker) colour if ! target
+
+ glBegin(GL_LINES);
+ glVertex2f(0,0); glVertex2f(rs0,rs0);
+ }
// NSLog(@"DEBUG rs0 %.3f %.3f",rs0, rs2);
@@ -1995,12 +2012,56 @@
float range = sqrt(target->zero_distance)/1000;
NSSize textsize = NSMakeSize( rdist * ONE_SIXTYFOURTH, rdist * ONE_SIXTYFOURTH);
float line_height = rdist * ONE_SIXTYFOURTH;
+ //
+ // cargo containers analyzer
+ NSString* info4 = @""; // here will go commodity name
+ BOOL pl_has_container_analyzer = YES; // to do: proper check
+ if ( pl_has_container_analyzer && ([target_ship getCargoType] == CARGO_RANDOM) )
+ {
+ int co_type = [target_ship getCommodityType];
+ info4 = [[player1 universe] nameForCommodity: co_type];
+ if ( [info4 hasPrefix: @"Radioactives"] )
+ {
+ GLfloat rad_color[4] = {0.75, 0.75, 0.0, 1.0};
+ // HUD color change from yellow/green to red in danger range
+ float range_safe = 5.000;
+ float range_trigger = 1.000;
+ if ( range <= range_trigger ){
+ if ([target_ship isRadiationCritical]){
+ [target_ship detonateRadContainer];
+ }
+ rad_color[0] = 1.0;
+ rad_color[1] = 0.0;
+ }
+ if ( range < range_safe && range > range_trigger ){
+ //danger zone
+ float r_comp = 0.75 + (0.25 * (range_trigger/range));
+ float g_comp = 0.75 * ((range)/range_safe);
+ rad_color[0] = r_comp;
+ rad_color[1] = g_comp;
+ }
+ glColor4fv(rad_color);
+ }
+ }
NSString* info1 = [target_ship identFromShip: player1];
NSString* info2 = (legal_desc == nil)? [NSString stringWithFormat:@"%0.3f km", range] : [NSString stringWithFormat:@"%0.3f km (%@)", range, legal_desc];
+ NSString* info3 = [NSString stringWithFormat:@"%0.3f km", range];
// no need to set color - tis green already!
- drawString( info1, rs0, 0.5 * rs2, 0, textsize);
- drawString( info2, rs0, 0.5 * rs2 - line_height, 0, textsize);
-
+ if (target == [player1 getPrimaryTarget])
+ {
+ drawString( info1, rs0, 0.5 * rs2, 0, textsize);
+ drawString( info2, rs0, 0.5 * rs2 - line_height, 0, textsize);
+ if (info4 != @"")
+ {
+ drawString( info4, rs0, 0.5 * rs2 - 2*line_height, 0, textsize);
+ }
+ } else {
+ drawString( info3, rs0, rs0, 0, textsize);
+ if (info4 != @"")
+ {
+ drawString( info4, rs0, rs0 - line_height, 0, textsize);
+ }
+ }
glPopMatrix();
}
Index: src/Core/ShipEntity.h
===================================================================
--- src/Core/ShipEntity.h (revision 364)
+++ src/Core/ShipEntity.h (working copy)
@@ -347,6 +347,10 @@
// DEBUGGING
int debug_condition;
+
+ // for exploding containers - pirate scanner
+ BOOL has_decided_criticallity;
+ BOOL is_critical;
}
// octree collision hunting
@@ -656,6 +660,10 @@
- (void) setTrackCloseContacts:(BOOL) value;
+// for exploding containers, pirate scanner
+- (BOOL) isRadiationCritical;
+- (void) detonateRadContainer;
+
/****************************************************************
straight c stuff
Index: src/Core/ShipEntity.m
===================================================================
--- src/Core/ShipEntity.m (revision 364)
+++ src/Core/ShipEntity.m (working copy)
@@ -198,6 +198,9 @@
//
heat_insulation = 1.0;
//
+ //container destruction - pirate scanner
+ has_decided_criticallity = NO;
+ is_critical = NO;
return self;
}
@@ -7200,4 +7203,39 @@
}
}
+- (BOOL) isRadiationCritical
+{
+ if (!has_decided_criticallity)
+ {
+ if( gen_rnd_number() < 64 ) // 25%
+ {
+ is_critical = YES;
+ }
+ has_decided_criticallity = YES;
+ }
+ return is_critical;
+}
+- (void) detonateRadContainer
+{
+ //copied from energy bomb
+ int det_damage = 200;
+ // scan max ran: 25600.0 / 10 = 2.56 km.
+ NSArray* targets = [universe getEntitiesWithinRange:SCANNER_MAX_RANGE/10 ofEntity:self];
+ if ([targets count] > 0)
+ {
+ int i;
+ for (i = 0; i < [targets count]; i++)
+ {
+ Entity *e2 = [targets objectAtIndex:i];
+ if (e2->isShip)
+ [(ShipEntity *)e2 takeEnergyDamage:det_damage from:self becauseOf:self];
+ }
+ }
+ //msg
+ PlayerEntity* player = (PlayerEntity *)[universe entityZero];
+ Random_Seed system_seed = player->system_seed;
+ [universe addMessage:[universe expandDescription:@"A container reached supercriticallity and exploded!" forSystem:system_seed] forCount:4.5];
+
+ [self becomeExplosion];
+}
@end