CAG, EST, CLS port/remake?

The place to discuss scripting and game modifications for X4: Foundations.

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

Ship to ship transporter

Poll ended at Mon, 11. Feb 19, 15:03

Lump cost in with CLS software
3
25%
Create a new "Transporter" ware
3
25%
Use transporter research (no additional cost)
6
50%
Other (described in comments)
0
No votes
 
Total votes: 12

morbideth
Posts: 391
Joined: Sun, 9. Nov 08, 03:07
x3tc

Re: CAG, EST, CLS port/remake?

Post by morbideth » Tue, 19. Feb 19, 11:29

Update Day 9: Finally found the bug from yesterday, I think. Which completes phase one! *golf clap*.

Phase 2 plan:
  • Add trading and logistics skills. Difficulty: Hard?
  • Add "special equipment" allowing you to rearm and resupply. Difficulty: Medium-Hard depending on some things.
  • Dependant upon the above, add support for large freighters. Difficulty: Easy-Hard, depending...
  • Add messages, logs, and relevant settings. Difficulty: Easy, but tedious and time-consuming
  • Add exceptions/blacklisting Difficulty: Moderate
  • Add "Data Storage" allowing you to save settings and load them on another ship. Difficulty: Easy, depending on data conversion
  • Add CLS software, and possibly Trading MK2 software. Difficulty: Easy iff the order requirement check works right, and can be checked in Lua.
The hardest and the most important thing is adding the skills. Truthfully, it doesn't need to be hard; if I do it the same way the original script does it wouldn't be difficult at all. However, that would mean a system separate from the existing skill system, and I think that would be confusing, thus I consider it a last resort. Today I did some initial testing to see what is possible, if all else fails, the last resort my prove the be the only resort. The first attempt at adding skills failed, I didn't have high hopes for that method, full integration, but it was worth a shot. The second method is still being investigated, showing some promise.

In an effort to balance things, I've also looked into how experience is awarded. The original script adds levels based on flight time, but that is with jump drives, so using the same method would be badly skewed if used in X4. In order to keep it consistent, I checked how the game rewards traders (and miners). I set up a loop that simulates giving the pilot experience equivalent to a trader completing a trade with a full cargo hold. The loop ran every 1ms. 2-3 hours later the pilot had only reached level 12, starting from 0... That's ~10 million trades... On second thought, I don't think I'm going to use that method.

The current plan is to release an alpha version at the end of phase two. I won't know for sure until I actually complete phase two and see how it plays, but that is what my goal is atm.

XTC0R
Posts: 401
Joined: Sat, 1. Dec 18, 19:58
x4

Re: CAG, EST, CLS port/remake?

Post by XTC0R » Tue, 19. Feb 19, 12:57

I don't want to interrupt your daily reports.
Just wanted to give you a KUDOS in the name of all the X4 players which are following your thread and progress.

morbideth
Posts: 391
Joined: Sun, 9. Nov 08, 03:07
x3tc

Re: CAG, EST, CLS port/remake?

Post by morbideth » Wed, 20. Feb 19, 09:12

XTC0R wrote:
Tue, 19. Feb 19, 12:57
I don't want to interrupt your daily reports.
Just wanted to give you a KUDOS in the name of all the X4 players which are following your thread and progress.
Thanks for the moral support.

Update Day 10: The 2nd method for adding skills proved to be successful, and I have managed to add 'trading' and 'logistics' skills as you can see below. The skills have been integrated into CAG: added promote pilot option; added pay pilot from homebase account option; added/formated flight time, employment time, and total pilot salary; added libraries for calculating payment, calculating experience, then promoting pilots, initializing custom skills, displaying skill levels. Tested CAG with the skills: Found a bug in renaming code when pilot skill is 0, and a rounding error in renaming code. Adding the skills to EST and CLS should follow without much difficulty. Then I'll have to decide which part of phase two to work on next.

