NPC ship Q-bombs added with has_energy_bomb are now represented as EQ_QC_MINE rather than EQ_ENERGY_BOMB. This change should also make NPCs able to use Q-bombs added through scripts.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@4491 127b21dd-08f5-0310-b4b7-95ae10353056
master
Jens Ayton 2011-03-25 18:04:33 +00:00
parent 5e5ff684ff
commit 3b5e5cb2e3
5 changed files with 39 additions and 13 deletions

View File

@ -131,7 +131,7 @@
max_police = "positiveInteger";
equipment_price_factor = "positiveFloat";
requires_docking_clearance = "boolean";
tunnel_corners= "positiveInteger";
tunnel_corners = "positiveInteger";
tunnel_start_angle = "float";
tunnel_aspect_ratio = "positiveFloat";
market = "string";

View File

@ -676,6 +676,8 @@ typedef enum
- (BOOL) fireMainWeapon;
- (OOWeaponType) weaponForView:(OOViewID)view;
- (BOOL) hasEnergyBomb;
- (void) rotateCargo;
- (BOOL) hasSufficientFuelForJump;

View File

@ -556,11 +556,11 @@ static GLfloat sBaseMass = 0.0;
// Deprecated equipment flags. New equipment shouldn't be added here (it'll be handled by the extra_equipment dictionary).
[result oo_setBool:[self hasDockingComputer] forKey:@"has_docking_computer"];
[result oo_setBool:[self hasGalacticHyperdrive] forKey:@"has_galactic_hyperdrive"];
[result oo_setBool:[self hasGalacticHyperdrive] forKey:@"has_galactic_hyperdrive"];
[result oo_setBool:[self hasEscapePod] forKey:@"has_escape_pod"];
[result oo_setBool:[self hasECM] forKey:@"has_ecm"];
[result oo_setBool:[self hasScoop] forKey:@"has_scoop"];
[result oo_setBool:[self hasEnergyBomb] forKey:@"has_energy_bomb"];
[result oo_setBool:[self hasEnergyBomb] forKey:@"has_energy_bomb"];
[result oo_setBool:[self hasFuelInjection] forKey:@"has_fuel_injection"];
if ([self hasEquipmentItem:@"EQ_NAVAL_ENERGY_UNIT"])
@ -3919,6 +3919,12 @@ static bool minShieldLevelPercentageInitialised = false;
}
- (BOOL) hasEnergyBomb
{
return [self hasEquipmentItem:@"EQ_ENERGY_BOMB"];
}
- (void) takeEnergyDamage:(double)amount from:(Entity *)ent becauseOf:(Entity *)other
{
Vector rel_pos;

View File

@ -539,7 +539,7 @@ typedef enum
- (BOOL) hasMilitaryShieldEnhancer;
- (BOOL) hasHeatShield;
- (BOOL) hasFuelInjection;
- (BOOL) hasEnergyBomb;
- (BOOL) hasCascadeMine;
- (BOOL) hasEscapePod;
- (BOOL) hasDockingComputer;
- (BOOL) hasGalacticHyperdrive;
@ -865,7 +865,7 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
- (void) cascadeIfAppropriateWithDamageAmount:(double)amount cascadeOwner:(Entity *)owner;
- (BOOL) activateCloakingDevice;
- (void) deactivateCloakingDevice;
- (BOOL) launchEnergyBomb;
- (BOOL) launchCascadeMine;
- (OOUniversalID) launchEscapeCapsule;
- (OOCargoType) dumpCargo;
- (ShipEntity *) dumpCargoItem;

View File

@ -276,8 +276,26 @@ static ShipEntity *doOctreesCollide(ShipEntity *prime, ShipEntity *other);
if ([shipDict oo_fuzzyBooleanForKey:@"has_ecm"]) [self addEquipmentItem:@"EQ_ECM"];
if ([shipDict oo_fuzzyBooleanForKey:@"has_scoop"]) [self addEquipmentItem:@"EQ_FUEL_SCOOPS"];
if ([shipDict oo_fuzzyBooleanForKey:@"has_escape_pod"]) [self addEquipmentItem:@"EQ_ESCAPE_POD"];
if ([shipDict oo_fuzzyBooleanForKey:@"has_energy_bomb"]) [self addEquipmentItem:@"EQ_ENERGY_BOMB"];
if ([shipDict oo_fuzzyBooleanForKey:@"has_cloaking_device"]) [self addEquipmentItem:@"EQ_CLOAKING_DEVICE"];
if ([shipDict oo_floatForKey:@"has_energy_bomb"] > 0)
{
/* NOTE: has_energy_bomb actually refers to QC mines.
max_missiles for NPCs is a newish addition, and ships have
traditionally not needed to reserve a slot for a Q-mine added this
way. If has_energy_bomb is possible, and max_missiles is not
explicit, we add an extra missile slot to compensate.
-- Ahruman 2011-03-25
*/
if (max_missiles == missiles && max_missiles < SHIPENTITY_MAX_MISSILES && [shipDict objectForKey:@"max_missiles"] == nil)
{
max_missiles++;
}
if ([shipDict oo_fuzzyBooleanForKey:@"has_energy_bomb"])
{
[self addEquipmentItem:@"EQ_QC_MINE"];
}
}
if (![UNIVERSE strict])
{
// These items are not available in strict mode.
@ -2881,9 +2899,9 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
}
- (BOOL) hasEnergyBomb
- (BOOL) hasCascadeMine
{
return [self hasEquipmentItem:@"EQ_ENERGY_BOMB"];
return [self hasEquipmentItem:@"EQ_QC_MINE" includeWeapons:YES];
}
@ -3595,12 +3613,12 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
int rhs = 3.2 / delta_t;
if (rhs) missile_chance = 1 + (ranrot_rand() % rhs);
if (([self hasEnergyBomb]) && (range < 10000.0) && canBurn)
if (([self hasCascadeMine]) && (range < 10000.0) && canBurn)
{
float qbomb_chance = 0.01 * delta_t;
if (randf() < qbomb_chance)
{
[self launchEnergyBomb];
[self launchCascadeMine];
}
}
@ -8040,14 +8058,14 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
}
- (BOOL) launchEnergyBomb
- (BOOL) launchCascadeMine
{
if (![self hasEnergyBomb]) return NO;
if (![self hasCascadeMine]) return NO;
[self setSpeed: maxFlightSpeed + 300];
ShipEntity* bomb = [UNIVERSE newShipWithRole:@"energy-bomb"];
if (bomb == nil) return NO;
[self removeEquipmentItem:@"EQ_ENERGY_BOMB"];
[self removeEquipmentItem:@"EQ_QC_MINE"];
double start = collision_radius + bomb->collision_radius;
Quaternion random_direction;