33@interface OOCharacter (Private)
36- (void)setCharacterFromDictionary:(NSDictionary*)dict;
58 [_shortDescription release];
59 [_scriptActions release];
67 if ((
self = [super init])) {
69 _genSeed = characterSeed;
70 _originSystem = system;
77- (id)initWithRole:(NSString*)role andOriginalSystem:(
OOSystemID)system
82 if ((
self = [
self initWithGenSeed:seed andOriginalSystem:system])) {
91 return [[[
self alloc] initWithRole:role andOriginalSystem:system] autorelease];
105 OOCharacter* character = [[[
OOCharacter alloc] initWithGenSeed:seed andOriginalSystem:system] autorelease];
122 NSDictionary* originInfo = [UNIVERSE generateSystemData:[
self planetIDOfOrigin]];
136 NSString* speciesString =
nil;
138 speciesString = [UNIVERSE getSystemInhabitants:[
self genSeed].e plural:NO];
140 speciesString = [UNIVERSE getSystemInhabitants:[
self planetIDOfOrigin] plural:NO];
142 if (![[
UNIVERSE descriptions] oo_boolForKey:
@"lowercase_ignore"]) {
159 NSDictionary* originInfo = [UNIVERSE generateSystemData:[
self planetIDOfOrigin]];
160 NSString* planet = [
originInfo oo_stringForKey:KEY_NAME];
162 int criminalTendency = government ^ 0x07;
169 NSString* genName =
nil;
170 if ([
species hasPrefix:
@"human"]) {
171 genName = [
NSString stringWithFormat:@"%@ %@", OOExpandWithSeed(genSeed, @"%R"), OOExpandKeyWithSeed(genSeed, @"nom")];
178 genName = [
NSString stringWithFormat:@"%@ %@", OOExpandWithSeed(genSeed, @"%R"), OOExpandWithSeed(genSeed, @"%R")];
182 [
self setShortDescription:OOExpandKeyWithSeed(genSeed, @"character-generic-description", species, planet)];
187 while (((
gen_rnd_number() & 0xf) < criminalTendency) && (legalIndex < 3)) {
190 if (legalIndex == 3) {
192 [
self setLegalStatus:criminalTendency + criminalTendency * (gen_rnd_number() & 0x03) + (gen_rnd_number() & gen_rnd_number() & 0x7f)];
200 if (legalIndex == 0) {
202 switch (insuranceIndex) {
219- (BOOL)castInRole:(NSString*)role
221 BOOL specialSetUpDone = NO;
223 role = [
role lowercaseString];
224 if ([role hasPrefix:
@"pirate"]) {
230 specialSetUpDone = YES;
231 }
else if ([role hasPrefix:
@"trader"]) {
235 switch (insuranceIndex) {
248 specialSetUpDone = YES;
249 }
else if ([role hasPrefix:
@"hunter"]) {
252 if (insuranceIndex == 3)
254 specialSetUpDone = YES;
255 }
else if ([role hasPrefix:
@"police"]) {
258 specialSetUpDone = YES;
259 }
else if ([role isEqual:
@"miner"]) {
262 specialSetUpDone = YES;
263 }
else if ([role isEqual:
@"passenger"]) {
266 switch (insuranceIndex) {
279 specialSetUpDone = YES;
280 }
else if ([role isEqual:
@"slave"]) {
283 specialSetUpDone = YES;
284 }
else if ([role isEqual:
@"thargoid"]) {
287 [
self setName:DESC(@"character-thargoid-name")];
289 specialSetUpDone = YES;
294 return specialSetUpDone;
330 [
self name], @"name",
339- (void)setName:(NSString*)value
345- (void)setShortDescription:(NSString*)value
347 [_shortDescription autorelease];
353 _originSystem = value;
361- (void)setLegalStatus:(
int)value
371- (void)setLegacyScript:(NSArray*)some_actions
373 [_scriptActions autorelease];
382- (void)setCharacterScript:(NSString*)scriptName
397- (void)setCharacterFromDictionary:(NSDictionary*)dict
403 if ([
origin isKindOfClass:[NSNumber
class]] || ([
origin respondsToSelector:
@selector(intValue)] && ([
origin intValue] != 0 || [
origin isEqual:
@"0"]))) {
406 }
else if ([
origin isKindOfClass:[NSString
class]]) {
407 OOSystemID sys = [UNIVERSE findSystemFromName:origin];
409 OOLogERR(
@"character.load.unknownSystem",
@"could not find a system named '%@' in this galaxy.",
origin);
419 if ([dict objectForKey:
@"random_seed"]) {
432 if ([dict oo_stringForKey:
@"role"])
434 if ([dict oo_stringForKey:
@"name"])
436 if ([dict oo_stringForKey:
@"short_description"])
438 if ([dict objectForKey:
@"legal_status"])
440 if ([dict objectForKey:
@"bounty"])
442 if ([dict objectForKey:
@"insurance"])
444 if ([dict oo_stringForKey:
@"script"])
446 if ([dict oo_arrayForKey:
@"script_actions"])
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)
#define OOLogERR(class, format,...)
Random_Seed RandomSeedFromString(NSString *abcdefString)
uint64_t OOCreditsQuantity
void setGenSeed:(Random_Seed value)
OOSystemID planetIDOfOrigin()
void setCharacterScript:(NSString *scriptName)
void setLegacyScript:(NSArray *scriptActions)
BOOL castInRole:(NSString *role)
OOCreditsQuantity insuranceCredits()
OOCreditsQuantity _insuranceCredits
NSString * planetOfOrigin()
void setName:(NSString *value)
void setLegalStatus:(int value)
void setOriginSystem:(OOSystemID value)
void setInsuranceCredits:(OOCreditsQuantity value)
NSDictionary * infoForScripting()
void setCharacterFromDictionary:(NSDictionary *dict)
void setShortDescription:(NSString *value)
NSString * shortDescription()
NSString * oo_jsClassName()
NSString * _shortDescription
NSString * descriptionComponents()
BOOL callMethod:inContext:withArguments:count:result:(jsid methodID,[inContext] JSContext *context,[withArguments] jsval *argv,[count] intN argc,[result] jsval *outResult)
id jsScriptFromFileNamed:properties:(NSString *fileName,[properties] NSDictionary *properties)
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
void make_pseudo_random_seed(Random_Seed *seed_ptr)
RANROTSeed RANROTGetFullSeed(void)
void seed_RNG_only_for_planet_description(Random_Seed s_seed)
void setRandomSeed(RNG_Seed a_seed)
RNG_Seed currentRandomSeed(void)
void RANROTSetFullSeed(RANROTSeed seed)
void seed_for_planet_description(Random_Seed s_seed)