Page 1 of 11

(WIP) Elite Trader

Posted: Mon Nov 09, 2020 4:41 pm
by spara
[Moved from topic "Tinkerer's Workshop - OXP tweaking for fun and profit!"]
Reval wrote: Mon Nov 09, 2020 2:55 pm
Yep. In my simple - and still hypothetical - 'Elite Trader' OXP I'd prefer to avoid saving or logging anything... just have a conditional statement to decide whether the trade was good or not, and update (or not) the player's Elite score accordingly.
Been there :D. It's not that simple to say whether a trade is a good or bad. For scooped items all trades are kind of good. How about cargo contracts? If you damage some cargo and have to buy replacements, do you need to take those into account? How about buying something for a price above the average and selling it for even higher? In short, I don't see a way for a simple conditional mechanic on Traders' rating that would not do some sort of logging.

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Mon Nov 09, 2020 4:48 pm
by Reval
Hmmm... Kiitoksia :) That's food for thought indeed. As I mentioned somewhere else I don't aim even to climb the foothills of the heights you've achieved with MO. It's something very much more basic - just a sop to the pride of us Grocers ;)

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Tue Nov 10, 2020 3:45 am
by Reval
spara wrote: Mon Nov 09, 2020 4:41 pm
Reval wrote: Mon Nov 09, 2020 2:55 pm
Yep. In my simple - and still hypothetical - 'Elite Trader' OXP I'd prefer to avoid saving or logging anything... just have a conditional statement to decide whether the trade was good or not, and update (or not) the player's Elite score accordingly.
Been there :D. It's not that simple to say whether a trade is a good or bad. For scooped items all trades are kind of good. How about cargo contracts? If you damage some cargo and have to buy replacements, do you need to take those into account? How about buying something for a price above the average and selling it for even higher? In short, I don't see a way for a simple conditional mechanic on Traders' rating that would not do some sort of logging.

Code: Select all

"use strict";

this.name = "Elite Trader (Milk Run)";
this.author = "Reval";
this.description = "A profitable trade scores toward Elite";

/* It can be as simple as this, and I think it should be:
	killing a pirate is not a complex matter either... 
	This is for a single bulk buy/sell on the market-floor
	on a typical Milk Run.
*/

	
this.playerSoldCargo = function(commodity, units, price) {

	// selling preliminaries - update quantity and price
	this.$etSoldUnits += units;
	this.$etSoldPrice += price;
	// see if we made a profit
	this.$etMadeProfit = (this.$etSoldPrice > this.$etBoughtPrice);
			
	if ((units > 2) && (!this.$etDone) && (this.$etBoughtUnits>0) && (this.$etMadeProfit)) {
		// increment score on the above conditions
		player.score ++;
		player.consoleMessage("You made a killing!");
		// for simplicity, only one score per station
		// but allows for in-system inter-station activity
		this.$etDone = true;
		// for simplicity, after one sale, reset the buy values
		this.$etBoughtPrice = 0;
		this.$etBoughtUnits = 0;
	}
}


this.playerBoughtCargo = function (commodity, units, price) {
	// buying preliminaries - record quantity and price
	this.$etBoughtUnits += units;
	this.$etBoughtPrice += price;
	// buy price for single commodity (simple)
	// assumes player buys just once.
	player.consoleMessage("In hold: "+this.$etBoughtUnits+" pods ( "+formatCredits((this.$etBoughtPrice*units)/10),true,true)+" )");
}


this.shipDockedWithStation = function(station) {
	// clear flags and sold-quantities on docking
	this.$etDone = false;
	this.$etMadeProfit = false;
	this.$etSoldUnits = 0;
	this.$etSoldPrice = 0;
}


