A UI modding adventure

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

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

Mad_Joker
Posts: 274
Joined: Sun, 14. May 06, 11:21
x3

Post by Mad_Joker » Thu, 24. Apr 14, 00:34

wysiwyg wrote:@mad_joker - what tools are you using to recompile the lua code? I've successfully decompiled the .xpl files with Night Nords's excellent python lua tool. I was just interested in what you recommend as a compiler. I'm fairly new to lua so still getting my head around it. Looking forward to seeing some of your work under the hood and in practice when it's ready.
I am using LuaJIT for compiling. The official site doesn't have a pre-compiled version though, so you'll have to compile one yourself (the site has instructions how to do this).

In my modding guide I plan to add a suite of tools as well, which will contain all of the compiler stuff as well as an exe to compile and pack your mod (there are some things you need to be careful of with that).

About Lua: I also never had used Lua before I started with this, but if you did any JavaScript, Lua is rather easy to get into. The only thing I noticed you should be aware of is that there is a colon and a dot operator in Lua, which both compile to the same byte code, which means during decompilation it will always be decompiled to the dot operator. The colon is practically identical to using dot and passing the calling object as the first argument. Below is an example:

Code: Select all

object.method(object, ...) == object:method(...)
This means you will for example often see code like

Code: Select all

setup.addSimpleRow(setup, ...)
in the original code, which should rather be read as

Code: Select all

setup:addSimpleRow(...)
which makes the code more readable imo.

Hafe vun modding!

User avatar
wysiwyg
Posts: 584
Joined: Thu, 26. Feb 04, 01:08
x4

Post by wysiwyg » Thu, 24. Apr 14, 00:38

Many thanks for the fast reply and tips - much appreciated.
Cheers
Wysi :)

Deleted User

Post by Deleted User » Sun, 27. Apr 14, 15:15

you're awesome man :)

Mad_Joker
Posts: 274
Joined: Sun, 14. May 06, 11:21
x3

Post by Mad_Joker » Sun, 27. Apr 14, 18:36

I am progressing well with the UI for UFO and the framework. Only thing missing is basic fleet commands. I am planning to implement two commands:

1) Escort ship
2) Move to Zone.

Command 2 will also take of the function of the old "Attack Zone" command, since what you can do is just put your fleet's stances to "Aggressive" and then tell them to move to a zone.

Yesterday and today I re-wrote pretty much all of UFO's scripts. It's funny how your perspective changes when you come back to your code after a couple of months. I have radically simplified the code, sometimes getting rid of 50% of the lines.

Oh, and for those of you who are interested: I believe I have just fixed the 'sliding ship' problem UFO was suffering from for a long time now.

So, stay tuned.

Calca
Posts: 123
Joined: Thu, 13. Mar 03, 00:10
x3

Post by Calca » Mon, 28. Apr 14, 14:06

:thumb_up: :thumb_up: :thumb_up: :thumb_up: :thumb_up:

great news!!

User avatar
BigBANGtheory
Posts: 2541
Joined: Sun, 23. Oct 05, 12:13
x4

Post by BigBANGtheory » Tue, 29. Apr 14, 17:18

Mad_Joker wrote:But with the new UI modding capabilities it should be possible to have a nice formation selector (though most likely just through a list, though it would be awesome to have a graphical drag & drop formation designer).
That's the holy grail a proper Graphical User Interface, people like to work with GUIs and context sensitive menus. That's how you get complex commands from your head to the AI objects quickly and efficiently. If it takes you more than 5-10 seconds you're back into X3 menu hell again.

If anyone can make sense of the zone maps decompiled that there is where a convergence of your efforts will yield the best results imho.

Its good work Mad Joker, you are definitely leading the way on this.

Mad_Joker
Posts: 274
Joined: Sun, 14. May 06, 11:21
x3

Post by Mad_Joker » Tue, 29. Apr 14, 20:09

BigBANGtheory wrote:
Mad_Joker wrote:But with the new UI modding capabilities it should be possible to have a nice formation selector (though most likely just through a list, though it would be awesome to have a graphical drag & drop formation designer).
That's the holy grail a proper Graphical User Interface, people like to work with GUIs and context sensitive menus. That's how you get complex commands from your head to the AI objects quickly and efficiently. If it takes you more than 5-10 seconds you're back into X3 menu hell again.

If anyone can make sense of the zone maps decompiled that there is where a convergence of your efforts will yield the best results imho.

Its good work Mad Joker, you are definitely leading the way on this.
Actually, by now I have a much more clear picture and sadly have to say I am rather disappointed in what the UI can do and what it can't (maybe I am doing it just wrong, who knows?).

