renamed condition to behaviour (better reflects use)
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@322 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
e5df0e1221
commit
2c4671442a
@ -2329,7 +2329,7 @@ static BOOL toggling_music;
|
|||||||
if (([gameView isDown:key_autopilot])&&(has_docking_computer)&&(![self isBeeping])) // look for the 'c' key
|
if (([gameView isDown:key_autopilot])&&(has_docking_computer)&&(![self isBeeping])) // look for the 'c' key
|
||||||
{
|
{
|
||||||
[self abortDocking]; // let the station know that you are no longer on approach
|
[self abortDocking]; // let the station know that you are no longer on approach
|
||||||
condition = CONDITION_IDLE;
|
behaviour = BEHAVIOUR_IDLE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
autopilot_engaged = NO;
|
autopilot_engaged = NO;
|
||||||
primaryTarget = NO_TARGET;
|
primaryTarget = NO_TARGET;
|
||||||
|
@ -38,8 +38,8 @@ Your fair use and other rights are in no way affected by the above.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
#import "ShipEntity.h"
|
#import "ShipEntity.h"
|
||||||
|
|
||||||
#ifdef GNUSTEP
|
#ifdef GNUSTEP
|
||||||
#import "SDLImage.h"
|
#import "SDLImage.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -2847,7 +2847,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
[mine setVelocity: mvel];
|
[mine setVelocity: mvel];
|
||||||
[mine setScanClass: CLASS_MINE];
|
[mine setScanClass: CLASS_MINE];
|
||||||
[mine setStatus: STATUS_IN_FLIGHT];
|
[mine setStatus: STATUS_IN_FLIGHT];
|
||||||
[mine setCondition: CONDITION_IDLE];
|
[mine setBehaviour: BEHAVIOUR_IDLE];
|
||||||
[mine setOwner: self];
|
[mine setOwner: self];
|
||||||
[[mine getAI] setState:@"GLOBAL"]; // start the timer !!!!
|
[[mine getAI] setState:@"GLOBAL"]; // start the timer !!!!
|
||||||
return YES;
|
return YES;
|
||||||
@ -3284,7 +3284,7 @@ double scoopSoundPlayTime = 0.0;
|
|||||||
[doppelganger setDesiredSpeed: flight_speed];
|
[doppelganger setDesiredSpeed: flight_speed];
|
||||||
[doppelganger setOwner: self];
|
[doppelganger setOwner: self];
|
||||||
[doppelganger setStatus: STATUS_IN_FLIGHT]; // necessary to get it going!
|
[doppelganger setStatus: STATUS_IN_FLIGHT]; // necessary to get it going!
|
||||||
[doppelganger setCondition: CONDITION_IDLE];
|
[doppelganger setBehaviour: BEHAVIOUR_IDLE];
|
||||||
|
|
||||||
[universe addEntity:doppelganger];
|
[universe addEntity:doppelganger];
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ static Vector zero_vector = { 0.0f, 0.0f, 0.0f};
|
|||||||
|
|
||||||
- (void) performFlyToRangeFromDestination
|
- (void) performFlyToRangeFromDestination
|
||||||
{
|
{
|
||||||
condition = CONDITION_FLY_RANGE_FROM_DESTINATION;
|
behaviour = BEHAVIOUR_FLY_RANGE_FROM_DESTINATION;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,14 +92,14 @@ static Vector zero_vector = { 0.0f, 0.0f, 0.0f};
|
|||||||
|
|
||||||
- (void) performIdle
|
- (void) performIdle
|
||||||
{
|
{
|
||||||
condition = CONDITION_IDLE;
|
behaviour = BEHAVIOUR_IDLE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) performHold
|
- (void) performHold
|
||||||
{
|
{
|
||||||
desired_speed = 0.0;
|
desired_speed = 0.0;
|
||||||
condition = CONDITION_TRACK_TARGET;
|
behaviour = BEHAVIOUR_TRACK_TARGET;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,10 +113,10 @@ static Vector zero_vector = { 0.0f, 0.0f, 0.0f};
|
|||||||
// a more considered approach here:
|
// a more considered approach here:
|
||||||
// if we're already busy attacking a target we don't necessarily want to break off
|
// if we're already busy attacking a target we don't necessarily want to break off
|
||||||
//
|
//
|
||||||
switch (condition)
|
switch (behaviour)
|
||||||
{
|
{
|
||||||
case CONDITION_ATTACK_FLY_FROM_TARGET:
|
case BEHAVIOUR_ATTACK_FLY_FROM_TARGET:
|
||||||
case CONDITION_ATTACK_FLY_TO_TARGET:
|
case BEHAVIOUR_ATTACK_FLY_TO_TARGET:
|
||||||
if (randf() < 0.75) // if I'm attacking, ignore 75% of new aggressor's attacks
|
if (randf() < 0.75) // if I'm attacking, ignore 75% of new aggressor's attacks
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
@ -140,7 +140,7 @@ static Vector zero_vector = { 0.0f, 0.0f, 0.0f};
|
|||||||
|
|
||||||
- (void) performAttack
|
- (void) performAttack
|
||||||
{
|
{
|
||||||
condition = CONDITION_ATTACK_TARGET;
|
behaviour = BEHAVIOUR_ATTACK_TARGET;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,19 +343,19 @@ static Vector zero_vector = { 0.0f, 0.0f, 0.0f};
|
|||||||
|
|
||||||
- (void) performCollect
|
- (void) performCollect
|
||||||
{
|
{
|
||||||
condition = CONDITION_COLLECT_TARGET;
|
behaviour = BEHAVIOUR_COLLECT_TARGET;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) performIntercept
|
- (void) performIntercept
|
||||||
{
|
{
|
||||||
condition = CONDITION_INTERCEPT_TARGET;
|
behaviour = BEHAVIOUR_INTERCEPT_TARGET;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) performFlee
|
- (void) performFlee
|
||||||
{
|
{
|
||||||
condition = CONDITION_FLEE_TARGET;
|
behaviour = BEHAVIOUR_FLEE_TARGET;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,7 +423,7 @@ static Vector zero_vector = { 0.0f, 0.0f, 0.0f};
|
|||||||
|
|
||||||
- (void) performFaceDestination
|
- (void) performFaceDestination
|
||||||
{
|
{
|
||||||
condition = CONDITION_FACE_DESTINATION;
|
behaviour = BEHAVIOUR_FACE_DESTINATION;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +432,7 @@ static Vector zero_vector = { 0.0f, 0.0f, 0.0f};
|
|||||||
flight_roll = max_flight_roll*2.0*(randf() - 0.5);
|
flight_roll = max_flight_roll*2.0*(randf() - 0.5);
|
||||||
flight_pitch = max_flight_pitch*2.0*(randf() - 0.5);
|
flight_pitch = max_flight_pitch*2.0*(randf() - 0.5);
|
||||||
// velocity = make_vector( flight_speed*2.0*(randf() - 0.5), flight_speed*2.0*(randf() - 0.5), flight_speed*2.0*(randf() - 0.5));
|
// velocity = make_vector( flight_speed*2.0*(randf() - 0.5), flight_speed*2.0*(randf() - 0.5), flight_speed*2.0*(randf() - 0.5));
|
||||||
condition = CONDITION_TUMBLE;
|
behaviour = BEHAVIOUR_TUMBLE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -952,15 +952,15 @@ WormholeEntity* whole;
|
|||||||
- (void) acceptDistressMessageFrom:(ShipEntity *)other
|
- (void) acceptDistressMessageFrom:(ShipEntity *)other
|
||||||
{
|
{
|
||||||
found_target = [[other getPrimaryTarget] universal_id];
|
found_target = [[other getPrimaryTarget] universal_id];
|
||||||
switch (condition)
|
switch (behaviour)
|
||||||
{
|
{
|
||||||
case CONDITION_ATTACK_TARGET :
|
case BEHAVIOUR_ATTACK_TARGET :
|
||||||
case CONDITION_ATTACK_FLY_TO_TARGET :
|
case BEHAVIOUR_ATTACK_FLY_TO_TARGET :
|
||||||
case CONDITION_ATTACK_FLY_FROM_TARGET :
|
case BEHAVIOUR_ATTACK_FLY_FROM_TARGET :
|
||||||
// busy - ignore the request
|
// busy - ignore the request
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_FLEE_TARGET :
|
case BEHAVIOUR_FLEE_TARGET :
|
||||||
// scared - ignore the request;
|
// scared - ignore the request;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1093,7 +1093,7 @@ WormholeEntity* whole;
|
|||||||
- (void) initialiseTurret
|
- (void) initialiseTurret
|
||||||
{
|
{
|
||||||
// NSLog(@"DEBUG initialising ball turret %@ (%@)", self, basefile);
|
// NSLog(@"DEBUG initialising ball turret %@ (%@)", self, basefile);
|
||||||
[self setCondition: CONDITION_TRACK_AS_TURRET];
|
[self setBehaviour: BEHAVIOUR_TRACK_AS_TURRET];
|
||||||
weapon_recharge_rate = 0.5; // test
|
weapon_recharge_rate = 0.5; // test
|
||||||
// weapon_energy = 0.1; // test
|
// weapon_energy = 0.1; // test
|
||||||
[self setStatus: STATUS_ACTIVE];
|
[self setStatus: STATUS_ACTIVE];
|
||||||
@ -1251,7 +1251,7 @@ WormholeEntity* whole;
|
|||||||
|
|
||||||
- (void) performEscort
|
- (void) performEscort
|
||||||
{
|
{
|
||||||
condition = CONDITION_FORMATION_FORM_UP;
|
behaviour = BEHAVIOUR_FORMATION_FORM_UP;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1591,7 +1591,7 @@ WormholeEntity* whole;
|
|||||||
|
|
||||||
- (void) performMining
|
- (void) performMining
|
||||||
{
|
{
|
||||||
condition = CONDITION_ATTACK_MINING_TARGET;
|
behaviour = BEHAVIOUR_ATTACK_MINING_TARGET;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,49 +41,49 @@ Your fair use and other rights are in no way affected by the above.
|
|||||||
|
|
||||||
#import "Entity.h"
|
#import "Entity.h"
|
||||||
|
|
||||||
#define CONDITION_IDLE 0
|
#define BEHAVIOUR_IDLE 0
|
||||||
#define CONDITION_TRACK_TARGET 1
|
#define BEHAVIOUR_TRACK_TARGET 1
|
||||||
#define CONDITION_FLY_TO_TARGET 2
|
#define BEHAVIOUR_FLY_TO_TARGET 2
|
||||||
#define CONDITION_HANDS_OFF 3
|
#define BEHAVIOUR_HANDS_OFF 3
|
||||||
#define CONDITION_TUMBLE 4
|
#define BEHAVIOUR_TUMBLE 4
|
||||||
|
|
||||||
#define CONDITION_STATION_KEEPING 10
|
#define BEHAVIOUR_STATION_KEEPING 10
|
||||||
|
|
||||||
#define IS_CONDITION_HOSTILE(c) ((c > 100)&&(c < 120))
|
#define IS_BEHAVIOUR_HOSTILE(c) ((c > 100)&&(c < 120))
|
||||||
#define CONDITION_ATTACK_TARGET 101
|
#define BEHAVIOUR_ATTACK_TARGET 101
|
||||||
#define CONDITION_ATTACK_FLY_TO_TARGET 102
|
#define BEHAVIOUR_ATTACK_FLY_TO_TARGET 102
|
||||||
#define CONDITION_ATTACK_FLY_FROM_TARGET 103
|
#define BEHAVIOUR_ATTACK_FLY_FROM_TARGET 103
|
||||||
#define CONDITION_RUNNING_DEFENSE 104
|
#define BEHAVIOUR_RUNNING_DEFENSE 104
|
||||||
// fleeing
|
// fleeing
|
||||||
#define CONDITION_FLEE_TARGET 105
|
#define BEHAVIOUR_FLEE_TARGET 105
|
||||||
// advanced combat...
|
// advanced combat...
|
||||||
#define CONDITION_ATTACK_FLY_TO_TARGET_SIX 106
|
#define BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX 106
|
||||||
#define CONDITION_ATTACK_MINING_TARGET 107
|
#define BEHAVIOUR_ATTACK_MINING_TARGET 107
|
||||||
// further advanced combat...
|
// further advanced combat...
|
||||||
#define CONDITION_ATTACK_FLY_TO_TARGET_TWELVE 112
|
#define BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE 112
|
||||||
|
|
||||||
#define CONDITION_AVOID_COLLISION 130
|
#define BEHAVIOUR_AVOID_COLLISION 130
|
||||||
|
|
||||||
#define CONDITION_TRACK_AS_TURRET 150
|
#define BEHAVIOUR_TRACK_AS_TURRET 150
|
||||||
|
|
||||||
#define CONDITION_FLY_RANGE_FROM_DESTINATION 200
|
#define BEHAVIOUR_FLY_RANGE_FROM_DESTINATION 200
|
||||||
#define CONDITION_FLY_TO_DESTINATION 201
|
#define BEHAVIOUR_FLY_TO_DESTINATION 201
|
||||||
#define CONDITION_FLY_FROM_DESTINATION 202
|
#define BEHAVIOUR_FLY_FROM_DESTINATION 202
|
||||||
#define CONDITION_FACE_DESTINATION 203
|
#define BEHAVIOUR_FACE_DESTINATION 203
|
||||||
|
|
||||||
#define CONDITION_COLLECT_TARGET 300
|
#define BEHAVIOUR_COLLECT_TARGET 300
|
||||||
#define CONDITION_INTERCEPT_TARGET 350
|
#define BEHAVIOUR_INTERCEPT_TARGET 350
|
||||||
|
|
||||||
#define CONDITION_MISSILE_FLY_TO_TARGET 901
|
#define BEHAVIOUR_MISSILE_FLY_TO_TARGET 901
|
||||||
|
|
||||||
#define CONDITION_FORMATION_FORM_UP 501
|
#define BEHAVIOUR_FORMATION_FORM_UP 501
|
||||||
#define CONDITION_FORMATION_BREAK 502
|
#define BEHAVIOUR_FORMATION_BREAK 502
|
||||||
|
|
||||||
#define CONDITION_ENERGY_BOMB_COUNTDOWN 601
|
#define BEHAVIOUR_ENERGY_BOMB_COUNTDOWN 601
|
||||||
|
|
||||||
#define CONDITION_TRACTORED 701
|
#define BEHAVIOUR_TRACTORED 701
|
||||||
|
|
||||||
#define CONDITION_EXPERIMENTAL 54321
|
#define BEHAVIOUR_EXPERIMENTAL 54321
|
||||||
|
|
||||||
|
|
||||||
#define MAX_TARGETS 24
|
#define MAX_TARGETS 24
|
||||||
@ -271,7 +271,7 @@ Your fair use and other rights are in no way affected by the above.
|
|||||||
double desired_speed; // speed at which to travel
|
double desired_speed; // speed at which to travel
|
||||||
double launch_time; // time at which launched
|
double launch_time; // time at which launched
|
||||||
|
|
||||||
int condition; // ship's behavioural state
|
int behaviour; // ship's behavioural state
|
||||||
double frustration, success_factor; // degree of dissatisfaction with the current behavioural state, factor used to test this
|
double frustration, success_factor; // degree of dissatisfaction with the current behavioural state, factor used to test this
|
||||||
|
|
||||||
int patrol_counter; // keeps track of where the ship is along a patrol route
|
int patrol_counter; // keeps track of where the ship is along a patrol route
|
||||||
@ -507,8 +507,8 @@ Vector randomPositionInBoundingBox(BoundingBox bb);
|
|||||||
- (Entity *) getPrimaryTarget;
|
- (Entity *) getPrimaryTarget;
|
||||||
- (int) getPrimaryTargetID;
|
- (int) getPrimaryTargetID;
|
||||||
|
|
||||||
- (int) condition;
|
- (int) behaviour;
|
||||||
- (void) setCondition:(int) cond;
|
- (void) setBehaviour:(int) cond;
|
||||||
|
|
||||||
- (void) trackOntoTarget:(double) delta_t withDForward: (GLfloat) dp;
|
- (void) trackOntoTarget:(double) delta_t withDForward: (GLfloat) dp;
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ Your fair use and other rights are in no way affected by the above.
|
|||||||
//
|
//
|
||||||
proximity_alert = NO_TARGET;
|
proximity_alert = NO_TARGET;
|
||||||
//
|
//
|
||||||
condition = CONDITION_IDLE;
|
behaviour = BEHAVIOUR_IDLE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
//
|
//
|
||||||
shipAI = [[AI alloc] init]; // alloc retains
|
shipAI = [[AI alloc] init]; // alloc retains
|
||||||
@ -541,7 +541,7 @@ static NSMutableDictionary* smallOctreeDict = nil;
|
|||||||
//
|
//
|
||||||
proximity_alert = NO_TARGET;
|
proximity_alert = NO_TARGET;
|
||||||
//
|
//
|
||||||
condition = CONDITION_IDLE;
|
behaviour = BEHAVIOUR_IDLE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
//
|
//
|
||||||
if (shipAI)
|
if (shipAI)
|
||||||
@ -647,7 +647,7 @@ static NSMutableDictionary* smallOctreeDict = nil;
|
|||||||
//
|
//
|
||||||
proximity_alert = NO_TARGET;
|
proximity_alert = NO_TARGET;
|
||||||
//
|
//
|
||||||
condition = CONDITION_IDLE;
|
behaviour = BEHAVIOUR_IDLE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
//
|
//
|
||||||
patrol_counter = 0;
|
patrol_counter = 0;
|
||||||
@ -1687,10 +1687,10 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
|
|
||||||
// DEBUGGING
|
// DEBUGGING
|
||||||
//
|
//
|
||||||
if (reportAImessages && (debug_condition != condition))
|
if (reportAImessages && (debug_condition != behaviour))
|
||||||
{
|
{
|
||||||
NSLog(@"DEBUG %@ condition is now %d", self, condition);
|
NSLog(@"DEBUG %@ behaviour is now %d", self, behaviour);
|
||||||
debug_condition = condition;
|
debug_condition = behaviour;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update time between shots
|
// update time between shots
|
||||||
@ -1801,7 +1801,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
[launch_actions removeAllObjects];
|
[launch_actions removeAllObjects];
|
||||||
}
|
}
|
||||||
|
|
||||||
// behaviours according to status and condition
|
// behaviours according to status and behaviour
|
||||||
//
|
//
|
||||||
if (status == STATUS_LAUNCHING)
|
if (status == STATUS_LAUNCHING)
|
||||||
{
|
{
|
||||||
@ -1813,7 +1813,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// ignore condition just keep moving...
|
// ignore behaviour just keep moving...
|
||||||
[self applyRoll:delta_t*flight_roll andClimb:delta_t*flight_pitch];
|
[self applyRoll:delta_t*flight_roll andClimb:delta_t*flight_pitch];
|
||||||
[self applyThrust:delta_t];
|
[self applyThrust:delta_t];
|
||||||
if (energy < max_energy)
|
if (energy < max_energy)
|
||||||
@ -1829,15 +1829,15 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// double check scooped condition
|
// double check scooped behaviour
|
||||||
//
|
//
|
||||||
if (status == STATUS_BEING_SCOOPED)
|
if (status == STATUS_BEING_SCOOPED)
|
||||||
{
|
{
|
||||||
if (condition != CONDITION_TRACTORED)
|
if (behaviour != BEHAVIOUR_TRACTORED)
|
||||||
{
|
{
|
||||||
// escaped tractor beam
|
// escaped tractor beam
|
||||||
status = STATUS_IN_FLIGHT; // should correct 'uncollidable objects' bug
|
status = STATUS_IN_FLIGHT; // should correct 'uncollidable objects' bug
|
||||||
condition = CONDITION_IDLE;
|
behaviour = BEHAVIOUR_IDLE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1886,10 +1886,10 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (condition)
|
switch (behaviour)
|
||||||
{
|
{
|
||||||
case CONDITION_IDLE :
|
case BEHAVIOUR_IDLE :
|
||||||
case CONDITION_STATION_KEEPING :
|
case BEHAVIOUR_STATION_KEEPING :
|
||||||
if ((!isStation)&&(scan_class != CLASS_BUOY))
|
if ((!isStation)&&(scan_class != CLASS_BUOY))
|
||||||
{
|
{
|
||||||
// damp roll and pitch
|
// damp roll and pitch
|
||||||
@ -1902,10 +1902,10 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
if (flight_pitch > 0)
|
if (flight_pitch > 0)
|
||||||
flight_pitch -= (flight_pitch > damping) ? damping : flight_pitch;
|
flight_pitch -= (flight_pitch > damping) ? damping : flight_pitch;
|
||||||
}
|
}
|
||||||
case CONDITION_TUMBLE :
|
case BEHAVIOUR_TUMBLE :
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_TRACTORED :
|
case BEHAVIOUR_TRACTORED :
|
||||||
{
|
{
|
||||||
ShipEntity* hauler = (ShipEntity*)[self owner];
|
ShipEntity* hauler = (ShipEntity*)[self owner];
|
||||||
if ((hauler)&&(hauler->isShip))
|
if ((hauler)&&(hauler->isShip))
|
||||||
@ -1934,7 +1934,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
{
|
{
|
||||||
// escaped tractor beam
|
// escaped tractor beam
|
||||||
status = STATUS_IN_FLIGHT;
|
status = STATUS_IN_FLIGHT;
|
||||||
condition = CONDITION_IDLE;
|
behaviour = BEHAVIOUR_IDLE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
[shipAI exitStateMachine]; // exit nullAI.plist
|
[shipAI exitStateMachine]; // exit nullAI.plist
|
||||||
}
|
}
|
||||||
@ -1947,15 +1947,15 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_TRACK_TARGET :
|
case BEHAVIOUR_TRACK_TARGET :
|
||||||
[self trackPrimaryTarget:delta_t:NO];
|
[self trackPrimaryTarget:delta_t:NO];
|
||||||
if ((proximity_alert != NO_TARGET)&&(proximity_alert != primaryTarget))
|
if ((proximity_alert != NO_TARGET)&&(proximity_alert != primaryTarget))
|
||||||
[self avoidCollision];
|
[self avoidCollision];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_INTERCEPT_TARGET :
|
case BEHAVIOUR_INTERCEPT_TARGET :
|
||||||
case CONDITION_COLLECT_TARGET :
|
case BEHAVIOUR_COLLECT_TARGET :
|
||||||
if (condition == CONDITION_INTERCEPT_TARGET)
|
if (behaviour == BEHAVIOUR_INTERCEPT_TARGET)
|
||||||
{
|
{
|
||||||
desired_speed = max_flight_speed;
|
desired_speed = max_flight_speed;
|
||||||
if (range < desired_range)
|
if (range < desired_range)
|
||||||
@ -2012,28 +2012,28 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
[self avoidCollision];
|
[self avoidCollision];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_ATTACK_TARGET :
|
case BEHAVIOUR_ATTACK_TARGET :
|
||||||
[self activateCloakingDevice];
|
[self activateCloakingDevice];
|
||||||
desired_speed = max_available_speed;
|
desired_speed = max_available_speed;
|
||||||
if (range < 0.035 * weapon_range)
|
if (range < 0.035 * weapon_range)
|
||||||
condition = CONDITION_ATTACK_FLY_FROM_TARGET;
|
behaviour = BEHAVIOUR_ATTACK_FLY_FROM_TARGET;
|
||||||
else
|
else
|
||||||
if (universal_id & 1) // 50% of ships are smart S.M.R.T. smart!
|
if (universal_id & 1) // 50% of ships are smart S.M.R.T. smart!
|
||||||
{
|
{
|
||||||
if (randf() < 0.75)
|
if (randf() < 0.75)
|
||||||
condition = CONDITION_ATTACK_FLY_TO_TARGET_SIX;
|
behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX;
|
||||||
else
|
else
|
||||||
condition = CONDITION_ATTACK_FLY_TO_TARGET_TWELVE;
|
behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
condition = CONDITION_ATTACK_FLY_TO_TARGET;
|
behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET;
|
||||||
}
|
}
|
||||||
frustration = 0.0; // condition changed, so reset frustration
|
frustration = 0.0; // behaviour changed, so reset frustration
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_ATTACK_FLY_TO_TARGET_SIX :
|
case BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX :
|
||||||
case CONDITION_ATTACK_FLY_TO_TARGET_TWELVE :
|
case BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE :
|
||||||
|
|
||||||
// deal with collisions and lost targets
|
// deal with collisions and lost targets
|
||||||
//
|
//
|
||||||
@ -2041,7 +2041,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
[self avoidCollision];
|
[self avoidCollision];
|
||||||
if (range > SCANNER_MAX_RANGE)
|
if (range > SCANNER_MAX_RANGE)
|
||||||
{
|
{
|
||||||
condition = CONDITION_IDLE;
|
behaviour = BEHAVIOUR_IDLE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
[shipAI reactToMessage:@"TARGET_LOST"];
|
[shipAI reactToMessage:@"TARGET_LOST"];
|
||||||
}
|
}
|
||||||
@ -2053,8 +2053,8 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
desired_speed = target_speed;
|
desired_speed = target_speed;
|
||||||
// avoid head-on collision
|
// avoid head-on collision
|
||||||
//
|
//
|
||||||
if ((range < 0.5 * distance)&&(condition == CONDITION_ATTACK_FLY_TO_TARGET_SIX))
|
if ((range < 0.5 * distance)&&(behaviour == BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX))
|
||||||
condition = CONDITION_ATTACK_FLY_TO_TARGET_TWELVE;
|
behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
desired_speed = max_available_speed; // use afterburner to approach
|
desired_speed = max_available_speed; // use afterburner to approach
|
||||||
@ -2064,20 +2064,20 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
//
|
//
|
||||||
if (distance < 750.0)
|
if (distance < 750.0)
|
||||||
{
|
{
|
||||||
condition = CONDITION_ATTACK_FLY_TO_TARGET;
|
behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
desired_speed = target_speed; // within the weapon's range don't use afterburner
|
desired_speed = target_speed; // within the weapon's range don't use afterburner
|
||||||
}
|
}
|
||||||
|
|
||||||
// target-six
|
// target-six
|
||||||
if (condition == CONDITION_ATTACK_FLY_TO_TARGET_SIX)
|
if (behaviour == BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX)
|
||||||
{
|
{
|
||||||
// head for a point weapon-range * 0.5 to the six of the target
|
// head for a point weapon-range * 0.5 to the six of the target
|
||||||
//
|
//
|
||||||
destination = [target distance_six:0.5 * weapon_range];
|
destination = [target distance_six:0.5 * weapon_range];
|
||||||
}
|
}
|
||||||
// target-twelve
|
// target-twelve
|
||||||
if (condition == CONDITION_ATTACK_FLY_TO_TARGET_TWELVE)
|
if (behaviour == BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE)
|
||||||
{
|
{
|
||||||
// head for a point 1.25km above the target
|
// head for a point 1.25km above the target
|
||||||
//
|
//
|
||||||
@ -2097,7 +2097,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
[self fireMainWeapon:range];
|
[self fireMainWeapon:range];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_ATTACK_MINING_TARGET :
|
case BEHAVIOUR_ATTACK_MINING_TARGET :
|
||||||
if ((range < 650)||(proximity_alert != NO_TARGET))
|
if ((range < 650)||(proximity_alert != NO_TARGET))
|
||||||
{
|
{
|
||||||
if (proximity_alert == NO_TARGET)
|
if (proximity_alert == NO_TARGET)
|
||||||
@ -2113,7 +2113,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
{
|
{
|
||||||
if (range > SCANNER_MAX_RANGE)
|
if (range > SCANNER_MAX_RANGE)
|
||||||
{
|
{
|
||||||
condition = CONDITION_IDLE;
|
behaviour = BEHAVIOUR_IDLE;
|
||||||
[shipAI reactToMessage:@"TARGET_LOST"];
|
[shipAI reactToMessage:@"TARGET_LOST"];
|
||||||
}
|
}
|
||||||
desired_speed = max_flight_speed * 0.375;
|
desired_speed = max_flight_speed * 0.375;
|
||||||
@ -2122,7 +2122,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
[self fireMainWeapon:range];
|
[self fireMainWeapon:range];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_ATTACK_FLY_TO_TARGET :
|
case BEHAVIOUR_ATTACK_FLY_TO_TARGET :
|
||||||
if ((range < COMBAT_IN_RANGE_FACTOR * weapon_range)||(proximity_alert != NO_TARGET))
|
if ((range < COMBAT_IN_RANGE_FACTOR * weapon_range)||(proximity_alert != NO_TARGET))
|
||||||
{
|
{
|
||||||
if (proximity_alert == NO_TARGET)
|
if (proximity_alert == NO_TARGET)
|
||||||
@ -2132,7 +2132,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
jink.x = (ranrot_rand() % 256) - 128.0;
|
jink.x = (ranrot_rand() % 256) - 128.0;
|
||||||
jink.y = (ranrot_rand() % 256) - 128.0;
|
jink.y = (ranrot_rand() % 256) - 128.0;
|
||||||
jink.z = 1000.0;
|
jink.z = 1000.0;
|
||||||
condition = CONDITION_ATTACK_FLY_FROM_TARGET;
|
behaviour = BEHAVIOUR_ATTACK_FLY_FROM_TARGET;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
desired_speed = max_available_speed;
|
desired_speed = max_available_speed;
|
||||||
}
|
}
|
||||||
@ -2141,7 +2141,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
//NSLog(@"DEBUG >>>>> %@ %d entering running defense mode", name, universal_id);
|
//NSLog(@"DEBUG >>>>> %@ %d entering running defense mode", name, universal_id);
|
||||||
|
|
||||||
jink = make_vector( 0.0f, 0.0f, 0.0f);
|
jink = make_vector( 0.0f, 0.0f, 0.0f);
|
||||||
condition = CONDITION_RUNNING_DEFENSE;
|
behaviour = BEHAVIOUR_RUNNING_DEFENSE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
desired_speed = max_flight_speed;
|
desired_speed = max_flight_speed;
|
||||||
}
|
}
|
||||||
@ -2155,7 +2155,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
{
|
{
|
||||||
if (range > SCANNER_MAX_RANGE)
|
if (range > SCANNER_MAX_RANGE)
|
||||||
{
|
{
|
||||||
condition = CONDITION_IDLE;
|
behaviour = BEHAVIOUR_IDLE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
[shipAI reactToMessage:@"TARGET_LOST"];
|
[shipAI reactToMessage:@"TARGET_LOST"];
|
||||||
}
|
}
|
||||||
@ -2187,7 +2187,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
jink.x = (ranrot_rand() % 256) - 128.0;
|
jink.x = (ranrot_rand() % 256) - 128.0;
|
||||||
jink.y = (ranrot_rand() % 256) - 128.0;
|
jink.y = (ranrot_rand() % 256) - 128.0;
|
||||||
jink.z = 1000.0;
|
jink.z = 1000.0;
|
||||||
condition = CONDITION_ATTACK_FLY_FROM_TARGET;
|
behaviour = BEHAVIOUR_ATTACK_FLY_FROM_TARGET;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
desired_speed = max_flight_speed;
|
desired_speed = max_flight_speed;
|
||||||
}
|
}
|
||||||
@ -2202,13 +2202,13 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
[self fireMainWeapon:range];
|
[self fireMainWeapon:range];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_ATTACK_FLY_FROM_TARGET :
|
case BEHAVIOUR_ATTACK_FLY_FROM_TARGET :
|
||||||
if (range > COMBAT_OUT_RANGE_FACTOR * weapon_range + 15.0 * jink.x)
|
if (range > COMBAT_OUT_RANGE_FACTOR * weapon_range + 15.0 * jink.x)
|
||||||
{
|
{
|
||||||
jink.x = 0.0;
|
jink.x = 0.0;
|
||||||
jink.y = 0.0;
|
jink.y = 0.0;
|
||||||
jink.z = 0.0;
|
jink.z = 0.0;
|
||||||
condition = CONDITION_ATTACK_TARGET;
|
behaviour = BEHAVIOUR_ATTACK_TARGET;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
[self trackPrimaryTarget:delta_t:YES];
|
[self trackPrimaryTarget:delta_t:YES];
|
||||||
@ -2220,13 +2220,13 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
[self activateCloakingDevice];
|
[self activateCloakingDevice];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_RUNNING_DEFENSE :
|
case BEHAVIOUR_RUNNING_DEFENSE :
|
||||||
if (range > weapon_range)
|
if (range > weapon_range)
|
||||||
{
|
{
|
||||||
jink.x = 0.0;
|
jink.x = 0.0;
|
||||||
jink.y = 0.0;
|
jink.y = 0.0;
|
||||||
jink.z = 0.0;
|
jink.z = 0.0;
|
||||||
condition = CONDITION_ATTACK_FLY_TO_TARGET;
|
behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
[self trackPrimaryTarget:delta_t:YES];
|
[self trackPrimaryTarget:delta_t:YES];
|
||||||
@ -2234,7 +2234,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
[self activateCloakingDevice];
|
[self activateCloakingDevice];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_FLEE_TARGET :
|
case BEHAVIOUR_FLEE_TARGET :
|
||||||
if (range > desired_range)
|
if (range > desired_range)
|
||||||
{
|
{
|
||||||
[shipAI message:@"REACHED_SAFETY"];
|
[shipAI message:@"REACHED_SAFETY"];
|
||||||
@ -2252,15 +2252,15 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
[self activateCloakingDevice];
|
[self activateCloakingDevice];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_FLY_RANGE_FROM_DESTINATION :
|
case BEHAVIOUR_FLY_RANGE_FROM_DESTINATION :
|
||||||
if (distance < desired_range)
|
if (distance < desired_range)
|
||||||
condition = CONDITION_FLY_FROM_DESTINATION;
|
behaviour = BEHAVIOUR_FLY_FROM_DESTINATION;
|
||||||
else
|
else
|
||||||
condition = CONDITION_FLY_TO_DESTINATION;
|
behaviour = BEHAVIOUR_FLY_TO_DESTINATION;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_FACE_DESTINATION :
|
case BEHAVIOUR_FACE_DESTINATION :
|
||||||
desired_speed = 0.0;
|
desired_speed = 0.0;
|
||||||
// NSLog(@"DEBUG >>>>> distance %.1f desired_range %.1f", distance, desired_range);
|
// NSLog(@"DEBUG >>>>> distance %.1f desired_range %.1f", distance, desired_range);
|
||||||
if (desired_range > 1.0)
|
if (desired_range > 1.0)
|
||||||
@ -2272,14 +2272,14 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
{
|
{
|
||||||
// desired facing achieved
|
// desired facing achieved
|
||||||
[shipAI message:@"FACING_DESTINATION"];
|
[shipAI message:@"FACING_DESTINATION"];
|
||||||
condition = CONDITION_IDLE;
|
behaviour = BEHAVIOUR_IDLE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
if ((proximity_alert != NO_TARGET)&&(proximity_alert != primaryTarget))
|
if ((proximity_alert != NO_TARGET)&&(proximity_alert != primaryTarget))
|
||||||
[self avoidCollision];
|
[self avoidCollision];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_FORMATION_FORM_UP :
|
case BEHAVIOUR_FORMATION_FORM_UP :
|
||||||
// get updated destination from owner
|
// get updated destination from owner
|
||||||
{
|
{
|
||||||
ShipEntity* leadShip = (ShipEntity *)[universe entityForUniversalID:owner];
|
ShipEntity* leadShip = (ShipEntity *)[universe entityForUniversalID:owner];
|
||||||
@ -2289,12 +2289,12 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
else
|
else
|
||||||
desired_speed = max_flight_speed;
|
desired_speed = max_flight_speed;
|
||||||
}
|
}
|
||||||
case CONDITION_FLY_TO_DESTINATION :
|
case BEHAVIOUR_FLY_TO_DESTINATION :
|
||||||
if (distance < desired_range)// + collision_radius)
|
if (distance < desired_range)// + collision_radius)
|
||||||
{
|
{
|
||||||
// desired range achieved
|
// desired range achieved
|
||||||
[shipAI message:@"DESIRED_RANGE_ACHIEVED"];
|
[shipAI message:@"DESIRED_RANGE_ACHIEVED"];
|
||||||
condition = CONDITION_IDLE;
|
behaviour = BEHAVIOUR_IDLE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
desired_speed = 0.0;
|
desired_speed = 0.0;
|
||||||
}
|
}
|
||||||
@ -2340,13 +2340,13 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
[self avoidCollision];
|
[self avoidCollision];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_FORMATION_BREAK :
|
case BEHAVIOUR_FORMATION_BREAK :
|
||||||
case CONDITION_FLY_FROM_DESTINATION :
|
case BEHAVIOUR_FLY_FROM_DESTINATION :
|
||||||
if (distance > desired_range)
|
if (distance > desired_range)
|
||||||
{
|
{
|
||||||
// desired range achieved
|
// desired range achieved
|
||||||
[shipAI message:@"DESIRED_RANGE_ACHIEVED"];
|
[shipAI message:@"DESIRED_RANGE_ACHIEVED"];
|
||||||
condition = CONDITION_IDLE;
|
behaviour = BEHAVIOUR_IDLE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
desired_speed = 0.0;
|
desired_speed = 0.0;
|
||||||
}
|
}
|
||||||
@ -2363,7 +2363,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
[self avoidCollision];
|
[self avoidCollision];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_AVOID_COLLISION :
|
case BEHAVIOUR_AVOID_COLLISION :
|
||||||
if (distance > desired_range)
|
if (distance > desired_range)
|
||||||
{
|
{
|
||||||
[self resumePostProximityAlert];
|
[self resumePostProximityAlert];
|
||||||
@ -2385,7 +2385,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_TRACK_AS_TURRET :
|
case BEHAVIOUR_TRACK_AS_TURRET :
|
||||||
{
|
{
|
||||||
double aim = [self ballTrackLeadingTarget:delta_t];
|
double aim = [self ballTrackLeadingTarget:delta_t];
|
||||||
ShipEntity* turret_owner = (ShipEntity *)[self owner];
|
ShipEntity* turret_owner = (ShipEntity *)[self owner];
|
||||||
@ -2406,7 +2406,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITION_EXPERIMENTAL :
|
case BEHAVIOUR_EXPERIMENTAL :
|
||||||
{
|
{
|
||||||
double aim = [self ballTrackTarget:delta_t];
|
double aim = [self ballTrackTarget:delta_t];
|
||||||
if (aim > .95)
|
if (aim > .95)
|
||||||
@ -2420,7 +2420,7 @@ BOOL ship_canCollide (ShipEntity* ship)
|
|||||||
//
|
//
|
||||||
// in (almost) every case...
|
// in (almost) every case...
|
||||||
//
|
//
|
||||||
if (condition != CONDITION_TRACK_AS_TURRET)
|
if (behaviour != BEHAVIOUR_TRACK_AS_TURRET)
|
||||||
{
|
{
|
||||||
[self applyRoll:delta_t*flight_roll andClimb:delta_t*flight_pitch];
|
[self applyRoll:delta_t*flight_roll andClimb:delta_t*flight_pitch];
|
||||||
[self applyThrust:delta_t];
|
[self applyThrust:delta_t];
|
||||||
@ -2803,7 +2803,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (condition == CONDITION_TUMBLE) return; //testing
|
if (behaviour == BEHAVIOUR_TUMBLE) return; //testing
|
||||||
|
|
||||||
|
|
||||||
// check for speed
|
// check for speed
|
||||||
@ -2886,7 +2886,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
|
|
||||||
previousCondition = [[NSMutableDictionary alloc] initWithCapacity:16];
|
previousCondition = [[NSMutableDictionary alloc] initWithCapacity:16];
|
||||||
|
|
||||||
[previousCondition setObject:[NSNumber numberWithInt:condition] forKey:@"condition"];
|
[previousCondition setObject:[NSNumber numberWithInt:behaviour] forKey:@"behaviour"];
|
||||||
[previousCondition setObject:[NSNumber numberWithInt:primaryTarget] forKey:@"primaryTarget"];
|
[previousCondition setObject:[NSNumber numberWithInt:primaryTarget] forKey:@"primaryTarget"];
|
||||||
[previousCondition setObject:[NSNumber numberWithFloat:desired_range] forKey:@"desired_range"];
|
[previousCondition setObject:[NSNumber numberWithFloat:desired_range] forKey:@"desired_range"];
|
||||||
[previousCondition setObject:[NSNumber numberWithFloat:desired_speed] forKey:@"desired_speed"];
|
[previousCondition setObject:[NSNumber numberWithFloat:desired_speed] forKey:@"desired_speed"];
|
||||||
@ -2900,7 +2900,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
|
|
||||||
desired_range = prox_ship->collision_radius * PROXIMITY_AVOID_DISTANCE;
|
desired_range = prox_ship->collision_radius * PROXIMITY_AVOID_DISTANCE;
|
||||||
|
|
||||||
condition = CONDITION_AVOID_COLLISION;
|
behaviour = BEHAVIOUR_AVOID_COLLISION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2911,7 +2911,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
|
|
||||||
// NSLog(@"DEBUG ***** proximity alert for %@ %d over", name, universal_id, proximity_alert);
|
// NSLog(@"DEBUG ***** proximity alert for %@ %d over", name, universal_id, proximity_alert);
|
||||||
|
|
||||||
condition = [(NSNumber*)[previousCondition objectForKey:@"condition"] intValue];
|
behaviour = [(NSNumber*)[previousCondition objectForKey:@"behaviour"] intValue];
|
||||||
primaryTarget = [(NSNumber*)[previousCondition objectForKey:@"primaryTarget"] intValue];
|
primaryTarget = [(NSNumber*)[previousCondition objectForKey:@"primaryTarget"] intValue];
|
||||||
desired_range = [(NSNumber*)[previousCondition objectForKey:@"desired_range"] floatValue];
|
desired_range = [(NSNumber*)[previousCondition objectForKey:@"desired_range"] floatValue];
|
||||||
desired_speed = [(NSNumber*)[previousCondition objectForKey:@"desired_speed"] floatValue];
|
desired_speed = [(NSNumber*)[previousCondition objectForKey:@"desired_speed"] floatValue];
|
||||||
@ -2991,7 +2991,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
if (d2 > cr2) // we're okay
|
if (d2 > cr2) // we're okay
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (condition == CONDITION_AVOID_COLLISION) // already avoiding something
|
if (behaviour == BEHAVIOUR_AVOID_COLLISION) // already avoiding something
|
||||||
{
|
{
|
||||||
ShipEntity* prox = (ShipEntity*)[universe entityForUniversalID:proximity_alert];
|
ShipEntity* prox = (ShipEntity*)[universe entityForUniversalID:proximity_alert];
|
||||||
if ((prox)&&(prox != other))
|
if ((prox)&&(prox != other))
|
||||||
@ -3039,12 +3039,12 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
{
|
{
|
||||||
if (primaryTarget == NO_TARGET)
|
if (primaryTarget == NO_TARGET)
|
||||||
return NO;
|
return NO;
|
||||||
if ((condition == CONDITION_AVOID_COLLISION)&&(previousCondition))
|
if ((behaviour == BEHAVIOUR_AVOID_COLLISION)&&(previousCondition))
|
||||||
{
|
{
|
||||||
int old_condition = [(NSNumber*)[previousCondition objectForKey:@"condition"] intValue];
|
int old_behaviour = [(NSNumber*)[previousCondition objectForKey:@"behaviour"] intValue];
|
||||||
return IS_CONDITION_HOSTILE(old_condition);
|
return IS_BEHAVIOUR_HOSTILE(old_behaviour);
|
||||||
}
|
}
|
||||||
return IS_CONDITION_HOSTILE(condition);
|
return IS_BEHAVIOUR_HOSTILE(behaviour);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableArray *) launch_actions
|
- (NSMutableArray *) launch_actions
|
||||||
@ -3607,9 +3607,9 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
// avoid shooting each other
|
// avoid shooting each other
|
||||||
if (([hunter group_id] == group_id)||(iAmTheLaw && uAreTheLaw))
|
if (([hunter group_id] == group_id)||(iAmTheLaw && uAreTheLaw))
|
||||||
{
|
{
|
||||||
if ([hunter condition] == CONDITION_ATTACK_FLY_TO_TARGET) // avoid me please!
|
if ([hunter behaviour] == BEHAVIOUR_ATTACK_FLY_TO_TARGET) // avoid me please!
|
||||||
{
|
{
|
||||||
[hunter setCondition:CONDITION_ATTACK_FLY_FROM_TARGET];
|
[hunter setBehaviour:BEHAVIOUR_ATTACK_FLY_FROM_TARGET];
|
||||||
[hunter setDesiredSpeed:[hunter max_flight_speed]];
|
[hunter setDesiredSpeed:[hunter max_flight_speed]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3644,7 +3644,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
//NSLog(@"Escape Pod launched");
|
//NSLog(@"Escape Pod launched");
|
||||||
[shipAI setStateMachine:@"nullAI.plist"];
|
[shipAI setStateMachine:@"nullAI.plist"];
|
||||||
[shipAI setState:@"GLOBAL"];
|
[shipAI setState:@"GLOBAL"];
|
||||||
condition = CONDITION_IDLE;
|
behaviour = BEHAVIOUR_IDLE;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
[self launchEscapeCapsule];
|
[self launchEscapeCapsule];
|
||||||
[self setScanClass: CLASS_CARGO]; // we're unmanned now!
|
[self setScanClass: CLASS_CARGO]; // we're unmanned now!
|
||||||
@ -4132,16 +4132,16 @@ Vector randomPositionInBoundingBox(BoundingBox bb)
|
|||||||
return primaryTarget;
|
return primaryTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int) condition
|
- (int) behaviour
|
||||||
{
|
{
|
||||||
return condition;
|
return behaviour;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setCondition:(int) cond
|
- (void) setBehaviour:(int) cond
|
||||||
{
|
{
|
||||||
if (cond !=condition)
|
if (cond !=behaviour)
|
||||||
frustration = 0.0; // change is a GOOD thing
|
frustration = 0.0; // change is a GOOD thing
|
||||||
condition = cond;
|
behaviour = cond;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (Vector) destination
|
- (Vector) destination
|
||||||
@ -5655,7 +5655,7 @@ Vector randomPositionInBoundingBox(BoundingBox bb)
|
|||||||
[bomb setScanClass: CLASS_MINE]; // TODO should be CLASS_ENERGY_BOMB
|
[bomb setScanClass: CLASS_MINE]; // TODO should be CLASS_ENERGY_BOMB
|
||||||
[bomb setStatus: STATUS_IN_FLIGHT];
|
[bomb setStatus: STATUS_IN_FLIGHT];
|
||||||
[bomb setEnergy: 5.0]; // 5 second countdown
|
[bomb setEnergy: 5.0]; // 5 second countdown
|
||||||
[bomb setCondition: CONDITION_ENERGY_BOMB_COUNTDOWN];
|
[bomb setBehaviour: BEHAVIOUR_ENERGY_BOMB_COUNTDOWN];
|
||||||
[bomb setOwner: self];
|
[bomb setOwner: self];
|
||||||
[universe addEntity:bomb];
|
[universe addEntity:bomb];
|
||||||
[[bomb getAI] setState:@"GLOBAL"];
|
[[bomb getAI] setState:@"GLOBAL"];
|
||||||
@ -5663,7 +5663,7 @@ Vector randomPositionInBoundingBox(BoundingBox bb)
|
|||||||
if (self != [universe entityZero]) // get the heck out of here
|
if (self != [universe entityZero]) // get the heck out of here
|
||||||
{
|
{
|
||||||
[self addTarget:bomb];
|
[self addTarget:bomb];
|
||||||
condition = CONDITION_FLEE_TARGET;
|
behaviour = BEHAVIOUR_FLEE_TARGET;
|
||||||
frustration = 0.0;
|
frustration = 0.0;
|
||||||
}
|
}
|
||||||
return YES;
|
return YES;
|
||||||
@ -6061,8 +6061,8 @@ Vector randomPositionInBoundingBox(BoundingBox bb)
|
|||||||
- (void) getTractoredBy:(ShipEntity *)other
|
- (void) getTractoredBy:(ShipEntity *)other
|
||||||
{
|
{
|
||||||
desired_speed = 0.0;
|
desired_speed = 0.0;
|
||||||
[self setAITo:@"nullAI.plist"]; // prevent AI from changing status or condition
|
[self setAITo:@"nullAI.plist"]; // prevent AI from changing status or behaviour
|
||||||
condition = CONDITION_TRACTORED;
|
behaviour = BEHAVIOUR_TRACTORED;
|
||||||
status = STATUS_BEING_SCOOPED;
|
status = STATUS_BEING_SCOOPED;
|
||||||
[self addTarget: other];
|
[self addTarget: other];
|
||||||
[self setOwner: other];
|
[self setOwner: other];
|
||||||
@ -6802,7 +6802,7 @@ inline BOOL pairOK(NSString* my_role, NSString* their_role)
|
|||||||
|
|
||||||
- (BOOL) isMining
|
- (BOOL) isMining
|
||||||
{
|
{
|
||||||
return ((condition == CONDITION_ATTACK_MINING_TARGET)&&(forward_weapon_type == WEAPON_MINING_LASER));
|
return ((behaviour == BEHAVIOUR_ATTACK_MINING_TARGET)&&(forward_weapon_type == WEAPON_MINING_LASER));
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setNumberOfMinedRocks:(int) value
|
- (void) setNumberOfMinedRocks:(int) value
|
||||||
|
@ -1256,12 +1256,12 @@ NSDictionary* instructions(int station_id, Vector coords, float speed, float ran
|
|||||||
{
|
{
|
||||||
if (primaryTarget == NO_TARGET)
|
if (primaryTarget == NO_TARGET)
|
||||||
return NO;
|
return NO;
|
||||||
if ((condition == CONDITION_AVOID_COLLISION)&&(previousCondition))
|
if ((behaviour == BEHAVIOUR_AVOID_COLLISION)&&(previousCondition))
|
||||||
{
|
{
|
||||||
int old_condition = [(NSNumber*)[previousCondition objectForKey:@"condition"] intValue];
|
int old_behaviour = [(NSNumber*)[previousCondition objectForKey:@"behaviour"] intValue];
|
||||||
return IS_CONDITION_HOSTILE(old_condition);
|
return IS_BEHAVIOUR_HOSTILE(old_behaviour);
|
||||||
}
|
}
|
||||||
return IS_CONDITION_HOSTILE(condition)||(alert_level == STATION_ALERT_LEVEL_YELLOW)||(alert_level == STATION_ALERT_LEVEL_RED);
|
return IS_BEHAVIOUR_HOSTILE(behaviour)||(alert_level == STATION_ALERT_LEVEL_YELLOW)||(alert_level == STATION_ALERT_LEVEL_RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////// extra AI routines
|
//////////////////////////////////////////////// extra AI routines
|
||||||
|
Loading…
x
Reference in New Issue
Block a user