Arcen Games

Games => AI War Classic => AI War Classic - Mods & Modding => Topic started by: roguevagabond on April 19, 2015, 05:12:20 PM

Title: FTL and ship design mods?
Post by: roguevagabond on April 19, 2015, 05:12:20 PM
Are there any AI War mods which allow standard ships to travel between systems with a warp, jump, or hyperdrive rather then via wormholes? and are there any which allow the players to create their own ship designs?
Title: Re: FTL and ship design mods?
Post by: Dominus Arbitrationis on April 19, 2015, 05:26:50 PM
I highly doubt you'll find any mods that advanced for the first one, and the second one doesn't seem like something anyone has really wanted to do ever. I could be wrong though.
Title: Re: FTL and ship design mods?
Post by: Aklyon on April 19, 2015, 05:28:44 PM
The closest you'll get are modular starships and Champions.
Title: Re: FTL and ship design mods?
Post by: Red.Queen on April 19, 2015, 07:45:48 PM
Hi Roguevagabond,

I can think of a way to approximate the direct-jump thing.  Teleraiders can hop from wormhole to wormhole so fast they're almost uncatchable (barring things like Black Hole Machines), and I'm not sure, but the Spirecraft Jumpship might be able to do long-distance hops.  Not sure on the last one as I haven't played with it yet.

Depending on how the ships have their abilities assigned, it would theoretically be possible to assign one of these teleport abilities to another ship.

AI War is a Unity-based game, which isn't too friendly to modding, but not impossible if you're stubborn enough and willing to get into the world of Assembly language programming.  Not many people are.  I am one of the few however.  8) (If anyone here is a fan of "Sir, You Are Being Hunted", you might be thinking my nickname is familiar -- I am the same Red Queen who's the lone lunatic modder in that community, and all my work there is done in a flavor of Assembly.)

Anyway, I'm enjoying AI War quite a bit, and it's pretty inevitable that I eventually start modding my favorite games, so you guys may see me start tinkering with this one at some point, once I've decided I have enough experience with the vanilla game, its balance, and its mechanics that I can make informed decisions about what I might like to do.

The only downside (well, assuming you don't consider working in Assembly a downside, which sane people do) is that keeping mods updated for stuff built on Unity is an unholy nightmare, it's a 100% manual job of patching the .dll that contains most of the game's "things wot do stuff" instructions, all by hand.  In something like Notepad.  :-\  It's a very 1985 kind of workflow.  The frequency with which Arcen tends to patch will be a big factor in whether or not I get into anything heavy-duty.

EDIT -- I would also only release modded files with Arcen's permission, especially as it would require posting modified copies of a major .dll.  That's more invasive than writing a companion plug-in, and not all devs are comfortable with people doing that.  Last thing I would want to do is annoy them.

Parting note -- Wow, the relevant .dll for this game is 3.5 megabytes.  Sir was 1.3ish and disassembled into over a million lines of code filling a 14 megabyte plain text file.  AI War would probably become between 3 and 4 million lines of code then.  Intriguing.  Must resist urge to throw it in a decompiler and read the C# until I don't think I will have too many spoilers from doing so...
Title: Re: FTL and ship design mods?
Post by: Aklyon on April 19, 2015, 08:38:40 PM
Arcen code (libraries in particular) has been related to a lumber mill at maximum speed with minimum support before by keith, Red Queen. You'd get more spoilers reading the journal xml files than whatever such a thing decompiles into, I'd think. :)
Title: Re: FTL and ship design mods?
Post by: Red.Queen on April 19, 2015, 09:03:16 PM
I'm pretty sure a normal person would have interpreted that as "Abandon hope, all ye who enter here", but all I heard was "See that mountain?  Everyone avoids it, it's too dangerous.  <whisper>  Climb it.  You know you want to."  ;)

No illusions that it would be easy though, I recall coming across an old post by Keith when he was preparing a big overhaul of some of the core AI and admitting it took *him* two weeks of reading it before he was willing to touch the thing.  On the other hand, that also hints at a glorious cornucopia of interesting systems to occupy myself studying from the inside for quite a long time, in addition to observing and theorizing while I play...  <drool>

Gah, if it's not other people tempting me to do this stuff, it's me tempting myself talking through my thoughts on it!
Title: Re: FTL and ship design mods?
Post by: topper on April 19, 2015, 09:13:28 PM
You are probably both happier if you put the suggestions (both for ideas and for new ships you want) on Mantis and wait for the next AI War expansion.  :P  But really, if they are good ideas then they have a decent chance of being in the next expansion, and there is always another expansion in the works. :D

The ship artwork is theoretically moddable already, but I doubt ship stats can be easily changed. Making an entirely new warping mechanic has got to be nearly impossible. I get the feeling your next comment is "challenge accepted" :)
Title: Re: FTL and ship design mods?
Post by: Pumpkin on April 20, 2015, 04:15:35 AM
AI War is a Unity-based game, which isn't too friendly to modding, but not impossible if you're stubborn enough and willing to get into the world of Assembly language programming.  Not many people are.  I am one of the few however.  8) (If anyone here is a fan of "Sir, You Are Being Hunted", you might be thinking my nickname is familiar -- I am the same Red Queen who's the lone lunatic modder in that community, and all my work there is done in a flavor of Assembly.)
:o

However, according to this (http://www.arcengames.com/forums/index.php/topic,10.0.html), Chris/Keith totally assume the fact that AI War isn't mod-friendly. And a disassembler-based mod/patch has been attempted before, AAR here (http://www.arcengames.com/forums/index.php/topic,16085.0.html).
Title: Re: FTL and ship design mods?
Post by: Red.Queen on April 21, 2015, 08:35:30 PM
You are probably both happier if you put the suggestions (both for ideas and for new ships you want) on Mantis and wait for the next AI War expansion.  :P  But really, if they are good ideas then they have a decent chance of being in the next expansion, and there is always another expansion in the works. :D

Definitely the sane approach, especially for the long term.  :)

Quote
The ship artwork is theoretically moddable already

Indeed.  And if someone finds a graphic they want to extract/replace that's not loose, but locked up in one of the .assets container files, I can point them at an excellent modder-made tool for pulling/replacing them, as well as give some tips on how to do it.  Technically works on just about everything in there.

Quote
but I doubt ship stats can be easily changed. Making an entirely new warping mechanic has got to be nearly impossible. I get the feeling your next comment is "challenge accepted" :)

