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

Targeting Computer

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

Post Reply
krombart
Competent
Competent
Posts: 52
Joined: Tue May 20, 2008 9:25 am

Targeting Computer

Post by krombart »

I suggest the following function in PlayerEntity.m

=============================================================================

Code: Select all

- (void) fillTargetMemory
{
  if([self hasEquipmentItem:@"EQ_TARGET_MEMORY"])
    {
      unsigned i = 0;
      unsigned j = 0;
      ShipEntity *ship = nil;
      [self checkScanner];
      
      for (i = 0; i < n_scanned_ships; i++) 
      {
	BOOL loadIt = YES;
	ship = scanned_ships[i];
	if([ship isCloaked]) loadIt = NO;
	if([ship isJammingScanning] && ![self hasMilitaryScannerFilter]) loadIt = NO;
	if( ship->scanClass == CLASS_PLAYER ) loadIt = NO;
	if( loadIt ) 
	{

		BOOL foundSlot = NO;

		for (j = 0; j < PLAYER_TARGET_MEMORY_SIZE; j++)
		{
			if (ship->universalID == target_memory[j])
			{
				target_memory_index = j;
				foundSlot = YES;
				break;
			}
		}

		for (j = 0; (j < PLAYER_TARGET_MEMORY_SIZE) && !foundSlot; j++)
		{
			if (target_memory[target_memory_index] == NO_TARGET)
			{
				target_memory[target_memory_index] = ship->universalID;
				foundSlot = YES;
				break;
			}
			target_memory_index = (target_memory_index + 1) % PLAYER_TARGET_MEMORY_SIZE;
		}
		 
	}
     }

      [UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[target-memory-filled]") forCount:2.0];
    }
}
=============================================================================

I introduced in my Oolite two new keys.

key_fill_target_memory
key_empty_target_memory

key_fill_target_memory calls the function above
key_empty_target_memory calls clearTargetMemory and [UNIVERSE addMessages:Exp ... ] for a notification for the busy commander :)

Intended behavior:

scan for ships,

add ships not in the target memory to the target memory until target memory is full. If target memory is full, do nothing.

Reasoning:

This does interefere least with existing controls.

Maybe one could do an Equipmentpiece around this an enable this only if you have the equipment "Targeting Computer" or you simply rename "Target Memory Expansion" to "Targeting Computer" and enabled the above behavior. Target is still limited to 16 memory "addresses".

As I'm a noob to objective C this might be rubbish for you, but for me it works. :D[/code]
Post Reply