About the skills: I did end up going with time-based level for the moment. It takes about a couple of game days to go from level 0 to level 15, rough estimate as I haven't sat down and calculated it. I included the vanilla exp rewards when adding exp for the custom skills, so you will still gain piloting, moral, and management skills while running EST, CAG, or CLS. Right now the new skills all start at 0. The original script allowed you to get a pilot with an initial skill level of 1-3 if you started while docked at certain stations. However, X4 does that annoying 'undock before running a new order' thing. I don't know if there is a way around that; too much effort to fool with right now anyway.

[ external image ]

morbideth
Posts: 391
Joined: Sun, 9. Nov 08, 03:07
x3tc

Re: CAG, EST, CLS port/remake?

Post by morbideth » Thu, 21. Feb 19, 11:28

Update Day 11: Added skills to EST and CLS. Updated the trader settings menu for both to add the features I added to CAG yesterday. Adjusted the experience calculation for the new skills to be less linear. It now takes slightly less time to get the first levels, but longer for the latter ones. All told, it takes 37.4 hours (game time) to reach level 15 from 0, but only ~20 mins for level 1 from 0. I think that is a good balance, needs more testing though. Adjusted the level based max jump range for EST to start at 1, at level 0, instead of 0, as it was too hard to level up since all the vanilla traders focus on in sector trades.

I've decided the next thing I'm going to work on is going to be messaging/logging, in the hopes that it will make debugging slightly easier. Towards that end, I've started planning out how I am going to do it. I'll go into details in another update.

morbideth
Posts: 391
Joined: Sun, 9. Nov 08, 03:07
x3tc

Re: CAG, EST, CLS port/remake?

Post by morbideth » Fri, 22. Feb 19, 15:36

Update Day 12: Added menus for message settings. Added a bunch of text for messages to the language files, and started working on the aiscripts side.

X4 has 4 ways to deliver messages to the player, the logbook, the ticker, subtitles, and coms. Unfortunately, everything but the coms is hidden by the map menu; something that is frequently kept open. Coms forces the map menu to close, but it also breaks seta and is rather intrusive. There isn't really a good way to deliver important info to the player and make sure they see it without being annoying. X3 has a little mail icon that would flash when you had an unread message. This makes it easy to send messages to the player in such a way they could read them at their leisure. The logbook should fulfill that function, but right now, it is set up quite poorly.

The logbook, in general, is a spammy mess that swallows any important messages. Also, it is not convenient to access. If you have more than a handful of ships the logbook quickly fills with minutia. What it needs is some way to filter things, the categories don't do the job. Something like filtering by the sender, group messages by commander, and most importantly a way to TURN MESSAGES OFF. Do I really need to know every single time a ship gets scanned by the police? Maybe if they had something illegal, but not every single time. That quickly fills the logbook with all kinds of meaningless spam. And then there is the spam from miners. Why would I want to know every time a miner delivered cargo to my factory? I only have half a dozen miners in my test save and it is still way too annoying.

But, I'm not planning on rewriting the logbook, I'm just venting. As for how I have set up messages, I've divided things into 3 categories: Notifications (i.e. pilot promoted), Trade messages, and Critical message (things that stop the script from running, i.e. no money). Each setting has options for the four ways to message the player, as appropriate for the category, i.e. only critical messages have an option to com the player, as well as an option to play a sound on receiving the message, in the hopes that, that will allow people to find the messages they want to look at.

One of the difficulties I've encountered is trying to figure out the subtitles, which use the <speak> command. For spoken text, you cannot use the normal way of inserting information into a string, no 'Blah blah %s blah blah'.[$varible]. The <speak> command only accepts the line and pageID as separate arguments, not a string that can be formatted. There is the option to add <name> and <description>, but the information about those two says, "Requires that a name has been defined in the correct format." without any hint of what the 'correct format' is. This is making it a bit difficult to display the messages as I want. I don't even want it to try to speak the text, just display it. I wish there was a dedicated subtitle command, but there doesn't seem to be.

morbideth
Posts: 391
Joined: Sun, 9. Nov 08, 03:07
x3tc

Re: CAG, EST, CLS port/remake?

Post by morbideth » Sat, 23. Feb 19, 15:21