this.startUp = function() {
    log(this.name, "Initialising OXP " + this.name);
	// declare & initialize globals
	this.$etDone = false;
	this.$etMadeProfit = false;
	this.$etSoldUnits = 0;
	this.$etSoldPrice = 0;
	this.$etBoughtPrice = 0;
	this.$etBoughtUnits = 0;
}
:) < ducks >

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Tue Nov 10, 2020 6:00 am
by spara
Sure it can be simple :D Just don't do any errors as a player. I mean, don't miss buy or change your mind during your station visit or anything. But yeah, that's probably roughly how I started envisioning MO's Traders' rating years ago and ended up with the current one after gazillion steps. The simpler you can make it, the better. Go for it.

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Tue Nov 10, 2020 6:07 am
by Reval
Cheers :)

There are obviously several little wrinkles to add to the code there. And I'm aware of the glitchy shortcomings of the script as it stands: For example, you must save the game with nothing in the hold. On startup, I will find a way to establish the manifest. It was just quick and dirty to demonstrate the point about simplicity. It works great alongside MO of course :)

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Tue Nov 10, 2020 6:20 am
by spara
Yup. The saving part is probably the most notable wrinkle. Buy something expensive, save, load and sell to boost your rating. You probably need to save at least the units bought and the price payed. This is getting a bit off topic btw. Maybe you should make a thread for this?

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Tue Nov 10, 2020 6:33 am
by Reval
spara wrote: Tue Nov 10, 2020 6:20 am
...is getting a bit off topic btw. Maybe you should make a thread for this?
Would do if I knew how (phpBB-wise) - ie. moving the pertinent posts there with it too...

Perhaps someone more familiar with the ins-and-outs could oblige?

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Tue Nov 10, 2020 6:58 am
by spara
Reval wrote: Tue Nov 10, 2020 6:33 am
spara wrote: Tue Nov 10, 2020 6:20 am
...is getting a bit off topic btw. Maybe you should make a thread for this?
Would do if I knew how (phpBB-wise) - ie. moving the pertinent posts there with it too...

Perhaps someone more familiar with the ins-and-outs could oblige?
Just start a new thread and ask another_commander to move the previous posts from this thread to the new thread.

Btw. The more I think about your simplified idea, the better it looks. I would even try to simplify it more. How about just looking at the balance when entering the market and leaving the market?

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Tue Nov 10, 2020 7:01 am
by Reval
spara wrote: Tue Nov 10, 2020 6:58 am
How about just looking at the balance when entering the market and leaving the market?
Not sure I'm quite with you... You mean there are event handlers for entering and leaving the market?

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Tue Nov 10, 2020 7:04 am
by spara
Reval wrote: Tue Nov 10, 2020 7:01 am
spara wrote: Tue Nov 10, 2020 6:58 am
How about just looking at the balance when entering the market and leaving the market?
Not sure I'm quite with you... You mean there are event handlers for entering and leaving the market?
There is an event handler for UI screen change with to and from information.

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Posted: Tue Nov 10, 2020 7:06 am
by Reval
Oh interesting. I shall Wiki that right now... :)

(WIP) Elite Trader

Posted: Tue Nov 10, 2020 7:12 am
by Reval
another_commander, would you be kind enough to move recent posts pertaining to this from the Tinkerer thread to here? Maybe starting with the one where Spara quotes me and says "Been there :D. It's not that simple to say whether a trade is a good or bad."

Thanks in advance :)

(WIP) Elite Trader

Posted: Tue Nov 10, 2020 8:38 am
by Reval
Thank you! But where's it gone? - It doesn't appear on any of my 'Quick links'. And the title is still "Re: Tinkerer's Workshop - OXP tweaking for fun and profit!" when shouldn't it be "(WIP) Elite Trader?"(Maybe this post will bump it)...

Edit: Ah wait - maybe I should change the title (can I do that?)

Edit2: Nope, still didn't do it.

Re: (WIP) Elite Trader

Posted: Tue Nov 10, 2020 8:46 am
by another_commander
Fixed.

Re: (WIP) Elite Trader

Posted: Tue Nov 10, 2020 9:19 am
by Reval
another_commander wrote: Tue Nov 10, 2020 8:46 am
Fixed.
Much obliged to you, a_c.

Spara, I wonder... could you elaborate a little on what you meant when you said "look at the balance" when entering or leaving the Market screen? Is there a pre-defined variable for the balance?