One example of something which I believe impossible is drop-downs or combo boxes. Also, the map you mentioned is not created in LUA, but somewhere in the C++ game code I guess. In the UI code, the only things I can do is to add the map to my menus and then display an object (e.g. sector, ship, station) on it. So pretty much only things the existing map can already do (which by the way is a 1.5k lines mess; I think creating multiple specific map screens instead of one monolithic structure would have been better).

All that being said, I think it's still possible to create UI's which allow you to do things quickly. For example, my UFO UIs (which I hope to release next weekend at the latest) allow me to create a new fleet, add some ships and then tell the new fleet to go to a target zone in offensive stance in about 20 seconds, which I think is already much much better than we had so far. But I am pretty sure, that once other more talented people start designing UIs, there are still better things to achieve.

Ayporos
Posts: 26
Joined: Sat, 28. Dec 13, 08:42

Post by Ayporos » Tue, 29. Apr 14, 20:29

Mad_Joker wrote:Well, what you are describing sounds pretty much exactly like what UFO is doing.

In UFO (so far) you would assign a ship to another ship (or rather its pilot/captain) which becomes it's commander, and which in turn can be assigned to another commander etc building a tree-like command hierarchy (just like in the real military).

I'm planning to keep this format, just the way that the hierarchies are formed will change, because the tree form is not very well representable with what the UI allows (at least I couldn't come up with a nice way).

This is how I imagine it to work: You create a fleet and select a ship (which becomes the commander). Then you can assign other ships to this fleet (which basically makes them escort their commander). You can then give this fleet orders, and one such order would be to "Escort Ship". As the target of that command, you could then choose a ship/the commander of another fleet, thereby creating the command hierarchy.

Do you agree with this approach? Any suggestions to make it better?
Having fleets commanded to escort other fleets is a very nice feature.
The biggest thing to improve here, imo, would be to maybe set specific ship roles (within a fleet) reflected by maybe an icon or text indicating which role/command it is currently executing.

So after each fleet/ship name you could have another box with text indicating its current command/role. This could be either pure text ("escort Fleet/Ship A"; "Patrol system.sector"; "Defend Station.X") with clickable links to details page of ship/sector.station.. or maybe you could insert general thumbnails indicating role which can be hovered over for exact information (like, hover over the 'patrol' icon to show you a alt-text telling you where it is patrolling) and you could then click the icon to alter/issue a command/role.

Basically I think it's important that you can, at a glance, see what each ship/fleet is doing and possibly also -where- the ship/fleet is located (for a ship this could be where its commander is, for a ship obviously where the ship is)... as an extra bonus it would be nice to -if this is possible- include (for combat ships) if it is currently engaged in combat and with which/what ship.

For trading ships said 'info' could reflect which wares it is buying/selling and where.. but that'd rely on proper integration with a trading system extension.

A possible point of interest might also be to include stations in this list, under a main station 'fleet' perhaps? expandable to show each owned station and further expandable to show ships assigned to said stations.

jeroll3d
Posts: 646
Joined: Thu, 26. Jun 08, 02:28
x3ap

Post by jeroll3d » Tue, 29. Apr 14, 22:40

Owww...nice wprk Mad_joker

:)
Entusiasta da série X3! The best game.

Mad_Joker
Posts: 274
Joined: Sun, 14. May 06, 11:21
x3

Post by Mad_Joker » Wed, 30. Apr 14, 11:09

Ayporos wrote:Having fleets commanded to escort other fleets is a very nice feature.
The biggest thing to improve here, imo, would be to maybe set specific ship roles (within a fleet) reflected by maybe an icon or text indicating which role/command it is currently executing.

So after each fleet/ship name you could have another box with text indicating its current command/role. This could be either pure text ("escort Fleet/Ship A"; "Patrol system.sector"; "Defend Station.X") with clickable links to details page of ship/sector.station.. or maybe you could insert general thumbnails indicating role which can be hovered over for exact information (like, hover over the 'patrol' icon to show you a alt-text telling you where it is patrolling) and you could then click the icon to alter/issue a command/role.

Basically I think it's important that you can, at a glance, see what each ship/fleet is doing and possibly also -where- the ship/fleet is located (for a ship this could be where its commander is, for a ship obviously where the ship is)... as an extra bonus it would be nice to -if this is possible- include (for combat ships) if it is currently engaged in combat and with which/what ship.

For trading ships said 'info' could reflect which wares it is buying/selling and where.. but that'd rely on proper integration with a trading system extension.

A possible point of interest might also be to include stations in this list, under a main station 'fleet' perhaps? expandable to show each owned station and further expandable to show ships assigned to said stations.
A lot of very good suggestions. Let me address the points one by one.