Update Day 13: Added and tested trade messages to CAG (log file, logbook, ticker, and sound). Added Notification messages to CAG (logbook, ticker, subtitle, and sound), untested. In progress of adding critical messages to CAG (logbook done, ticker done, subtitle done, sound done), untested. Coms for critical messages is all that remains; that, and I'm still fiddling with the formatting here and there.

o-papaya-o
Posts: 42
Joined: Sun, 29. Mar 09, 11:53
x4

Re: CAG, EST, CLS port/remake?

Post by o-papaya-o » Sat, 23. Feb 19, 16:14

Hello,
I am really impressed by the work to be done, I am looking forward to testing the mod, I think your work deserves a reward.
C’est en voyant un moustique se poser sur ses coui**** que l’on s’aperçoit qu’on ne peut pas régler tous les problèmes par la violence.

morbideth
Posts: 391
Joined: Sun, 9. Nov 08, 03:07
x3tc

Re: CAG, EST, CLS port/remake?

Post by morbideth » Sun, 24. Feb 19, 16:15

o-papaya-o wrote:
Sat, 23. Feb 19, 16:14
Hello,
I am really impressed by the work to be done, I am looking forward to testing the mod, I think your work deserves a reward.
Thanks for the kind thoughts.

Update Day 14: Finished the Coms for CAG, and tested both notifications and coms. Coms worked out pretty well: when you interact with the pilot your given the option to go right to whatever the problem is, i.e. no wares selected? open the add ware submenu, no money at a station? open the manage funds menu, etc. Added all messaging stuff to EST and CLS and tested them. Tweaked the formatting of some of the messages a bit, still not 100% happy with them in every situation. Added a sound entry to the sound_libary, as the one I wanted to use wasn't already listed. Added an override to the vanilla trade messages for CAG, CLS, and EST. It's my way or nothing. Adjusted the timeout of ticker messages based on whether or not you have SETA active, so you can actually read them if you have SETA active. I don't know why it doesn't do that automatically. Can't seem to find an option to adjust the timeout for subtitles. They also use game time instead of real time. Which you have probably noticed if you have flown near a fight with SETA active as the guys will not shut up. That's because the delay between background speech is in game time.

Guy really wants paid...
[ external image ]

morbideth
Posts: 391
Joined: Sun, 9. Nov 08, 03:07
x3tc

Re: CAG, EST, CLS port/remake?

Post by morbideth » Mon, 25. Feb 19, 14:42

Update Day 15: Added pilot level to the text in logbook entries for promotions. Tweaked the formatting more. The header for the logbook entries had a place to put the homebase and sector of homebase, but if the ship didn't have a homebase it ended up being -(), which was bugging me, so I tweaked it so there is no line if there isn't a homebase. Fixed a few bugs that I came across, more from chaging the formatting than anything. Odd thing... <play_cutscene sound=" " requires an entry from the sound library. <show_notification sound=" " requires an entry from the sound library. <play_sound sound=" " requires an entry from the sound library, as a string. Why?! What did I do to deserve this kind of abuse? Consistency is important people!

Next step is equipment. I've started working on the menu, and made decent progress. I can't decide what I am going to about populating the list though. I can either load the info from the library, and run the risk of loading something that can't be built, or I can try to search for a random shipyard and load it from that; finding a station is not an easy thing to do in Lua.

Did you know that you cannot output tables to the debug log from Lua via DebugError? Given that Lua is basically built around tables this seems like an odd choice. I've made a little debugging md script to work around it:

Code: Select all

<cue name="Debug_to_file_from_Lua" instantiate="true" version="1">
      <conditions>
        <event_object_signalled object="player.ship" param="'debugToFile'"/>
      </conditions>
      <actions>
        <debug_to_file directory="'CLS'" name="player.ship.idcode" output="true" append="true"
                        text="'Debug from Lua: %s'.[event.param2]"/>
      </actions>
    </cue>
And to use it in Lua:

Code: Select all

SignalObject(ConvertStringToLuaID(tostring(C.GetPlayerControlledShipID())), 'debugToFile', someTable)
This has been incredibly useful for debugging Lua stuff. Of course, you don't have to pass a table, anything that can be sent to an aiscript can be used.

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Re: CAG, EST, CLS port/remake?

