Page 1 of 1

Making missions provide rounded rewards

Posted: Fri Nov 24, 2017 5:18 pm
by caligari87
So I'm trying my hand at my very first SE mod (hoping to assist with development at some point if I can).

What I'd like to do is make missions provide rounded (whole dollar) amounts for a reward. Mainly because I figure it'll be a simple change, and also because it seems weird that people would be giving cent amounts on a bulletin board. Starting with the Taxi module, I found this line:

Code: Select all

local makeAdvert = function (station)
	...
	reward = ((dist / max_taxi_dist) * typical_reward * (group / 2) * (1+risk) * (1+3*urgency) * Engine.rand:Number(0.8,1.2))
This seems pretty straightforward even for someone not versed in Lua, so I added a line.

Code: Select all

local makeAdvert = function (station)
	...
	reward = ((dist / max_taxi_dist) * typical_reward * (group / 2) * (1+risk) * (1+3*urgency) * Engine.rand:Number(0.8,1.2))
	reward = math.ceil(reward)
As expected, taxi missions now give a whole dollar amount!

If I were to do this on all the mission types and make a pull request would it be accepted? Related, how can I make the BBS and ads not show the .00 on the reward amount, to make this visually consistent?

Re: Making missions provide rounded rewards

Posted: Sat Nov 25, 2017 3:39 pm
by impaktor
I'd prefer if you added some more general utility function, that then the missions made use of. We have function to format distances, so why not rewards.

You don't need to ask premission here to open a PR. Code can be discussed there, if you have something working.

Regarding you other question, on decimal printing:
https://en.wikipedia.org/wiki/Printf_format_string
(http://lua-users.org/wiki/FormattingNumbers)

Re: Making missions provide rounded rewards

Posted: Sat Nov 25, 2017 3:42 pm
by impaktor
....also this borders on a even deeper question: what should a sane reward be compared to the work done. Must rewards always take risk, distance, and deadline into consideration, etc.

What if there were deadlines that were very long?

What if there was a "soft deadline"? With decreasing pay the longer it took? Although that would just add more complications to a system that is already half unbalanced as it is. I'd like there to be some fundamental unit in pioneer that ship prices, goods buy/sell price differences, and missions were normalized against. Like hour of game play, or I dunno.

Re: Making missions provide rounded rewards

Posted: Sat Nov 25, 2017 3:52 pm
by caligari87
So far I'm having trouble tracking down where exactly rewards are formatted in the same module (this is probably due to my lack of familiarity with the codebase and Lua in general). If you can give me a pointer to how distances do it I might be able to hack it together...?

Re: Making missions provide rounded rewards

Posted: Sat Nov 25, 2017 4:05 pm
by impaktor
looks like we already have a Format.Money(). src/LuaFormat.cpp

Re: Making missions provide rounded rewards

Posted: Sat Nov 25, 2017 4:13 pm
by caligari87
Okay, seems all that's required is setting the second parameter to "false" to remove the cent portion. I'll make that change for the mission types I'm modifying.

Re: Making missions provide rounded rewards

Posted: Sat Nov 25, 2017 5:37 pm
by caligari87
Pull request made, seems to work fine for me with no unintended side effects.