Sighhhhhh...

Challenge accepted (to at least pop the top and evaluate feasibility of some sort of proof of concept as a test) ...

RIP my free time.  (Sanity's already long gone, programming in Assembly does that.)

:o

<lol>

Quote
However, according to this (http://www.arcengames.com/forums/index.php/topic,10.0.html), Chris/Keith totally assume the fact that AI War isn't mod-friendly. And a disassembler-based mod/patch has been attempted before, AAR here (http://www.arcengames.com/forums/index.php/topic,16085.0.html).

Yup, spotted those, good to see that I'm not the only one crazy enough to slither up close to the metal and work that way when confronted with software that claims itself unmoddable.  Rara avis in terrorem.  And it's definitely true, anything built on Unity, unless the devs have made their own modloader component for it, isn't very mod-friendly.  Only disassembly or hex editing works, decompiling won't net you anything functional.

My usual workflow when hacking Unity games is to have four different utilities open, aside from Unity engine documentation a couple of sketchy MSIL references (there isn't that much on this language, humans don't generally use it).  There is also generally either caffeine or alcohol of some variety on my desk for modder fuel, and I probably have some flavor of industrial/noize pumping over my headphones.  Though, occasionally, it may be Baroque classical because Why Not.  Harpsichords and cellos rock too.

Telerik JustDecompile with a batch of relevant classes open in half a dozen tabs, set to display in C# so I can read and search through the vanilla code quickly -- this lets me trace what I'm interested in, find things I can potentially cannibalize, and generally better understand the big picture.  I have Visual Studio's DevPrompt open in the background for running ILASM/ILDASM to assemble and disassemble the C# code.

The gigantic raw .il file gets thrown into Notepad++ (there are no MSIL IDEs, it's all oldschool -- yeah, baby!) as an assembly reference, and then I open a copy in another tab that I actually start writing to.  More complex changes get written out in a temp tab first, and then folded in.  Lots of working copies are made, I have had times where I have had about 10-12 tabs open in Notepad++ as the code has evolved.  When it's time to check my work, I run ILASM to reassemble it (I'm skipping the !!fun!! that happens when it fails to assemble and how you troubleshoot that), and throw it into ILSpy, another decompiler.

ILSpy is set to display in C# mode.  I prefer to use ILSpy for testing as it decompiles slightly differently than Telerik, so it's like having a second opinion that something is legit, plus Telerik throws a fit if you have two files with the same name open, which is a bit of a problem when you want to compare the same class before and after.  Then I look for errors/anything that looks stupid -- just because it assembles, doesn't mean it turns into something comprehensible in the C# world.  Sometimes that's because it's just bad code, sometimes it's because it's "alien" -- some things that are perfectly valid to write in pure assembly that never has to migrate to a non-assembly world aren't comprehensible to a C# interpreter.

This cycle repeats until what's in ILSpy looks not-stupid, in which case it's time to back up the original .dll in the game folder and chuck in the modded .dll and see what goes wrong.  (Something always goes wrong.  If nothing seems to, I assume it's just something less obvious I haven't triggered yet that I will find at the most annoying possible moment later, generally about 30 seconds after I published whatever it was, necessitating an embarrassing immediate hotfix.)  Lather, rinse, repeat until it's in a good enough shape for playtesting and publishing with copious disclaimers.

Why did I just write all that?  Eh, whatever, it's there and it's staying.   :)
Title: Re: FTL and ship design mods?
Post by: Red.Queen on April 29, 2015, 04:53:29 AM
For some reason, at the end of a tiring week when yawning my head off and waiting for the painkillers to finally kick in and do something about a headache, my brain decides that the best thing for me to do, rather than sleep, is to clear out Telerik and chuck AI War into the decompiler.

First impression?  Arcen's coding style is quite a bit different from the last few things I've looked at.  Odd mix of "this function name tells you literally everything that it does" vs. "this boolean's name is just 'number 12', go read 50 lines of code if you want to know what it's for".  Also, I can now say I have finally encountered classes so huge they take a full 2.5 seconds to open.  50,000+ lines in C# -- this is going to be *hilarious* in Assembly, if it clocks in at under 3.5M lines I will be amazed.  Navigating that is going to be an adventure.  Cue the "I see an electrical outlet and I'm gonna stick a fork in it" laugh.

Something something this game has Excel library functionality?  I wonder if that's how it does some of its "what's my best set of action options" sorting wizardry I remember seeing in a devblog post.  If so, that's the most inventive use of that bane-of-my-existence program I've ever seen.  (Ever seen some moron try to build a pseudo-website in Excel?  And then ask you to convert it to tiff images so it can be sent to a lawyer?  I HAVE.  Hate.)

HA!  I was right, Threat does ignore adjacent planet player fleet strength if it thinks it's engaged in combat.  What I saw in my last game was functioning normally as I suspected, there is still a hole that can be exploited to rope-a-dope the Threatfleet.  I can't wait to test exactly how far that deception can be pushed.

Oo planetary reinforcement seems to be influenced by how scary the stuff the player has nearby is, I thought I detected signs of this while playing, theories were right again.

These last two findings show I can actually play mind games with this AI.  I am going to get myself in so much trouble doing that and then miscalculating somehow.  It's going to be glorious.

Difficulty 9 is the last step before some AIP threshold stuff starts to scale non-linearly.

Right, I said I'd look at teleporting stuff, didn't I, time to stop rifling through the AI's brain for the moment and get back on topic.

Fascinating... I think teleportation might simply be handled via a couple of blocks buried in the main unit movement function, mostly an X/Y grid coordinate update bracketed by a fade out/in of the graphic and a cooldown on how frequently it can move.  I was expecting to find a dedicated teleportation function that gets called by the normal movement logic to override more ordinary movement, but apparently no.

Oh man, some of these single functions are just enormous, I can't wait to get this disassembled and see just how much space some of these reserve on the stack lol.  This thing just dwarfs the last game I worked on.

Found the classes where it sets a bunch of the individual unit properties, presumably importing them from the Unity prefab xmls packed in the .assets files.  It's like a text-based switchboard.  It even has a block where it just runs through all the ship types to see what it's looking at, helpfully showing me what all the internal names are and how to read them to ask the game "hey, uhhh what ship am I again?".  That will make manipulating individual ship properties so much less of a pain, shouldn't need to bother with hex editing prefabs and repacking them.  Good, because that was NOT happening, I hate hex editing.

I like this game as a player, and I am liking what I see under the hood as a modder, after getting past the initial shock of seeing single classes almost 60K lines long in C#.  I'm sure there are plenty of bear traps buried in stuff waiting for me to step in them as I wander about and mess with forces I don't fully comprehend, but eh.  I'm used to that.  Crashes are merely finger calisthenics for Alt+F4 and Ctrl+Alt+Del.

TL;DR: I can work with this.

Sometime when I am not falling asleep on my keyboard that is.  ;)
Title: Re: FTL and ship design mods?
Post by: Pumpkin on April 29, 2015, 08:50:14 AM
I'm looking forward to see Keith finding this post! :D
Title: Re: FTL and ship design mods?
Post by: Aklyon on April 29, 2015, 12:49:14 PM
IIRC, the excel functionality is either broken or it crashed something before, but it spits out a gianthuge pile of ships and stats and someone used it to update the wiki once before Dominus was here on the forums.
Title: Re: FTL and ship design mods?
Post by: Red.Queen on April 30, 2015, 02:39:09 AM
I'm looking forward to see Keith finding this post! :D

 8)

I already have some ideas brewing in my head for stuff to try.  I'll do a proof of concept with switching on teleportation for a normally non-teleporter first, since that's how this got started, and it'll be a way of checking to make sure my tools don't have some issue with handling disassembly/reassembly of this much code.

After that, it'll be time for me to go ahead and start filling the Blueprints folder in my working area with notes on potential stuff to build/alter that my brain is already starting to chew on.  I really need to sit down and actually open a Github repository for my stuff one of these days but time spent learning Git is time not spent learning Assembly/Lua/whatever language my current project needs...

IIRC, the excel functionality is either broken or it crashed something before, but it spits out a gianthuge pile of ships and stats and someone used it to update the wiki once before Dominus was here on the forums.

Good to know.  I'll probably run into a reference to whatever it is for at some point while diving the codebase.

***

Incidentally the sheer amount of logging this game does is incredible.  I knew it could do a lot just from the advanced logging snips I've seen posted around the forum, but damn.  Not quite the same impact as when you actually see all the instructions for it threaded through the actual working code.

Yeah, I just blissed out a bit on logging code of all things...  I get a bit excited when I have some beautiful new mystery to vivisect and tinker with.  It's fun from a practical perspective of "I get to play with fun results" and also from a development perspective of "I get to see how everything works and I get to absorb new techniques and new ideas."
Title: Re: FTL and ship design mods?
Post by: Red.Queen on April 30, 2015, 08:37:38 PM
Test case:  Upgrade Fighters with basic Teleportation to demonstrate feasibility of manipulating ship properties.

Disassembly: Success.  1.04M lines, 42 megabyte output.  Big fat file.

Arcen's odd coding style has the amusing result that certain functions are actually *less verbose* in MSIL than they are in C#.

Huh, never seen some of these operators before.  Open up some references in case I need 'em.  New stuff to learn.  Cool.

Large numerical values mean output is split between decimal and hexadecimal.  Arsepain.  I hate you sometimes ILDASM.

Arcen's sometimes-generic function and variable names make my usual tricks for finding what I want based off the C# less effective.  I am going to have to make heavy use of bookmarking and other assists to move around this stuff in any half-reasonable fashion.

Target acquired and relevant code inserted.  Hope I didn't just break stuff!

Reassembly: Success.

Weakness of ILSpy vs. Telerik discovered, ILSpy takes 3x longer to decompile huge classes.  That's going to suck in the future.

Visual sanity check passed, time to fire it up and see what goes wrong.

Game starts ok.

Savegame loads ok.

Mouseover nearest fighter -- "Teleporting" appears in the abilities list. Cool.

(http://i.imgur.com/TaUcdan.png)

Click on Fighter and right-click in circles around my home command station.  Poof poof poof poof.  Chuckle.

***TEST OK.***

Proof of concept file attached with instructions in the .zip.

Initial Modding Test:  Success.
Title: Re: FTL and ship design mods?
Post by: Aklyon on April 30, 2015, 08:46:35 PM
Is it effecting only player fighters though, or also the AI's fighters?
Title: Re: FTL and ship design mods?
Post by: Toranth on April 30, 2015, 09:30:58 PM
Disassembly: Success.  1.04M lines, 42 megabyte output.  Big fat file.
I'm impressed.  That's where I gave up.  The thought of trying to go through everything to make mods was just more than I wanted to deal with.

Is it effecting only player fighters though, or also the AI's fighters?
It should be all fighters.  Generally, the AI uses the same unit type object, with a different owner.  As far as I know, only for things that have different stats does the AI use a different unit type object.
Title: Re: FTL and ship design mods?
Post by: Red.Queen on May 01, 2015, 05:48:32 AM
I'm impressed.  That's where I gave up.  The thought of trying to go through everything to make mods was just more than I wanted to deal with.

<bow>

I switched over to AI War from 6 months of modding another game this way, I've gone numb to it at this point (mostly).  :) Now I just see IL_#### line tags and opcodes scrolling by in my sleep.  I use my own line tagging codes to make finding stuff again later easier, though for this one with its giant functions and frequently generic/unnamed elements I am going to have to just log overall vanilla/updated line positions in my repository so I can maintain stuff.

Is it effecting only player fighters though, or also the AI's fighters?
It should be all fighters.  Generally, the AI uses the same unit type object, with a different owner.  As far as I know, only for things that have different stats does the AI use a different unit type object.

Yup, you're correct Toranth.  The only other exception that I noticed at this point, sort of, is the Resistance vs. Marauder split.  They fall back to the same block of code that defines their numerical stats, but point to different assets in graphical construction, display name, and hostility.

Arcen's monolithic coding approach has its advantages.  What it lacks in readability/navigability at points, it makes up for it in being easy to extend.  This proof of concept took all of three lines of MSIL code to do -- the displayed ship properties update, movement changes, etc were all picked up automatically by the existing structures.  Hell, I wouldn't be surprised if it would automatically get filtered by the "teleporting" ship type in map setup, though I would have to double-check that, I do remember seeing certain classes tracked their covered ships by name rather than other properties.

Anyway, the priority in design on making it easy to expand for them is pretty apparent when you pop the top -- makes sense in light of their concern with long-term support/updating.
Title: Re: FTL and ship design mods?
Post by: Pumpkin on May 01, 2015, 07:29:19 AM
 :o

Very impressive. Gratz. It's like reading a sort of AAR :D

So, what are you up to, now? What was your goal, beyond "I can do it!!!" ? Is the point to test players' ideas before saying Chris/Keith: "it's okay, you can do that"?
Title: Re: FTL and ship design mods?
Post by: Red.Queen on May 01, 2015, 08:17:08 PM
 :) Thanks Pumpkin.  Hehe I suppose my modding devposts are rather AAR-like.  I got into the habit of doing that while working on SYABH both because I thought they were fun to write and share my thinking on design, and because there is so little documentation on how this method of modding is even done.

My own initial toehold had come from two offhanded posts from a guy tinkering with 7 Days to Die where he mentioned ILASM/ILDASM so I was able to start tracking down the tools I needed to reverse the C#, and another brief comment about the IL line numbering scheme that cleared up another question I had.  I decided once I started to get the hang of this kind of work that I would talk through what I do so there would be more information out there on how this is done.  It's not a full-blown "manual to MSIL modding" but it's a breadcrumb trail that someone who was interested enough could at least get some clues on how to get started.

Not that I ever expect sane people to bother with doing this, it's very time-consuming to write even small chunks of code in this language.  It's about as close to the metal as you can get before moving into the world of directly manipulating memory registers (and you CAN specifically read and write a given memory address from Assembly, if you want to) and binary.

In other words, it's sort of a pidgin language that humans can use when speaking to the machine -- and you have to think like the machine too in a lot of ways ("I have 8 slots available on the stack, I need to remember these 5 things and the order they are in, now I remove two and add three things back and then I do this last operation and all 6 things then produce the answer...").  Then you add in the detective-work involved every time I have to call anything in a Unity library...

As much of a headache as it can be/often is though, it's also very cool.  Working in it will teach you a lot about what the machine is actually doing, and there's something I find rather beautiful about its pure, no-frills functionality and logical clarity -- it's the essence of "no bullsh!t".  There is no ambiguity -- only A then B then C, tiny building-blocks of logic like atoms combining to produce emergent, sometimes chaotic complexity from predictable simplicity.

Sorry, I get a little poetic when I program sometimes.  :)