Post by UniTrader » Mon, 25. Feb 19, 15:51

just a hint: your event will probably fail when you change the ship because the event object is on!y set up once (when the event is set up/starts listening), but you send the signal to the current player ship rather than the one which used to be it. Either use a better suited event object like the player.entity or re-register the event whenever the player changes the ship. Former way is imo better because it doesn't have edge cases (player riding a ship without control!ling it, player walking on station with possibly no player ship docked)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

morbideth
Posts: 391
Joined: Sun, 9. Nov 08, 03:07
x3tc

Re: CAG, EST, CLS port/remake?

Post by morbideth » Tue, 26. Feb 19, 16:39

UniTrader wrote:
Mon, 25. Feb 19, 15:51
just a hint: your event will probably fail when you change the ship because the event object is on!y set up once (when the event is set up/starts listening), but you send the signal to the current player ship rather than the one which used to be it. Either use a better suited event object like the player.entity or re-register the event whenever the player changes the ship. Former way is imo better because it doesn't have edge cases (player riding a ship without control!ling it, player walking on station with possibly no player ship docked)
Yes, you can also use C.GetPlayerID() and player.entity if you are doing something where the player character needs to change ships. You can also use the player.entity with the NPCblackboard. This is useful as some things like true/false print differently if they are a Lua true vs a script true when they are printed. i.e. a table of {true, false} with print as {1LF, 0LF} for script values and {1, 0} for Lua values even though the Lua values are converted via the signal object function. This is useful for checking to make sure you have properly converted boolean values loaded from scripts into Lua boolean values.

Update Day 16: Continued work on the equipment menu. In hindsight, it would have been easier to start from scratch rather than mutilating the ship_configuration_menu into what I want. But then I wouldn't get to hear it scream as I rip chunks out of it, so a bit of a mixed bag either way. Lots of library functions have been created to support the equipment menu. I decided to go with searching for a nearby shipyard, instead of using the library/Encylopedia. I added a search for nearest shipyard function to the library for that. For the equipment menu, I added an option to select a specific place to resupply. For that, I added isshipyard, and canbuildships options to the select_object library. I left off working on the saving and loading, which is where the hindsight kicks in: getting it to display not a difference from the current loadout, but an absolute amount without considering the current loadout. I also spent a bit of time updating comments; muddling my way through the ship_configuration_menu reinforced the importance of having good comments.

morbideth
Posts: 391
Joined: Sun, 9. Nov 08, 03:07
x3tc

Re: CAG, EST, CLS port/remake?

Post by morbideth » Wed, 27. Feb 19, 17:40

Update Day 17: Mostly done with the equipment menu, still have to do cleanup code, but that's it. Added paint mods as an option. Not very useful right now, but once data storage and the global menu is done you will be able to mass set the paint mods of your ships. Poked around a bit on the aiscript side, mostly just planning though.

morbideth
Posts: 391
Joined: Sun, 9. Nov 08, 03:07
x3tc

Re: CAG, EST, CLS port/remake?

Post by morbideth » Thu, 28. Feb 19, 17:10

Update Day 18: Began working on aiscript side of auto-resupply, which is frustrating, inconsistent, and oh my god why doesn't this work right. It's ship.cargo.{$ware}.free and ship.cargo.{$ware}.count for the cargo hold but ammo is ship.ammostorage.{$ware}.free and ship.ammostorage.{$macro}.count?! Also, there doesn't seem to be a way to get the price of ammo, etc, via scripts. When buying ammo you don't go and say "hey, I want to buy x amount of ammo," because that would make way too much sense, you have to go "Hey, I want to have x amount of ammo." It also interrupts the order that is running if you resupply.

Thus far, I've gotten it to convert the macros to script versions, then check to see if you need to resupply, and then fly to a station and resupply. I have not done the searching for station part yet, nor the price, and logging of the price. I have to figure out some way around the interrupt thing too, as that displays the menu when it restarts the order, order_syncpoint maybe?

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Re: CAG, EST, CLS port/remake?

Post by UniTrader » Thu, 28. Feb 19, 19:47

regarding getting prices:
$macro.ware.averageprice
$ware.averageprice

