Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,906 changes: 266 additions & 1,640 deletions LuaRules/Configs/dynamic_comm_defs.lua

Large diffs are not rendered by default.

82 changes: 82 additions & 0 deletions LuaRules/Configs/expected_module_ids.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
--
local basicChassis = { "recon", "strike", "assault", "support", "knight" }

local generated = {
[1] = { name = "nullmodule", },
[2] = { name = "nullbasicweapon", requireChassis = { [1] = "knight", }, },
[3] = { name = "nulladvweapon", },
[4] = { name = "nulldualbasicweapon", },
[5] = { name = "commweapon_beamlaser", },
[6] = { name = "commweapon_flamethrower", requireChassis = { [1] = "recon", [2] = "assault", [3] = "knight", }, },
[7] = { name = "commweapon_heatray", requireChassis = { [1] = "assault", [2] = "knight", }, },
[8] = { name = "commweapon_heavymachinegun", requireChassis = { [1] = "recon", [2] = "assault", [3] = "strike", [4] = "knight", }, },
[9] = { name = "commweapon_lightninggun", requireChassis = { [1] = "recon", [2] = "support", [3] = "strike", [4] = "knight", }, },
[10] = { name = "commweapon_lparticlebeam", requireChassis = { [1] = "support", [2] = "recon", [3] = "strike", [4] = "knight", }, },
[11] = { name = "commweapon_missilelauncher", requireChassis = { [1] = "support", [2] = "strike", [3] = "knight", }, },
[12] = { name = "commweapon_riotcannon", requireChassis = { [1] = "assault", [2] = "knight", }, },
[13] = { name = "commweapon_rocketlauncher", requireChassis = { [1] = "assault", [2] = "knight", }, },
[14] = { name = "commweapon_shotgun", requireChassis = { [1] = "recon", [2] = "support", [3] = "strike", [4] = "knight", }, },
[15] = { name = "commweapon_hparticlebeam", requireChassis = { [1] = "support", [2] = "knight", }, },
[16] = { name = "commweapon_shockrifle", requireChassis = { [1] = "support", [2] = "knight", }, },
[17] = { name = "commweapon_clusterbomb", requireChassis = { [1] = "recon", [2] = "assault", [3] = "knight", }, },
[18] = { name = "commweapon_concussion", requireChassis = { [1] = "recon", [2] = "knight", }, },
[19] = { name = "commweapon_disintegrator", requireChassis = { [1] = "assault", [2] = "strike", [3] = "knight", }, },
[20] = { name = "commweapon_disruptorbomb", requireChassis = { [1] = "recon", [2] = "support", [3] = "strike", [4] = "knight", }, },
[21] = { name = "commweapon_multistunner", requireChassis = { [1] = "support", [2] = "recon", [3] = "strike", [4] = "knight", }, },
[22] = { name = "commweapon_napalmgrenade", requireChassis = { [1] = "assault", [2] = "recon", [3] = "knight", }, },
[23] = { name = "commweapon_slamrocket", requireChassis = { [1] = "assault", [2] = "knight", }, },
[24] = { name = "econ", },
[25] = { name = "commweapon_personal_shield", },
[26] = { name = "commweapon_areashield", requireChassis = { [1] = "assault", [2] = "support", [3] = "knight", }, },
[27] = { name = "weaponmod_napalm_warhead", requireChassis = { [1] = "assault", [2] = "knight", }, },
[28] = { name = "conversion_disruptor", requireChassis = { [1] = "strike", [2] = "recon", [3] = "support", [4] = "knight", }, },
[29] = { name = "weaponmod_stun_booster", requireChassis = { [1] = "support", [2] = "strike", [3] = "recon", [4] = "knight", }, },
[30] = { name = "module_jammer", },
[31] = { name = "module_radarnet", },
[32] = { name = "module_personal_cloak", },
[33] = { name = "module_cloak_field", requireChassis = { [1] = "support", [2] = "strike", [3] = "knight", }, },
[34] = { name = "module_resurrect", requireChassis = { [1] = "support", [2] = "knight", }, },
[35] = { name = "module_jumpjet", requireChassis = { [1] = "knight", }, },
[36] = { name = "module_companion_drone", },
[37] = { name = "module_battle_drone", requireChassis = { [1] = "assault", [2] = "support", [3] = "knight", }, },
[38] = { name = "module_autorepair", requireChassis = { [1] = "strike", [2] = "knight", }, },
[39] = { name = "module_autorepair", requireChassis = { [1] = "assault", [2] = "recon", [3] = "support", }, },
[40] = { name = "module_ablative_armor", requireChassis = { [1] = "assault", [2] = "knight", }, },
[41] = { name = "module_heavy_armor", requireChassis = { [1] = "assault", [2] = "knight", }, },
[42] = { name = "module_ablative_armor", requireChassis = { [1] = "strike", [2] = "recon", [3] = "support", }, },
[43] = { name = "module_heavy_armor", requireChassis = { [1] = "strike", [2] = "recon", [3] = "support", }, },
[44] = { name = "module_dmg_booster", },
[45] = { name = "module_high_power_servos", requireChassis = { [1] = "recon", [2] = "knight", }, },
[46] = { name = "module_high_power_servos", requireChassis = { [1] = "strike", [2] = "assault", [3] = "support", }, },
[47] = { name = "module_adv_targeting", },
[48] = { name = "module_adv_nano", requireChassis = { [1] = "support", }, },
[49] = { name = "module_adv_nano", requireChassis = { [1] = "strike", [2] = "assault", [3] = "knight", }, },
[50] = { name = "module_adv_nano", requireChassis = { [1] = "recon", }, },
[51] = { name = "banner_overhead", },
[52] = { name = "commweapon_beamlaser_adv", },
[53] = { name = "commweapon_flamethrower_adv", requireChassis = { [1] = "recon", [2] = "assault", [3] = "knight", }, },
[54] = { name = "commweapon_heatray_adv", requireChassis = { [1] = "assault", [2] = "knight", }, },
[55] = { name = "commweapon_heavymachinegun_adv", requireChassis = { [1] = "recon", [2] = "assault", [3] = "strike", [4] = "knight", }, },
[56] = { name = "commweapon_lightninggun_adv", requireChassis = { [1] = "recon", [2] = "support", [3] = "strike", [4] = "knight", }, },
[57] = { name = "commweapon_lparticlebeam_adv", requireChassis = { [1] = "support", [2] = "recon", [3] = "strike", [4] = "knight", }, },
[58] = { name = "commweapon_missilelauncher_adv", requireChassis = { [1] = "support", [2] = "strike", [3] = "knight", }, },
[59] = { name = "commweapon_riotcannon_adv", requireChassis = { [1] = "assault", [2] = "knight", }, },
[60] = { name = "commweapon_rocketlauncher_adv", requireChassis = { [1] = "assault", [2] = "knight", }, },
[61] = { name = "commweapon_shotgun_adv", requireChassis = { [1] = "recon", [2] = "support", [3] = "strike", [4] = "knight", }, },
}

