Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

Headlights

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

AlexD
Average
Average
Posts: 9
Joined: Wed Mar 22, 2006 10:39 am
Location: Russia; Tyumen

Post by AlexD »

oO wrote:
it would have a 10% chance of detonating radioactive containers, doing a splash damage (player included) like a mine or something destroying adjacent containers in the proccess.
Yea! It's great idea! :)
oO wrote:
The shop could look like:
1.000 - Spotlight - "A simple 100.000 watts bulb"
5.000 - X-Ray Container Scanner - "Useful for choosing what to scoop"
30.000 - Advanced Naval Targetting System - "The ultimate targetting computer"
Would be nice. :)
User avatar
jonnycuba
Deadly
Deadly
Posts: 233
Joined: Fri May 21, 2004 1:04 pm
Location: Witchspace

Post by jonnycuba »

I think mining craft should have fore mounted lights, also rock hermits should have lights that come on when a ship approaches the docking bay (but not pirate coves).
Team Zorg are Go!
oO
Competent
Competent
Posts: 32
Joined: Sat Oct 15, 2005 8:51 pm

Post by oO »

Version 2 of the advanced targetting patch, this time it only displays distance (no ship name nor legal status) of entities in radar range, maybe with all the info it was too easy?

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
+				// if advanced_scanner_item is present...
+				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);
 	
@@ -1997,10 +2014,15 @@
 	float line_height = rdist * ONE_SIXTYFOURTH;
 	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);
+	} else {
+		drawString( info3, rs0, rs0, 0, textsize);
+	}
 	glPopMatrix();
 }
User avatar
Arexack_Heretic
Dangerous Subversive Element
Dangerous Subversive Element
Posts: 1876
Joined: Tue Jun 07, 2005 7:32 pm
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Contact:

Post by Arexack_Heretic »

oO wrote:
it would have a 10% chance of detonating radioactive containers, doing a splash damage (player included) like a mine or something destroying adjacent containers in the proccess.
You'd need a neutron-emitting scanner, I think, to trigger a cascade in radioactives...and then only enrighed ores would detonate.

(Radioactives in elite ARE usefull ores rather than radioactive waste, nukes or irradiated trash as in most space trading games)
Riding the Rocket!
oO
Competent
Competent
Posts: 32
Joined: Sat Oct 15, 2005 8:51 pm

Post by oO »

Arexack_Heretic wrote:
You'd need a neutron-emitting scanner, I think, to trigger a cascade in radioactives...and then only enrighed ores would detonate.

(Radioactives in elite ARE usefull ores rather than radioactive waste, nukes or irradiated trash as in most space trading games)
Hmm that made me think that instead of a fixed % it could be triggered depending of your distance to the container (plus a 25% chance that the radioactives are indeed enriched).

So i modified the HUD code to show a different reticle color that goes from (green or yellow) -> red with the distance to the radioactive container. Plus it shows the content of all containers (which is the initial purpose of the pirate scanner).

Then if the player gets into a certain distance (1km) there should be a 25% chance to start a chain reaction inside the container, the scanner should detect that and send a message to the player "Supercriticallity about to be reached in a container!", giving the player 5-10 seconds to run out of there.
User avatar
Arexack_Heretic
Dangerous Subversive Element
Dangerous Subversive Element
Posts: 1876
Joined: Tue Jun 07, 2005 7:32 pm
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Contact:

Post by Arexack_Heretic »

Be sure not to make the explosions too deadly.

for example: a missile has been designed to explode with maximum yield, shipping containers containing potentially explosive materials tend to be designed instead with an eye to containing any eventual detonation.

An explosion bigger and more powerfull than a missile would therefore be unlikely.



On a more practical note:
Could you share the code you are using for delaying the detonation of the target container?
I have been working with several AIs to detonate fuelpods and timebombs, but I havent been able to get them to work properly...:(
(and currently my time is taken up with study rather than fixing my OXPs)


Do you use 'performScriptOnTarget' to set off the target?
Do you introduce customised cannisters with weaponenergy?

(2)
Searchlights....does lightstrength decrease over distance as it should?
Riding the Rocket!
oO
Competent
Competent
Posts: 32
Joined: Sat Oct 15, 2005 8:51 pm

Post by oO »

Arexack_Heretic wrote:
On a more practical note:
Could you share the code you are using for delaying the detonation of the target container?

Do you use 'performScriptOnTarget' to set off the target?
Do you introduce customised cannisters with weaponenergy?
I don't have enough knowledge of the code to do the explosion part yet... i've only written some HUD stuff.
Arexack_Heretic wrote:
(2)
Searchlights....does lightstrength decrease over distance as it should?
I mentioned in a previous msg in this thread that i tried to code spotlights, but failed. Is that what you meant with searchlights?

EDIT: I think i'll just [ShipEntity dealEnergyDamageWithinDesiredRange] when player enters critical range for a % of rad. containers (since you said delayed explosions are difficult :P) with the power of a missile like you said.
User avatar
Arexack_Heretic
Dangerous Subversive Element
Dangerous Subversive Element
Posts: 1876
Joined: Tue Jun 07, 2005 7:32 pm
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Contact:

Post by Arexack_Heretic »

Ah, I see.

You would need to have a script (determining if EQ is present and performing the aquiring of a target, identifying cargo, message information and performScriptOnTarget)

and a EQ_ entry describing the equipment.

The only problem I see with this set-up, is setting the weapon_energy of the cannisters to above 0 (which is the standard value).

(The weapon_energy together with setDesiredRange and dealEnergyDamageWithinDesiredRange determine the damage done and the maximum diameter of the blast.)


If no solution is forthcoming, I'd suggest leaving this elaboration for a later version as it is not critical to functionality.


Another suggestion: extra data on scanned vessels:
not much extra data as shields and armour interfere,
tonnes of cargo could be a nice thing to know
or the type of laser equiped (front laser only if multiple types)

however: using a high-powered x-ray scanner on a ship with crew should be considdered an attack (on progeny ;) ), so don't use it unless prepared to fight.
Also other advanced scanners are being developed, that are less likely to be noticed by the scanee.
Riding the Rocket!
oO
Competent
Competent
Posts: 32
Joined: Sat Oct 15, 2005 8:51 pm

