Turret switch

An area for discussing new ideas and additions to Oolite.

Moderators: another_commander, winston

Post Reply
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Turret switch

Post by Screet »

Yes, this has been discussed in the general weapon switch thread, where it's related, however it seems that different people like different behaviour.

As I wrote, I did add a turret switch (shift-A) to my own build of trunk code. That was a while ago and it works well. I've configured a joystick button to send that key, so I can use the stick without having to modify the stick control code of Oolite. I would still suggest it for the devs to add something like this to general oolite, but it seems that currently there is no desire for such a move. What I did is simple and no secret, thus, I just tried to gather all the changes concerning that part, in case that someone who's able to build a personal oolite but not good at programming might simply copy my mod.

It may be that I missed some part. I don't think so, but my burnout really creates problems while doing such things. If this here is not enough, please let me know and I'll do a further check on what I might have missed and add it.

PlayerEntityControls.m

Code: Select all

static BOOL				turret_pressed;
before

Code: Select all

#if DOCKING_CLEARANCE_ENABLED
static BOOL                        docking_clearance_request_key_pressed;

Code: Select all

	LOAD_KEY_SETTING(key_turret,				'A'					);
before

Code: Select all

#ifndef NDEBUG
	LOAD_KEY_SETTING(key_dump_target_state,		'H'			);

Code: Select all

			if([gameView isDown:key_turret]) {
				if(!turret_pressed) {
					turret_pressed = YES;
					if(turretsEnabled) {
						turretsEnabled = NO;
						[UNIVERSE addMessage:DESC(@"Turrets offline") forCount:2.0];
					} else {
						turretsEnabled = YES;
						[UNIVERSE addMessage:DESC(@"Turrets online") forCount:2.0];
					}
				}
			} else {
				turret_pressed = NO;
			}
before

Code: Select all

				exceptionContext = @"ident R";
				//  shoot 'r'   // switch on ident system



PlayerEntity.m
---> this one is most probably obsolete to add

after

Code: Select all

	[self setTrumbleValueFrom:[dict objectForKey:@"trumbles"]];	// if it doesn't exist we'll check user-defaults
add

Code: Select all

	turretsEnabled = YES;


ShipEntity.m

Code: Select all

// Designated initializer
- (id)initWithKey:(NSString *)key definition:(NSDictionary *)dict
{
add to this

Code: Select all

	turretsEnabled = YES;

Code: Select all

- (BOOL) setUpFromDictionary:(NSDictionary *) shipDict
{
	OOJS_PROFILE_ENTER
add to this

Code: Select all

	turretsEnabled = YES;

Code: Select all

- (void) behaviour_track_as_turret:(double) delta_t
{
add as first line:

Code: Select all

	if (!([[self rootShipEntity] areTurretsEnabled])) 
		return;
add

Code: Select all

- (BOOL) areTurretsEnabled
{
	return turretsEnabled;
}
ShipEntity.h

add to "protected":

Code: Select all

	BOOL					turretsEnabled;
I hope that's not annoying anyone but helps those who really want that functionality.

Screet

User avatar
Mauiby de Fug
---- E L I T E ----
---- E L I T E ----
Posts: 824
Joined: Tue Sep 07, 2010 2:23 pm

Re: Turret switch

Post by Mauiby de Fug »

Cheers, Screet! I might well give this a whirl and see what happens! Quick question: do you just have to add the changes you've mentioned to the named files, save them (while keeping the originals as a backup, for obvious reasons), and then restart Oolite with shift down, or is there more involved?

Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Re: Turret switch

Post by Screet »

Mauiby de Fug wrote:Cheers, Screet! I might well give this a whirl and see what happens! Quick question: do you just have to add the changes you've mentioned to the named files, save them (while keeping the originals as a backup, for obvious reasons), and then restart Oolite with shift down, or is there more involved?
Those files are the source code modifications required. That means it's necessary to have the build environment for oolite installed, get the source via svn (it's possible to get either trunk which is under heavy development or a version of the latest release). There are topics on how to do this on the board, for the different operating systems (windows, mac,...).

Then it is required to apply the changes I've mentioned and compile (make) which creates the modified executable from the source. It's possible to play directly with that version or to create an installer and install the new version. In that case I would suggest installing to a different directory and copying all AddOns and the required saves to the new installation.

If someone has problems with these steps, I can provide a windows only installer, but I'm currently only having trunk versions and those may have good days and bad days. Furthermore, to windows it currently only shows as "oolite" which may be confusing - I lost my "oolite extended" makefile some time ago and cannot recreate it easily.

Screet

User avatar
Mauiby de Fug
---- E L I T E ----
---- E L I T E ----
Posts: 824
Joined: Tue Sep 07, 2010 2:23 pm

Re: Turret switch

Post by Mauiby de Fug »

Thanks for the clarification! Time to nip over to the Linux section of the forum...

Post Reply