***

Pulling my head out of the digital clouds for a moment, the question about what my goal with all this is and what I'm up to.  Fair questions!

Well... I needed a test case to confirm that there were no initial obstacles to working on this particular game, so "I can do it!!!" was definitely a big part of it.  :)

Beyond that, it's mostly a cocktail of challenge-seeking and data-craving (must acquire new information, always, all the time!), plus the love of customizing my games to exactly what I want, whenever I want.  I also happen to like the atmosphere on these boards, the vast majority of people are polite and friendly here, so I'm inclined to share my work rather than just hoarding it.  If someone happens to want to use something I posted, great, if not, no big deal, everyone prefers different things in their game.

There's the added bonus of sharing here with the sociable devs in case they see something that saves them trouble, or that they like, either in whole or in part, or just makes them smile to see someone tinkering with their baby and exploring how it works.

Otherwise, the stuff currently getting mulled over to start with is trying some tweaks to Assault Transports, seeing what I can do to rework Beachheads into something I would want to try playing with, and maybe playing with cloaking and the AI.  All this Transport-talk made me think "wouldn't it be HORRIBLE if higher-mark Carriers could cloak like the player ATs?"  Or upgrading something with a cloaking aura so it has mobile cloak-sharing.

A common rule I have when thinking of stuff to do is that if it makes me laugh evilly when it pops into my head, it's an idea worth exploring.  >D  I also have a habit of trawling for forum posts discussing balance/ideas/etc to look for inspiration, either for new stuff to build or to identify potential balance quirks that might benefit from changing.  Saves me the trouble of having to run into every thing myself if I see a good discussion of other peoples' experiences that have plenty of hard data and persuasive arguments for why X should be Y instead.

Maybe I should post an open suggestions/brainstorming thread in this subforum or something, dunno -- that might get peoples' hopes up a bit too much on what I can/am willing to do.  I am a selfish creature who will generally work on what amuses ME most, first.  (It's *my* time, sanity, and alcohol supply that's getting spent, so I am going to get the stuff on my own wish list first.  ;) )

There are many possibilities, and I haven't even finished exploring the codebase yet.  :)
Title: Re: FTL and ship design mods?
Post by: Traveller on June 02, 2015, 02:53:03 PM
Hey Red.Queen, what's the difficulty for changing basic ship stats (cost, energy use, caps, shots, damage, etc) without doing fancy stuff like teleporting?  Does that still need decompiling/recompiling?  I've got some ideas for turret changes that I want to experiment with and see how they play.