Making missions provide rounded rewards

Post Reply
caligari87
Posts: 4
Joined: Wed Nov 22, 2017 9:04 pm

Making missions provide rounded rewards

Post by caligari87 » Fri Nov 24, 2017 5:18 pm

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?

impaktor
Posts: 704
Joined: Fri Dec 20, 2013 9:54 am
Location: Tellus
Contact:

Re: Making missions provide rounded rewards

Post by impaktor » Sat Nov 25, 2017 3:39 pm

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)

impaktor
Posts: 704
Joined: Fri Dec 20, 2013 9:54 am
Location: Tellus
Contact:

Re: Making missions provide rounded rewards

Post by impaktor » Sat Nov 25, 2017 3:42 pm

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

caligari87
Posts: 4
Joined: Wed Nov 22, 2017 9:04 pm

Re: Making missions provide rounded rewards

Post by caligari87 » Sat Nov 25, 2017 3:52 pm

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...?

impaktor
Posts: 704
Joined: Fri Dec 20, 2013 9:54 am
Location: Tellus
Contact:

Re: Making missions provide rounded rewards

Post by impaktor » Sat Nov 25, 2017 4:05 pm

looks like we already have a Format.Money(). src/LuaFormat.cpp

caligari87
Posts: 4
Joined: Wed Nov 22, 2017 9:04 pm

Re: Making missions provide rounded rewards

Post by caligari87 » Sat Nov 25, 2017 4:13 pm

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.

caligari87
Posts: 4
Joined: Wed Nov 22, 2017 9:04 pm

Re: Making missions provide rounded rewards

Post by caligari87 » Sat Nov 25, 2017 5:37 pm

Pull request made, seems to work fine for me with no unintended side effects.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest