Source Code and Ideas question

General discussion for players of Oolite.

Moderators: another_commander, winston

Post Reply
hangar18
Competent
Competent
Posts: 45
Joined: Sun Sep 04, 2011 9:10 am

Source Code and Ideas question

Post 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.
Zireael
---- E L I T E ----
---- E L I T E ----
Posts: 1396
Joined: Tue Nov 09, 2010 1:44 pm

Re: Source Code and Ideas question

Post by Zireael »

You need to look through the .h and .m files in Core folder.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Source Code and Ideas question

Post 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.
Zireael
---- E L I T E ----
---- E L I T E ----
Posts: 1396
Joined: Tue Nov 09, 2010 1:44 pm

Re: Source Code and Ideas question

Post 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!
hangar18
Competent
Competent
Posts: 45
Joined: Sun Sep 04, 2011 9:10 am

Re: Source Code and Ideas question

Post by hangar18 »

Many thanks guys, this is really helpful!
hangar18
Competent
Competent
Posts: 45
Joined: Sun Sep 04, 2011 9:10 am

Re: Source Code and Ideas question

Post 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;
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Source Code and Ideas question

Post 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.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6547
Joined: Wed Feb 28, 2007 7:54 am

Re: Source Code and Ideas question

Post 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.
hangar18
Competent
Competent
Posts: 45
Joined: Sun Sep 04, 2011 9:10 am

Re: Source Code and Ideas question

Post by hangar18 »

Many thanks!
hangar18
Competent
Competent
Posts: 45
Joined: Sun Sep 04, 2011 9:10 am

Re: Source Code and Ideas question

Post 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?
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6310
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Re: Source Code and Ideas question

Post 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..
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
hangar18
Competent
Competent
Posts: 45
Joined: Sun Sep 04, 2011 9:10 am

Re: Source Code and Ideas question

Post by hangar18 »

THanks, presumably the source code that gets pulled from there is the latest ie 1.77.1?
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6310
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Re: Source Code and Ideas question

Post 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.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
hangar18
Competent
Competent
Posts: 45
Joined: Sun Sep 04, 2011 9:10 am

Re: Source Code and Ideas question

Post 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.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6547
Joined: Wed Feb 28, 2007 7:54 am

Re: Source Code and Ideas question

Post 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>.
Post Reply