Starting work on creating a real economy.

The place to discuss scripting and game modifications for X Rebirth.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

Berserk Knight
Posts: 398
Joined: Tue, 17. Dec 13, 01:34
x4

Starting work on creating a real economy.

Post by Berserk Knight »

The intent is to remove as much "fake" stuff as possible.
- Job ships that are spawned in instead of being built.
- Shipyards building ships only to send them into a dummy cluster where they'll be destroyed.
- AI factions not using money.

Additional goals in the scope
- Try to fix multi-ware production modules by making it a parallel production.
(I'm thinking of sub-modules, each with only one ware. The production rate will have to be toned down, but hey, "slower but stable" is infinitely better than the "all stop" we get right now.)
- Optionally, put in some upkeep modules that consume resources, creating a secondary resource sink.

The additional goals should be moderately simple.
Just a little juggling around of some components and adding a few new ones.

The primary goals will need background scripts that handle "faction AI", reworked shipyard scripts, reworked station scripts...a lot of work.


Currently working on the shipyard framework.
This framework needs to be done before most of the other stuff can be touched.


Shipyard will now check for available build modules, then check the build order queue for a ship it can build with those modules.
(I'll also need to add a resource check as well.)

Format for the build order queue entry will look something like this.

Code: Select all

[cluster, owner, ship macro, [drone loadout], 'initializer script name', [parameters for initializer script]]
Cluster will filter out orders placed from other clusters so we don't have Argon Government placing orders for a Gigurum at the Civ Ship Dockyard in Cuspid Splint.
Owner will filter out hostile factions that shouldn't be able to order from the particular shipyard in the first place.
Macro will, among many other important things, check if any of the available build modules are suitable for building the said ship.

Failing to build anything while going through the list will schedule another check 5~10 minutes later.

Built ships will now run their "initializer" scripts.
These scripts will specifically be made to run all the checks they need to figure out which station to work for (if any) and which script they should finally run.
(For example, Pirates will have "neutral" as the faction in the queue, but the script will take the ship to a safe location, then change ownership.)


I had to create a workaround for adding things to the build order queue.

Having multiple entities access the same list at the same time is NEVER good, especially if ANY of them are accessing to modify data.
I already have a working "lock" mechanism that puts other entities that use the same mechanism on hold.
This system relies on the script command "wait", a blocking action, which can NOT be used in interrupt blocks, and interrupt blocks are where we'd mostly find what we need to add.
Signalling a cue (with the lock mechanism) that handles the addition would be good, but AI scripts can't signal cues. (Doh!)
I created a cue actor that'll exist for the sole purpose of hijacking the "event_object_signalled" which the AI scripts CAN fire off.
User avatar
NZ-Wanderer
Posts: 1627
Joined: Thu, 5. Aug 04, 01:57
x4

Post by NZ-Wanderer »

This looks really interesting :)
I hope you can do it reasonably easily and it doesn't give you too many headaches..
Subscribes to topic to keep an eye on it...
Link to the list of Mods working in X4-Foundations and also Link to the list of Mods working in X-Rebirth

NOTE: I play with a modded game, so any reports I make outlining suggestions/problems/bugs/annoyances, are made with mods installed and running.
SupraRZ
Posts: 319
Joined: Fri, 11. Oct 13, 12:02
x4

Post by SupraRZ »

Didn't jey1234 try something like this?

Good luck with this it will be some achievement....I will be following this :D
User avatar
Baconnaise
Posts: 766
Joined: Sat, 23. Nov 13, 15:50
x4

Post by Baconnaise »

SupraRZ wrote:Didn't jey1234 try something like this?

Good luck with this it will be some achievement....I will be following this :D
He wasn't the only one that gave it a go. I just hope BK doesn't burn out in the attempt. Clueless if a simple and elegant solution is even possible.
Berserk Knight
Posts: 398
Joined: Tue, 17. Dec 13, 01:34
x4

Post by Berserk Knight »

This project's been on the back of my head for months now.
I've had plenty of time to think, and one of the largest problems I've identified during that time was the Shipyard - Build Order Queue connection.

Right now, I've got a prototype for the shipyard framework.
I'll need to cook up some menu commands and initializer scripts, then test it out.
Ginger470
Posts: 158
Joined: Sun, 20. Jun 04, 03:24
x2

Post by Ginger470 »

Hey BK,

Are you factoring in cross-faction economics? If your mod, and BlackRain's World War X (and my tentative plans for a pseudo political simulator) used the faction relationships as a starting point and an end measure, then all these mods could potentially add to each other rather than conflicting rendering a /very/ dynamic universe.
Patholos
Posts: 821
Joined: Fri, 16. Apr 10, 11:24
x4

Post by Patholos »

Berserk.

For even attempting this, I tip my space hat in recognition.
Sure glad I didn't purchase a new computer this release.
Berserk Knight
Posts: 398
Joined: Tue, 17. Dec 13, 01:34
x4

Post by Berserk Knight »

After struggling with syntax problems for a bit, I've finally got the shipyards to successfully build off the Build Order Queue.

Now I need to add in minimum resource reserve, price calculation, and money transaction.
...Time to decompile the ship dealer's UI and see how it's calculated.
Berserk Knight
Posts: 398
Joined: Tue, 17. Dec 13, 01:34
x4

Post by Berserk Knight »

Price calculation command needs some better documentation.
It's pretty vague, so I'll have to run some tests with it.


Also, the framework for resource checks have been made so it can be expanded upon if needed.

There's 3 list of macros : Override, Albion, and Omicron.

Override list's entries indicate that some other mod or something wishes to handle the resource check for those macros, so the default resource check is skipped.

Albion and Omicron lists contain macros for shipyards that use matching build methods so the proper list of resources will be used for the check.

There's also 2 lists of wares paired with the amount to be checked for, one for each build method.
(If ware requirements for ships are changed through a mod, then this list is the only thing that needs to be changed.)


Here's an example of how "expanding" the resource check is intended to work.
(...Okay, I'll admit it. I made it expandable so it'll be compatible with my mod.)

My BuildShipyards adds small ship building capabilities to Medium Shipyards and the DeVries shipyard.
Medium shipyards aren't in either of the Albion or Omicron lists, so they don't need to be added anywhere.
The DeVries shipyard is in the Albion list, so it will need to be added to the Override list, so the default resource check (which always sets the "can build small ships" flag as false) will be ignored.
Then another cue in the BuildShipyards mod will do the resource checks for the DeVries shipyard, additionally checking for small ship building resources and setting the flag accordingly.


Outsourcing the resource check to an MD script makes things so much easier.
The "AI script to MD script" signalling I made is probably the biggest breakthrough I've made.
Berserk Knight
Posts: 398
Joined: Tue, 17. Dec 13, 01:34
x4

Post by Berserk Knight »

Figured out how to use the price calculation command, but it returns extremely low values compared to the prices we see when building ships ourselves.
I'm guessing it's due to the shipyards overcharging us by almost 100% :evil: for the ships.
(Once I double the calculated price, then it starts to be similar. ...Very well, then I reflect that mechanism to the price calculation by manually adding to it.)

So far, so good.

Time to create a dummy CEO NPC for an NPC faction with an account and see if NPC transactions actually work.

Edit : Got the calculation a bit more refined, and now the prices are EXACTLY the same as what WE are presented with.
BlackRain
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 7465
Joined: Mon, 15. Dec 03, 18:53
x4

Post by BlackRain »

Keep up the good work, can't wait to see this.
Berserk Knight
Posts: 398
Joined: Tue, 17. Dec 13, 01:34
x4

Post by Berserk Knight »

Just made an NPC named "PMC CEO" :lol: and made him 'buy me' 4 Construction Vessels.
(The money came out of his pocket. The ships, however, belong to me. :twisted:)

Money transfer between NPC factions also work.

The framework is in place!
(Except for the minor oversight I've made with the resource check. I need to include the upgrade materials to the reserve as well.)


Now the boring part...

Removing job ships entirely (the "ugly" way to do it takes about 5 seconds, but I'm not doing that, so it'll take a lot longer)
Coding in ship quotas for each station type based on the current jobs.xml (which requires me to track down every single station in every single sector, making a list of them, making a list of the ships in the jobs.xml and what they do, distributing the ships between stations, THEN finally coding it in)
Creating faction AI (oh, that "PMC CEO" up there will be doing this for PMC)
Creating initializer scripts...

Hmm, wait a sec. ...Okay, the last two aren't going to be that boring.
User avatar
NZ-Wanderer
Posts: 1627
Joined: Thu, 5. Aug 04, 01:57
x4

Post by NZ-Wanderer »

Wonders out loud if this will work with Observes player sectors :)
Link to the list of Mods working in X4-Foundations and also Link to the list of Mods working in X-Rebirth

NOTE: I play with a modded game, so any reports I make outlining suggestions/problems/bugs/annoyances, are made with mods installed and running.
dmace
Posts: 14
Joined: Wed, 9. Jun 10, 14:33
x3tc

Post by dmace »

Really interested in this, want to be able to cripple my enemy financially as well as militarily.
Berserk Knight
Posts: 398
Joined: Tue, 17. Dec 13, 01:34
x4

Post by Berserk Knight »

After giving all major factions their own accounts to work out of, I added some lines to the faction leaders' AI to report their money every minute.

While I did get about an hour worth of macro-scale economic data, I'm afraid it's contaminated by the wares spawned with the freighters.

Ledda Industrial made 300million (yes, that's three hundred million) in 30minutes, then stabilized.
None of the other factions had even 50million in profits over the entire full hour. Well, AES did come close with 46million.
(Losses, on the other hand... Shipyard owners take losses of 150~200million in the first ten minutes, then keep dropping at a slower pace from there.)

The thing is, I don't think Ledda would've made THAT much money in such a short period of time if it didn't have ware spawning.

I'll have to remove the spawned wares and try again.


On a side note, now you know what to do, people. Kill Ledda and take over their industry to maximize profits.
vadiolive
Posts: 337
Joined: Wed, 18. Dec 13, 04:36
x4

Post by vadiolive »

omg i just sense this become EPIC MOD!
Keep going
Dygaza
Posts: 271
Joined: Sun, 8. Dec 13, 13:03
x4

Post by Dygaza »

Good work so far, really looking forward into this.

Just a question, how are you gonna solve the problem of one party getting too rich, and one party getting too poor without 3rd party income (civilian masstraffic).

In closed economy if one gets rich, others get poor. I bet you don't want to see situation where few factions have 90% of the capital of the whole universe.
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

With limited supply in the closed universe it should be self balancing, a little like the old foxes + rabbits game. PMC would likely start by totally dominating the market in albion, but as their resources become stretched other companies can start slipping in and building a capital base back up. I'll be watching the progress with interest.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
User avatar
pirke123
Posts: 381
Joined: Tue, 3. Sep 13, 18:00
x4

Post by pirke123 »

This should have been part of the base game... they promised a real economy!
Privata
Posts: 719
Joined: Mon, 19. Dec 11, 22:59
x4

Post by Privata »

pirke123 wrote:This should have been part of the base game... they promised a real economy!
in a sense they did , just not in all the detail we wanted/hoped for.

X3 did not have real economie either , or rather it had a simpler version of Xrebirth economie.
that does not mean it is bad , just simple and well with rebirth I wanted more (this mod will fix that witch is awsome :) )

my main issue with economies in X are:
old Xs X1-3
what is it for? only there to serve the player to get him/her credits and immersion

Rebirth , to feed the shipyards that then spawn ships with a go and die script , its amazing when compared to X3 but its only one step better , know however rebirth IMO is just a heavy tech demo for whats to comme

Return to “X Rebirth - Scripts and Modding”