Page 1 of 7

Source Code and Ideas question

Posted: Sat Jan 18, 2014 12:53 am
by hangar18
Hi All,

Still very much a noob but been making some progress with OXPs but much of what I want to change requires a source code change and for the life of me, I cant figure any of it out. The only file that seems to be the main source code one is called project.pbxproj but all that one seems to is read in a lot of files e.g.

/* Begin PBXBuildFile section */
083325DD09DDBCDE00F5B8E4 /* OOColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 083325DB09DDBCDE00F5B8E4 /* OOColor.h */; };
083325DE09DDBCDE00F5B8E4 /* OOColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 083325DC09DDBCDE00F5B8E4 /* OOColor.m */; };
0865431C06B8447D000CA0AB /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };


Hence I have no idea where to find the piece of code that limits the maximum amount of gems you can sell to 127g.

Another thing I want to do is change the amount and names of elite rankings (e.g. there might be say 8 from harmless to elite, and I want to have 15) and increase the players legal status from the 3 basic ones (clean - fugitive) to say to say 8 with varying degrees of bounty hunter and police interest. Also want to have a random chance of a players legal status changing from clean to something else, even if the police aren't around. Ie the ship under attack launches a distress signal which might get picked up eventually by police. The police would then question you and depending on your answers, maybe even if your still carrying the cargo you stole (as it would be stamped with the ship's ID you stole it from) your legal status might change. Appreciate this might not be an easy thing to answer but if theres anything I can read up on or a few basic pointers people can give, that would be fantastic.

Re: Source Code and Ideas question

Posted: Sat Jan 18, 2014 3:44 pm
by Zireael
You need to look through the .h and .m files in Core folder.

Re: Source Code and Ideas question

Posted: Sat Jan 18, 2014 3:55 pm
by cim
hangar18 wrote:
Hence I have no idea where to find the piece of code that limits the maximum amount of gems you can sell to 127g.
src/Core/Entities/PlayerEntity.m in the trySellingCommodity method, and a few other places in the same file.
hangar18 wrote:
Another thing I want to do is change the amount and names of elite rankings (e.g. there might be say 8 from harmless to elite, and I want to have 15)
The rank levels are defined, in hexadecimal, in src/Core/OOConstToString.m in the OODisplayRatingStringFromKillCount function. The names of the ranks that function gets from Resources/Config/descriptions.plist
hangar18 wrote:
and increase the players legal status from the 3 basic ones (clean - fugitive) to say to say 8 with varying degrees of bounty hunter and police interest.
Same as rating, but the OODisplayStringFromLegalStatus function.

Note that there are already varying degrees of interest - the low end of the offender scale gets much less harsh treatment than the high end, especially in the less safe systems: most police and bounty hunter calculations use the bounty level rather than its name.
hangar18 wrote:
Also want to have a random chance of a players legal status changing from clean to something else, even if the police aren't around. Ie the ship under attack launches a distress signal which might get picked up eventually by police. The police would then question you and depending on your answers, maybe even if your still carrying the cargo you stole (as it would be stamped with the ship's ID you stole it from) your legal status might change.
That one is OXPable without further source changes. Use worldscript events to track the player doing something illegal and not being directly caught, then run some mission screens to question the player when they next dock and increase their bounty through JS on a "wrong" answer.

EDIT: project.pbxproj is the project definition if you're on a Mac and using XCode to build it. Unless you're on a Mac and needing to add entirely new source code files, it doesn't need changing.

Re: Source Code and Ideas question

Posted: Sat Jan 18, 2014 6:32 pm
by Zireael
Another thing I want to do is change the amount and names of elite rankings (e.g. there might be say 8 from harmless to elite, and I want to have 15)
Look at this thread, more specifically at this post by cim:
Probably the dictionary is a red herring if you're doing it with two separate arrays in description.plist. Instead, assuming that the two arrays remain in ascending order of kills:
1) Iterate over the ratingKills array until you find an index with more kills than the player currently has.
1b) If you don't find any such index in the array, then the player is at maximum rank.
2) Subtract one from that index, and select the string with that number from the ratingNames array.
3) Get DisplayRatingStringFromKillCount to return that string rather than the one it currently does.
If you manage to do it, I will worship you forever, in addition to some more people!

