Jump to content

Modding Question: How are Upgrades Stored?


Draxiss

Recommended Posts

I've been looking into making my own system upgrade scripts, and I've formed some questions:

 

Are the scripts located in /data/scripts/systems called only when a new system upgrade is generated, or every time a system upgrade is used?

 

If it's the latter, does that mean that system upgrades are stored as a seed and rarity value? If so, how would I go about creating a customizable upgrade? Would it be better to try to reverse-engineer a seed from the values given?

 

Eventually, I want to be able to custom-create my own system upgrades using commands.

 

While I have done a tutorial or two on LUA, I'm not super fluent (and I'm pretty unused to not having to declare my variables and an int, string, etc.), so there's a chance I'm missing something super obvious.

 

Also, are there any tutorials on adding custom turrets, system upgrades, blocks or suchlike to Avorion?

Link to comment
Share on other sites

Are the scripts located in /data/scripts/systems called only when a new system upgrade is generated, or every time a system upgrade is used?

 

The scripts in this directory are required to load a system upgrade (so you could not use an upgrade without its script). The seed gets generated when the upgrade is generated the first time, the values of the upgrade are always regenerated by the script, using the seed to calculate always the same values. By editing values in the scripts you can also modify upgrades you already have.

 

To make an own upgrade you could try to copy an existing and replace values, names and icons by your own ones (thats how I would do it).

If you want your upgrade to drop from enemies and get sold by equipment docks, you need to add your own script in /data/scripts/lib/upgradegenerator.lua like this:

 

.............
UpgradeGenerator.add("data/scripts/systems/shieldbooster.lua", 1)
UpgradeGenerator.add("data/scripts/systems/tradingoverview.lua", 1)
UpgradeGenerator.add("data/scripts/systems/velocitybypass.lua", 1)
UpgradeGenerator.add("data/scripts/systems/energytoshieldconverter.lua", 1)
UpgradeGenerator.add("data/scripts/systems/valuablesdetector.lua", 1)
UpgradeGenerator.add("data/scripts/systems/yourcustomscript.lua", 1)

 

The last line is the line you need to add, change "yourcustomscript" to the name of your script. Do not change any existing line.

 

If you want to create these upgrades only by commands you could try to modify the admin commands package and add your upgrade to it.

Link to comment
Share on other sites

Thanks for the info! That confirms what I was feared: you cannot directly control the properties of an upgrade unless you are able to calculate the exact seed needed to get your results. This makes what I'm trying to do a lot harder.

 

Is there a limit to the length of a seed?

Link to comment
Share on other sites

Basically, my problem is that I want to be able to create modules whose properties I could control, the way there's commands to control the properties of turrets. Since the only reference to seeds I could find gives a 32-bit integer for the value, that's all I have to go on. Does anyone know where seed generation for turrets is done? Is there any way I could store additional information about a module that I've custom-made?

 

Maybe if I set up a .txt file that has a list of custom turrets, treat the seed like a key to a particular custom configuration, and have the game reference the .txt file . . . ?

Link to comment
Share on other sites

You can controll the values of the upgrades. But not by commands.

Example - hyperspace reach amount:

 

reach = math.max(0, getInt(rarity.value, rarity.value * 2.5)) + 1

 

if you change this to

reach = (math.max(0, getInt(rarity.value, rarity.value * 2.5)) + 1) * 10

 

the total reach is multiplied by 10.

 

Or you do:

rech = 20

 

Then ALL upgrades that got the reach bonus, have a bonus 20. Doesnt matter wich rarity.

Then you could add a custom module with the values you want to have.

 

 

Btw... sometimes you talk about turrets, sometimes about upgrade. I dont understand at all wich one you want to modify.

 

For getting your own turrets you should use a turret spawning modded command.

Link to comment
Share on other sites

My end goal is to be able to control the creation of a given System Upgrade in a similar way to how I can control the creation of turrets: with commands.

 

I do not simply want to change how the Upgrade Script analyzes seeds (and rarities); I want to find a way to store more information about the upgrade so that a custom-generated upgrade will maintain its properties. The best workaround I can think of is writing an script for a new kind of system upgrade, called a Custom Upgrade, that uses the values passed through a seed in a predictable and controlled manner.

 