Post by oO »

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

User avatar
winston
Pirate
Pirate
Posts: 731
Joined: Mon Sep 27, 2004 10:21 pm
Location: Port St. Mary, Isle of Man
Contact:

Post by winston »

oO wrote:
(rev. 366, "cat stuff.patch | patch -p0"
On a point of pedantry, you can demoggify this command and just issue:

patch -p0 <stuff.patch
oO
Competent
Competent
Posts: 32
Joined: Sat Oct 15, 2005 8:51 pm

Post by oO »

Yea, to apply: patch -p0 < stuff.patch
to remove: patch -R -p0 < stuff.patch (or just do "svn status" and "svn revert" all files marked as M)

Yesterday i had a look to the wormhole code, and have come with... the Wormhole Analyzer! :P

This patch displays the name of the system a wormhole is pointing to, plus the distance in light years to said system. It's a cummulative patch over the previous, so the previous has to be applied first (remove in inverse order):

Code: Select all

--- src/Core/HeadUpDisplay.m.ORIG	2006-03-26 16:38:22.000000000 +0200
+++ src/Core/HeadUpDisplay.m	2006-03-26 19:11:54.000000000 +0200
@@ -463,6 +463,7 @@
 				
 				if (drawthing->isWormhole)
 				{
+					hudDrawReticleOnTarget(drawthing, player, z1);
 					col[0] = blue_color[0];	col[1] = (flash)? 1.0 : blue_color[1];	col[2] = blue_color[2];	col[3] = alpha * blue_color[3];
 				}
 				
@@ -2016,8 +2017,10 @@
 	// 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) )
+	if ([target scanClass] != CLASS_WORMHOLE && [target scanClass] != CLASS_MINE)
 	{
+	  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"] ) 
@@ -2042,25 +2045,43 @@
 			}
 			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*	info1;
+	NSString*	info2;
 	NSString*	info3 = [NSString stringWithFormat:@"%0.3f km", range];
-	// no need to set color - tis green already!
-	if (target == [player1 getPrimaryTarget])
+	if ([target scanClass] != CLASS_WORMHOLE && [target scanClass] != CLASS_MINE)
 	{
+	  info1 = [target_ship identFromShip: player1];
+	  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!
+	  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 {
+	  } else {
 		drawString( info3, rs0, rs0, 0, textsize);
 		if (info4 != @"")
 		{
 			drawString( info4, rs0, rs0 - line_height, 0, textsize);
 		}
+	  }
+	} else {
+		WormholeEntity* target_worm = (WormholeEntity *)target;
+		//name
+		Random_Seed destination = [target_worm destination];
+		NSString* sys_name = [NSString stringWithFormat:@"to %@", [[player1 universe] getSystemName: destination]];
+		//dist
+		Random_Seed here = [[player1 universe] systemSeed];
+		double dist = distanceBetweenPlanetPositions(here.d, here.b, destination.d, destination.b);
+		NSString* text_dist = [NSString stringWithFormat:@"%0.1f ly", dist];
+		
+		drawString( sys_name, rs0, rs0, 0, textsize);
+		drawString ( text_dist, rs0, rs0 - line_height, 0, textsize);
 	}
 	glPopMatrix();
 }

And... a wormhole scanClass is CLASS_MINE? then what's CLASS_WORMHOLE for?
User avatar
aegidian
Master and Commander
Master and Commander
Posts: 1160
Joined: Thu May 20, 2004 10:46 pm
Location: London UK
Contact:

While I'm all in favour of patches...

Post by aegidian »

@oO: Do you think we could please have them posted under new topic titles rather than appending them to this one topic.

Then I could work through the issues with each small change at a time.

Or email each one to me. I can't guarantee I'll look at them straight away because I'm busy with a long to-do list, but then your patch won't be forgotten among the piles of other posts here.

But I won't okay or nay-say a patch that appears on this forum, AFAIC it's the wrong place.
"The planet Rear is scourged by well-intentioned OXZs."

Oolite models and gear? click here!
oO
Competent
Competent
Posts: 32
Joined: Sat Oct 15, 2005 8:51 pm

Re: While I'm all in favour of patches...

Post by oO »

aegidian wrote:
@oO: Do you think we could please have them posted under new topic titles rather than appending them to this one topic.

Then I could work through the issues with each small change at a time.
Yea sure, i'll post them to new topics.
EDIT: better if i do in the Expansion Pack forum, i guess.
aegidian wrote:
Or email each one to me. I can't guarantee I'll look at them straight away because I'm busy with a long to-do list, but then your patch won't be forgotten among the piles of other posts here.
Nah, if you're busy i'll better post them to the forum. They're not very... complete yet.
aegidian wrote:
But I won't okay or nay-say a patch that appears on this forum, AFAIC it's the wrong place.
Indeed, that wasn't my purpose, i just had some fun coding small modifications and though other people would like to try them, make suggestions and comment :) .
Post Reply