Re: Source Code and Ideas question

Posted: Sat Jan 18, 2014 9:03 pm
by hangar18
Many thanks guys, this is really helpful!

Re: Source Code and Ideas question

Posted: Sat Jan 18, 2014 9:40 pm
by hangar18
Next silly question....how do I compile the changes into an executable or even just run them? The help files say I need to uninstall my existing oolite (which is the 1.77.1 package) and the Win32 installer doesn't seem to do anything.

What I want to test is that changing the elite rankings (original below) is simply a case of changing the hexadecimal numbers and inserting a few more to the 9 listed below to get say 15 (naturally also increasing the names in the relevant Plist file too).

NSArray *ratingNames = nil;
const unsigned killThresholds[kRatingCount - 1] =
{
0x0008,
0x0010,
0x0020,
0x0040,
0x0080,
0x0200,
0x0A00,
0x1900
};
unsigned i;

Re: Source Code and Ideas question

Posted: Sat Jan 18, 2014 9:50 pm
by cim
hangar18 wrote:
Next silly question....how do I compile the changes into an executable or even just run them?
If you're on Windows, you'll need to make the build environment first. The easy way is to do this is to download the ready-made one which another_commander has put together - see this thread for instructions. Then keep following the instructions to compile. Once that works, make your source changes, compile it again, and see if it worked.

Re: Source Code and Ideas question

Posted: Sat Jan 18, 2014 9:51 pm
by another_commander
hangar18 wrote:
Next silly question....how do I compile the changes into an executable or even just run them? The help files say I need to uninstall my existing oolite (which is the 1.77.1 package) and the Win32 installer doesn't seem to do anything.
Here are the instructions you are looking for: https://bb.oolite.space/viewtopic.php?f=8&t=5943.

Re: Source Code and Ideas question

Posted: Sat Jan 18, 2014 10:52 pm
by hangar18
Many thanks!

Re: Source Code and Ideas question

Posted: Sun Jan 19, 2014 4:52 am
by hangar18
Thanks guys but after step 2

git clone https://github.com/OoliteProject/oolite.git

it asks for a username and password. I tried my own login/password for this forum but didn't work. Any ideas?

Re: Source Code and Ideas question

Posted: Sun Jan 19, 2014 5:27 am
by Diziet Sma
You need to sign up for your own free github account here first:
https://github.com/
then use those login details when you pull the source..

Re: Source Code and Ideas question

Posted: Sun Jan 19, 2014 5:43 am
by hangar18
THanks, presumably the source code that gets pulled from there is the latest ie 1.77.1?

Re: Source Code and Ideas question

Posted: Sun Jan 19, 2014 6:42 am
by Diziet Sma
It depends on which branch(es) you pull. "Master" will give you 1.79, which is the current development branch that will one day become 1.80. If you want 1.77.1 you'd have to pull "maintenance/1.77", which is the branch that will one day become 1.78, when the devs decide it has spent enough time in the bugfix finding/fixing zone.

Re: Source Code and Ideas question

Posted: Sun Jan 19, 2014 8:58 am
by hangar18
Sorry...another silly question -- how do I put either the master 1.79 or Maintenance 1.77.1 into my repository. I've tried searching in the pull request tab both in the Explore and Find a repository but it either returns nothing or 10000s of records.

Re: Source Code and Ideas question

Posted: Sun Jan 19, 2014 9:54 am
by another_commander
You do not need a github account to download the source, unless you are one of the developers with commit rights. Many people without github accounts have built from source already, so we know that the instructions do work. hangar18, what is the actual message you are getting? Have you followed the instructions exactly as shown in the first post of the thread we linked you to?

Also, pull requests are not related to downloading the source for casual users, they are requests from people who have made changes to the code in their own external repositories, asking us to pull their changes in. Once you have pulled the entire repository, you can change to any of the existing branches using git checkout <branchname>.