The problem I'm running into is that my (currently unoptimized) script requires the seed to be around 80 digits long (in base-10). As this is a little bit more than the 32-bit integer I found in the documentation, I'm looking into ways to compress/unpack the needed information.

 

Is the seed variable passed to System Upgrade scripts an instance of the Seed class found in the documentation? Is it possible to store and/or use multiple seeds for one System Upgrade? For that matter, is it possible to store other kinds of data for a particular System Upgrade?

Link to comment
Share on other sites

For that matter, where should I look to find the script that manages the storage/generation/modification of System Upgrades? For THAT matter, how would I go about creating entirely new kinds of inventory items? So far, I've seen System Upgrades, Turrets, and Licenses.

Link to comment
Share on other sites

It's a little confusing what you're trying to make; but from my interpretation you want to gain some level of control over how your upgrades are generated.

Personally, i wouldn't use the seed in any part. I'd probably use an alternate, custom function that i'd have control over instead. Possibly tapping into the distance to core and some RNG for good measure.

 

Also as your original posts how the upgrades are stored: When the lua runs and creates an upgrade. That upgrade is stored as an object, with it's own set of properties and methods.

 

The last bit of advice, and i hope this really helps. Check out the Avorion\Documentation folder in your installation folder. It has many of the properties/methods that can be called upon and is a great modding resource.

 

 

Link to comment
Share on other sites

Sort of.

 

Actually, based on your advice about RNG and distance to The Core, I'm actually trying to accomplish the opposite of what you describe. I want to eliminate the random components of System Upgrades. I'm want to be able to change the stats of a System Upgrade Module in a controlled many, such that I *wouldn't* have to guess-and-check my way to finding the right stats by trying out different seeds until I get the one I like. I want to be able to store the information I need about the module and retrieve it later.

 

I'm looking to eventually create a command to give a user a System Upgrade with the bonuses and energy costs specified in the command.

 

The two relevant sections in the documentation that have anything to do with this are SystemUpgradeTemplate and VanillaInventoryItem. The SystemUpgradeTemplate seems to be the most relevant; and confirms what I just said in an earlier post. The information the game uses to determine the stats of a System Upgrade is determined solely from a seed, rarity, and script location.

 

All the stats are calculated from the seed and rarity, using the script! I am *trying* to find a way to create a special class of System Upgrade that does not use seeds to retrieve information about already-created System Upgrades. Instead, I'm trying to create special scripts that can store/retrieve, say, Radar Bonuses from stored bonuses.

 

At this point, it looks like I must create a class that extends SystemUpgradeTemplate, and then figure out how to tell the game to use that extended object to call the script that actually details how to use that template. I'm sorry if I'm not articulating this clearly enough, but I'm having a lot of trouble figuring out what's going on and which scripts to look at next. I'm not even sure where the appropriate location to start writing a file that extends the SystemUpgradeTemplate. I'm currently just looking for classes that call SystemUpgradeTemplate to try to decide where to go from here.

Link to comment
Share on other sites

You could have a look at the [statsbonuses] in the enum.html (in the documentation)

 

It has these you could play around with:

 

RadarReach

HiddenSectorRadarReach

ScannerReach

HyperspaceReach

HyperspaceCooldown

HyperspaceRechargeEnergy

ShieldDurability

ShieldRecharge

Velocity

Acceleration

GeneratedEnergy

EnergyCapacity

BatteryRecharge

ArbitraryTurrets

UnarmedTurrets

ArmedTurrets

CargoHold

Engineers

Mechanics

Gunners

Miners

Security

Attackers

Sergeants

Lieutenants

Commanders

Generals

Captains

 

Just give it a linear value based on tech or distanct to core (or even material) - and then you eliminate any randomness

Link to comment
Share on other sites

I could NOT give it a linear value based on material because System Upgrades have no 'material' property. They have a seed, rarity, and script, and whatever calls the script passes down only a seed and rarity, so that's all I have to work with to create stat bonuses from. If I used the distance from core as a parameter to determine the bonus, that would just mean that a given System Upgrade's bonus would change as I got closer to the core. The problem is, the scripts I have to work with don't get passed an instance of a SystemUpgradeTemplate, they get passed a seed and a rarity.

 

For example, I cannot readily modify a script such as "arbitrarycts.lua" to set the number of bonus turrets and then later retrieve the value I set.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...