34@interface OOCharacter (Private)
37- (void) setCharacterFromDictionary:(NSDictionary *)dict;
62 [_shortDescription release];
63 [_scriptActions release];
72 if ((
self = [super init]))
75 _genSeed = characterSeed;
76 _originSystem = system;
84- (id) initWithRole:(NSString *)role andOriginalSystem:(
OOSystemID)system
89 if ((
self = [
self initWithGenSeed:seed andOriginalSystem:system]))
84- (id) initWithRole:(NSString *)role andOriginalSystem:(
OOSystemID)system {
…}
99 return [[[
self alloc] initWithRole:role andOriginalSystem:system] autorelease];
114 OOCharacter *character = [[[
OOCharacter alloc] initWithGenSeed:seed andOriginalSystem:system] autorelease];
133 NSDictionary *originInfo = [UNIVERSE generateSystemData:[
self planetIDOfOrigin]];
149 NSString* speciesString =
nil;
150 if (
species == 3) speciesString = [UNIVERSE getSystemInhabitants:[
self genSeed].e plural:NO];
151 else speciesString = [UNIVERSE getSystemInhabitants:[
self planetIDOfOrigin] plural:NO];
153 if (![[
UNIVERSE descriptions] oo_boolForKey:
@"lowercase_ignore"])
172 NSDictionary *originInfo = [UNIVERSE generateSystemData:[
self planetIDOfOrigin]];
173 NSString *planet = [
originInfo oo_stringForKey:KEY_NAME];
175 int criminalTendency = government ^ 0x07;
182 NSString *genName =
nil;
183 if ([
species hasPrefix:
@"human"])
185 genName = [
NSString stringWithFormat:@"%@ %@", OOExpandWithSeed(genSeed, @"%R"), OOExpandKeyWithSeed(genSeed, @"nom")];
192 genName = [
NSString stringWithFormat:@"%@ %@", OOExpandWithSeed(genSeed, @"%R"), OOExpandWithSeed(genSeed, @"%R")];
196 [
self setShortDescription:OOExpandKeyWithSeed(genSeed, @"character-generic-description", species, planet)];
201 while (((
gen_rnd_number() & 0xf) < criminalTendency) && (legalIndex < 3))
208 [
self setLegalStatus:criminalTendency + criminalTendency * (gen_rnd_number() & 0x03) + (gen_rnd_number() & gen_rnd_number() & 0x7f)];
218 switch (insuranceIndex)
237- (BOOL) castInRole:(NSString *)role
239 BOOL specialSetUpDone = NO;
241 role = [
role lowercaseString];
242 if ([role hasPrefix:
@"pirate"])
249 specialSetUpDone = YES;
251 else if ([role hasPrefix:
@"trader"])
256 switch (insuranceIndex)
270 specialSetUpDone = YES;
272 else if ([role hasPrefix:
@"hunter"])
276 if (insuranceIndex == 3)
278 specialSetUpDone = YES;
280 else if ([role hasPrefix:
@"police"])
284 specialSetUpDone = YES;
286 else if ([role isEqual:
@"miner"])
290 specialSetUpDone = YES;
292 else if ([role isEqual:
@"passenger"])
296 switch (insuranceIndex)
310 specialSetUpDone = YES;
312 else if ([role isEqual:
@"slave"])
316 specialSetUpDone = YES;
318 else if ([role isEqual:
@"thargoid"])
322 [
self setName:DESC(@"character-thargoid-name")];
324 specialSetUpDone = YES;
329 return specialSetUpDone;
237- (BOOL) castInRole:(NSString *)role {
…}
372 [
self name], @"name",
382- (void)setName:(NSString *)value
382- (void)setName:(NSString *)value {
…}
389- (void)setShortDescription:(NSString *)value
391 [_shortDescription autorelease];
389- (void)setShortDescription:(NSString *)value {
…}
398 _originSystem = value;
408- (void)setLegalStatus:(
int)value
408- (void)setLegalStatus:(
int)value {
…}
420- (void)setLegacyScript:(NSArray *)some_actions
422 [_scriptActions autorelease];
420- (void)setLegacyScript:(NSArray *)some_actions {
…}
433- (void) setCharacterScript:(NSString *)scriptName
433- (void) setCharacterScript:(NSString *)scriptName {
…}
442- (void) doScriptEvent:(jsid)message
442- (void) doScriptEvent:(jsid)message {
…}
450- (void) setCharacterFromDictionary:(NSDictionary *)dict
456 if ([
origin isKindOfClass:[NSNumber
class]] ||
457 ([
origin respondsToSelector:
@selector(intValue)] && ([
origin intValue] != 0 || [
origin isEqual:
@"0"])))
462 else if ([
origin isKindOfClass:[NSString
class]])
464 OOSystemID sys = [UNIVERSE findSystemFromName:origin];
467 OOLogERR(
@"character.load.unknownSystem",
@"could not find a system named '%@' in this galaxy.",
origin);
481 if ([dict objectForKey:
@"random_seed"])
497 if ([dict oo_stringForKey:
@"role"]) [
self castInRole:[
dict oo_stringForKey:@"role"]];
498 if ([dict oo_stringForKey:
@"name"]) [
self setName:[
dict oo_stringForKey:@"name"]];
499 if ([dict oo_stringForKey:
@"short_description"]) [
self setShortDescription:[
dict oo_stringForKey:@"short_description"]];
500 if ([dict objectForKey:
@"legal_status"]) [
self setLegalStatus:[
dict oo_intForKey:@"legal_status"]];
501 if ([dict objectForKey:
@"bounty"]) [
self setLegalStatus:[
dict oo_intForKey:@"bounty"]];
502 if ([dict objectForKey:
@"insurance"]) [
self setInsuranceCredits:[
dict oo_unsignedLongLongForKey:@"insurance"]];
504 if ([dict oo_arrayForKey:
@"script_actions"]) [
self setLegacyScript:[
dict oo_arrayForKey:@"script_actions"]];
450- (void) setCharacterFromDictionary:(NSDictionary *)dict {
…}
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)