diff --git a/mod_info.lua b/mod_info.lua index f131ff0..86923d0 100644 --- a/mod_info.lua +++ b/mod_info.lua @@ -23,4 +23,11 @@ ui_only = false -- One unit in SupCom is 19.525m, we'll round to 20m -- Threat level is just BV, build cost is BV or BV*10 -- --- Damage conversions between BT and SupCom are 1:30, battlemechs have 30 times the HP as in tabletop +-- Damage conversions between BT and SupCom are 1:30, battlemechs have 30 times +-- the HP as in tabletop +-- +-- Most mechs are not heat-neutral or heat-negative on an alpha strike, and so +-- the damage their weapons do should be modified to account for pauses +-- required to avoid overheating. if a mech exceeds its heatsinks by 50% +-- (e.g. sinks 10 heat, alpha strike makes 15) there should be a 50% penalty to +-- damage or rate of fire \ No newline at end of file diff --git a/notebook.ipynb b/notebook.ipynb index 57e586e..1411f67 100644 --- a/notebook.ipynb +++ b/notebook.ipynb @@ -2,158 +2,459 @@ "cells": [ { "cell_type": "code", - "execution_count": null, - "id": "48125b87", + "execution_count": 70, + "id": "2cc54913", "metadata": {}, "outputs": [], "source": [ "import glob\n", "import re\n", "import pprint\n", + "import luadata\n", + "import json" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "id": "48125b87", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['units\\\\CLANERPPCTURRET\\\\CLANERPPCTURRET_unit.bp',\n", + " 'units\\\\CLANFACTORYAT1\\\\CLANFACTORYAT1_unit.bp',\n", + " 'units\\\\CLANJI50\\\\HHJI50_unit.bp',\n", + " 'units\\\\CLANJI50ML\\\\CLANJI50ML_unit.bp',\n", + " 'units\\\\CLANKIRGHIZB\\\\CLANKIRGHIZB_unit.bp',\n", + " 'units\\\\CLANLBX5TURRET\\\\CLANLBX5TURRET_unit.bp',\n", + " 'units\\\\CLANMECHBAY\\\\CLANMECHBAY_unit.bp',\n", + " 'units\\\\CLANMFACTORYT1\\\\CLANMFACTORYT1_unit.bp',\n", + " 'units\\\\CLANMFACTORYT2\\\\CLANMFACTORYT2_unit.bp',\n", + " 'units\\\\CLANMPLTURRET\\\\CLANMPLTURRET_unit.bp',\n", + " 'units\\\\CLANVFACTORYT1\\\\CLANVFACTORYT1_unit.bp',\n", + " 'units\\\\CLANVFACTORYT2\\\\CLANVFACTORYT2_unit.bp',\n", + " 'units\\\\CLANVISIGOTHB\\\\CLANVISIGOTHB_unit.bp',\n", + " 'units\\\\CLANWARHAWKPRIME\\\\CLANWARHAWKPRIME_unit.bp',\n", + " 'units\\\\FSAGS2D\\\\FSAGS2D_unit.bp',\n", + " 'units\\\\FSALACORN\\\\FSALACORN_unit.bp',\n", + " 'units\\\\FSAS7D\\\\FSAS7D_unit.bp',\n", + " 'units\\\\FSASW8Q\\\\FSASW8Q_unit.bp',\n", + " 'units\\\\FSBSWS2\\\\FSBSWS2_unit.bp',\n", + " 'units\\\\FSBSWX1\\\\FSBSWX1_unit.bp',\n", + " 'units\\\\FSBULLDOG\\\\FSBULLDOG_unit.bp',\n", + " 'units\\\\FSCALI\\\\FSCALI_unit.bp',\n", + " 'units\\\\FSCENTIPEDE\\\\FSCENTIPEDE_unit.bp',\n", + " 'units\\\\FSCENTURION\\\\FSCENTURION_unit.bp',\n", + " 'units\\\\FSCOM2D\\\\FSCOM2D_unit.bp',\n", + " 'units\\\\FSCOMET\\\\FSCOMET_unit.bp',\n", + " 'units\\\\FSCONDOR\\\\FSCONDOR_unit.bp',\n", + " 'units\\\\FSCPTLC1\\\\FSCPTLC1_unit.bp',\n", + " 'units\\\\FSCUT01D\\\\FSCUT01D_unit.bp',\n", + " 'units\\\\FSCUT1E\\\\FSCUT1E_unit.bp',\n", + " 'units\\\\FSFACTORYAT1\\\\FSFACTORYAT1_unit.bp',\n", + " 'units\\\\FSFACTORYAT2\\\\FSFACTORYAT2_unit.bp',\n", + " 'units\\\\FSFACTORYDST2\\\\FSFACTORYDST2_unit.bp',\n", + " 'units\\\\FSFACTORYLT1\\\\FSFACTORYLT1_unit.bp',\n", + " 'units\\\\FSFACTORYLT2\\\\FSFACTORYLT2_unit.bp',\n", + " 'units\\\\FSFACTORYNT1\\\\FSFACTORYNT1_unit.bp',\n", + " 'units\\\\FSGAZELLE\\\\FSGAZELLE_unit.bp',\n", + " 'units\\\\FSGENT1\\\\FSGENT1_unit.bp',\n", + " 'units\\\\FSGENT2\\\\FSGENT2_unit.bp',\n", + " 'units\\\\FSGRTURRET\\\\FSGRTURRET_unit.bp',\n", + " 'units\\\\FSHARASSER\\\\FSHARASSER_unit.bp',\n", + " 'units\\\\FSHVYTOWER\\\\FSHVYTOWER_unit.bp',\n", + " 'units\\\\FSISBA\\\\FSISBA_unit.bp',\n", + " 'units\\\\FSJEDGAR\\\\FSJEDGAR_unit.bp',\n", + " 'units\\\\FSJI50\\\\FSJI50_unit.bp',\n", + " 'units\\\\FSJI50ML\\\\FSJI50ML_unit.bp',\n", + " 'units\\\\FSJR7D\\\\FSJR7D_unit.bp',\n", + " 'units\\\\FSKARNOV\\\\FSKARNOV_unit.bp',\n", + " 'units\\\\FSLCT1M\\\\FSLCT1M_unit.bp',\n", + " 'units\\\\FSLEOPARD\\\\FSLEOPARDDS_unit.bp',\n", + " 'units\\\\FSLONGTOM\\\\FSLONGTOM_unit.bp',\n", + " 'units\\\\FSLONGTOMCANNON\\\\FSLONGTOMCANNON_unit.bp',\n", + " 'units\\\\FSLRM\\\\FSLRM_unit.bp',\n", + " 'units\\\\FSMANTICORE\\\\FSMANTICORE_unit.bp',\n", + " 'units\\\\FSMECHBAY\\\\FSMECHBAY_unit.bp',\n", + " 'units\\\\FSMETEOR\\\\FSMETEOR_unit.bp',\n", + " 'units\\\\FSMONITOR\\\\FSMONITOR_unit.bp',\n", + " 'units\\\\FSNEPTUNESTD\\\\FSNEPTUNESTD_unit.bp',\n", + " 'units\\\\FSPARTISAN\\\\FSPARTISAN_unit.bp',\n", + " 'units\\\\FSPEGASUS\\\\FSPEGASUS_unit.bp',\n", + " 'units\\\\FSPIKE\\\\FSPIKE_unit.bp',\n", + " 'units\\\\FSPILUM\\\\FSPILUM_unit.bp',\n", + " 'units\\\\FSREGULATOR\\\\FSREGULATOR_unit.bp',\n", + " 'units\\\\FSRVN3L\\\\FSRVN3L_unit.bp',\n", + " 'units\\\\FSSARACEN\\\\FSSARACEN_unit.bp',\n", + " 'units\\\\FSSCHREK\\\\FSSCHREK_unit.bp',\n", + " 'units\\\\FSSCORPIONLT\\\\FSSCORPIONLT_unit.bp',\n", + " 'units\\\\FSSF1X\\\\FSSF1X_unit.bp',\n", + " 'units\\\\FSSRM\\\\FSSRM_unit.bp',\n", + " 'units\\\\FSSTRIKERLT\\\\FSSTRIKERLT_unit.bp',\n", + " 'units\\\\FSSTUK5\\\\FSSTUK5_unit.bp',\n", + " 'units\\\\FST1AA\\\\FST1AA_unit.bp',\n", + " 'units\\\\FST1LLTURRET\\\\FST1LLTURRET_unit.bp',\n", + " 'units\\\\FST2AA\\\\FST2AA_unit.bp',\n", + " 'units\\\\FSTDR7SE\\\\FSTDR7SE_unit.bp',\n", + " 'units\\\\FSUZL2S\\\\FSUZL2S_unit.bp',\n", + " 'units\\\\FSVFACTORYT1\\\\FSVFACTORYT1_unit.bp',\n", + " 'units\\\\FSVFACTORYT2\\\\FSVFACTORYT2_unit.bp',\n", + " 'units\\\\FSVNLK100\\\\FSVNLK100_unit.bp',\n", + " 'units\\\\FSWARRIORH7\\\\FSWARRIORH7_unit.bp',\n", + " 'units\\\\HHEPONA\\\\HHEPONA_unit.bp',\n", + " 'units\\\\HHGOLEMROCK\\\\HHGOLEMROCK_unit.bp',\n", + " 'units\\\\HHHEPHAESTUS\\\\HHHEPHAESTUS_unit.bp',\n", + " 'units\\\\HHHVYTOWER\\\\HHHVYTOWER_unit.bp',\n", + " 'units\\\\HHMADDOGE\\\\HHMADDOGE_unit.bp',\n", + " 'units\\\\HHMARSXL\\\\HHMARSXL_unit.bp',\n", + " 'units\\\\HHORO\\\\HHORO_unit.bp',\n", + " 'units\\\\LAALACORN\\\\LAALACORN_unit.bp',\n", + " 'units\\\\LAAS7D\\\\LAAS7D_unit.bp',\n", + " 'units\\\\LAASW8Q\\\\LAASW8Q_unit.bp',\n", + " 'units\\\\LABSWS2\\\\LABSWS2_unit.bp',\n", + " 'units\\\\LABSWX1\\\\LABSWX1_unit.bp',\n", + " 'units\\\\LABULLDOG\\\\LABULLDOG_unit.bp',\n", + " 'units\\\\LACALI\\\\LACALI_unit.bp',\n", + " 'units\\\\LACENTIPEDE\\\\LACENTIPEDE_unit.bp',\n", + " 'units\\\\LACENTURION\\\\LACENTURION_unit.bp',\n", + " 'units\\\\LACOM2D\\\\LACOM2D_unit.bp',\n", + " 'units\\\\LACPTLC1\\\\LACPTLC1_unit.bp',\n", + " 'units\\\\LAEMP6S\\\\LAEMP6S_unit.bp',\n", + " 'units\\\\LAESTOC\\\\LAESTOC_unit.bp',\n", + " 'units\\\\LAF90\\\\LAF90_unit.bp',\n", + " 'units\\\\LAFACTORYAT1\\\\LAFACTORYAT1_unit.bp',\n", + " 'units\\\\LAFACTORYAT2\\\\LAFACTORYAT2_unit.bp',\n", + " 'units\\\\LAFACTORYDST2\\\\LAFACTORYDST2_unit.bp',\n", + " 'units\\\\LAFACTORYLT1\\\\LAFACTORYLT1_unit.bp',\n", + " 'units\\\\LAFACTORYLT2\\\\LAFACTORYLT2_unit.bp',\n", + " 'units\\\\LAFACTORYNT1\\\\LAFACTORYNT1_unit.bp',\n", + " 'units\\\\LAFNR5\\\\LAFNR5_unit.bp',\n", + " 'units\\\\LAGAZELLE\\\\LAGAZELLE_unit.bp',\n", + " 'units\\\\LAGENT1\\\\LAGENT1_unit.bp',\n", + " 'units\\\\LAGENT2\\\\LAGENT2_unit.bp',\n", + " 'units\\\\LAGRTURRET\\\\LAGRTURRET_unit.bp',\n", + " 'units\\\\LAGURTELTIERMBT\\\\LAGURTELTIERMBT_unit.bp',\n", + " 'units\\\\LAHBK4G\\\\LAHBK4G_unit.bp',\n", + " 'units\\\\LAHOLLANDERII\\\\LAHOLLANDERII_unit.bp',\n", + " 'units\\\\LAHVYTOWER\\\\LAHVYTOWER_unit.bp',\n", + " 'units\\\\LAISBA\\\\LAISBA_unit.bp',\n", + " 'units\\\\LAJI50\\\\LAJI50_unit.bp',\n", + " 'units\\\\LAJI50ML\\\\LAJI50ML_unit.bp',\n", + " 'units\\\\LAKARNOV\\\\LAKARNOV_unit.bp',\n", + " 'units\\\\LALEOPARD\\\\LALEOPARDDS_unit.bp',\n", + " 'units\\\\LALONGTOM\\\\LALONGTOM_unit.bp',\n", + " 'units\\\\LALONGTOMCANNON\\\\LALONGTOMCANNON_unit.bp',\n", + " 'units\\\\LALRM\\\\LALRM_unit.bp',\n", + " 'units\\\\LALTOWER\\\\LALTOWER_unit.bp',\n", + " 'units\\\\LAMANTICORE\\\\LAMANTICORE_unit.bp',\n", + " 'units\\\\LAMECHBAY\\\\LAMECHBAY_unit.bp',\n", + " 'units\\\\LAMONITOR\\\\LAMONITOR_unit.bp',\n", + " 'units\\\\LANEPTUNESTD\\\\LANEPTUNESTD_unit.bp',\n", + " 'units\\\\LAOWL\\\\LAOWL_unit.bp',\n", + " 'units\\\\LAOWL2\\\\LAOWL2_unit.bp',\n", + " 'units\\\\LAPARTISAN\\\\LAPARTISAN_unit.bp',\n", + " 'units\\\\LAPATTON\\\\LAPATTON_unit.bp',\n", + " 'units\\\\LAPATTONULTRA\\\\LAPATTONULTRA_unit.bp',\n", + " 'units\\\\LAPEGASUS\\\\LAPEGASUS_unit.bp',\n", + " 'units\\\\LAPILUM\\\\LAPILUM_unit.bp',\n", + " 'units\\\\LAPPR5T\\\\LAPPR5T_unit.bp',\n", + " 'units\\\\LAREGULATOR\\\\LAREGULATOR_unit.bp',\n", + " 'units\\\\LAROMMEL\\\\LAROMMEL_unit.bp',\n", + " 'units\\\\LASCHREK\\\\LASCHREK_unit.bp',\n", + " 'units\\\\LASRM\\\\LASRM_unit.bp',\n", + " 'units\\\\LASTEINADLER\\\\LASTEINADLER_unit.bp',\n", + " 'units\\\\LASTO4A\\\\LASTO4A_unit.bp',\n", + " 'units\\\\LASTRIKERLT\\\\LASTRIKERLT_unit.bp',\n", + " 'units\\\\LASTUK5\\\\LASTUK5_unit.bp',\n", + " 'units\\\\LASYDZ3A\\\\LASYDZ3A_unit.bp',\n", + " 'units\\\\LAT1AA\\\\LAT1AA_unit.bp',\n", + " 'units\\\\LAT1LLTURRET\\\\LAT1LLTURRET_unit.bp',\n", + " 'units\\\\LAT2AA\\\\LAT2AA_unit.bp',\n", + " 'units\\\\LATDR7SE\\\\LATDR7SE_unit.bp',\n", + " 'units\\\\LAUZL2S\\\\LAUZL2S_unit.bp',\n", + " 'units\\\\LAVFACTORYT1\\\\LAVFACTORYT1_unit.bp',\n", + " 'units\\\\LAVFACTORYT2\\\\LAVFACTORYT2_unit.bp',\n", + " 'units\\\\LAVNLK65N\\\\LAVNLK65N_unit.bp',\n", + " 'units\\\\LAWARRIORH7\\\\LAWARRIORH7_unit.bp',\n", + " 'units\\\\SRELEMENTAL\\\\SRELEMENTAL_unit.bp',\n", + " 'units\\\\SRKITFOX\\\\SRKITFOX_unit.bp',\n", + " 'units\\\\SRKITFOXC\\\\SRKITFOXC_unit.bp',\n", + " 'units\\\\SRKODIAK3\\\\SRKODIAK3_unit.bp',\n", + " 'units\\\\SRMADDOG\\\\SRMADDOG_unit.bp',\n", + " 'units\\\\SRORO\\\\SRORO_unit.bp',\n", + " 'units\\\\SROROHAG\\\\SROROHAG_unit.bp',\n", + " 'units\\\\SRRIFLEMANIIC\\\\SRRIFLEMANIIC_unit.bp',\n", + " 'units\\\\SRSTORMCROW\\\\SRSTORMCROW_unit.bp',\n", + " 'units\\\\SRSTORMCROWA\\\\SRSTORMCROWA_unit.bp',\n", + " 'units\\\\SRTIMBERWOLF\\\\SRTIMBERWOLF_unit.bp',\n", + " 'units\\\\WDBANDITCP\\\\WDBANDITCP_unit.bp']" + ] + }, + "execution_count": 68, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Find all blueprints\n", "\n", "files = glob.glob('units/*/*_unit.bp')\n", - "pprint.pprint(files)" + "files" ] }, { "cell_type": "code", "execution_count": null, - "id": "100d0de8", + "id": "7974de88", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "{'Destroyed': 125,\n", + " 'DoneBeingBuilt': 49,\n", + " 'UISelection': 167,\n", + " 'Fire': 407,\n", + " 'Construct': 27,\n", + " 'ConstructLoop': 27,\n", + " 'DeathExplosion': 34,\n", + " 'AmbientMove': 105,\n", + " 'CaptureLoop': 6,\n", + " 'HoverKilledOnWater': 19,\n", + " 'ReclaimLoop': 6,\n", + " 'StartCapture': 6,\n", + " 'StartMove': 118,\n", + " 'StartReclaim': 6,\n", + " 'StopMove': 118,\n", + " 'AirUnitWaterImpact': 23,\n", + " 'Killed': 65,\n", + " 'Landing': 23,\n", + " 'Refueling': 15,\n", + " 'Thruster': 23,\n", + " 'AmbientMoveLand': 13,\n", + " 'AmbientMoveWater': 13,\n", + " 'EnterWater': 13,\n", + " 'TransitionWater': 13,\n", + " 'ActiveLoop': 4,\n", + " 'AmbientMoveSub': 2,\n", + " 'StartMoveSub': 2,\n", + " 'StopMoveSub': 2,\n", + " 'SubmergeStart': 2,\n", + " 'SurfaceStart': 2,\n", + " 'BarrelLoop': 4,\n", + " 'BarrelStart': 4,\n", + " 'MuzzleChargeStart': 1}" + ] + }, + "execution_count": 69, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "for filename in files:\n", - " file = open(filename, 'r')\n", + "# Find all sound types\n", + "\n", + "sounds = {}\n", + "\n", + "for filepath in files:\n", + " file = open(filepath, 'r')\n", " lines = file.readlines()\n", "\n", - " for idx, line in enumerate(lines):\n", - " check = re.match(\"^(\\s*)(Health) = ([0-9]+),$\", line)\n", + " for line in lines:\n", + " check = re.match(r\"^(\\s*)(\\w+) = Sound {$\", line)\n", " if check is not None:\n", - " white = check.group(1)\n", - " label = check.group(2)\n", - " value = check.group(3)\n", - " num = int(value)\n", - " lines[idx] = f\"{white}{label} = {num * 30}, -- ({value}) * 30\\n\"\n", + " sound_type = check.group(2)\n", + " if sound_type in sounds:\n", + " sounds[sound_type] += 1\n", + " else:\n", + " sounds[sound_type] = 1\n", "\n", - " file.close()\n", - "\n", - " out = open(filename, 'w')\n", - " out.writelines(lines)\n", - " out.close()" + "sounds" ] }, { "cell_type": "code", "execution_count": null, - "id": "f1a0bbd2", + "id": "8075055d", "metadata": {}, "outputs": [], "source": [ - "for filename in files:\n", - " file = open(filename, 'r')\n", - " lines = file.readlines()\n", + "# Read lua\n", "\n", - " for idx, line in enumerate(lines):\n", - " maxcheck = re.match(\"^(\\s*)(MaxHealth) = ([0-9]+),$\", line)\n", - " if maxcheck is not None:\n", - " white = maxcheck.group(1)\n", - " label = maxcheck.group(2)\n", - " value = maxcheck.group(3)\n", - " num = int(value)\n", - " lines[idx] = f\"{white}{label} = {num * 30},\\n\"\n", + "damage_mult = 30\n", + "range_mult = 3\n", "\n", - " file.close()\n", + "for filepath in files:\n", + " blueprint = luadata.read(filepath)\n", "\n", - " out = open(filename, 'w')\n", - " out.writelines(lines)\n", - " out.close()" + " blueprint['Defense']['Health'] = blueprint['Defense']['Health'] * damage_mult\n", + " blueprint['Defense']['MaxHealth'] = blueprint['Defense']['MaxHealth'] * damage_mult\n", + "\n", + " for weapon in blueprint['Weapon']:\n", + " if weapon['DisplayName'] == 'Particle Projector Cannon':\n", + " weapon['Damage'] = 10 * damage_mult\n", + " weapon['MaxRadius'] = 18 * range_mult\n", + " weapon['MinRadius'] = 3 * range_mult\n", + " weapon['MuzzleVelocity'] = 30\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Small Laser':\n", + " weapon['Damage'] = 3 * damage_mult\n", + " weapon['MaxRadius'] = 3 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = 60\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Medium Laser':\n", + " weapon['Damage'] = 5 * damage_mult\n", + " weapon['MaxRadius'] = 9 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = 60\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Large Laser':\n", + " weapon['Damage'] = 8 * damage_mult\n", + " weapon['MaxRadius'] = 15 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = 60\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Small Pulse Laser':\n", + " weapon['Damage'] = 3 * damage_mult\n", + " weapon['MaxRadius'] = 3 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = 120\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Medium Pulse Laser':\n", + " weapon['Damage'] = 6 * damage_mult\n", + " weapon['MaxRadius'] = 6 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = 120\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Large Pulse Laser':\n", + " weapon['Damage'] = 9 * damage_mult\n", + " weapon['MaxRadius'] = 10 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = 120\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Short Range Missiles':\n", + " weapon['Damage'] = 2 * damage_mult\n", + " weapon['MaxRadius'] = 9 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = 15\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Missile'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Long Range Missiles':\n", + " weapon['Damage'] = 1 * damage_mult\n", + " weapon['MaxRadius'] = 21 * range_mult\n", + " weapon['MinRadius'] = 6 * range_mult\n", + " weapon['MuzzleVelocity'] = 15\n", + " weapon['BallisticArc'] = 'RULEUBA_High'\n", + " weapon['WeaponCategory'] = 'Missile'\n", + " weapon['RangeCategory'] = 'UWRC_IndirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Autocannon/2':\n", + " weapon['Damage'] = 2 * damage_mult\n", + " weapon['MaxRadius'] = 24 * range_mult\n", + " weapon['MinRadius'] = 4 * range_mult\n", + " weapon['MuzzleVelocity'] = 30\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Autocannon/5':\n", + " weapon['Damage'] = 1 * damage_mult\n", + " weapon['MaxRadius'] = 18 * range_mult\n", + " weapon['MinRadius'] = 3 * range_mult\n", + " weapon['MuzzleVelocity'] = 30\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Autocannon/10':\n", + " weapon['Damage'] = 10 * damage_mult\n", + " weapon['MaxRadius'] = 15 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = 30\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Autocannon/20':\n", + " weapon['Damage'] = 20 * damage_mult\n", + " weapon['MaxRadius'] = 9 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = 30\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'LB 10-X Autocannon':\n", + " weapon['Damage'] = 1 * damage_mult\n", + " weapon['MaxRadius'] = 18 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = 30\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Ultra Autocannon/5':\n", + " weapon['Damage'] = 5 * damage_mult\n", + " weapon['MaxRadius'] = 20 * range_mult\n", + " weapon['MinRadius'] = 5 * range_mult\n", + " weapon['MuzzleVelocity'] = 30\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + "luadata.write(filepath, blueprint, indent=' ', prefix='UnitBlueprint ')" ] }, { "cell_type": "code", "execution_count": null, - "id": "63e82c8d", + "id": "4fa4eaa9", "metadata": {}, "outputs": [], "source": [ - "for filename in files:\n", - " file = open(filename, 'r')\n", - " lines = file.readlines()\n", + "# luadata fixes\n", "\n", + "for filepath in files:\n", + " # gotta replace double quotes with singles\n", + " lines = open(filepath, 'r').readlines()\n", " for idx, line in enumerate(lines):\n", - " typecheck = re.match(\"^(\\s*)(ArmorType) = '(\\w+)',$\", line)\n", - " if typecheck is not None:\n", - " white = typecheck.group(1)\n", - " value = typecheck.group(3)\n", - " lines[idx] = f\"{white}ArmorType = 'Normal', -- '{value}'\\n\"\n", - "\n", - " file.close()\n", - "\n", - " out = open(filename, 'w')\n", - " out.writelines(lines)\n", - " out.close()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "0e1a79be", - "metadata": {}, - "outputs": [], - "source": [ - "for filename in files:\n", - " file = open(filename, 'r')\n", - " lines = file.readlines()\n", + " lines[idx] = line.replace('\\\"', '\\'')\n", "\n", + " # re-add sound class declaration\n", " for idx, line in enumerate(lines):\n", - " damcheck = re.match(\"^(\\s*)(Damage) = (.+),$\", line)\n", - " if damcheck is not None:\n", - " dncheck = re.match(\"^(\\s*)(DisplayName) = '(.+)',$\", lines[idx + 3])\n", - " if dncheck is not None:\n", - " white = damcheck.group(1)\n", - " value = damcheck.group(3)\n", - " num = \"\"\n", + " for sound in sounds.keys():\n", + " check = re.match(f\"^(\\s*){sound} = {{\", line)\n", + " if check is not None:\n", + " white = check.group(1)\n", + " lines[idx] = f\"{white}{sound} = Sound {{\\n\"\n", "\n", - " dn = dncheck.group(3)\n", - " if dn is \"Particle Projector Cannon\":\n", - " num = \"30, -- (10) * 30\"\n", - " if dn is \"Medium Laser\":\n", - " num = \"150, -- (5) * 30\"\n", - "\n", - " lines[idx] = f\"{white}Damage = {num},\\n\"\n", - "\n", - " file.close()\n", - "\n", - " out = open(filename, 'w')\n", - " out.writelines(lines)\n", - " out.close()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "2792e0e6", - "metadata": {}, - "outputs": [], - "source": [ - "for filename in files:\n", - " file = open(filename, 'r')\n", - " lines = file.readlines()\n", - "\n", - " for idx, line in enumerate(lines):\n", - " check = re.match(\"^(\\s*)(DamageType) = '(.+)',$\", line)\n", - " if check is not None and check.group(3) == \"BTCluster\":\n", - " white = check.group(1)\n", - " label = check.group(2)\n", - " second = re.match(\"^(\\s*)(DisplayName) = '(.+)',$\", lines[idx + 1])\n", - " if second is not None:\n", - " if second.group(3) == \"Long Range Missles\" or second.group(3) == \"Short Range Missles\":\n", - " lines[idx] = f\"{white}{label} = 'BTClusterMissile',\\n\"\n", - " if second.group(3) == \"LB 10-X Autocannon\" or second.group(3) == \"LBX5_rounds\":\n", - " lines[idx] = f\"{white}{label} = 'BTClusterBallistic',\\n\"\n", - " file.close()\n", - "\n", - " out = open(filename, 'w')\n", + " out = open(filepath, 'w')\n", " out.writelines(lines)\n", " out.close()" ] diff --git a/old_notebook.ipynb b/old_notebook.ipynb new file mode 100644 index 0000000..e60669e --- /dev/null +++ b/old_notebook.ipynb @@ -0,0 +1,202 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "9850e7b2", + "metadata": {}, + "outputs": [], + "source": [ + "# Convert all health values\n", + "\n", + "track = 0\n", + "\n", + "for filename in files:\n", + " file = open(filename, 'r')\n", + " lines = file.readlines()\n", + "\n", + " for idx, line in enumerate(lines):\n", + " check = re.match(\"^(\\s*)Health = ([0-9]+),$\", line)\n", + " if check is not None:\n", + " white = check.group(1)\n", + " value = check.group(2)\n", + " num = int(value)\n", + " lines[idx] = f\"{white}Health = {num * 30}, -- ({value}) * 30\\n\"\n", + "\n", + " maxcheck = re.match(\"^(\\s*)MaxHealth = ([0-9]+),$\", lines[idx + 1])\n", + " assert maxcheck is not None\n", + " white = maxcheck.group(1)\n", + " value = maxcheck.group(2)\n", + " num = int(value)\n", + " lines[idx + 1] = f\"{white}MaxHealth = {num * 30},\\n\"\n", + "\n", + " track += 1\n", + "\n", + " file.close()\n", + "\n", + " out = open(filename, 'w')\n", + " out.writelines(lines)\n", + " out.close()\n", + "\n", + "print(track)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6ab90bb8", + "metadata": {}, + "outputs": [], + "source": [ + "# Swap all armor types to Normal\n", + "\n", + "track = 0\n", + "\n", + "for filename in files:\n", + " file = open(filename, 'r')\n", + " lines = file.readlines()\n", + "\n", + " for idx, line in enumerate(lines):\n", + " check = re.match(\"^(\\s*)ArmorType = '(\\w+)',$\", line)\n", + " if check is not None:\n", + " white = check.group(1)\n", + " value = check.group(2)\n", + " lines[idx] = f\"{white}ArmorType = 'Normal', -- '{value}'\\n\"\n", + "\n", + " file.close()\n", + "\n", + " out = open(filename, 'w')\n", + " out.writelines(lines)\n", + " out.close()\n", + "\n", + "print(track)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a691b1cb", + "metadata": {}, + "outputs": [], + "source": [ + "# Update weapon damage\n", + "\n", + "track = 0\n", + "\n", + "for filename in files:\n", + " file = open(filename, 'r')\n", + " lines = file.readlines()\n", + "\n", + " for idx, line in enumerate(lines):\n", + " check = re.match(\"^(\\s*)Damage = (.+),$\", line)\n", + " if check is not None:\n", + " second = re.match(\"^(\\s*)DisplayName = '(.+)',$\", lines[idx + 4])\n", + " if second is None:\n", + " print(f'missed dn {filename}:{idx + 4}')\n", + " continue\n", + " third = re.match(\"^(\\s*)BallisticArc = '(.+)',$\", lines[idx - 2])\n", + " if third is None:\n", + " print(f'missed ba {filename}:{idx - 2}')\n", + " continue\n", + "\n", + " white = check.group(1)\n", + " second_white = second.group(1)\n", + " third_white = third.group(1)\n", + " damage = check.group(2)\n", + " display = second.group(2)\n", + "\n", + " number = 0\n", + " ballistic = \"\"\n", + " if display is \"Particle Projector Cannon\":\n", + " number = 10\n", + "\n", + " if display is \"Small Laser\":\n", + " number = 3\n", + " if display is \"Medium Laser\":\n", + " number = 5\n", + " if display is \"Large Laser\":\n", + " number = 8\n", + "\n", + " if display is \"Short Range Missiles\":\n", + " number = 2\n", + " if display is \"Long Range Missiles\":\n", + " number = 1\n", + "\n", + " if display is \"Autocannon/2\":\n", + " number = 2\n", + " ballistic = \"RULEUBA_LowArc\"\n", + " if display is \"Autocannon/5\":\n", + " number = 5\n", + " ballistic = \"RULEUBA_LowArc\"\n", + " if display is \"Autocannon/10\":\n", + " number = 10\n", + " ballistic = \"RULEUBA_LowArc\"\n", + " if display is \"Autocannon/20\":\n", + " number = 20\n", + " ballistic = \"RULEUBA_LowArc\"\n", + "\n", + " track += 1\n", + " lines[idx] = f\"{white}Damage = {number * 30}, -- ({number}) * 30\\n\"\n", + " if len(ballistic) > 0:\n", + " lines[idx - 2] = f\"{third_white}BallisticArc = '{ballistic}',\\n\"\n", + "\n", + " file.close()\n", + "\n", + " # out = open(filename, 'w')\n", + " # out.writelines(lines)\n", + " # out.close()\n", + "\n", + "print(track)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7da6ab86", + "metadata": {}, + "outputs": [], + "source": [ + "# Split cluster damage types\n", + "\n", + "track = 0\n", + "\n", + "for filename in files:\n", + " file = open(filename, 'r')\n", + " lines = file.readlines()\n", + "\n", + " for idx, line in enumerate(lines):\n", + " check = re.match(\"^(\\s*)(DamageType) = '(.+)',$\", line)\n", + " if check is not None and check.group(3) == \"BTCluster\":\n", + " white = check.group(1)\n", + " label = check.group(2)\n", + " \n", + " second = re.match(\"^(\\s*)(DisplayName) = '(.+)',$\", lines[idx + 1])\n", + " if second is not None:\n", + " if second.group(3) == \"Long Range Missles\" or second.group(3) == \"Short Range Missles\":\n", + " lines[idx] = f\"{white}{label} = 'BTClusterMissile',\\n\"\n", + " if second.group(3) == \"LB 10-X Autocannon\" or second.group(3) == \"LBX5_rounds\":\n", + " lines[idx] = f\"{white}{label} = 'BTClusterBallistic',\\n\"\n", + " file.close()\n", + "\n", + " out = open(filename, 'w')\n", + " out.writelines(lines)\n", + " out.close()\n", + "\n", + "print(track)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv (3.11.3)", + "language": "python", + "name": "python3" + }, + "language_info": { + "name": "python", + "version": "3.11.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}