diff --git a/bootstrap.ipynb b/bootstrap.ipynb new file mode 100644 index 0000000..1d32326 --- /dev/null +++ b/bootstrap.ipynb @@ -0,0 +1,483 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "303e19a3", + "metadata": {}, + "outputs": [], + "source": [ + "# Imports\n", + "\n", + "import glob\n", + "import re\n", + "import luadata" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "ef2ee6b7", + "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": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Find all blueprints\n", + "\n", + "files = glob.glob('units/*/*_unit.bp')\n", + "files" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "6f07d9b7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'Destroyed': 125,\n", + " 'DoneBeingBuilt': 49,\n", + " 'UISelection': 167,\n", + " 'Fire': 409,\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": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Find all sound types\n", + "\n", + "sounds = {}\n", + "\n", + "for filepath in files:\n", + " file = open(filepath, 'r')\n", + " lines = file.readlines()\n", + " file.close()\n", + "\n", + " for line in lines:\n", + " check = re.match(r\"^(\\s*)(\\w+) = Sound {$\", line)\n", + " if check is not None:\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", + "sounds" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "570ecc1a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Find units without vision\n", + "\n", + "missing = []\n", + "\n", + "for filepath in files:\n", + " file = open(filepath, 'r')\n", + " lines = file.readlines()\n", + " file.close()\n", + "\n", + " found = False\n", + " for line in lines:\n", + " if 'VisionRadius' in line:\n", + " found = True\n", + "\n", + " if not found:\n", + " missing.append(filepath)\n", + "\n", + "missing" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c3cc0f94", + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "for filepath in files:\n", + " file = open(filepath, 'r')\n", + " lines = file.readlines()\n", + " file.close()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "dd858b10", + "metadata": {}, + "outputs": [], + "source": [ + "# Bootstrap battletech unit blueprints\n", + "\n", + "for filepath in files:\n", + " blueprint = luadata.read(filepath)\n", + "\n", + " blueprint['BTSource'] = {}\n", + " blueprint['BTSource']['BattleValue'] = blueprint['Defense']['SurfaceThreatLevel']\n", + " blueprint['BTSource']['Tonnage'] = blueprint['BuildIconSortPriority']\n", + " blueprint['BTSource']['HitPoints'] = blueprint['Defense']['Health']\n", + "\n", + " if 'MECH' in blueprint['Categories']:\n", + " blueprint['BTSource']['UnitType'] = 'BATTLEMECH'\n", + " if 'HOVER' in blueprint['Categories']:\n", + " blueprint['BTSource']['UnitType'] = 'TANK'\n", + " if 'VEHICLE' in blueprint['Categories']:\n", + " blueprint['BTSource']['UnitType'] = 'TANK'\n", + " if 'SUBMERSIBLE' in blueprint['Categories']:\n", + " blueprint['BTSource']['UnitType'] = 'NAVAL'\n", + " if 'DESTROYER' in blueprint['Categories']:\n", + " blueprint['BTSource']['UnitType'] = 'NAVAL'\n", + "\n", + " luadata.write(filepath, blueprint, indent=' ', prefix='UnitBlueprint ')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "23a74ed9", + "metadata": {}, + "outputs": [], + "source": [ + "# Replace faction categories with verbose copies\n", + "\n", + "for filepath in files:\n", + " blueprint = luadata.read(filepath)\n", + "\n", + " if 'CLAN' in blueprint['Categories']:\n", + " blueprint['Categories'].append('AEON')\n", + " blueprint['General']['FactionName'] = 'CLAN'\n", + "\n", + " if 'HH' in blueprint['Categories']:\n", + " blueprint['Categories'].remove('HH')\n", + " blueprint['Categories'].append('CLAN')\n", + " blueprint['Categories'].append('HELLSHORSES')\n", + " blueprint['Categories'].append('AEON')\n", + " blueprint['General']['FactionName'] = 'CLAN'\n", + "\n", + " if 'FS' in blueprint['Categories']:\n", + " blueprint['Categories'].remove('FS')\n", + " blueprint['Categories'].append('FEDERATEDSUNS')\n", + " blueprint['Categories'].append('INNERSPHERE')\n", + " blueprint['Categories'].append('UEF')\n", + " blueprint['General']['FactionName'] = 'INNERSPHERE'\n", + "\n", + " if 'LA' in blueprint['Categories']:\n", + " blueprint['Categories'].remove('LA')\n", + " blueprint['Categories'].append('LYRANALLIANCE')\n", + " blueprint['Categories'].append('INNERSPHERE')\n", + " blueprint['Categories'].append('UEF')\n", + " blueprint['General']['FactionName'] = 'INNERSPHERE'\n", + "\n", + " if 'SR' in blueprint['Categories']:\n", + " blueprint['Categories'].remove('SR')\n", + " blueprint['Categories'].append('CLAN')\n", + " blueprint['Categories'].append('SNOWRAVEN')\n", + " blueprint['Categories'].append('AEON')\n", + " blueprint['General']['FactionName'] = 'CLAN'\n", + "\n", + " blueprint['Categories'].sort()\n", + "\n", + " luadata.write(filepath, blueprint, indent=' ', prefix='UnitBlueprint ')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b64a0f08", + "metadata": {}, + "outputs": [], + "source": [ + "# Fix clan weapon labels\n", + "\n", + "for filepath in files:\n", + " blueprint = luadata.read(filepath)\n", + " if 'Weapon' in blueprint:\n", + " for weapon in blueprint['Weapon']:\n", + " if 'CLAN' in blueprint['Categories']:\n", + " if not weapon['DisplayName'].startswith('Clan '):\n", + " weapon['DisplayName'] = 'Clan ' + weapon['DisplayName']\n", + "\n", + " luadata.write(filepath, blueprint, indent=' ', prefix='UnitBlueprint ')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "19ebbe75", + "metadata": {}, + "outputs": [], + "source": [ + "# luadata fixes\n", + "\n", + "for filepath in files:\n", + " inc = open(filepath, 'r')\n", + " lines = inc.readlines()\n", + " inc.close()\n", + "\n", + " # gotta replace double quotes with singles\n", + " for idx, line in enumerate(lines):\n", + " lines[idx] = line.replace('\\\"', '\\'')\n", + "\n", + " # re-add sound class declaration\n", + " for idx, line in enumerate(lines):\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", + " out = open(filepath, 'w')\n", + " out.writelines(lines)\n", + " out.close()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv (3.11.3)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/mod_info.lua b/mod_info.lua index c7a17c4..c651392 100644 --- a/mod_info.lua +++ b/mod_info.lua @@ -2,7 +2,7 @@ name = "Supreme Mech Commander 2" uid = "6ceff22d-b021-44d2-86a1-638c2af4ef95" version = 1 copyright = "GPL v3" -description = "Supreme Mech Commander 2" +description = "An update to Supreme Mech Commander with tabletop-faithful conversion of BattleTech units." author = "Kamisama171 and FuegoTigre and CardboardBread" -- url = "https://example.com" icon = "/mods/Supreme Mech Commander 2/Mini_icon.jpg" diff --git a/notebook.ipynb b/notebook.ipynb index 2807d1d..2e7f387 100644 --- a/notebook.ipynb +++ b/notebook.ipynb @@ -2,19 +2,29 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "2cc54913", "metadata": {}, "outputs": [], "source": [ + "# Imports and globals\n", + "\n", "import glob\n", "import re\n", - "import luadata" + "import luadata\n", + "\n", + "damage_mult = 30\n", + "range_mult = 3\n", + "\n", + "ballistic_velocity = 30\n", + "energy_velocity = 60\n", + "pulse_velocity = 120\n", + "missile_velocity = 15\n" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 8, "id": "48125b87", "metadata": {}, "outputs": [ @@ -190,7 +200,7 @@ " 'units\\\\WDBANDITCP\\\\WDBANDITCP_unit.bp']" ] }, - "execution_count": 2, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -204,7 +214,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 9, "id": "7974de88", "metadata": {}, "outputs": [ @@ -246,7 +256,7 @@ " 'MuzzleChargeStart': 1}" ] }, - "execution_count": 3, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -273,107 +283,22 @@ "sounds" ] }, - { - "cell_type": "code", - "execution_count": 5, - "id": "7a2e3da2", - "metadata": {}, - "outputs": [], - "source": [ - "# Bootstrap battletech unit blueprints\n", - "\n", - "for filepath in files:\n", - " blueprint = luadata.read(filepath)\n", - "\n", - " thing1 = blueprint['Defense']['SurfaceThreatLevel']\n", - " thing2 = blueprint['Defense']['SubThreatLevel']\n", - " thing3 = blueprint['Defense']['EconomyThreatLevel']\n", - " thing4 = blueprint['Defense']['AirThreatLevel']\n", - "\n", - " blueprint['Source'] = {}\n", - " blueprint['Source']['BattleValue'] = blueprint['Defense']['SurfaceThreatLevel']\n", - " blueprint['Source']['Tonnage'] = blueprint['BuildIconSortPriority']\n", - " blueprint['Source']['HitPoints'] = blueprint['Defense']['Health']\n", - "\n", - " if 'MECH' in blueprint['Categories']:\n", - " blueprint['Source']['UnitType'] = 'BATTLEMECH'\n", - " if 'HOVER' in blueprint['Categories']:\n", - " blueprint['Source']['UnitType'] = 'TANK'\n", - " if 'VEHICLE' in blueprint['Categories']:\n", - " blueprint['Source']['UnitType'] = 'TANK'\n", - " if 'SUBMERSIBLE' in blueprint['Categories']:\n", - " blueprint['Source']['UnitType'] = 'NAVAL'\n", - " if 'DESTROYER' in blueprint['Categories']:\n", - " blueprint['Source']['UnitType'] = 'NAVAL'\n", - "\n", - " luadata.write(filepath, blueprint, indent=' ', prefix='UnitBlueprint ')" - ] - }, { "cell_type": "code", "execution_count": null, - "id": "7e47c775", + "id": "f75cfb51", "metadata": {}, "outputs": [], "source": [ - "# Replace clan categories with verbose copies\n", + "# Sanity check\n", "\n", "for filepath in files:\n", " blueprint = luadata.read(filepath)\n", "\n", - " if 'CLAN' in blueprint['Categories']:\n", - " blueprint['Categories'].append('AEON')\n", - " blueprint['General']['FactionName'] = 'CLAN'\n", - "\n", - " if 'HH' in blueprint['Categories']:\n", - " blueprint['Categories'].remove('HH')\n", - " blueprint['Categories'].append('CLAN')\n", - " blueprint['Categories'].append('HELLSHORSES')\n", - " blueprint['Categories'].append('AEON')\n", - " blueprint['General']['FactionName'] = 'CLAN'\n", - "\n", - " if 'FS' in blueprint['Categories']:\n", - " blueprint['Categories'].remove('FS')\n", - " blueprint['Categories'].append('FEDSUNS')\n", - " blueprint['Categories'].append('INNERSPHERE')\n", - " blueprint['Categories'].append('UEF')\n", - " blueprint['General']['FactionName'] = 'INNERSPHERE'\n", - "\n", - " if 'LA' in blueprint['Categories']:\n", - " blueprint['Categories'].remove('LA')\n", - " blueprint['Categories'].append('LYRANALLIANCE')\n", - " blueprint['Categories'].append('INNERSPHERE')\n", - " blueprint['Categories'].append('UEF')\n", - " blueprint['General']['FactionName'] = 'INNERSPHERE'\n", - "\n", - " if 'SR' in blueprint['Categories']:\n", - " blueprint['Categories'].remove('SR')\n", - " blueprint['Categories'].append('CLAN')\n", - " blueprint['Categories'].append('SNOWRAVEN')\n", - " blueprint['Categories'].append('AEON')\n", - " blueprint['General']['FactionName'] = 'CLAN'\n", - "\n", - " luadata.write(filepath, blueprint, indent=' ', prefix='UnitBlueprint ')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "94b33b3a", - "metadata": {}, - "outputs": [], - "source": [ - "# Fix clan weapon labels\n", - "\n", - "for filepath in files:\n", - " blueprint = luadata.read(filepath)\n", - " if 'Weapon' in blueprint:\n", - " for weapon in blueprint['Weapon']:\n", - " if 'CLAN' in blueprint['Categories']:\n", - " if not weapon['DisplayName'].startsWith('Clan '):\n", - " weapon['DisplayName'] = 'Clan ' + weapon['DisplayName']\n", - "\n", - " luadata.write(filepath, blueprint, indent=' ', prefix='UnitBlueprint ')" + " assert 'BTSource' in blueprint\n", + " assert 'BattleValue' in blueprint['BTSource']\n", + " assert 'Tonnage' in blueprint['BTSource']\n", + " assert 'HitPoints' in blueprint['BTSource']" ] }, { @@ -383,37 +308,256 @@ "metadata": {}, "outputs": [], "source": [ - "# Compute converted unit values\n", - "\n", - "damage_mult = 30\n", - "range_mult = 3\n", + "# Compute defense\n", "\n", "for filepath in files:\n", " blueprint = luadata.read(filepath)\n", "\n", - " battle_value = blueprint['Source']['BattleValue']\n", + " assert 'Defense' in blueprint\n", + " \n", + " battle_value = blueprint['BTSource']['BattleValue']\n", + " tonnage = blueprint['BTSource']['Tonnage']\n", + " hit_points = blueprint['BTSource']['HitPoints']\n", + "\n", + " # air threat\n", + " is_air_threat = 'AIR' in blueprint['Categories'] or 'ANTIAIR' in blueprint['Categories'] or 'HIGHALTAIR' in blueprint['Categories']\n", + " if is_air_threat:\n", + " if battle_value != 0:\n", + " blueprint['Defense']['AirThreatLevel'] = battle_value / 10\n", + " elif tonnage != 0:\n", + " blueprint['Defense']['AirThreatLevel'] = tonnage\n", + " else:\n", + " blueprint['Defense']['AirThreatLevel'] = hit_points / 1000\n", + " if not is_air_threat and 'AirThreatLevel' in blueprint['Defense']:\n", + " blueprint['Defense'].remove('AirThreatLevel')\n", + "\n", + " # economy threat\n", + " is_economy_threat = 'STRUCTURE' in blueprint['Categories']\n", + " if is_economy_threat:\n", + " if battle_value != 0:\n", + " blueprint['Defense']['EconomyThreatLevel'] = battle_value / 10\n", + " elif tonnage != 0:\n", + " blueprint['Defense']['EconomyThreatLevel'] = tonnage\n", + " else:\n", + " blueprint['Defense']['EconomyThreatLevel'] = hit_points / 1000\n", + " if not is_economy_threat and 'EconomyThreatLevel' in blueprint['Defense']:\n", + " blueprint['Defense'].remove('EconomyThreatLevel')\n", + "\n", + " # sub threat\n", + " is_sub_threat = 'NAVAL' in blueprint['Categories'] or 'ANTINAVY' in blueprint['Categories']\n", + " if is_sub_threat:\n", + " if battle_value != 0:\n", + " blueprint['Defense']['SubThreatLevel'] = battle_value / 10\n", + " elif tonnage != 0:\n", + " blueprint['Defense']['SubThreatLevel'] = tonnage\n", + " else:\n", + " blueprint['Defense']['SubThreatLevel'] = hit_points / 1000\n", + " if not is_sub_threat and 'SubThreatLevel' in blueprint['Defense']:\n", + " blueprint['Defense'].remove('SubThreatLevel')\n", + "\n", + " # surface threat\n", + " is_surface_threat = 'LAND' in blueprint['Categories']\n", + " if is_surface_threat:\n", + " if battle_value != 0:\n", + " blueprint['Defense']['SurfaceThreatLevel'] = battle_value / 10\n", + " elif tonnage != 0:\n", + " blueprint['Defense']['SurfaceThreatLevel'] = tonnage\n", + " else:\n", + " blueprint['Defense']['SurfaceThreatLevel'] = hit_points / 1000\n", + " if not is_surface_threat and 'SurfaceThreatLevel' in blueprint['Defense']:\n", + " blueprint['Defense'].remove('SurfaceThreatLevel')\n", + "\n", + " # health\n", + " blueprint['Defense']['Health'] = hit_points * damage_mult\n", + " blueprint['Defense']['MaxHealth'] = hit_points * damage_mult\n", + "\n", + " luadata.write(filepath, blueprint, indent=' ', prefix='UnitBlueprint ')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d69eb968", + "metadata": {}, + "outputs": [], + "source": [ + "# Compute economy\n", + "\n", + "for filepath in files:\n", + " blueprint = luadata.read(filepath)\n", + "\n", + " assert 'Economy' in blueprint\n", + "\n", + " battle_value = blueprint['BTSource']['BattleValue']\n", + " tonnage = blueprint['BTSource']['Tonnage']\n", + " hit_points = blueprint['BTSource']['HitPoints']\n", + "\n", + " # build cost\n", " if battle_value != 0:\n", " blueprint['Economy']['BuildCostMass'] = battle_value\n", " blueprint['Economy']['BuildCostEnergy'] = battle_value * 10\n", - "\n", - " tonnage = blueprint['Source']['Tonnage']\n", - " blueprint['Economy']['BuildTime'] = tonnage * 30\n", - " if battle_value != 0:\n", - " blueprint['Economy']['BuildRate'] = battle_value / tonnage\n", " else:\n", - " blueprint['Economy']['BuildRate'] = 60\n", + " blueprint['Economy']['BuildCostMass'] = hit_points / 5\n", + " blueprint['Economy']['BuildCostEnergy'] = hit_points / 2\n", "\n", - " if 'ANTIAIR' in blueprint['Categories'] and battle_value != 0:\n", - " blueprint['Defense']['AirThreatLevel'] = battle_value\n", + " # build time\n", + " if tonnage != 0 and battle_value != 0:\n", + " blueprint['Economy']['BuildTime'] = (tonnage * 10) * (battle_value / 100)\n", + " elif tonnage != 0:\n", + " blueprint['Economy']['BuildTime'] = tonnage * 50\n", + " elif battle_value != 0:\n", + " blueprint['Economy']['BuildTime'] = battle_value / 60\n", + " else:\n", + " blueprint['Economy']['BuildTime'] = hit_points / 3600\n", "\n", - " if 'StorageEnergy' in blueprint['Economy']:\n", + " # storage\n", + " if battle_value != 0 and 'StorageEnergy' in blueprint['Economy']:\n", " blueprint['Economy']['StorageEnergy'] = battle_value * 5\n", - " if 'StorageMass' in blueprint['Economy']:\n", + " if battle_value != 0 and 'StorageMass' in blueprint['Economy']:\n", " blueprint['Economy']['StorageMass'] = battle_value / 2\n", "\n", - " hit_points = blueprint['Source']['HitPoints']\n", - " blueprint['Defense']['Health'] = hit_points * damage_mult\n", - " blueprint['Defense']['MaxHealth'] = hit_points * damage_mult\n", + " luadata.write(filepath, blueprint, indent=' ', prefix='UnitBlueprint ')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "23747809", + "metadata": {}, + "outputs": [], + "source": [ + "# Standardize weapon targets\n", + "\n", + "for filepath in files:\n", + " blueprint = luadata.read(filepath)\n", + " \n", + " if 'Weapon' in blueprint:\n", + " for weapon in blueprint['Weapon']:\n", + "\n", + " # weapon['AboveWaterFireOnly']\n", + " # weapon['AboveWaterTargetsOnly']\n", + "\n", + " weapon['FireTargetLayerCapsTable'] = {} # clear existing\n", + "\n", + " if 'AIR' in blueprint['Categories'] or 'HIGHALTAIR' in blueprint['Categories']:\n", + " weapon['FireTargetLayerCapsTable']['Air'] = 'Air|Land|Water'\n", + " weapon['FireTargetLayerCapsTable']['Land'] = 'Air|Land|Water'\n", + "\n", + " if 'LAND' in blueprint['Categories']:\n", + " weapon['FireTargetLayerCapsTable']['Land'] = 'Air|Land|Water'\n", + " \n", + " if 'MECH' in blueprint['Categories']:\n", + " weapon['FireTargetLayerCapsTable']['Land'] = 'Air|Land|Water'\n", + " weapon['FireTargetLayerCapsTable']['Water'] = 'Air|Land|Water|Sub|Seabed'\n", + " weapon['FireTargetLayerCapsTable']['Seabed'] = 'Water|Sub|Seabed'\n", + "\n", + " if 'HOVER' in blueprint['Categories']:\n", + " weapon['FireTargetLayerCapsTable']['Land'] = 'Air|Land|Water'\n", + " weapon['FireTargetLayerCapsTable']['Water'] = 'Air|Land|Water'\n", + "\n", + " if 'NAVAL' in blueprint['Categories']:\n", + " weapon['FireTargetLayerCapsTable']['Water'] = 'Air|Land|Water|Sub|Seabed'\n", + "\n", + " if 'SUBMERSIBLE' in blueprint['Categories']:\n", + " weapon['FireTargetLayerCapsTable']['Water'] = 'Air|Land|Water|Sub|Seabed'\n", + " weapon['FireTargetLayerCapsTable']['Sub'] = 'Water|Sub|Seabed'\n", + " weapon['FireTargetLayerCapsTable']['Seabed'] = 'Water|Sub|Seabed'\n", + "\n", + " weapon['TargetRestrictDisallow'] = 'UNTARGETABLE'\n", + "\n", + " if 'Intel' in blueprint and 'RadarRadius' in blueprint['Intel']:\n", + " weapon['TrackingRadius'] = blueprint['Intel']['RadarRadius']\n", + " elif 'Intel' in blueprint and 'VisionRadius' in blueprint['Intel']:\n", + " weapon['TrackingRadius'] = blueprint['Intel']['VisionRadius']\n", + "\n", + " luadata.write(filepath, blueprint, indent=' ', prefix='UnitBlueprint ')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c2ce647b", + "metadata": {}, + "outputs": [], + "source": [ + "# Standardize weapon target priorities\n", + "\n", + "minimal = [\n", + " 'SPECIALHIGHPRI',\n", + " 'SPECIALLOWPRI',\n", + " 'ALLUNITS',\n", + "]\n", + "bomber = [\n", + " 'SPECIALHIGHPRI',\n", + " 'STRUCTURE',\n", + " 'SPECIALLOWPRI',\n", + " 'ALLUNITS',\n", + "]\n", + "basic = [\n", + " 'SPECIALHIGHPRI',\n", + " 'MOBILE',\n", + " 'STRUCTURE DEFENSE',\n", + " 'SPECIALLOWPRI',\n", + " 'ALLUNITS',\n", + "]\n", + "chaff = [\n", + " 'SPECIALHIGHPRI',\n", + " 'TECH1 MOBILE',\n", + " 'TECH2 MOBILE',\n", + " 'TECH3 MOBILE',\n", + " 'STRUCTURE DEFENSE',\n", + " 'SPECIALLOWPRI',\n", + " 'ALLUNITS',\n", + "]\n", + "focus = [\n", + " 'SPECIALHIGHPRI',\n", + " 'TECH3 MOBILE',\n", + " 'TECH2 MOBILE',\n", + " 'TECH1 MOBILE',\n", + " 'STRUCTURE DEFENSE',\n", + " 'SPECIALLOWPRI',\n", + " 'ALLUNITS',\n", + "]\n", + "air = [\n", + " 'SPECIALHIGHPRI',\n", + " 'AIR MOBILE HIGHPRIAIR',\n", + " 'AIR MOBILE TECH3 BOMBER',\n", + " 'AIR MOBILE BOMBER',\n", + " 'AIR MOBILE GROUNDATTACK',\n", + " 'AIR MOBILE TRANSPORTATION',\n", + " 'AIR MOBILE',\n", + " 'SPECIALLOWPRI',\n", + " 'ALLUNITS',\n", + "]\n", + "air_focus = [\n", + " 'SPECIALHIGHPRI',\n", + " 'TECH3 MOBILE',\n", + " 'TECH2 MOBILE',\n", + " 'TECH1 MOBILE',\n", + " 'AIR MOBILE HIGHPRIAIR',\n", + " 'AIR MOBILE TECH3 BOMBER',\n", + " 'AIR MOBILE BOMBER',\n", + " 'AIR MOBILE GROUNDATTACK',\n", + " 'AIR MOBILE TRANSPORTATION',\n", + " 'AIR MOBILE',\n", + " 'STRUCTURE DEFENSE',\n", + " 'SPECIALLOWPRI',\n", + " 'ALLUNITS',\n", + "]\n", + "naval_maingun = [\n", + " 'SPECIALHIGHPRI',\n", + " 'NAVAL MOBILE',\n", + " 'SPECIALLOWPRI',\n", + " 'ALLUNITS',\n", + "]\n", + "\n", + "for filepath in files:\n", + " blueprint = luadata.read(filepath)\n", + " \n", + " if 'Weapon' in blueprint:\n", + " for weapon in blueprint['Weapon']:\n", + " if blueprint['WeaponCategory'] == 'Bomb':\n", + " weapon['TargetPriorities'] = bomber\n", "\n", " luadata.write(filepath, blueprint, indent=' ', prefix='UnitBlueprint ')" ] @@ -427,264 +571,161 @@ "source": [ "# Standardize weapon stats\n", "\n", - "damage_mult = 30\n", - "range_mult = 3\n", - "\n", - "ballistic_velocity = 30\n", - "energy_velocity = 60\n", - "pulse_velocity = 120\n", - "missile_velocity = 15\n", - "\n", "for filepath in files:\n", " blueprint = luadata.read(filepath)\n", + " \n", " if 'Weapon' in blueprint:\n", " for weapon in blueprint['Weapon']:\n", - " # if 'MECH' in blueprint['Categories']:\n", - " # weapon['FireTargetLayerCapsTable']['Land'] = 'Land|Water|Air'\n", - " # weapon['FireTargetLayerCapsTable']['Water'] = 'Land|Water'\n", - " # weapon['FireTargetLayerCapsTable']['Seabed'] = 'Water|Sub|Seabed'\n", - " # if 'VEHICLE' in blueprint['Categories']:\n", - " # weapon['FireTargetLayerCapsTable']['Land'] = 'Land|Water|Air'\n", - " # if 'HOVER' in blueprint['Categories']:\n", - " # weapon['FireTargetLayerCapsTable']['Land'] = 'Land|Water|Air'\n", - " # weapon['FireTargetLayerCapsTable']['Water'] = 'Land|Water|Air'\n", - " # if 'DESTROYER' in blueprint['Categories']:\n", - " # weapon['FireTargetLayerCapsTable']['Water'] = 'Land|Water|Air'\n", - " # if 'SUBMERSIBLE' in blueprint['Categories']:\n", - " # weapon['FireTargetLayerCapsTable']['Water'] = 'Land|Water|Air|Sub|Seabed'\n", - " # weapon['FireTargetLayerCapsTable']['Sub'] = 'Water|Sub|Seabed'\n", - " # weapon['FireTargetLayerCapsTable']['Seabed'] = 'Water|Sub|Seabed'\n", - "\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['MuzzleVelocity'] = ballistic_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['ProjectileId'] = '/projectiles/ADFOblivionCannon01/ADFOblivionCannon01_proj.bp'\n", "\n", " if weapon['DisplayName'] == 'Extended-Range Particle Projector Cannon':\n", " weapon['Damage'] = 10 * damage_mult\n", " weapon['MaxRadius'] = 23 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 30\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['ProjectileId'] = '/projectiles/ADFOblivionCannon02/ADFOblivionCannon02_proj.bp'\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['MuzzleVelocity'] = energy_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['ProjectileId'] = '/projectiles/CDFLaserHeavy01/CDFLaserHeavy01_proj.bp'\n", + " # weapon['BeamCollisionDelay'] = 2\n", + " # weapon['BeamLifetime'] = 2\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['MuzzleVelocity'] = energy_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['ProjectileId'] = '/projectiles/CDFLaserHeavy02/CDFLaserHeavy02_proj.bp'\n", + " # weapon['BeamCollisionDelay'] = 2\n", + " # weapon['BeamLifetime'] = 2\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['MuzzleVelocity'] = energy_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['ProjectileId'] = '/projectiles/CDFLaserHeavy03/CDFLaserHeavy03_proj.bp'\n", + " # weapon['BeamCollisionDelay'] = 2\n", + " # weapon['BeamLifetime'] = 2\n", "\n", " if weapon['DisplayName'] == 'Extended-Range Small Laser':\n", " weapon['Damage'] = 3 * damage_mult\n", " weapon['MaxRadius'] = 5 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 60\n", + " weapon['MuzzleVelocity'] = energy_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['ProjectileId'] = '/projectiles/CDFLaserHeavy01/CDFLaserHeavy01_proj.bp'\n", + " # weapon['BeamCollisionDelay'] = 2\n", + " # weapon['BeamLifetime'] = 2\n", "\n", " if weapon['DisplayName'] == 'Extended-Range Medium Laser':\n", " weapon['Damage'] = 5 * damage_mult\n", " weapon['MaxRadius'] = 12 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 60\n", + " weapon['MuzzleVelocity'] = energy_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['ProjectileId'] = '/projectiles/CDFLaserHeavy02/CDFLaserHeavy02_proj.bp'\n", + " # weapon['BeamCollisionDelay'] = 2\n", + " # weapon['BeamLifetime'] = 2\n", "\n", " if weapon['DisplayName'] == 'Extended-Range Large Laser':\n", " weapon['Damage'] = 8 * damage_mult\n", " weapon['MaxRadius'] = 19 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 60\n", + " weapon['MuzzleVelocity'] = energy_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['ProjectileId'] = '/projectiles/CDFLaserHeavy03/CDFLaserHeavy03_proj.bp'\n", + " # weapon['BeamCollisionDelay'] = 2\n", + " # weapon['BeamLifetime'] = 2\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['MuzzleVelocity'] = pulse_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['BeamCollisionDelay'] = 0.5\n", + " weapon['BeamLifetime'] = 0.5\n", "\n", " if weapon['DisplayName'] == 'Medium Pulse Laser':\n", - " weapon['Damage'] = 6 * damage_mult\n", + " weapon['Damage'] = 6 * damage_mult / 2\n", " weapon['MaxRadius'] = 6 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 120\n", + " weapon['MuzzleVelocity'] = pulse_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['BeamCollisionDelay'] = 0.5\n", + " weapon['BeamLifetime'] = 0.5\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['MuzzleVelocity'] = pulse_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['BeamCollisionDelay'] = 0.5\n", + " weapon['BeamLifetime'] = 0.5\n", "\n", " if weapon['DisplayName'] == 'Short Range Missiles' or weapon['DisplayName'] == 'Clan 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['MuzzleVelocity'] = missile_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Missile'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['ProjectileId'] = '/mods/Supreme Mech Commander 2/projectiles/LRMMissile/LRMMissile_proj.bp'\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['MuzzleVelocity'] = missile_velocity\n", + " weapon['BallisticArc'] = 'RULEUBA_HighArc'\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 2-X Autocannon':\n", - " weapon['Damage'] = 1 * damage_mult\n", - " weapon['MaxRadius'] = 27 * 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'] == 'LB 5-X Autocannon':\n", - " weapon['Damage'] = 1 * damage_mult\n", - " weapon['MaxRadius'] = 21 * 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'] == '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'] == 'LB 20-X Autocannon':\n", - " weapon['Damage'] = 1 * damage_mult\n", - " weapon['MaxRadius'] = 12 * 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/2':\n", - " weapon['Damage'] = 2 * damage_mult\n", - " weapon['MaxRadius'] = 25 * 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'] == 'Ultra Autocannon/5':\n", - " weapon['Damage'] = 5 * damage_mult\n", - " weapon['MaxRadius'] = 20 * range_mult\n", - " weapon['MinRadius'] = 2 * 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/10':\n", - " weapon['Damage'] = 10 * 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/20':\n", - " weapon['Damage'] = 20 * damage_mult\n", - " weapon['MaxRadius'] = 10 * 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", + " weapon['ProjectileId'] = '/mods/Supreme Mech Commander 2/projectiles/LRMMissile/LRMMissile_proj.bp'\n", "\n", " if weapon['DisplayName'] == 'Gauss Rifle':\n", " weapon['Damage'] = 15 * damage_mult\n", " weapon['MaxRadius'] = 22 * range_mult\n", " weapon['MinRadius'] = 2 * range_mult\n", - " weapon['MuzzleVelocity'] = 30\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", @@ -693,7 +734,7 @@ " weapon['Damage'] = 25 * damage_mult # FIXME: damage falloff 25/20/10\n", " weapon['MaxRadius'] = 20 * range_mult\n", " weapon['MinRadius'] = 4 * range_mult\n", - " weapon['MuzzleVelocity'] = 30\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", @@ -702,7 +743,7 @@ " weapon['Damage'] = 1 * damage_mult\n", " weapon['MaxRadius'] = 6 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 30\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", @@ -711,7 +752,7 @@ " weapon['Damage'] = 2 * damage_mult\n", " weapon['MaxRadius'] = 3 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 30\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", @@ -720,7 +761,7 @@ " weapon['Damage'] = 3 * damage_mult\n", " weapon['MaxRadius'] = 7 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 30\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", @@ -729,20 +770,27 @@ " weapon['Damage'] = 2 * damage_mult\n", " weapon['MaxRadius'] = 2 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 30\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " # weapon['FireTargetLayerCapsTable']['Air'] = 'Air'\n", + " weapon['FireTargetLayerCapsTable']['Land'] = 'Land'\n", + " weapon['FireTargetLayerCapsTable']['Water'] = 'Water'\n", + " # weapon['FireTargetLayerCapsTable']['Sub'] = 'Sub'\n", + " weapon['FireTargetLayerCapsTable']['Seabed'] = 'Seabed'\n", "\n", " if weapon['DisplayName'] == 'Short Range Torpedoes':\n", " weapon['Damage'] = 2 * damage_mult\n", " weapon['MaxRadius'] = 9 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 15\n", + " weapon['MuzzleVelocity'] = missile_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Anti Navy'\n", " weapon['RangeCategory'] = 'UWRC_AntiNavy'\n", " weapon['TargetRestrictDisallow'] = 'UNTARGETABLE, HOVER'\n", + " # weapon['FireTargetLayerCapsTable']['Air'] = 'Water|Sub|Seabed'\n", + " # weapon['FireTargetLayerCapsTable']['Land'] = 'Water|Sub|Seabed'\n", " weapon['FireTargetLayerCapsTable']['Water'] = 'Water|Sub|Seabed'\n", " weapon['FireTargetLayerCapsTable']['Sub'] = 'Water|Sub|Seabed'\n", " weapon['FireTargetLayerCapsTable']['Seabed'] = 'Water|Sub|Seabed'\n", @@ -751,83 +799,275 @@ " weapon['Damage'] = 1 * damage_mult\n", " weapon['MaxRadius'] = 21 * range_mult\n", " weapon['MinRadius'] = 6 * range_mult\n", - " weapon['MuzzleVelocity'] = 15\n", + " weapon['MuzzleVelocity'] = missile_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Anti Navy'\n", " weapon['RangeCategory'] = 'UWRC_AntiNavy'\n", " weapon['TargetRestrictDisallow'] = 'UNTARGETABLE, HOVER'\n", + " weapon['FireTargetLayerCapsTable']['Air'] = 'Water|Sub|Seabed'\n", + " weapon['FireTargetLayerCapsTable']['Land'] = 'Water|Sub|Seabed'\n", " weapon['FireTargetLayerCapsTable']['Water'] = 'Water|Sub|Seabed'\n", " weapon['FireTargetLayerCapsTable']['Sub'] = 'Water|Sub|Seabed'\n", " weapon['FireTargetLayerCapsTable']['Seabed'] = 'Water|Sub|Seabed'\n", "\n", + " if weapon['DisplayName'] == 'Anti Missile System':\n", + " weapon['Damage'] = 1 * damage_mult\n", + " weapon['MaxRadius'] = 1 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Defense'\n", + " weapon['RangeCategory'] = 'UWRC_Countermeasure'\n", + " weapon['TargetType'] = 'RULEWTT_Projectile'\n", + " weapon['TargetRestrictOnlyAllow'] = 'TACTICAL MISSILE'\n", + "\n", + " luadata.write(filepath, blueprint, indent=' ', prefix='UnitBlueprint ')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "56a7499a", + "metadata": {}, + "outputs": [], + "source": [ + "# Standardize autocannon weapon stats\n", + "\n", + "for filepath in files:\n", + " blueprint = luadata.read(filepath)\n", + " \n", + " if 'Weapon' in blueprint:\n", + " for weapon in blueprint['Weapon']:\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'] = ballistic_velocity\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'] = ballistic_velocity\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'] = ballistic_velocity\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'] = ballistic_velocity\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'LB 2-X Autocannon':\n", + " weapon['Damage'] = 1 * damage_mult\n", + " weapon['MaxRadius'] = 27 * range_mult\n", + " weapon['MinRadius'] = 4 * range_mult\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'LB 5-X Autocannon':\n", + " weapon['Damage'] = 1 * damage_mult\n", + " weapon['MaxRadius'] = 21 * range_mult\n", + " weapon['MinRadius'] = 3 * range_mult\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\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'] = ballistic_velocity\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'LB 20-X Autocannon':\n", + " weapon['Damage'] = 1 * damage_mult\n", + " weapon['MaxRadius'] = 12 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Ultra Autocannon/2':\n", + " weapon['Damage'] = 2 * damage_mult\n", + " weapon['MaxRadius'] = 25 * range_mult\n", + " weapon['MinRadius'] = 3 * range_mult\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\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'] = 2 * range_mult\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Ultra Autocannon/10':\n", + " weapon['Damage'] = 10 * damage_mult\n", + " weapon['MaxRadius'] = 18 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Ultra Autocannon/20':\n", + " weapon['Damage'] = 20 * damage_mult\n", + " weapon['MaxRadius'] = 10 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Rotary Autocannon/2':\n", + " weapon['Damage'] = 2 * damage_mult\n", + " weapon['MaxRadius'] = 18 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " if weapon['DisplayName'] == 'Rotary Autocannon/5':\n", + " weapon['Damage'] = 5 * damage_mult\n", + " weapon['MaxRadius'] = 15 * range_mult\n", + " weapon['MinRadius'] = 0 * range_mult\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", + " weapon['BallisticArc'] = 'RULEUBA_None'\n", + " weapon['WeaponCategory'] = 'Direct Fire'\n", + " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + "\n", + " # if weapon['DisplayName'] == 'Rotary Autocannon/10':\n", + " # if weapon['DisplayName'] == 'Rotary Autocannon/20':\n", + "\n", + " luadata.write(filepath, blueprint, indent=' ', prefix='UnitBlueprint ')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3d1cc8e3", + "metadata": {}, + "outputs": [], + "source": [ + "# Standardize clan weapon stats\n", + "\n", + "for filepath in files:\n", + " blueprint = luadata.read(filepath)\n", + " \n", + " if 'Weapon' in blueprint:\n", + " for weapon in blueprint['Weapon']:\n", " if weapon['DisplayName'] == 'Clan Extended-Range Particle Projector Cannon':\n", " weapon['Damage'] = 15 * damage_mult\n", " weapon['MaxRadius'] = 23 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 30\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['ProjectileId'] = '/projectiles/ADFOblivionCannon03/ADFOblivionCannon03_proj.bp'\n", "\n", " if weapon['DisplayName'] == 'Clan Extended-Range Small Laser':\n", " weapon['Damage'] = 5 * damage_mult\n", " weapon['MaxRadius'] = 6 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 60\n", + " weapon['MuzzleVelocity'] = energy_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['ProjectileId'] = '/projectiles/CDFLaserHeavy01/CDFLaserHeavy01_proj.bp'\n", + " # weapon['BeamCollisionDelay'] = 2\n", + " # weapon['BeamLifetime'] = 2\n", "\n", " if weapon['DisplayName'] == 'Clan Extended-Range Medium Laser':\n", " weapon['Damage'] = 7 * damage_mult\n", " weapon['MaxRadius'] = 15 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 60\n", + " weapon['MuzzleVelocity'] = energy_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['ProjectileId'] = '/projectiles/CDFLaserHeavy02/CDFLaserHeavy02_proj.bp'\n", + " # weapon['BeamCollisionDelay'] = 2\n", + " # weapon['BeamLifetime'] = 2\n", "\n", " if weapon['DisplayName'] == 'Clan Extended-Range Large Laser':\n", " weapon['Damage'] = 10 * damage_mult\n", " weapon['MaxRadius'] = 25 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 60\n", + " weapon['MuzzleVelocity'] = energy_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['ProjectileId'] = '/projectiles/CDFLaserHeavy03/CDFLaserHeavy03_proj.bp'\n", + " # weapon['BeamCollisionDelay'] = 2\n", + " # weapon['BeamLifetime'] = 2\n", "\n", " if weapon['DisplayName'] == 'Clan Small Pulse Laser':\n", " weapon['Damage'] = 3 * damage_mult\n", " weapon['MaxRadius'] = 6 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 60\n", + " weapon['MuzzleVelocity'] = pulse_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['BeamCollisionDelay'] = 0.5\n", + " weapon['BeamLifetime'] = 0.5\n", "\n", " if weapon['DisplayName'] == 'Clan Medium Pulse Laser':\n", " weapon['Damage'] = 7 * damage_mult\n", " weapon['MaxRadius'] = 12 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 60\n", + " weapon['MuzzleVelocity'] = pulse_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['BeamCollisionDelay'] = 0.5\n", + " weapon['BeamLifetime'] = 0.5\n", "\n", " if weapon['DisplayName'] == 'Clan Large Pulse Laser':\n", " weapon['Damage'] = 10 * damage_mult\n", " weapon['MaxRadius'] = 20 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 60\n", + " weapon['MuzzleVelocity'] = pulse_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", + " weapon['BeamCollisionDelay'] = 0.5\n", + " weapon['BeamLifetime'] = 0.5\n", "\n", " if weapon['DisplayName'] == 'Clan Gauss Rifle':\n", " weapon['Damage'] = 15 * damage_mult\n", " weapon['MaxRadius'] = 22 * range_mult\n", " weapon['MinRadius'] = 2 * range_mult\n", - " weapon['MuzzleVelocity'] = 60\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", @@ -836,7 +1076,7 @@ " weapon['Damage'] = 1 * damage_mult\n", " weapon['MaxRadius'] = 24 * range_mult\n", " weapon['MinRadius'] = 2 * range_mult\n", - " weapon['MuzzleVelocity'] = 30\n", + " weapon['MuzzleVelocity'] = ballistic_velocity\n", " weapon['BallisticArc'] = 'RULEUBA_None'\n", " weapon['WeaponCategory'] = 'Direct Fire'\n", " weapon['RangeCategory'] = 'UWRC_DirectFire'\n", @@ -845,17 +1085,51 @@ " weapon['Damage'] = 1 * damage_mult\n", " weapon['MaxRadius'] = 21 * range_mult\n", " weapon['MinRadius'] = 0 * range_mult\n", - " weapon['MuzzleVelocity'] = 15\n", - " weapon['BallisticArc'] = 'RULEUBA_High'\n", + " weapon['MuzzleVelocity'] = missile_velocity\n", + " weapon['BallisticArc'] = 'RULEUBA_HighArc'\n", " weapon['WeaponCategory'] = 'Missile'\n", " weapon['RangeCategory'] = 'UWRC_IndirectFire'\n", + " weapon['ProjectileId'] = '/mods/Supreme Mech Commander 2/projectiles/LRMMissile/LRMMissile_proj.bp'\n", "\n", " luadata.write(filepath, blueprint, indent=' ', prefix='UnitBlueprint ')" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, + "id": "b63faa32", + "metadata": {}, + "outputs": [], + "source": [ + "# Cleanup\n", + "\n", + "for filepath in files:\n", + " blueprint = luadata.read(filepath)\n", + "\n", + " # blueprint.sort()\n", + " # blueprint['Air'].sort()\n", + " # blueprint['Audio'].sort()\n", + " # blueprint['Buffs']['Regen'].sort()\n", + " # blueprint['Categories'].sort()\n", + " # blueprint['Defense'].sort()\n", + " # blueprint['Display'].sort()\n", + " # blueprint['Economy'].sort()\n", + " # blueprint['General'].sort()\n", + " # blueprint['Intel'].sort()\n", + " # blueprint['Veteran'].sort()\n", + "\n", + " # if 'Weapon' in blueprint:\n", + " # for weapon in blueprint['Weapon']:\n", + " # if weapon['MinRadius'] == 0:\n", + " # weapon.remove('MinRadius')\n", + " # weapon.sort()\n", + " \n", + " # luadata.write(filepath, blueprint, indent=' ', prefix='UnitBlueprint ')" + ] + }, + { + "cell_type": "code", + "execution_count": 40, "id": "f545b050", "metadata": {}, "outputs": [],