1) About specific roles per ship in fleet: My current approach is very similar to what you are describing, but more on the fleet level, instead of ship level. Someone mentioned that my fleets look more like wings, and that might indeed be true. For now, each fleet has one role or command (currently only "Move to Zone" and "Escort Ship" are available), and all ships in the fleet will follow that order. In the future, one might introduce an additional level, and make fleets consist of wings, which consist of single ships. Then you would give the fleet a high level order (e.g. "Patrol Zone X") and each wing a more specific order (e.g. "Engage enemies", "Support", "Refuel" etc.).

Tooltips like you are imagining are currently not possible, or rather not possible with reasonable effort (I think I know a way, but I would have to bend the code pretty darn much for it).

2) See what everybody is doing at a glance:

Right now in the UI, the current command is shown after the fleet name:

Code: Select all

Fleet 1                        Command: Move to Zone Steady Mole
And for ships, the current hull, shields, and the location in the form "Cluster / Sector / Zone" is shown. For NPCs it shows the current stance. I am at work right now, so I can't post a screenshot, but I'll try to remember to post a new screenshot this evening.

What you say about being in combat sounds interesting. I'm thinking about making the name of the fleet flash in red if the fleet is engaged in combat (this should hopefully not be too hard to achieve). Not sure if I can make it on ship level though.

UFO already has (and will keep) real-time status reports, where information about which fleet is engaging how many enemies and where is shown on the event monitor.

3) Trading ships:

Currently, there is no special handling for trading ships. It's rather the opposite, since trading ships have to be in the player squad and have their own special script, which makes it impossible for them to interact with UFO since it starts its own scripts on each fleet ship. This is something that could be added in the future, where you can flag a ship as a trader, and still add it to the fleet without any scripts being started, as to show what it's buying/selling.

Right now, I would recommend interaction with traders only by making fleets escort them.

4) Stations:

I like the idea of having a "station fleet", which would be a normal fleet, except that it's commander would be a station, not a ship. Alternatively, there could simply be a fleet command called "Protect Station", but that would not take advantage of the defence officer that is on the station.



Like I said, lots of good ideas, keep 'em coming.

User avatar
TheRealBix
Posts: 399
Joined: Thu, 2. Jul 09, 14:34
x4

Post by TheRealBix » Wed, 30. Apr 14, 12:28

Did you worked on a "no friendly fire" script for your fleet ?
As there can be a lot of ships in a fleet, they will fire on each other one time or another, it's inescapable.

A sript that make the victim say "hey, 'guilty ship', you're firing on me."
And make the guilty ship say "Sorry, 'guilty turrets' hold fire for x seconds", and then turrets stop firing for x seconds.
The problem is that turrets will restart firing even if the victim is still in front of the victim.

I don't konw if a script like this one can be maked alone to be applied to your fleets and lone ships/stations in same faction together, I think it have to be within each behaviour script.

Say me what you think

User avatar
YorrickVander
Posts: 2682
Joined: Tue, 29. Oct 13, 22:59
x4

Post by YorrickVander » Wed, 30. Apr 14, 12:51

I'm gonna go out on a limb and suggest this friendly fire is something ES needs to address in the exe - the normal game cheat of 'fire through' friendlies at the base code level would be the sane option.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

Mad_Joker
Posts: 274
Joined: Sun, 14. May 06, 11:21
x3

Post by Mad_Joker » Wed, 30. Apr 14, 13:11

Yeah, sadly I can't do anything about the friendly fire issues (either ships or stations). I am never really controlling the turrets myself, but instead I just tell the ship which targets it should fire upon. The rest is out of my control :(

User avatar
TheRealBix
Posts: 399
Joined: Thu, 2. Jul 09, 14:34
x4

Post by TheRealBix » Wed, 30. Apr 14, 13:16

YorrickVander wrote:I'm gonna go out on a limb and suggest this friendly fire is something ES needs to address in the exe - the normal game cheat of 'fire through' friendlies at the base code level would be the sane option.
The thing is that Egosoft needs to do a lot of things that modders have done/are doing/will do.
This souldn't be a problem if those features added by modders weren't needful, but actually they are.
For exemple, what is an X without fleet managing ? What is an X without enemy fleets ?

So yes, if Egosoft don't do it, someone have to do it for them.

Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 7873
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp » Wed, 30. Apr 14, 13:17

Whilst far from a solution, a suppose capital ship shields mods could help to avoid hull damage when capitals fire on fighters buzzing between them.

Post Reply

Return to “X Rebirth - Scripts and Modding”