Newbie here - small trading mod

Freeform discussion about anything related to modding Transcendence.
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

I have a simple idea for a mod that affects the trading system.

Basically, the idea is that every (timeperiod) stations with an existingCount more than (multiplier) x averageCount will automatically 'sell/use' averageCount / (divider) of the objects. So your typical ice farm will not keep sitting on those 200 fuel rods you sold them but will gradually lose them allowing you to sell some more.

Obviously this mod would make the game a little easier, but depending on (multiplier) and (divider) it shouldn't be excessive.

I don't suppose there would be a way to include that in the replenish event (when stations credit increases a little)?

It looks like I'd need to create a RecurringTimerEvent on every station with the 'Buy' screen. I'm a bit worried about how much system resources that would take. Do timer events still take up a lot of system resources if they fire very infrequently? (e.g. every half hour or so)

Anyway, looking for general advice on implementation. :)
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

Alterecco and I made some attempts at overhauling the trade system. One mod accomplished exactly what you are talking about, but I don't think it was finished. The other mod changed the prices of items according to the other stations in the system. For example: An ice farm will not pay as much for fuel rods if there were a fuel station nearby, but if there was an enemy station it would pay more for everything as getting supplies would be more dangerous. That mod was never finished either but was looking very promising.
Coming soon: The Syrtian War adventure mod!
A Turret defense genre mod exploring the worst era in Earth's history.
Can you defend the Earth from the Syrtian invaders?
Stay tuned for updates!
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

Prophet wrote:Alterecco and I made some attempts at overhauling the trade system. One mod accomplished exactly what you are talking about, but I don't think it was finished.
If it's still hanging around could it be put up in the broken mods section for reference?
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

looks like a thread on modding and not on scripting: teleport to Shipyards... energize!

^moved^
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

I put up this some time ago. It is not doing what you wanted it to do, but it might be able to help you tinker with how to update stations and their inventory/cash on a recurring basis.

As for the things Prophet and I did, I don't think I have any of it lying around... perhaps Prophet does?
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

alterecco wrote:I put up this some time ago. It is not doing what you wanted it to do, but it might be able to help you tinker with how to update stations and their inventory/cash on a recurring basis.
That does look very useful, although it's going to take me quite a while to get up to speed on the code used.

Take this bit, for example

Code: Select all

			(setq gt_StationRemoveItems (lambda (sta)
				(enum (gt_GetStationItems sta) itm
					(objRemoveItem sta itm (itmGetCount itm))
				)
			))
Instead of clearing the entire inventory I'd like to change it to, for each item,
* 1/3 chance do nothing
* 1/3 chance remove half of that item
* 1/3 chance clear all of that item

Would the following be anywhere near to how to do that?

Code: Select all

(setq gt_StationRemoveItems (lambda (sta)
	(enum (gt_GetStationItems sta) itm
		(random (switch
			(Nil)
			(objRemoveItem sta itm ((itmGetCount itm)/2) )
			(objRemoveItem sta itm (itmGetCount itm))
		))
	)
))
:?
Bobby
Militia Captain
Militia Captain
Posts: 675
Joined: Wed Jul 25, 2007 7:39 pm

Try replacing switch with list, that's some non-standard use of switch, while I don't think it will work I can't say for sure having never tried it.
Your division syntax is off. (divide (itmGetCount itm) 2)

but yes, that's quite close.
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

That might cause some problems because the mod will restock the stations to their original inventory levels. You could modify the restock function check current inventory and only produce X items if below the optimal threshold and then find the remaining items in the station (that the station acquired from trading) and remove some of them.

This might work, the station will still overproduce some items that it is willing to buy and sell (like a CW station or trade depot) but once the inventory gets too high it will remove more of them.

Code: Select all

