Add support for variable ranged turrets

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3834 127b21dd-08f5-0310-b4b7-95ae10353056
master
cmdrjames 2010-11-22 23:28:59 +00:00
parent bb7c5495a1
commit 3dec932e3f
5 changed files with 41 additions and 13 deletions

View File

@ -200,6 +200,7 @@
"forward_weapon_type",
"aft_weapon_type",
"weapon_energy",
"weapon_range", //added 2010-10-31 by cmdr_james for variable range plasma turrets
"scanner_range",
"fuel_charge_rate",
"missiles",

View File

@ -20,6 +20,7 @@
forward_weapon_type = "$weaponType";
aft_weapon_type = "$weaponType";
weapon_energy = "positiveFloat";
weapon_range = "positiveFloat";
scanner_range = "positiveFloat";
fuel_charge_rate = "positiveFloat";
missiles = "positiveInteger";

View File

@ -624,6 +624,10 @@ MA 02110-1301, USA.
- (void)setThrustForDemo:(float)factor;
/*
Sets the bounty on this ship to amount.
Does not check to see if the ship is allowed to have a bounty, for example if it is police.
*/
- (void) setBounty:(OOCreditsQuantity) amount;
- (OOCreditsQuantity) bounty;
@ -817,6 +821,10 @@ BOOL class_masslocks(int some_class);
- (void) leaveWitchspace;
- (void) witchspaceLeavingEffects;
/*
Mark this ship as an offender, this is different to setBounty as some ships such as police
are not markable. The final bounty may not be equal to existing bounty plus offence_value.
*/
- (void) markAsOffender:(int)offence_value;
- (void) switchLightsOn;

View File

@ -751,6 +751,7 @@ static GLfloat calcFuelChargeRate (GLfloat my_mass, GLfloat base_mass)
[subentity setBehaviour:BEHAVIOUR_TRACK_AS_TURRET];
[subentity setWeaponRechargeRate:[subentDict oo_floatForKey:@"fire_rate" defaultValue:TURRET_SHOT_FREQUENCY]];
[subentity setWeaponEnergy:[subentDict oo_floatForKey:@"weapon_energy" defaultValue:TURRET_TYPICAL_ENERGY]];
[subentity setWeaponRange:[subentDict oo_floatForKey:@"weapon_range" defaultValue:TURRET_SHOT_RANGE]];
[subentity setStatus: STATUS_ACTIVE];
}
else
@ -5310,13 +5311,27 @@ NSComparisonResult ComparePlanetsBySurfaceDistance(id i1, id i2, void* context)
- (void) setBounty:(OOCreditsQuantity) amount
{
bounty = amount;
if ([self isSubEntity])
{
[[self parentEntity] setBounty:amount];
}
else
{
bounty = amount;
}
}
- (OOCreditsQuantity) bounty
{
return bounty;
if ([self isSubEntity])
{
return [[self parentEntity] bounty];
}
else
{
return bounty;
}
}
@ -5326,7 +5341,7 @@ NSComparisonResult ComparePlanetsBySurfaceDistance(id i1, id i2, void* context)
return 5 * collision_radius;
if (scanClass == CLASS_ROCK)
return 0;
return bounty;
return [self bounty];
}
@ -5661,7 +5676,10 @@ NSComparisonResult ComparePlanetsBySurfaceDistance(id i1, id i2, void* context)
- (void) setHulk:(BOOL)isNowHulk
{
isHulk = isNowHulk;
if (![self isSubEntity])
{
isHulk = isNowHulk;
}
}
- (void) getDestroyedBy:(Entity *)whom context:(NSString *)context
@ -7404,7 +7422,7 @@ BOOL class_masslocks(int some_class)
{
if ([self shotTime] < weapon_recharge_rate)
return NO;
if (range > TURRET_SHOT_RANGE * 1.01) // 1% more than max range - open up just slightly early
if (range > weaponRange * 1.01) // 1% more than max range - open up just slightly early
return NO;
Vector origin = position;
@ -7429,7 +7447,7 @@ BOOL class_masslocks(int some_class)
OOPlasmaShotEntity *shot = [[OOPlasmaShotEntity alloc] initWithPosition:origin
velocity:vel
energy:weapon_damage
duration:TURRET_SHOT_DURATION
duration:weaponRange/TURRET_SHOT_SPEED
color:laser_color];
[shot autorelease];
@ -8783,7 +8801,7 @@ BOOL class_masslocks(int some_class)
return OK;
}
if (EXPECT([self launchEscapeCapsule] != NO_TARGET)) // -launchEscapeCapsule takes care of everyhing for the player
if (EXPECT([self launchEscapeCapsule] != NO_TARGET)) // -launchEscapeCapsule takes care of everything for the player
{
if (![self isPlayer])
{
@ -8797,8 +8815,7 @@ BOOL class_masslocks(int some_class)
desired_speed = 0.0;
//[self setHulk:YES]; // already set inside launchEscapeCapsule
if ([self group]) [self setGroup:nil]; // remove self from group.
if ([self owner]) [self setOwner:nil];
if (![self isSubEntity] && [self owner]) [self setOwner:nil]; //unset owner, but not if we are a subent
if ([self hasEscorts])
{
OOShipGroup *escortGroup = [self escortGroup];
@ -9008,7 +9025,11 @@ BOOL class_masslocks(int some_class)
- (void) markAsOffender:(int)offence_value
{
if (scanClass != CLASS_POLICE && ![self isCloaked]) bounty |= offence_value;
if (![self isPolice] && ![self isCloaked] && self != [UNIVERSE station])
{
if ([self isSubEntity]) [[self parentEntity]markAsOffender:offence_value];
else bounty |= offence_value;
}
}

View File

@ -6084,7 +6084,6 @@ static NSDictionary *sCachedSystemData = nil;
}
}
[systemsToCheck release];
systemsToCheck = nil;
return result;
}
@ -7167,7 +7166,6 @@ double estimatedTimeForJourney(double distance, int hops)
if ([extras containsObject:key])
{
[options removeObject:equipmentKey];
eqPrice = 0;
break;
}
}
@ -7180,7 +7178,6 @@ double estimatedTimeForJourney(double distance, int hops)
if ([extras containsObject:@"EQ_ENERGY_UNIT"])
{
[options removeObject:equipmentKey];
eqPrice = 0;
break;
}
}