Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: ship_data and weapon_data Scripted Overwrite  (Read 4487 times)

Ranakastrasz

  • Admiral
  • *****
  • Posts: 702
  • Prince Corwin of Amber
    • View Profile
ship_data and weapon_data Scripted Overwrite
« on: April 21, 2015, 05:04:08 PM »

Is it possible to have a script of some kind, from a mod, access the fully setup ship_data or weapon_data files and edit them via whatever rule set you want?

I want to be able to apply certain changes to every ship globally, and doing so manually, or via an external program would be a pain, as well as requiring a redo with any alteration to said data.

My main intention is to increase armor (similar to orost's Revenge of the Armor Plates), and add hull and Armor regeneration (Orost's Armor Repair Hullmod), by adding passive hull mods and altering base value.

Additional things I want to try is altering ship's weapon type (energy/projectile/missile) depending on angle and angle size, and alter weapon types as well, to make something like Vacuum has. Also add ammo regen to all missiles, and other stuff. Mainly just want to be able to test global balance tweaks.

I mainly want to set this up for my own use. Hence I don't really care about innate balance, so much as being able to know if it is possible.
Logged
I think is easy for Simba and Mufasa sing the Circle of Life when they're on the top of the food chain, I bet the zebras hate that song.

Cigarettes are a lot like hamsters. Perfectly harmless, until you put one in your mouth and light it on fire

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: ship_data and weapon_data Scripted Overwrite
« Reply #1 on: April 21, 2015, 05:31:05 PM »

Use a grep parser :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

whatdoesthisbuttondo

  • Lieutenant
  • **
  • Posts: 90
    • View Profile
Re: ship_data and weapon_data Scripted Overwrite
« Reply #2 on: April 21, 2015, 05:36:31 PM »

Use a grep parser :)

I was just about to say...  ;D

Since he'll most likely want to do it on Windows, I'd suggest opening the ship_data.csv in Excel, applying a 'multiply column X by amount Y', and exporting to csv again.

For the hullmods, regex parsing and insert/replace over all the .ship files in your mod structure should do it, I'd say use Perl, no idea what you'd best use on Windows though.

You'll probably want to ship the vanilla data, as well as any data from mods you want to support with your mod though, and have your mod replace the original data.
Logged

Ranakastrasz

  • Admiral
  • *****
  • Posts: 702
  • Prince Corwin of Amber
    • View Profile
Re: ship_data and weapon_data Scripted Overwrite
« Reply #3 on: April 21, 2015, 07:03:43 PM »

That clears up what I thought.

The thing I was asking was if there was a way to do that without actually having to make those files to overwrite the old files via mod.
If this is not possible, then your methods would probably work.

That does seem like a faster method than search and replace however, and I wouldn't be surprised if Notepad++ supports it either.
Logged
I think is easy for Simba and Mufasa sing the Circle of Life when they're on the top of the food chain, I bet the zebras hate that song.

Cigarettes are a lot like hamsters. Perfectly harmless, until you put one in your mouth and light it on fire

whatdoesthisbuttondo

  • Lieutenant
  • **
  • Posts: 90
    • View Profile
Re: ship_data and weapon_data Scripted Overwrite
« Reply #4 on: April 21, 2015, 07:28:32 PM »

Notepad++ definitely supports Perl style regular expressions, and it apparently also has some pretty nifty features for csv editing as well according to a quick google search.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4688
    • View Profile
    • GitHub profile
Re: ship_data and weapon_data Scripted Overwrite
« Reply #5 on: April 21, 2015, 08:09:34 PM »

On the other hand, mass editing the files is something that can't be easily turned on/off and needs to be done separately for each mod that someone wants to tweak. So being able to do it in SS's Java code would still be nice.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: ship_data and weapon_data Scripted Overwrite
« Reply #6 on: April 22, 2015, 11:01:08 AM »

Yeah, well, we don't have access to those core data structures via the API, so we can't.  It's really too bad; it'd be very nice to alter this WeaponAPI or this weaponAPI's base Object that it is a clone of, etc., etc.  It's too bad that's all static.

You can also alter all of this data when a ShipAPI is spawned in combat; but then it's totally non-transparent to the players and I really don't think that's a good approach.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Ranakastrasz

  • Admiral
  • *****
  • Posts: 702
  • Prince Corwin of Amber
    • View Profile