(switch
	;; items that the station produces (will not buy) should all be removed
	(not (objgetbuyprice obj thisItem))
		(objRemoveItem sta thisItem (itmGetCount thisItem))

	;; the station has way too many, cut the inv by half
	(geq (multiply (itmGetAverageAppearing thisItem) 5) (itmGetCount thisItem))
		(objRemoveItem sta thisItem (divide (itmGetCount thisItem) 2))

	;; remove 20% or 10 items, whichever is more
	(geq (multiply (itmGetAverageAppearing thisItem) 4) (itmGetCount thisItem))
		(objRemoveItem sta thisItem (max (divide (itmGetCount thisItem) 5) 10))

	(geq (multiply (itmGetAverageAppearing thisItem) 3) (itmGetCount thisItem))
		(objRemoveItem sta thisItem (max (divide (itmGetCount thisItem) 3) 6))

	(geq (multiply (itmGetAverageAppearing thisItem) 2) (itmGetCount thisItem))
		(objRemoveItem sta thisItem (max (divide (itmGetCount thisItem) 2) 4))
	
	;; dwindling stock gets wiped (it's on sale!!)
	(objRemoveItem sta thisItem (min (divide (itmGetCount thisItem) 2) 3))
	)

Come to IRC some time, there's usually someone there that can help and it's much quicker :)

** edited to remove imaginary and misleading functions :D
Last edited by Prophet on Tue May 18, 2010 1:57 pm, edited 1 time in total.
Coming soon: The Syrtian War adventure mod!
A Turret defense genre mod exploring the worst era in Earth's history.
Can you defend the Earth from the Syrtian invaders?
Stay tuned for updates!
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

Prophet wrote:That might cause some problems because the mod will restock the stations to their original inventory levels.
I tried to set it to stock half the items it would otherwise stock at random. With, on average, half the items being taken away and half the items being added the theory was that it would average out over time. I'm just playing around, really.
This might work, the station will still overproduce some items that it is willing to buy and sell (like a CW station or trade depot) but once the inventory gets too high it will remove more of them.
Thanks very much for the advice from you and Bobby.
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

Looks like I need to make a 'thisItemGetCount' now...

could I just use itmGetCount ?

And thisItemGetAverageAppearing needs to be a function to calculate the average of the dice range numberAppearing ?
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

oops! :oops:

I guess I should have been more careful, I used replace all instead of going through it, so all the "itm" 's got changed to "thisItem" and messed up the functions....

so thisItemGetAverageAppearing should be itmGetAverageAppearing

and

thisItemGetCount should be itmGetCount

no new functions necessary.

Sorry about that!
Coming soon: The Syrtian War adventure mod!
A Turret defense genre mod exploring the worst era in Earth's history.
Can you defend the Earth from the Syrtian invaders?
Stay tuned for updates!
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

Prophet wrote:

Code: Select all

	;; dwindling stock gets wiped (it's on sale!!)
	(objRemoveItem sta thisItem (min (divide (itmGetCount thisItem) 2) 3))
You don't want to do this. Most interesting items are only available singly or in 1d4s. This will pretty much wipe out the entire stock of any weapons dealer apart from ammo and do a lot of damage to armor dealers. It's also going to erase nearly all ROMs except the mapping ROMs at fuel depots because they all appear singly.
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

I've been playing around with alterecco's mod, and the code changes I made work fairly well for commonwealth stations, armor and weapon stations but miner stations and fuel stations just lose all their stuff and don't get get any new items. :(

I think this is probably too complicated for me to cope with at the moment, so I'll be sitting back and looking at other people's code instead for now.
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

I think it helps enormously to have coded before, even if not in a Lisp related language. Knowing how to write algorithms is essential but not really easy to teach yourself. It also helps to be at least somewhat familiar with RPN since Lisp is in Polish Notation, which is RPN just reversed RPN.
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

Atarlost wrote:I think it helps enormously to have coded before, even if not in a Lisp related language. Knowing how to write algorithms is essential but not really easy to teach yourself. It also helps to be at least somewhat familiar with RPN since Lisp is in Polish Notation, which is RPN just reversed RPN.
I'm quite familiar with C and C++, on an amateur basis. I've been spoiled by the debugging facilities of Visual Studios though ;-)
Post Reply