Made missiles always return true in ShipEntity's hasHostileTarget: Implemented targetting of nearest incoming missile. This is activated using Shift+t or an assigned joystick button. Testing is still required. The entire implementation is guarded with the TARGET_INCOMING_MISSILES macro, disabled by default until it is agreed that this change does not influence gameplay in undesireable ways.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2151 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
7c0d723be0
commit
8d77a7b467
@ -4,6 +4,7 @@ BUILD_WITH_DEBUG_FUNCTIONALITY = yes
|
||||
DOCKING_CLEARANCE = yes
|
||||
PROCEDURAL_PLANETS = yes
|
||||
WORMHOLE_SCANNER = yes
|
||||
TARGET_INCOMING_MISSILES = no
|
||||
vpath %.m src/SDL:src/Core:src/Core/Entities:src/Core/Materials:src/Core/Scripting:src/Core/OXPVerifier:src/Core/Debug
|
||||
vpath %.h src/SDL:src/Core:src/Core/Entities:src/Core/Materials:src/Core/Scripting:src/Core/OXPVerifier:src/Core/Debug
|
||||
vpath %.c src/SDL:src/Core:src/BSDCompat:src/Core/Debug
|
||||
@ -50,6 +51,10 @@ ifeq ($(WORMHOLE_SCANNER),yes)
|
||||
ADDITIONAL_CFLAGS += -DWORMHOLE_SCANNER
|
||||
ADDITIONAL_OBJCFLAGS += -DWORMHOLE_SCANNER
|
||||
endif
|
||||
ifeq ($(TARGET_INCOMING_MISSILES),yes)
|
||||
ADDITIONAL_CFLAGS += -DTARGET_INCOMING_MISSILES
|
||||
ADDITIONAL_OBJCFLAGS += -DTARGET_INCOMING_MISSILES
|
||||
endif
|
||||
|
||||
OBJC_PROGRAM_NAME = oolite
|
||||
|
||||
|
@ -87,6 +87,9 @@ enum {
|
||||
BUTTON_ARMMISSILE,
|
||||
BUTTON_LAUNCHMISSILE,
|
||||
BUTTON_UNARM,
|
||||
#ifdef TARGET_INCOMING_MISSILES
|
||||
BUTTON_TARGETINCOMINGMISSILE,
|
||||
#endif
|
||||
BUTTON_CYCLEMISSILE,
|
||||
BUTTON_ENERGYBOMB,
|
||||
BUTTON_ID,
|
||||
|
@ -349,6 +349,9 @@ typedef enum
|
||||
|
||||
OOKeyCode key_target_missile;
|
||||
OOKeyCode key_untarget_missile;
|
||||
#ifdef TARGET_INCOMING_MISSILES
|
||||
OOKeyCode key_target_incoming_missile;
|
||||
#endif
|
||||
OOKeyCode key_ident_system;
|
||||
|
||||
OOKeyCode key_scanner_zoom;
|
||||
|
@ -62,6 +62,9 @@ static BOOL previous_target_pressed;
|
||||
static BOOL next_missile_pressed;
|
||||
static BOOL fire_missile_pressed;
|
||||
static BOOL target_missile_pressed;
|
||||
#ifdef TARGET_INCOMING_MISSILES
|
||||
static BOOL target_incoming_missile_pressed;
|
||||
#endif
|
||||
static BOOL ident_pressed;
|
||||
static BOOL safety_pressed;
|
||||
static BOOL cloak_pressed;
|
||||
@ -190,6 +193,9 @@ static NSTimeInterval time_last_frame;
|
||||
|
||||
LOAD_KEY_SETTING(key_target_missile, 't' );
|
||||
LOAD_KEY_SETTING(key_untarget_missile, 'u' );
|
||||
#ifdef TARGET_INCOMING_MISSILES
|
||||
LOAD_KEY_SETTING(key_target_incoming_missile, 'T' );
|
||||
#endif
|
||||
LOAD_KEY_SETTING(key_ident_system, 'r' );
|
||||
|
||||
LOAD_KEY_SETTING(key_scanner_zoom, 'z' );
|
||||
@ -688,6 +694,18 @@ static NSTimeInterval time_last_frame;
|
||||
ident_pressed = YES;
|
||||
}
|
||||
else ident_pressed = NO;
|
||||
#ifdef TARGET_INCOMING_MISSILES
|
||||
// target nearest incoming missile 'T' - useful for quickly giving a missile target to turrets
|
||||
if ([gameView isDown:key_target_incoming_missile] || joyButtonState[BUTTON_TARGETINCOMINGMISSILE])
|
||||
{
|
||||
if (!target_incoming_missile_pressed)
|
||||
{
|
||||
[self targetNearestIncomingMissile];
|
||||
}
|
||||
target_incoming_missile_pressed = YES;
|
||||
}
|
||||
else target_incoming_missile_pressed = NO;
|
||||
#endif
|
||||
|
||||
// shoot 't' // switch on missile targetting
|
||||
if (([gameView isDown:key_target_missile] || joyButtonState[BUTTON_ARMMISSILE])&&(missile_entity[activeMissile]))
|
||||
|
@ -233,6 +233,9 @@ typedef enum
|
||||
|
||||
- (BOOL) mapKey:(NSString *) keycode toOXP:(OOScript *)oxp;
|
||||
- (void) targetNearestHostile;
|
||||
#ifdef TARGET_INCOMING_MISSILES
|
||||
- (void) targetNearestIncomingMissile;
|
||||
#endif
|
||||
|
||||
- (void) setGalacticHyperspaceBehaviourTo:(NSString *) galacticHyperspaceBehaviourString;
|
||||
- (void) setGalacticHyperspaceFixedCoordsTo:(NSString *) galacticHyperspaceFixedCoordsString;
|
||||
|
@ -2645,6 +2645,24 @@ static int scriptRandomSeed = -1; // ensure proper random function
|
||||
}
|
||||
|
||||
|
||||
#ifdef TARGET_INCOMING_MISSILES
|
||||
- (void) targetNearestIncomingMissile
|
||||
{
|
||||
[self scanForNearestIncomingMissile];
|
||||
if (found_target != NO_TARGET)
|
||||
{
|
||||
Entity *ent = [UNIVERSE entityForUniversalID:found_target];
|
||||
if (ent != 0x00)
|
||||
{
|
||||
ident_engaged = YES;
|
||||
missile_status = MISSILE_STATUS_TARGET_LOCKED;
|
||||
[self addTarget:ent];
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
- (void) setGalacticHyperspaceBehaviourTo:(NSString *)galacticHyperspaceBehaviourString
|
||||
{
|
||||
OOGalacticHyperspaceBehaviour ghBehaviour = StringToGalacticHyperspaceBehaviour(galacticHyperspaceBehaviourString);
|
||||
|
@ -425,6 +425,13 @@ MA 02110-1301, USA.
|
||||
allowable: HW_BUTTON
|
||||
axisfn: STICK_NOFUNCTION
|
||||
butfn: BUTTON_UNARM]];
|
||||
#ifdef TARGET_INCOMING_MISSILES
|
||||
[funcList addObject:
|
||||
[self makeStickGuiDict: @"Target nearest incoming missile"
|
||||
allowable: HW_BUTTON
|
||||
axisfn: STICK_NOFUNCTION
|
||||
butfn: BUTTON_TARGETINCOMINGMISSILE]];
|
||||
#endif
|
||||
[funcList addObject:
|
||||
[self makeStickGuiDict: @"Cycle secondary"
|
||||
allowable: HW_BUTTON
|
||||
|
@ -3575,6 +3575,8 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
||||
{
|
||||
if (primaryTarget == NO_TARGET)
|
||||
return NO;
|
||||
if ([self isMissile])
|
||||
return YES; // missiles are always fired against a hostile target
|
||||
if ((behaviour == BEHAVIOUR_AVOID_COLLISION)&&(previousCondition))
|
||||
{
|
||||
int old_behaviour = [previousCondition intForKey:@"behaviour"];
|
||||
|
@ -37,8 +37,10 @@ MA 02110-1301, USA.
|
||||
- (void) switchAITo:(NSString *)aiString;
|
||||
|
||||
- (void) scanForHostiles;
|
||||
|
||||
- (void) performTumble;
|
||||
- (void) performStop;
|
||||
#ifdef TARGET_INCOMING_MISSILES
|
||||
- (void) scanForNearestIncomingMissile;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
@ -274,6 +274,19 @@ MA 02110-1301, USA.
|
||||
}
|
||||
|
||||
|
||||
#ifdef TARGET_INCOMING_MISSILES
|
||||
- (void) scanForNearestIncomingMissile
|
||||
{
|
||||
BinaryOperationPredicateParameter param =
|
||||
{
|
||||
HasScanClassPredicate, [NSNumber numberWithInt:CLASS_MISSILE],
|
||||
IsHostileAgainstTargetPredicate, self
|
||||
};
|
||||
[self scanForNearestShipWithPredicate:ANDPredicate parameter:¶m];
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
- (void) performTumble
|
||||
{
|
||||
flightRoll = max_flight_roll*2.0*(randf() - 0.5);
|
||||
|
@ -73,3 +73,6 @@ BOOL HasRolePredicate(Entity *ship, void *parameter); // Parameter: NSString
|
||||
BOOL HasPrimaryRolePredicate(Entity *ship, void *parameter); // Parameter: NSString
|
||||
BOOL HasRoleInSetPredicate(Entity *ship, void *parameter); // Parameter: NSSet
|
||||
BOOL HasPrimaryRoleInSetPredicate(Entity *ship, void *parameter); // Parameter: NSSet
|
||||
#ifdef TARGET_INCOMING_MISSILES
|
||||
BOOL IsHostileAgainstTargetPredicate(Entity *ship, void *parameter); // Parameter: id
|
||||
#endif
|
||||
|
@ -166,3 +166,11 @@ BOOL HasPrimaryRoleInSetPredicate(Entity *ship, void *parameter)
|
||||
{
|
||||
return [(NSSet *)parameter containsObject:[(ShipEntity *)ship primaryRole]];
|
||||
}
|
||||
|
||||
|
||||
#ifdef TARGET_INCOMING_MISSILES
|
||||
BOOL IsHostileAgainstTargetPredicate(Entity *ship, void *parameter)
|
||||
{
|
||||
return [(ShipEntity *)ship hasHostileTarget] && [(ShipEntity *)ship primaryTarget] == (ShipEntity *)parameter;
|
||||
}
|
||||
#endif
|
||||
|
@ -115,7 +115,13 @@ void OOPrintLogHeader(void)
|
||||
#define OPT3_STR ""
|
||||
#endif
|
||||
|
||||
#define OPT_STR OPT1_STR OPT2_STR OPT3_STR
|
||||
#ifdef TARGET_INCOMING_MISSILES
|
||||
#define OPT4_STR " [Target Incoming Missiles]"
|
||||
#else
|
||||
#define OPT4_STR ""
|
||||
#endif
|
||||
|
||||
#define OPT_STR OPT1_STR OPT2_STR OPT3_STR OPT4_STR
|
||||
|
||||
// systemString: NSString with system type and possibly version.
|
||||
#if OOLITE_MAC_OS_X
|
||||
|
@ -66,6 +66,9 @@ enum {
|
||||
BUTTON_FIRE,
|
||||
BUTTON_ARMMISSILE,
|
||||
BUTTON_LAUNCHMISSILE,
|
||||
#ifdef TARGET_INCOMING_MISSILES
|
||||
BUTTON_TARGETINCOMINGMISSILE,
|
||||
#endif
|
||||
BUTTON_UNARM,
|
||||
BUTTON_CYCLEMISSILE,
|
||||
BUTTON_ENERGYBOMB,
|
||||
|
Loading…
x
Reference in New Issue
Block a user