A UI modding adventure

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

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

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: 585
Joined: Thu, 26. Feb 04, 00: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: 127
Joined: Wed, 12. Mar 03, 23:10
x4

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: 3168
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, 07: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: 665
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: 400
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: 2702
Joined: Tue, 29. Oct 13, 21: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: 400
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: 8074
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.

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

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

I don't even know if it's possible in scripting to call the "guilty" turret.
There's no way to recognize the mother of a projectile fired for the moment, right ?

User avatar
YorrickVander
Posts: 2702
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander » Wed, 30. Apr 14, 15:40

TheRealBix wrote:So yes, if Egosoft don't do it, someone have to do it for them.
Understood mate, I've even made a couple of simple mods myself (Shady Slater, Copilot Convo etc) due to some of the more glaring and irritating design failures. My point here is simply that scripting a solution for friendly fire isn't really feasible without the actual collision physics allowing for fleet members not being hit :(
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

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

Post by Ayporos » Wed, 30. Apr 14, 20:35

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.
How is that a sane option?

I might come over a bit idealistic here but if you ask me it'd be quite immersion breaking to watch an epic space battle between fleets take place and friendlies just shooting straight through each other.

How about spatial tactics? positioning? flak defensive lines (that your own fighters/drones better stay far clear of if they don't wish to be torn to bits)?


@Mad_Joker, regarding the 'station fleet' thing, I believe it'd be cleaner to group those into a 'fleet'(?) called STATIONS, under which the -actual- station fleets are located.. this way if you have, say, 20+ stations, the first 20 entries in your fleet management window isn't taken up by all those stations that may or may not have ships/fleets assigned to them.

Grouping them all together in one big 'STATION' parent entry means you can either expand that to look at your station fleets or ignore this one single fleet entry and work on all of your ship fleets.

That's just how I imagine it'd be best to go about keeping the fleet window uncluttered, I just mention it to make you aware of the fact that it could get messy real quick if one has many stations/fleets.

User avatar
YorrickVander
Posts: 2702
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander » Wed, 30. Apr 14, 20:46

Maybe i phrased that badly :) Replace 'sane' then with 'likely to happen in a reasonable timeframe' perhaps? Telling your fighters to stay out of the capitals firing solution (BSG springs to mind) would be great but I imagine there would be a lot of fiddly code and probably inherent lag for in-zone fights with the extra overhead.
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, 21:05

Alright, here then a screenshot of the final version of the fleet management screen for now. Tomorrow is a holiday where I live, so I hope I will be able to release UFO tomorrow.

http://static-2.nexusmods.com/15/mods/1 ... 884615.png


{Images posted directly to the forums should not be greater than 640x480 or 100kb, oversize image now linked - Terre}

Post Reply

Return to “X Rebirth - Scripts and Modding”