Re: ship_data and weapon_data Scripted Overwrite
« Reply #7 on: April 22, 2015, 06:02:43 PM »

Yeah, well, we don't have access to those core data structures via the API, so we can't.  It's really too bad; it'd be very nice to alter this WeaponAPI or this weaponAPI's base Object that it is a clone of, etc., etc.  It's too bad that's all static.

You can also alter all of this data when a ShipAPI is spawned in combat; but then it's totally non-transparent to the players and I really don't think that's a good approach.

That is the actual question I Asked. So you cannot write a mod script that alters that data while the game is loading. You must do this in the data itself.

Irritating, but still do-able.
Logged
I think is easy for Simba and Mufasa sing the Circle of Life when they're on the top of the food chain, I bet the zebras hate that song.

Cigarettes are a lot like hamsters. Perfectly harmless, until you put one in your mouth and light it on fire

Ranakastrasz

  • Admiral
  • *****
  • Posts: 702
  • Prince Corwin of Amber
    • View Profile
Re: ship_data and weapon_data Scripted Overwrite
« Reply #8 on: April 29, 2015, 12:58:55 PM »

As a Followup, is it possible to add a set hullmod to all ships on spawn/load? That would make things a lot easier.
Logged
I think is easy for Simba and Mufasa sing the Circle of Life when they're on the top of the food chain, I bet the zebras hate that song.

Cigarettes are a lot like hamsters. Perfectly harmless, until you put one in your mouth and light it on fire

kazi

  • Admiral
  • *****
  • Posts: 714
    • View Profile
Re: ship_data and weapon_data Scripted Overwrite
« Reply #9 on: April 29, 2015, 06:07:22 PM »

Edit the .ship files to have a built-in hullmod.
Logged

TJJ

  • Admiral
  • *****
  • Posts: 1905
    • View Profile
Re: ship_data and weapon_data Scripted Overwrite
« Reply #10 on: April 30, 2015, 01:41:17 AM »

So you want to programmatically alter the data during load?
Logged

Ranakastrasz

  • Admiral
  • *****
  • Posts: 702
  • Prince Corwin of Amber
    • View Profile
Re: ship_data and weapon_data Scripted Overwrite
« Reply #11 on: April 30, 2015, 04:19:41 AM »

So you want to programmatically alter the data during load?
Yes, that is the idea, if possible.
Logged
I think is easy for Simba and Mufasa sing the Circle of Life when they're on the top of the food chain, I bet the zebras hate that song.

Cigarettes are a lot like hamsters. Perfectly harmless, until you put one in your mouth and light it on fire

whatdoesthisbuttondo

  • Lieutenant
  • **
  • Posts: 90
    • View Profile
Re: ship_data and weapon_data Scripted Overwrite
« Reply #12 on: April 30, 2015, 04:33:03 AM »

Edit the .ship files to have a built-in hullmod.

That would actually be pretty easy to do with a regex edit, and easily repeatable if you put it into a script.
Logged

LB

  • Lieutenant
  • **
  • Posts: 54
    • View Profile
Re: ship_data and weapon_data Scripted Overwrite
« Reply #13 on: May 07, 2015, 06:39:04 PM »

grep/perl/regexes are honestly really suboptimal tools for this situation; what you want is stream editing, so awk, sed, etc., since what you are really interested here is particular columns in CSVs, which is the perfect job for a stream editor which does all the tokenizing for you instead of trying to roll your own regex tokenization. Of course they're line-based so you'll have to find something else to edit .variant files for hullmods, which you could accomplish with something like (real roughly):

Input:
Code
"builtInMods":["brfluxmod", "high_maintenance"],   
Code
mv brdy_asura.ship brdy_asura.ship.bak && awk -F\" -v OFS=\" '/builtInMods/ { $4 = "targetingunit\", \"" $4; }1' brdy_asura.ship.bak > brdy_asura.ship

Where you can replace targetingunit with something else of your choosing or add more than one at once. The only thing is that spacing in the source file isn't guaranteed but hopefully no modder splits that line.

(now that I look at this, two sed cases plus a grep-check for "builtInMods" in a shell script would have been better since you catch .ships without an existing builtInMods line)
Logged