for k, v in pairs(generated) do
if v.requireChassis == nil then
v.requireChassis = Spring.Utilities.CopyTable(basicChassis)
end
if v.name:find("_adv$") then
for pos, chassis in pairs(v.requireChassis) do
if chassis == "knight" then
table.remove(v.requireChassis, pos)
break
end
end
end
end

return generated
12 changes: 7 additions & 5 deletions LuaRules/Gadgets/unit_commander_upgrade.lua
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
function gadget:GetInfo()
return {
return {
name = "Commander Upgrade",
desc = "",
author = "Google Frog",
date = "30 December 2015",
license = "GNU GPL, v2 or later",
layer = 1,
enabled = true -- loaded by default?
}
}
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

--SYNCED
if (not gadgetHandler:IsSyncedCode()) then
return
return
end

include("LuaRules/Configs/constants.lua")
Expand Down Expand Up @@ -83,8 +83,8 @@ local function ApplyWeaponData(unitID, weapon1, weapon2, shield, rangeMult, dama
end
end

weapon1 = weapon1 or "commweapon_beamlaser"
local chassis = Spring.GetUnitRulesParam(unitID, "comm_chassis")
weapon1 = weapon1 or (chassis and chassisDefs[chassis] and chassisDefs[chassis].initWeapon) or "commweapon_beamlaser"

if chassis and chassisDefs[chassis] and chassisDefs[chassis].secondPeashooter and (not weapon2) and Spring.GetUnitRulesParam(unitID, "comm_level") > 2 then
weapon2 = "commweapon_beamlaser"
Expand Down Expand Up @@ -162,6 +162,7 @@ local function ApplyModuleEffects(unitID, data, totalCost, images)
GG.Overdrive.AddUnitResourceGeneration(unitID, data.metalIncome, data.energyIncome, true)
end

---@type false|number
local newHealth = false
if data.healthBonus then
local health, maxHealth = Spring.GetUnitHealth(unitID)
Expand Down Expand Up @@ -418,7 +419,8 @@ local function Upgrades_CreateStarterDyncomm(dyncommID, x, y, z, facing, teamID,
local commProfileInfo = GG.ModularCommAPI.GetCommProfileInfo(dyncommID)
local chassisDefID = chassisDefNames[commProfileInfo.chassis]
if not chassisDefID then
Spring.Echo("Incorrect dynamic comm chassis", commProfileInfo.chassis)

Spring.Echo("Incorrect dynamic comm chassis", commProfileInfo.chassis, "dyncommID: " .. dyncommID)
return false
end

Expand Down
38 changes: 26 additions & 12 deletions LuaRules/Gadgets/unit_shield_charge.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@
--------------------------------------------------------------------------------

function gadget:GetInfo()
return {
name = "Shield Charge",
desc = "Reimplementation of charging for shields. Intended for attributes and priority support.",
author = "Google Frog",
date = "16 August 2015",
license = "GNU GPL, v2 or later",
layer = -1,
enabled = true -- loaded by default?
}
return {
name = "Shield Charge",
desc = "Reimplementation of charging for shields. Intended for attributes and priority support.",
author = "Google Frog",
date = "16 August 2015",
license = "GNU GPL, v2 or later",
layer = -1,
enabled = true -- loaded by default?
}
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

if (not gadgetHandler:IsSyncedCode()) then
return false -- no unsynced code
return false -- no unsynced code
end

include("LuaRules/Configs/constants.lua")

---@diagnostic disable-next-line: undefined-global
local TEAM_SLOWUPDATE_RATE = TEAM_SLOWUPDATE_RATE
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

Expand Down Expand Up @@ -74,10 +76,21 @@ for unitDefID = 1, #UnitDefs do
end

local commShieldDefs = {
WeaponDefNames["commweapon_areashield"],
WeaponDefNames["commweapon_personal_shield"],
--WeaponDefNames["commweapon_areashield"],
--WeaponDefNames["commweapon_personal_shield"],
--WeaponDefNames["commweapon_chickenshield"]
}

local weaponsList = VFS.DirList("gamedata/modularcomms/weapons", "*.lua") or {}
for i = 1, #weaponsList do
local name, array = VFS.Include(weaponsList[i])
local wd = WeaponDefNames[name]
if wd.type == [[Shield]] then
commShieldDefs[#commShieldDefs + 1] = wd
end
end


for i = 1, #commShieldDefs do
local wd = commShieldDefs[i]
shieldCommWeaponDefID[wd.id] = LoadShieldWeaponDef(wd)
Expand Down Expand Up @@ -111,6 +124,7 @@ function gadget:GameFrame(n)

local updatePriority = (n % TEAM_SLOWUPDATE_RATE == 0)
local setParam = ((n % 30) == 8)
---@type false|table
local toDestroy = false

for i = 1, unitCount do
Expand Down
6 changes: 5 additions & 1 deletion LuaUI/Configs/startup_info_selector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ local chassisImages = {
knight = "LuaUI/Images/startup_info_selector/chassis_cremcom.png"
}

local moduleDefs, emptyModules, chassisDefs, upgradeUtilities, chassisDefByBaseDef, moduleDefNames, chassisDefNames = VFS.Include("LuaRules/Configs/dynamic_comm_defs.lua")
local moduleDefs, chassisDefs, upgradeUtilities, LEVEL_BOUND, chassisDefByBaseDef, moduleDefNames, chassisDefNames = VFS.Include("LuaRules/Configs/dynamic_comm_defs.lua")

for key, value in pairs(chassisDefs) do
chassisImages[value.name] = value.chassisImage or chassisImages[value.name]
end

local colorWeapon = "\255\255\32\32"
local colorConversion = "\255\255\96\0"
Expand Down
Loading