So, let's start at the beginning. First, open the file PlayerEntity.h in the source and go to line 1029 and replace that line with the following:
Code: Select all
NSString *OODisplayStringFromLegalStatus(unsigned legalStatus);
Code: Select all
- (NSComparisonResult)oo_compareNumerically:(NSString *)str;
Code: Select all
NSString *OODisplayRatingsFromNumericalValue(NSString *context, unsigned inputNum);
Code: Select all
NSDictionary *ratings; // holds data for the elite rankings and legal status systems
Code: Select all
- (NSDictionary *) ratings;
Code: Select all
- (NSComparisonResult)oo_compareNumerically:(NSString *)str
{
NSNumber * num1 = [NSNumber numberWithInt:[self intValue]];
NSNumber * num2 = [NSNumber numberWithInt:[str intValue]];
return [num1 compare:num2];
}
Code: Select all
ratings = [[ResourceManager dictionaryFromFilesNamed:@"ratings.plist" inFolder:@"Config" andMerge:YES] retain];
Code: Select all
[ratings release];
Code: Select all
- (NSDictionary *) ratings
{
return ratings;
}
Code: Select all
[ratings autorelease];
ratings = [[ResourceManager dictionaryFromFilesNamed:@"ratings.plist" inFolder:@"Config" andMerge:YES] retain];
Code: Select all
NSString *OODisplayRatingsFromNumericalValue(NSString *context, unsigned inputNum)
{
NSMutableDictionary *ratingDict = [[NSMutableDictionary alloc] init];
NSString *ratingString;
NSArray *ratingKeys;
NSMutableArray *mutableRatingKeys = [[NSMutableArray alloc] init];
NSArray *sortedRatingKeys;
unsigned i;
int numInt;
BOOL customStringInvalid;
NSString *logKey;
[ratingDict addEntriesFromDictionary:[[UNIVERSE ratings] oo_dictionaryForKey:context]];
ratingKeys = [ratingDict allKeys];
customStringInvalid = NO;
numInt = 0;
logKey = @"_default";
if ([context isEqualToString:@"rankings"]) logKey = @"new.rankings.error";
if ([context isEqualToString:@"legal_status"]) logKey = @"new.legal.status.error";
for (i = 0; i < [ratingKeys count]; ++i)
{
ratingString = [NSString stringWithFormat:@"%u", [ratingKeys oo_intAtIndex:i]];
numInt = [ratingString integerValue];
if (numInt < 0)
{
customStringInvalid = YES;
OOLog(logKey, @"The '%@' dictionary in ratings.plist contains a negative value key - reverting to original system.", context);
break;
}
ratingString = [NSString stringWithFormat:@"%u", [ratingKeys oo_intAtIndex:i]];
[mutableRatingKeys addObject:ratingString];
}
sortedRatingKeys = [mutableRatingKeys sortedArrayUsingSelector:@selector(oo_compareNumerically:)];
if ([sortedRatingKeys oo_unsignedIntAtIndex:0] != 0 && !customStringInvalid)
{
customStringInvalid = YES;
OOLog(logKey, @"The value keys in the '%@' dictionary in ratings.plist do not start at 0 - reverting to original system.", context);
}
if (!customStringInvalid)
{
for (i = 0; i < [sortedRatingKeys count]; ++i)
{
if (inputNum < [sortedRatingKeys oo_unsignedIntAtIndex:i])
{
ratingString = [NSString stringWithFormat:@"%u", [sortedRatingKeys oo_unsignedIntAtIndex:i-1]];
if ([ratingDict objectForKey:ratingString] != nil)
{
return [ratingDict objectForKey:ratingString];
}
else
{
customStringInvalid = YES;
OOLog(logKey, @"'nil' value returned when trying to display %@ - reverting to original system.", context);
break;
}
}
}
}
if (customStringInvalid)
{
if ([context isEqualToString:@"rankings"])
{
enum { kRatingCount = 9 };
const unsigned killThresholds[kRatingCount - 1] =
{
0x0008,
0x0010,
0x0020,
0x0040,
0x0080,
0x0200,
0x0A00,
0x1900
};
NSString *eliteRating = [NSString stringWithUTF8String:"★★★ E L I T E ★★★"];
NSString *deadlyRating = [NSString stringWithUTF8String:"☆ Deadly ☆"];
NSArray *stringArray = [NSArray arrayWithObjects:@"Harmless",@"Mostly Harmless",@"Poor",@"Average",@"Above Average",@"Competent",@"Dangerous",deadlyRating,eliteRating,nil];
for (i = 0; i < kRatingCount - 1; ++i)
{
if (inputNum < killThresholds[i]) return [stringArray oo_stringAtIndex:i];
}
return [stringArray oo_stringAtIndex:kRatingCount - 1];
}
if ([context isEqualToString:@"legal_status"])
{
enum { kStatusCount = 3 };
const int statusThresholds[kStatusCount - 1] =
{
1,
51
};
NSArray *stringArray = [NSArray arrayWithObjects:@"Clean",@"Offender",@"Fugitive",nil];
for (i = 0; i != kStatusCount - 1; ++i)
{
if (inputNum < statusThresholds[i]) return [stringArray oo_stringAtIndex:i];
}
return [stringArray oo_stringAtIndex:kStatusCount - 1];
}
}
i = [sortedRatingKeys count] - 1;
ratingString = [NSString stringWithFormat:@"%u", [sortedRatingKeys oo_unsignedIntAtIndex:i]];
return [ratingDict objectForKey:ratingString];
}
Code: Select all
NSString *OODisplayRatingStringFromKillCount(unsigned kills)
{
NSString *contextType = @"rankings";
return [NSString stringWithFormat:@"%@", OODisplayRatingsFromNumericalValue(contextType, kills)];
}
Code: Select all
NSString *OODisplayStringFromLegalStatus(unsigned legalStatus)
{
NSString *contextType = @"legal_status";
return [NSString stringWithFormat:@"%@", OODisplayRatingsFromNumericalValue(contextType, legalStatus)];
}
Code: Select all
{
"rankings" =
{
"0" = "Harmless";
"8" = "Mostly Harmless";
"16" = "Poor";
"32" = "Average";
"64" = "Above Average";
"128" = "Competent";
"512" = "Dangerous";
"2560" = "☆ Deadly ☆";
"6400" = "★★★ E L I T E ★★★";
};
"legal_status" =
{
"0" = "Clean";
"1" = "Offender";
"51" = "Fugitive";
};
}
Code: Select all
new.rankings.error = yes;
new.legal.status.error = yes;
There are limitations, such as they both have to start at 0 and cannot contain negative values (this will cause the game to fall back to the original system, which is now hardcoded). Also, there are certain commands (I'm thinking of the new Priority AI in particular here) that assume there are only three legal statuses. But for all intents and purposes this is how this could be accomplished...