Deciphering Galactic Traders

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

I've been experimenting with the very interesting mod by alterecco, Galactic Traders.

I've played around with the code a bit and generally made some progress in adjusting it to my personal preferences, but now I'm a little stuck. It appears that 'sell only' stations are not getting any new stock when the stations refresh. That is to say, mining stations, fuel stations, etc. I'm not sure if it's something I changed or something from the original code.

Anyway, as a debug aid I've got the following code inside the definition of gt_CreateRandomItems

Code: Select all

(if (eq (random 0 50) 50)
    (block Nil
        (plyMessage gplayer
            (cat (itmGetName tempItem 8) " added to station stocks.")
        )
        (lnkAppend itemList tempItem)
    )
)
That works, but I'd like to say _which_ station the items have been added to. The problem is that inside the function gt_CreateRandomItems there is no reference to the station, so I can't use (objGetName sta 1) in there. The reference to the station would have to be passed through a lambda or two and I'm still having trouble understanding quite how they work.

Would anyone have a useful suggestion or two on how to proceed?
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

Nevermind - I think I've figured out the problem

GalacticTraders.xml only uses the gt_GetStationRandomItemRules function not the gt_GetStationStaticItemRules or gt_GetStationLookupItemRules functions (although they are defined). So basically static items (e.g. fuel station) and lookup items (e.g. mining station) are not generated. I should be able to fill in the gaps now.
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

gt_CreateRandomItems is called from inside gt_RefreshStation. gt_RefreshStation in turn is called once per station, so you can print the name of the station there...

Try changing the following code in gt_RefreshStation

Code: Select all

(enum rules rule
  (gt_objAddItems sta (gt_CreateRandomItems rule))
)
to:

Code: Select all

(dbgLog "Working on station: " (objGetName sta 1))
(enum rules rule
  (gt_objAddItems sta (gt_CreateRandomItems rule))
)
if you use that, and the code from you own post, you should get an output like:

Code: Select all

Working on station: XXXX
XXXX added to station stocks.
- " - repeat
Working on station: xXXX
- " - repeat
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

alterecco wrote:gt_CreateRandomItems is called from inside gt_RefreshStation. gt_RefreshStation in turn is called once per station
Ah! I really should have thought of that. :oops: Thanks!
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Oh! I just noticed that you use (plyMessage ..), not (dbgLog ..). I think you will find some information in the log already, but in any case it is much simpler to just keep an eye on the log, rather than the player messages.

Use some program that can show you logs while written. Not sure which to use :)
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

alterecco wrote:Oh! I just noticed that you use (plyMessage ..), not (dbgLog ..). I think you will find some information in the log already, but in any case it is much simpler to just keep an eye on the log, rather than the player messages.
Yeah, I know it's not efficient - but I like actually _playing_ while debugging. ;-)

I also add function descriptions to the wiki as I use them - it helps to remember the details.
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

I just keep a window open on the side, tailing the log while i fly around, but anything goes I guess :)
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

alterecco wrote:I just keep a window open on the side, tailing the log while i fly around
The tension of not wanting to miss vital messages makes me pay better attention to the game so I don't get killed by stupidity to often. :lol:
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

By the way... I am thinking of making a rewrite of this mod. It was written quite a time ago, and there are several things that can be done to simplify it, and make it more usable (hackable)...

Are there some changes you have made that you would like included in it?
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

alterecco wrote:By the way... I am thinking of making a rewrite of this mod. It was written quite a time ago, and there are several things that can be done to simplify it, and make it more usable (hackable)...

Are there some changes you have made that you would like included in it?
Well I'm not sure my code is worth anything, but I do have some ideas (as seen in what I've done so far).

General concept - gradual turnover rather than complete restocking. Enough activity to encourage trading as a valid game approach, but not enough to be that unbalancing.

'buy only' goods eventually disappear so you can sell stuff to them again.

One thing I've noticed with the code changes I've made so far is that stations that potentially buy and sell a lot of things (like commonwealth stations) get longer, and longer, inventories. Not good. Increasing the stock available for sale also has the side effect of making it harder to sell any loot or trade items you acquire. My current idea on that is to have loose min/max number of different items allowed for each station type. When the station reaches / passes the max number of different items on sale items are removed at random down to the minimum number.

You're welcome to what I've done so far if you think it might be any use.
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Well, I would certainly like your input. Here is what I have been working on this evening. It is basically a rewrite of the current version, missing some of the real worker functions, but showing of how I would like it to be simpler and more flexible.
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

After some hours of playing around, and a lot of talking things over with Prophet on IRC, I have pushed this to github. It is a rough draft that does not actually reduce/restock any items, but logs a lot of what it intends to do to the debug log. It requires the latest version of CommonFunctions.xml from DSF which can also be had on github.

If you feel like playing with it, please do.

It is planned that the mod operates with two "passes". One, the "restock" pass, for adjusting items on stations, ie. adding/removing items, another, the "priceAdjust" pass, for adjusting the prices of items based on different criteria (availability, current stock are some that spring to mind).

For the vanilla game, these passes take rules from a master trade list. Each station that we want to work with has an entry in this master list, containing two sub-lists, a "restock" list, and a "priceAdjust" list. Each of these sub list contain a series of function calls that will be executed on each pass, for each station. This should allow for a very large degree of flexibility. Functions can be created to take special circumstances into account.

For those who want to create new stations, and have the benefit of having them updated, it is possible to add static data to the station, containing these sub-lists. An example would be

Code: Select all

<StaticData>
  <Restock>
    (....)
  </Restock>
  <PriceAdjust>
    (....)
  </PriceAdjust>
</StaticData>
Pretty simple and straight forward.

More to follow as things progress


.]
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

The project has drifted into a new direction, and is now showing some real potential :)

Rather than have the stations "magically" alter their inventory, we hijacked some NPC ships and they are now flying from station to station making trades. They will reduce overflow items (helium fuel rods from ice farms, food from hotels, everything from enclaves etc.) as well as buying and selling whatever else the station will allow. They also buy and sell regular items, the same that the player has access to so their inventory is no longer static.

As a side-effect this has provided a new potential income source: Pirating freighters.

Theses NPC ships are spawned by most CW stations, they are the ones that go and loot wrecks, the ones that are freighters now start with an initial inventory and sometimes some escorts, as a deterrent to pirates.

It's a WIP and is riddled with dbgLog so you may find the game quite laggy but the logs will help understand what is going on behind the scenes.
Last edited by Prophet on Mon Jun 07, 2010 11:10 am, 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
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

so, are you telling me that doing "the pirate" is not worthwhile because ships are carrying around random cargo ? :D
Post Reply