(alternatively .minprice and .maxprice also exist, and the .pricerange )

see scriptproperties.html ;) (best extract game completely, open said file in firefox and slowly type the first expression i posted here in the input box on the top, then you understand how it works ;) )
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

morbideth
Posts: 391
Joined: Sun, 9. Nov 08, 03:07
x3tc

Re: CAG, EST, CLS port/remake?

Post by morbideth » Fri, 1. Mar 19, 09:14

UniTrader wrote:
Thu, 28. Feb 19, 19:47
regarding getting prices:
$macro.ware.averageprice
$ware.averageprice
$station.buyprice.{$ware} and $station.sellprice.{$ware} both return ware.averageprice, that's the problem. Ware.averageprice is not the price shown in the UI. And it isn't just some relation adjustment either; the price in the UI can be above or below ware.averageprice even at max rep. The 'real' price is only available from C.GetBuildWarePrice. If I knew how it was calculated... but I don't.

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Re: CAG, EST, CLS port/remake?

Post by UniTrader » Fri, 1. Mar 19, 09:54

ah, so you are referring to the Prices for the Player where the %s of commissions and rebates are included... For that you have to find the offer on the Station and get the price of the offer, because that's what the Player and all Trade ships see/look for.

I don't know why .buyprice and .sellprice return the average price, but it might be because the Ware is only traded there, not produced or consumed, which makes prices not depend on storage. Also these don't include aforementioned %s but rather represent the price setting of the station before they are applied.
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

morbideth
Posts: 391
Joined: Sun, 9. Nov 08, 03:07
x3tc

Re: CAG, EST, CLS port/remake?

Post by morbideth » Fri, 1. Mar 19, 17:27

UniTrader wrote:
Fri, 1. Mar 19, 09:54
ah, so you are referring to the Prices for the Player where the %s of commissions and rebates are included... For that you have to find the offer on the Station and get the price of the offer, because that's what the Player and all Trade ships see/look for.

I don't know why .buyprice and .sellprice return the average price, but it might be because the Ware is only traded there, not produced or consumed, which makes prices not depend on storage. Also these don't include aforementioned %s but rather represent the price setting of the station before they are applied.
You can't get a trade offer, because they are not trade wares. Entirely different category. Things that are built like ships' equipment are not stockpiled, thus the normal trading method does not work at all. In essence, the ware doesn't exist until after you have ordered it built. So you are not in fact trading at all, you are ordering a build, even if the build is for more ammo for an existing ship. I ran into this issue with my Sat Network mod and, had hoped they would have fixed this for 2.0, but they didn't. It doesn't look like ships that rearm at player shipyards would pay for their supplies, unless that is happening somewhere outside of the resupply interrupt. If it is, I can't find it.

Update Day 19: Found a work around for the price issue. It now charges you the same amount that you would see in the UI. Trying to find a way around the restarting order thing. add_build_to_modify_ship creates an order, which is what is causing the problem, and also a horrible design. Can you imagine trying to create a fleet command script like CODEA when every time a ship needs to rearm it wipes all of the variables and restarts? What a nightmare. Not to mention the inevitable performance hit from having to recalculate everything all over again.

Been sick that past few days, and getting worse, may not be an update for a day or three.

albysmith
Posts: 37
Joined: Thu, 6. Dec 18, 14:57
x4

Re: CAG, EST, CLS port/remake?

Post by albysmith » Mon, 4. Mar 19, 07:47

How did you add skills?

rosssack
Posts: 50
Joined: Fri, 8. Mar 19, 12:44
x4

Re: CAG, EST, CLS port/remake?

Post by rosssack » Wed, 13. Mar 19, 15:17

hi im one of them that played x3 ,really respect you for this mod wen ready ,will you be giving codea a shot ,this mod was epic in x3

regards

photomankc
Posts: 232
Joined: Wed, 16. Jul 14, 15:01

Re: CAG, EST, CLS port/remake?

Post by photomankc » Mon, 18. Mar 19, 17:51

Dear God thank you for working on bringing this to X4!

Post Reply

Return to “X4: Foundations - Scripts and Modding”