Page 3 of 4

Posted: Fri Oct 09, 2009 6:24 am
by Diziet Sma
Commander Learner wrote:
mitchelln wrote:
Anyway, got the source code and built a version with a mining laser that seems about par with what I'm used to. Oh the joys of open source :) Tempting to spec into super laser territory, but that would just spoil the fun.
What does he mean by build a laser?
He modified the source code so the mining laser behaved more like he remembered, and compiled it to create a new executable.. Voila! a new Oolite with a higher-powered, faster-cycling mining laser!

Posted: Fri Oct 09, 2009 6:26 am
by Commander Learner
:shock: :?: :?:
How is the source code modified to recompile and create a new laser?

:!: I am still a beginner so this might sound stupid, hence my name-Learner :!:

Posted: Fri Oct 09, 2009 6:41 am
by Diziet Sma
That's ok.. we all had to learn from somewhere..

Hmm.. big topic.. let's see now..

Step one: Download the source-code.. there was a link earlier in this thread..

Step two: Find the file dealing with the lasers.. (there are hundreds of files and hundreds of thousands of lines of code, so this may take a while - but it's not so bad once you get the hang of what's what - the file-names usually give a clue as to what they're about)

Step three: Locate the code that specifies the parameters for the mining laser. Basically this entails reading the code, even if you don't understand much, until you spot what you're looking for... comments inserted by the programmers can help here, as do sensibly named parameters.

Step four: Change the parameters to something more like what you have in mind. (this can be a process of trial and error to get it right)

Step five: Compile the code to produce a new executable program and copy it to the correct location in your Oolite directory. Compiling is a big topic in its own right and there are a number of threads detailing this, which ones you should read depends on your operating system.

Step six: Test the new Oolite to see if it works the way you want.. rinse and repeat until satisfied.


ok.. that's the short version.. :lol: any questions? 8) 8)

Posted: Fri Oct 09, 2009 6:46 am
by Commander Learner
Not yet Professor! :P Will go searching for threads about compiling for Windows.

Posted: Fri Oct 09, 2009 6:58 am
by Diziet Sma
For windows, this is the definitive guide.. At the Oolite Wiki http://wiki.alioth.net/index.php/Runnin ... rom_source

Then there's another_commanders easier method https://bb.oolite.space/viewtopic.php?t=5943

Posted: Fri Oct 09, 2009 8:39 am
by Commander Learner
Whew, can´t even find the file dealing with lasers....wonder what did mitchelln do.

Posted: Fri Oct 09, 2009 8:45 am
by Screet
Commander Learner wrote:
Whew, can´t even find the file dealing with lasers....wonder what did mitchelln do.
Use an editor like notpad++ which has find in files.

Then do a find in files for "WEAPON_MINING_LASER" and you will come up with some files. If you look at their names, you probably decide to begin with "PlayerEntity.m" but also want to modify "ShipEntity.m" accordingly so that the player does not differ too much from NPC ;)

Screet

Posted: Fri Oct 09, 2009 8:48 am
by another_commander
Commander Learner: You need to open ShipEntity.m and locate this method:

Code: Select all

- (void) setWeaponDataFromType: (OOWeaponType) weapon_type
{
	switch (weapon_type)
	{
		case WEAPON_PLASMA_CANNON:
			weapon_energy =			6.0;
			weapon_recharge_rate =	0.25;
			weaponRange =			5000;
			break;
		case WEAPON_PULSE_LASER:
			weapon_energy =			15.0;
			weapon_recharge_rate =	0.33;
			weaponRange =			12500;
			break;
		case WEAPON_BEAM_LASER:
			weapon_energy =			15.0;
			weapon_recharge_rate =	0.25;
			weaponRange =			15000;
			break;
		case WEAPON_MINING_LASER:
			weapon_energy =			50.0;
			weapon_recharge_rate =	0.5;
			weaponRange =			12500;
			break;
		case WEAPON_THARGOID_LASER:		// omni directional lasers FRIGHTENING!
			weapon_energy =			12.5;
			weapon_recharge_rate =	0.5;
			weaponRange =			17500;
			break;
		case WEAPON_MILITARY_LASER:
			weapon_energy =			23.0;
			weapon_recharge_rate =	0.20;
			weaponRange =			30000;
			break;
		case WEAPON_NONE:
		case WEAPON_UNDEFINED:
			weapon_energy =			0.0;	// indicating no weapon!
			weapon_recharge_rate =	0.20;	// maximum rate
			weaponRange =			32000;
			break;
	}
}
The part that is of interest to you is:

