Turret switch
Posted: Sat Jan 22, 2011 11:24 am
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
before
before
before
PlayerEntity.m
---> this one is most probably obsolete to add
after
add
ShipEntity.m
add to this
add to this
add as first line:
add
ShipEntity.h
add to "protected":
I hope that's not annoying anyone but helps those who really want that functionality.
Screet
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;
Code: Select all
#if DOCKING_CLEARANCE_ENABLED
static BOOL docking_clearance_request_key_pressed;
Code: Select all
LOAD_KEY_SETTING(key_turret, 'A' );
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;
}
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
Code: Select all
turretsEnabled = YES;
ShipEntity.m
Code: Select all
// Designated initializer
- (id)initWithKey:(NSString *)key definition:(NSDictionary *)dict
{
Code: Select all
turretsEnabled = YES;
Code: Select all
- (BOOL) setUpFromDictionary:(NSDictionary *) shipDict
{
OOJS_PROFILE_ENTER
Code: Select all
turretsEnabled = YES;
Code: Select all
- (void) behaviour_track_as_turret:(double) delta_t
{
Code: Select all
if (!([[self rootShipEntity] areTurretsEnabled]))
return;
Code: Select all
- (BOOL) areTurretsEnabled
{
return turretsEnabled;
}
add to "protected":
Code: Select all
BOOL turretsEnabled;
Screet