- Added a JS script to pilots. On unloading at a station, the event "unloadCharacter()" is send to the pilot-script.
- Characters in character.plist now always do a basic setup. That way there is always a valid pilot when not using all character keys. This allows for partial randomisation of pilots for the unused keys. - Added a JS script for the constrictor-pilot. - Added default pilots to be used by oxps. git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3841 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
4fe9f0227e
commit
b8359a110b
@ -4,36 +4,41 @@
|
||||
"random_seed" = "1 3 5 7 11 13"; // fix the name and details, but use the key to keep it secret
|
||||
bounty = 1000; // not actually used, we do the reward in the script
|
||||
origin = 7; // system number seven (Lave in Galaxy 0)
|
||||
"script_actions" =
|
||||
(
|
||||
/*
|
||||
check if docked
|
||||
print congratulatory message from the Imperial Navy
|
||||
award a special bounty
|
||||
*/
|
||||
{
|
||||
conditions =
|
||||
(
|
||||
"status_string equal STATUS_DOCKED"
|
||||
);
|
||||
do =
|
||||
(
|
||||
{
|
||||
conditions =
|
||||
(
|
||||
"gui_screen_string notequal GUI_SCREEN_MISSION"
|
||||
);
|
||||
do = (
|
||||
"setMissionMusic: none",
|
||||
"setMissionImage: none",
|
||||
"showShipModel: none",
|
||||
"setGuiToMissionScreen"
|
||||
);
|
||||
},
|
||||
"awardCredits: 1000",
|
||||
"addMissionText: constrictor_hunt_thief_captured"
|
||||
);
|
||||
}
|
||||
);
|
||||
script = "oolite-constrictor-pilot.js";
|
||||
};
|
||||
|
||||
/*
|
||||
For ships added in custom roles, Oolite will always add a randomised pilot.
|
||||
When you want control over the bounty and insurance of the pilot, you can define
|
||||
a specific pilot for your ship by using one of the following character keys as pilot
|
||||
in shipdata.plist. e.g.: "pilot" = "oolite-trader";
|
||||
*/
|
||||
"oolite-hunter" =
|
||||
{
|
||||
role = "hunter";
|
||||
};
|
||||
"oolite-miner" =
|
||||
{
|
||||
role = "miner";
|
||||
};
|
||||
"oolite-passenger" =
|
||||
{
|
||||
role = "passenger";
|
||||
};
|
||||
"oolite-pirate" =
|
||||
{
|
||||
role = "pirate";
|
||||
};
|
||||
"oolite-police" =
|
||||
{
|
||||
role = "police";
|
||||
};
|
||||
"oolite-slave" =
|
||||
{
|
||||
role = "slave";
|
||||
};
|
||||
"oolite-trader" =
|
||||
{
|
||||
role = "trader";
|
||||
};
|
||||
}
|
||||
|
45
Resources/Scripts/oolite-constrictor-pilot.js
Normal file
45
Resources/Scripts/oolite-constrictor-pilot.js
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
|
||||
oolite-constrictor-pilot.js
|
||||
|
||||
Character script for Constrictor Hunt mission.
|
||||
|
||||
|
||||
Oolite
|
||||
Copyright © 2004-2010 Giles C Williams and contributors
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
this.name = "oolite-constrictor-pilot";
|
||||
this.author = "Eric Walch";
|
||||
this.copyright = "© 2008-2010 the Oolite team.";
|
||||
this.version = "1.75";
|
||||
|
||||
|
||||
this.unloadCharacter = function ()
|
||||
{
|
||||
/*
|
||||
print congratulatory message from the Imperial Navy
|
||||
award a special bounty
|
||||
*/
|
||||
player.addMessageToArrivalReport(expandMissionText("constrictor_hunt_thief_captured"));
|
||||
player.credits += 1000;
|
||||
|
||||
}
|
@ -91,7 +91,11 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
||||
OOCharacter* rescuee = (OOCharacter*)[rescuees objectAtIndex: i];
|
||||
if ([rescuee script])
|
||||
{
|
||||
[self runUnsanitizedScriptActions:[rescuee script]
|
||||
[rescuee doScriptEvent:@"unloadCharacter"];
|
||||
}
|
||||
else if ([rescuee legacyScript])
|
||||
{
|
||||
[self runUnsanitizedScriptActions:[rescuee legacyScript]
|
||||
allowingAIMethods:YES
|
||||
withContextName:[NSString stringWithFormat:@"<character \"%@\" script>", [rescuee name]]
|
||||
forTarget:nil];
|
||||
|
@ -27,6 +27,7 @@ MA 02110-1301, USA.
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "OOTypes.h"
|
||||
#import "legacy_random.h"
|
||||
#import "OOScript.h"
|
||||
|
||||
#ifdef OO_BRAIN_AI
|
||||
@class OOBrain;
|
||||
@ -47,6 +48,7 @@ MA 02110-1301, USA.
|
||||
#endif
|
||||
|
||||
NSArray *script_actions;
|
||||
OOScript *_script;
|
||||
}
|
||||
|
||||
- (id) initWithGenSeed:(Random_Seed)g_seed andOriginalSystemSeed:(Random_Seed)s_seed;
|
||||
@ -83,8 +85,11 @@ MA 02110-1301, USA.
|
||||
- (OOCreditsQuantity) insuranceCredits;
|
||||
- (void) setInsuranceCredits:(OOCreditsQuantity)value;
|
||||
|
||||
- (NSArray *) script;
|
||||
- (void) setScript:(NSArray *)some_actions;
|
||||
- (NSArray *) legacyScript;
|
||||
- (void) setLegacyScript:(NSArray *)some_actions;
|
||||
- (OOScript *)script;
|
||||
- (void) setCharacterScript:(NSString *)script_name;
|
||||
- (void) doScriptEvent:(NSString *)message;
|
||||
|
||||
#ifdef OO_BRAIN_AI
|
||||
- (OOBrain *) brain;
|
||||
|
@ -64,7 +64,7 @@ MA 02110-1301, USA.
|
||||
#ifdef OO_BRAIN_AI
|
||||
[brain release];
|
||||
#endif
|
||||
|
||||
DESTROY(_script);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@ -239,7 +239,6 @@ MA 02110-1301, USA.
|
||||
BOOL specialSetUpDone = NO;
|
||||
|
||||
role = [role lowercaseString];
|
||||
|
||||
if ([role isEqual:@"pirate"])
|
||||
{
|
||||
// determine legalStatus for a completely random character
|
||||
@ -255,7 +254,7 @@ MA 02110-1301, USA.
|
||||
specialSetUpDone = YES;
|
||||
}
|
||||
|
||||
if ([role isEqual:@"trader"])
|
||||
else if ([role isEqual:@"trader"])
|
||||
{
|
||||
[self setLegalStatus: 0]; // clean
|
||||
|
||||
@ -277,7 +276,7 @@ MA 02110-1301, USA.
|
||||
specialSetUpDone = YES;
|
||||
}
|
||||
|
||||
if ([role isEqual:@"hunter"])
|
||||
else if ([role isEqual:@"hunter"])
|
||||
{
|
||||
[self setLegalStatus:0]; // clean
|
||||
int insurance_index = gen_rnd_number() & 0x03;
|
||||
@ -286,21 +285,21 @@ MA 02110-1301, USA.
|
||||
specialSetUpDone = YES;
|
||||
}
|
||||
|
||||
if ([role isEqual:@"police"])
|
||||
else if ([role isEqual:@"police"])
|
||||
{
|
||||
[self setLegalStatus:0]; // clean
|
||||
[self setInsuranceCredits:125];
|
||||
specialSetUpDone = YES;
|
||||
}
|
||||
|
||||
if ([role isEqual:@"miner"])
|
||||
else if ([role isEqual:@"miner"])
|
||||
{
|
||||
[self setLegalStatus:0]; // clean
|
||||
[self setInsuranceCredits:25];
|
||||
specialSetUpDone = YES;
|
||||
}
|
||||
|
||||
if ([role isEqual:@"passenger"])
|
||||
else if ([role isEqual:@"passenger"])
|
||||
{
|
||||
[self setLegalStatus:0]; // clean
|
||||
int insurance_index = gen_rnd_number() & 0x03;
|
||||
@ -321,7 +320,7 @@ MA 02110-1301, USA.
|
||||
specialSetUpDone = YES;
|
||||
}
|
||||
|
||||
if ([role isEqual:@"slave"])
|
||||
else if ([role isEqual:@"slave"])
|
||||
{
|
||||
[self setLegalStatus:0]; // clean
|
||||
[self setInsuranceCredits:0];
|
||||
@ -377,7 +376,7 @@ MA 02110-1301, USA.
|
||||
}
|
||||
|
||||
|
||||
- (NSArray *)script
|
||||
- (NSArray *)legacyScript
|
||||
{
|
||||
return script_actions;
|
||||
}
|
||||
@ -450,16 +449,41 @@ MA 02110-1301, USA.
|
||||
}
|
||||
|
||||
|
||||
- (void)setScript:(NSArray *)some_actions
|
||||
- (void)setLegacyScript:(NSArray *)some_actions
|
||||
{
|
||||
[script_actions autorelease];
|
||||
script_actions = [some_actions copy];
|
||||
}
|
||||
|
||||
|
||||
- (OOScript *)script;
|
||||
{
|
||||
return _script;
|
||||
}
|
||||
|
||||
- (void) setCharacterScript:(NSString *)script_name
|
||||
{
|
||||
NSMutableDictionary *properties = nil;
|
||||
|
||||
properties = [NSMutableDictionary dictionary];
|
||||
[properties setObject:self forKey:@"character"];
|
||||
|
||||
[_script autorelease];
|
||||
_script = [OOScript JSScriptFromFileNamed:script_name properties:properties];
|
||||
|
||||
[_script retain];
|
||||
}
|
||||
|
||||
|
||||
- (void) doScriptEvent:(NSString *)message
|
||||
{
|
||||
[_script doEvent:message withArguments:nil];
|
||||
}
|
||||
|
||||
- (void) setCharacterFromDictionary:(NSDictionary *) dict
|
||||
{
|
||||
id origin = nil;
|
||||
Random_Seed g_seed = kNilRandomSeed;
|
||||
|
||||
origin = [dict objectForKey:@"origin"];
|
||||
if ([origin isKindOfClass:[NSNumber class]] ||
|
||||
@ -474,19 +498,35 @@ MA 02110-1301, USA.
|
||||
if (is_nil_seed(seed))
|
||||
{
|
||||
OOLogERR(@"character.load.unknownSystem", @"could not find a system named '%@' in this galaxy.", origin);
|
||||
[self setOriginSystemSeed:[UNIVERSE systemSeedForSystemNumber:ranrot_rand() & 0xff]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setOriginSystemSeed:seed];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// no origin defined, select one at random.
|
||||
[self setOriginSystemSeed:[UNIVERSE systemSeedForSystemNumber:ranrot_rand() & 0xff]];
|
||||
}
|
||||
|
||||
|
||||
if ([dict objectForKey:@"random_seed"])
|
||||
{
|
||||
Random_Seed g_seed = RandomSeedFromString([dict oo_stringForKey:@"random_seed"]);
|
||||
[self setGenSeed: g_seed];
|
||||
[self basicSetUp];
|
||||
g_seed = RandomSeedFromString([dict oo_stringForKey:@"random_seed"]); // returns kNilRandomSeed on failure
|
||||
}
|
||||
else
|
||||
{
|
||||
g_seed.a = (ranrot_rand() & 0xff);
|
||||
g_seed.b = (ranrot_rand() & 0xff);
|
||||
g_seed.c = (ranrot_rand() & 0xff);
|
||||
g_seed.d = (ranrot_rand() & 0xff);
|
||||
g_seed.e = (ranrot_rand() & 0xff);
|
||||
g_seed.f = (ranrot_rand() & 0xff);
|
||||
}
|
||||
[self setGenSeed: g_seed];
|
||||
[self basicSetUp];
|
||||
|
||||
if ([dict oo_stringForKey:@"role"]) [self castInRole:[dict oo_stringForKey:@"role"]];
|
||||
if ([dict oo_stringForKey:@"name"]) [self setName:[dict oo_stringForKey:@"name"]];
|
||||
@ -495,7 +535,9 @@ MA 02110-1301, USA.
|
||||
if ([dict objectForKey:@"legal_status"]) [self setLegalStatus:[dict oo_intForKey:@"legal_status"]];
|
||||
if ([dict objectForKey:@"bounty"]) [self setLegalStatus:[dict oo_intForKey:@"bounty"]];
|
||||
if ([dict objectForKey:@"insurance"]) [self setInsuranceCredits:[dict oo_unsignedLongLongForKey:@"insurance"]];
|
||||
if ([dict oo_arrayForKey:@"script_actions"]) [self setScript:[dict oo_arrayForKey:@"script_actions"]];
|
||||
if ([dict oo_stringForKey:@"script"]) [self setCharacterScript:[dict oo_stringForKey:@"script"]];
|
||||
if ([dict oo_arrayForKey:@"script_actions"]) [self setLegacyScript:[dict oo_arrayForKey:@"script_actions"]];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user