Code: Select all

case WEAPON_MINING_LASER:
			weapon_energy =			50.0;
			weapon_recharge_rate =	0.5;
			weaponRange =			12500;
You can try to play with the three numbers for weapon_energy, weapon_recharge_rate and weaponRange if you want to suit the mining laser to your needs.

Random irrelevant note: See how the beam laser has exactly the same oomph as the pulse one, only it shoots faster and further.

Posted: Fri Oct 09, 2009 9:06 am
by Commander McLane
@ Commander Learner: You should be aware, though, that from the moment on when you implement changes to the source code, you have changed your game. You don't play the same game anymore than everybody else. Which is not a problem as such, because we are all free. But if you start modifying other parts of the source code on your computer, at some point your game won't be Oolite anymore, but something like "NeOlite" instead.

Posted: Fri Oct 09, 2009 11:07 am
by another_commander
I made a beginner's mistake earlier: The method Commander Learner needs to tweak for the player mining laser is -fireMainWeapon in PlayerEntity.m, around line 3200, where the following is contained:

Code: Select all

- (BOOL) fireMainWeapon
{
	int weapon_to_be_fired = [self weaponForView: currentWeaponFacing];

	if (weapon_temp / PLAYER_MAX_WEAPON_TEMP >= 0.85)
	{
		[self playWeaponOverheated];
		[UNIVERSE addMessage:DESC(@"weapon-overheat") forCount:3.0];
		return NO;
	}

	if (weapon_to_be_fired == WEAPON_NONE)
		return NO;

	switch (weapon_to_be_fired)
	{
		case WEAPON_PLASMA_CANNON :
			weapon_energy =						6.0f;
			weapon_energy_per_shot =			6.0f;
			weapon_heat_increment_per_shot =	8.0f;
			weapon_reload_time =				0.25f;
			weaponRange = 5000;
			break;
		case WEAPON_PULSE_LASER :
			weapon_energy =						15.0f;
			weapon_energy_per_shot =			1.0f;
			weapon_heat_increment_per_shot =	8.0f;
			weapon_reload_time =				0.5f;
			weaponRange = 12500;
			break;
		case WEAPON_BEAM_LASER :
			weapon_energy =						15.0f;
			weapon_energy_per_shot =			1.0f;
			weapon_heat_increment_per_shot =	8.0f;
			weapon_reload_time =				0.1f;
			weaponRange = 15000;
			break;
		case WEAPON_MINING_LASER :
			weapon_energy =						50.0f;
			weapon_energy_per_shot =			1.0f;
			weapon_heat_increment_per_shot =	8.0f;
			weapon_reload_time =				2.5f;
			weaponRange = 12500;
			break;
		case WEAPON_THARGOID_LASER :
		case WEAPON_MILITARY_LASER :
			weapon_energy =						23.0f;
			weapon_energy_per_shot =			1.0f;
			weapon_heat_increment_per_shot =	8.0f;
			weapon_reload_time =				0.1f;
			weaponRange = 30000;
			break;
	} ... (more stuff follows)
The part of interest is of course

Code: Select all

case WEAPON_MINING_LASER :
			weapon_energy =						50.0f;
			weapon_energy_per_shot =			1.0f;
			weapon_heat_increment_per_shot =	8.0f;
			weapon_reload_time =				2.5f;
			weaponRange = 12500;
			break;
These are the numbers to be tweaked. The previous instructions would only change the NPC stats.

Posted: Fri Oct 09, 2009 12:18 pm
by Commander Learner
:!: Off topic question.

another_commander, what is your local time when you posted this? Mine shows 7.07 pm. :D

Posted: Fri Oct 09, 2009 1:06 pm
by another_commander
Off topic answer: 13:07.

Posted: Fri Oct 09, 2009 1:29 pm
by Diziet Sma
Commander Learner wrote:
:!: Off topic question.

another_commander, what is your local time when you posted this? Mine shows 7.07 pm. :D
Still OT. So would that put you in timezone GMT+8, Commander Learner? Perth, Aust. perhaps?

Posted: Fri Oct 09, 2009 2:33 pm
by Commander McLane
Instead of a super laser you could also try a super missile.

Posted: Sat Oct 10, 2009 8:30 am
by Commander Learner
That missile is oh so cheating and frivolous, there won't be any point in Oolite if you use those!!