From 6e35a80872c35ab12775d58649aa570dd988fdac Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 17 Dec 2024 13:05:27 +0000 Subject: [PATCH] adad --- .vscode/settings.json | 85 ++++++------------- hook/lua/editor/UnitCountBuildConditions.lua | 32 ++++++- hook/lua/sim/defaultweapons.lua | 10 +-- .../BRNAT1ADVFIGproj_script.lua | 5 +- .../BRNAT2FIGHTERproj_script.lua | 4 +- .../BRNT2EXM2proj/BRNT2EXM2proj_script.lua | 5 +- .../BROT1EXMOBARTproj_script.lua | 9 +- .../BROT3BTBOTproj/BROT3BTBOTproj_script.lua | 9 +- .../BROAT1ENGINEERDRONE_script.lua | 33 ++++++- 9 files changed, 106 insertions(+), 86 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ce82c9e..5375824 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,62 +1,29 @@ { - "Lua.runtime.version": "Lua 5.1", - "Lua.runtime.path": ["?.lua", "?/init.lua", "/?"], - "Lua.completion.showWord": "Disable", - "Lua.runtime.special": { + "Lua.runtime.version": "Lua 5.3", + "Lua.runtime.path": [ + "?.lua", + "?/init.lua", + "/?" + ], + "Lua.completion.showWord": "Disable", + "Lua.runtime.special": { "import": "require", - "doscript": "require" - }, - "Lua.runtime.nonstandardSymbol": ["!="], - "Lua.completion.requireSeparator": "/", - "Lua.runtime.exportEnvDefault": true, - "Lua.diagnostics.globals": ["moho"], - "Lua.runtime.plugin": "${3rd}/fa/plugin.lua", - "Lua.workspace.library": ["${3rd}/fa/library"], - "Lua.workspace.checkThirdParty": false, - "cSpell.words": [ - "AeonBROAT1FIGproj", - "AeonBROST2ADVBATTLESHIPproj", - "AeonBROT1BTCLAWproj", - "AeonBROT1EXMOBART2proj", - "AeonBROT1EXMOBARTproj", - "AeonBROT1PDROproj", - "AeonBROT2EXBMproj", - "AeonBROT2HTproj", - "AeonBROT2MTRLproj", - "AeonBROT3BTBOT2proj", - "AeonBROT3COUGproj", - "AeonBROT3HTproj", - "AeonBROT3NCMPproj", - "AeonBROT3NCMproj", - "AeonBROT3NCNlaserproj", - "AeonBROT3PBMproj", - "AeonBROT3PDROproj", - "AeonBROT3SHBMEMPproj", - "AeonBROT3SHBMproj", - "AeonHvyClawproj", - "Akuma", - "battlebot", - "BRMAT2ADVBOMBERproj", - "BRMST3BOMproj", - "BRMT1ADVBOTRLproj", - "BRMT1BTRLproj", - "Clawgun", - "CybBRMAT2ADVBOMBERproj", - "CybBRMST3BOMproj", - "CybBRMT1ADVBOTRLproj", - "CybBRMT1BTRLproj", - "CybBRMT1EXTANKproj", - "CybBRMT2HVYproj", - "CybBRMT3HAMRLproj", - "CybNULLWEAPONproj", - "maingun", - "NULLWEAPON", - "proj", - "Quadrobot", - "SerBRPT1EXTANK2proj", - "SerBRPT3SHBMproj", - "TMavaprojectiles", - "uefBRNT3ARGUSLASERproj", - "UefBRNT3ARGUSMINIproj" - ] + "doscript": "require", + "LazyImport": "require", + }, + "Lua.runtime.nonstandardSymbol": [ + "continue", + "!=" + ], + "Lua.completion.requireSeparator": "/", + "Lua.runtime.exportEnvDefault": true, + "Lua.runtime.plugin": "${3rd}/fa/plugin.lua", + "Lua.diagnostics.globals": [ + "moho", + "ScenarioInfo" + ], + "Lua.workspace.library": [ + "F:/GitRepos/fa", + ], + "Lua.workspace.checkThirdParty": false } \ No newline at end of file diff --git a/hook/lua/editor/UnitCountBuildConditions.lua b/hook/lua/editor/UnitCountBuildConditions.lua index d5f3e98..642f9b7 100644 --- a/hook/lua/editor/UnitCountBuildConditions.lua +++ b/hook/lua/editor/UnitCountBuildConditions.lua @@ -1,4 +1,10 @@ - +---@param aiBrain AIBrain +---@param radius number +---@param locationType string +---@param unitCount number +---@param categoryEnemy string +---@param compareType string +---@return boolean function HaveEnemyUnitAtLocation(aiBrain, radius, locationType, unitCount, categoryEnemy, compareType) if not aiBrain.BuilderManagers[locationType] then AIWarn('*AI WARNING: HaveEnemyUnitAtLocation - Invalid location - ' .. locationType) @@ -11,16 +17,34 @@ function HaveEnemyUnitAtLocation(aiBrain, radius, locationType, unitCount, categ --AILog(aiBrain:GetArmyIndex()..' CompareBody {World} radius:['..radius..'] '..repr(DEBUG)..' ['..numEnemyUnits..'] '..compareType..' ['..unitCount..'] return '..repr(CompareBody(numEnemyUnits, unitCount, compareType))) return CompareBody(numEnemyUnits, unitCount, compareType) end --- { UCBC, 'EnemyUnitsGreaterAtLocationRadius', { BasePanicZone, 'LocationType', 0, categories.MOBILE * categories.LAND }}, -- radius, LocationType, unitCount, categoryEnemy + +-- { UCBC, 'EnemyUnitsGreaterAtLocationRadius', { BasePanicZone, 'LocationType', 0, categories.MOBILE * categories.LAND }}, -- radius, LocationType, unitCount, categoryEnemy +---@param aiBrain AIBrain +---@param radius number +---@param locationType string +---@param unitCount number +---@param categoryEnemy string +---@return boolean function EnemyUnitsGreaterAtLocationRadius(aiBrain, radius, locationType, unitCount, categoryEnemy) return HaveEnemyUnitAtLocation(aiBrain, radius, locationType, unitCount, categoryEnemy, '>') end --- { UCBC, 'EnemyUnitsLessAtLocationRadius', { BasePanicZone, 'LocationType', 1, categories.MOBILE * categories.LAND }}, -- radius, LocationType, unitCount, categoryEnemy + +-- { UCBC, 'EnemyUnitsLessAtLocationRadius', { BasePanicZone, 'LocationType', 1, categories.MOBILE * categories.LAND }}, -- radius, LocationType, unitCount, categoryEnemy +---@param aiBrain AIBrain +---@param radius number +---@param locationType string +---@param unitCount number +---@param categoryEnemy string +---@return boolean function EnemyUnitsLessAtLocationRadius(aiBrain, radius, locationType, unitCount, categoryEnemy) return HaveEnemyUnitAtLocation(aiBrain, radius, locationType, unitCount, categoryEnemy, '<') end --- { UCBC, 'HaveUnitRatioVersusCap', { 0.024, '<=', categories.STRUCTURE * categories.FACTORY * categories.LAND } }, -- Maximal 3 factories at 125 unitcap, 12 factories at 500 unitcap... +-- { UCBC, 'HaveUnitRatioVersusCap', { 0.024, '<=', categories.STRUCTURE * categories.FACTORY * categories.LAND } }, -- Maximal 3 factories at 125 unitcap, 12 factories at 500 unitcap... +---@param aiBrain AIBrain +---@param ratio number +---@param compareType string +---@param categoryOwn string function HaveUnitRatioVersusCap(aiBrain, ratio, compareType, categoryOwn) local numOwnUnits = aiBrain:GetCurrentUnits(categoryOwn) local cap = GetArmyUnitCap(aiBrain:GetArmyIndex()) diff --git a/hook/lua/sim/defaultweapons.lua b/hook/lua/sim/defaultweapons.lua index c67a2d9..147bb8b 100644 --- a/hook/lua/sim/defaultweapons.lua +++ b/hook/lua/sim/defaultweapons.lua @@ -1,15 +1,13 @@ ---@class SCUDeathWeapon : BareBonesWeapon SCUDeathWeapon = Class(BareBonesWeapon){ - ---@param self SCUDeathWeapon unused - OnFire = function(self) - --NOP + OnFire = function() end, ---@param self SCUDeathWeapon unused Fire = function(self) - local myBlueprint = self.Blueprint - local myProjectile = self.unit:CreateProjectile(myBlueprint.ProjectileId, 0, 0, 0, nil, nil, nil):SetCollision(false) - myProjectile:PassDamageData(self:GetDamageTable()) + local bp = self.Blueprint + local proj = self.unit:CreateProjectile(bp.ProjectileId, 0, 0, 0, nil, nil, nil):SetCollision(false) + proj:PassDamageData(self:GetDamageTable()) end, } diff --git a/projectiles/BRNAT1ADVFIGproj/BRNAT1ADVFIGproj_script.lua b/projectiles/BRNAT1ADVFIGproj/BRNAT1ADVFIGproj_script.lua index 78b19fa..076fedb 100644 --- a/projectiles/BRNAT1ADVFIGproj/BRNAT1ADVFIGproj_script.lua +++ b/projectiles/BRNAT1ADVFIGproj/BRNAT1ADVFIGproj_script.lua @@ -1,4 +1,6 @@ local UefBRNAT1ADVFIGproj = import('/mods/fa-total-mayhem/lua/TMavaprojectiles.lua').UefBRNAT1ADVFIGproj +local TrashBagAdd = TrashBag.Add + ---@class BRNAT1ADVFIGproj : UefBRNAT1ADVFIGproj BRNAT1ADVFIGproj = Class(UefBRNAT1ADVFIGproj){ @@ -6,7 +8,8 @@ BRNAT1ADVFIGproj = Class(UefBRNAT1ADVFIGproj){ ---@param self BRNAT1ADVFIGproj OnCreate = function(self) UefBRNAT1ADVFIGproj.OnCreate(self) - self:ForkThread(self.UpdateThread) + local trash = self.Trash + TrashBagAdd(trash, ForkThread(self.UpdateThread, self)) end, ---@param self BRNAT1ADVFIGproj diff --git a/projectiles/BRNAT2FIGHTERproj/BRNAT2FIGHTERproj_script.lua b/projectiles/BRNAT2FIGHTERproj/BRNAT2FIGHTERproj_script.lua index ba37a20..01beb52 100644 --- a/projectiles/BRNAT2FIGHTERproj/BRNAT2FIGHTERproj_script.lua +++ b/projectiles/BRNAT2FIGHTERproj/BRNAT2FIGHTERproj_script.lua @@ -1,4 +1,5 @@ local UefBRNAT2FIGHTERproj = import('/mods/fa-total-mayhem/lua/TMavaprojectiles.lua').UefBRNAT2FIGHTERproj +local TrashBagAdd = TrashBag.Add ---@class BRNAT2FIGHTERproj : UefBRNAT2FIGHTERproj BRNAT2FIGHTERproj = Class(UefBRNAT2FIGHTERproj){ @@ -6,7 +7,8 @@ BRNAT2FIGHTERproj = Class(UefBRNAT2FIGHTERproj){ ---@param self BRNAT2FIGHTERproj OnCreate = function(self) UefBRNAT2FIGHTERproj.OnCreate(self) - self:ForkThread(self.UpdateThread) + local trash = self.Trash + TrashBagAdd(trash, ForkThread(self.UpdateThread, self)) end, ---@param self BRNAT2FIGHTERproj diff --git a/projectiles/BRNT2EXM2proj/BRNT2EXM2proj_script.lua b/projectiles/BRNT2EXM2proj/BRNT2EXM2proj_script.lua index 1d08629..2ff8299 100644 --- a/projectiles/BRNT2EXM2proj/BRNT2EXM2proj_script.lua +++ b/projectiles/BRNT2EXM2proj/BRNT2EXM2proj_script.lua @@ -1,4 +1,5 @@ local UefBRNT2EXM2proj = import('/mods/fa-total-mayhem/lua/TMprojectiles.lua').UefBRNT2EXM2proj +local TrashBagAdd = TrashBag.Add ---@class BRNT2EXM2proj : UefBRNT2EXM2proj BRNT2EXM2proj = Class(UefBRNT2EXM2proj){ @@ -6,8 +7,10 @@ BRNT2EXM2proj = Class(UefBRNT2EXM2proj){ ---@param self BRNT2EXM2proj OnCreate = function(self) UefBRNT2EXM2proj.OnCreate(self) + local trash = self.Trash + self:SetCollisionShape('Sphere', 0, 0, 0, 2) - self.MoveThread = self:ForkThread(self.MovementThread) + self.MoveThread = TrashBagAdd(trash, ForkThread(self.MovementThread, self)) end, ---@param self BRNT2EXM2proj diff --git a/projectiles/BROT1EXMOBARTproj/BROT1EXMOBARTproj_script.lua b/projectiles/BROT1EXMOBARTproj/BROT1EXMOBARTproj_script.lua index 293eec8..8610652 100644 --- a/projectiles/BROT1EXMOBARTproj/BROT1EXMOBARTproj_script.lua +++ b/projectiles/BROT1EXMOBARTproj/BROT1EXMOBARTproj_script.lua @@ -7,15 +7,13 @@ local RandomFloat = import('/lua/utilities.lua').GetRandomFloat BROT1EXMOBARTproj = Class(AeonBROT1EXMOBARTproj){ ---@param self BROT1EXMOBARTproj - ---@param TargetType string unused - ---@param TargetEntity Entity unused - OnImpact = function(self, TargetType, TargetEntity) + OnImpact = function(self) local FxFragEffect = TMEffectTemplate.AeonUnitDeathRing02 local ChildProjectileBP = '/mods/fa-total-mayhem/projectiles/BROT1EXMOBART2proj/BROT1EXMOBART2proj_proj.bp' -- Split effects - for k, v in FxFragEffect do - CreateEmitterAtEntity(self, self:GetArmy(), v) + for _, v in FxFragEffect do + CreateEmitterAtEntity(self, self.Army, v) self:Destroy() end @@ -48,7 +46,6 @@ BROT1EXMOBARTproj = Class(AeonBROT1EXMOBARTproj){ proj:SetVelocity(velocity) proj:PassDamageData(self.DamageData) end - local pos = self:GetPosition() end } diff --git a/projectiles/BROT3BTBOTproj/BROT3BTBOTproj_script.lua b/projectiles/BROT3BTBOTproj/BROT3BTBOTproj_script.lua index 43b85d3..953a403 100644 --- a/projectiles/BROT3BTBOTproj/BROT3BTBOTproj_script.lua +++ b/projectiles/BROT3BTBOTproj/BROT3BTBOTproj_script.lua @@ -7,15 +7,13 @@ local RandomFloat = import('/lua/utilities.lua').GetRandomFloat BROT3BTBOTproj = Class(AeonBROT3BTBOTproj){ ---@param self BROT3BTBOTproj - ---@param TargetType string unused - ---@param TargetEntity Entity unused - OnImpact = function(self, TargetType, TargetEntity) + OnImpact = function(self) local FxFragEffect = EffectTemplate.AIFBallisticMortarHit01 local ChildProjectileBP = '/mods/fa-total-mayhem/projectiles/BROT3BTBOT2proj/BROT3BTBOT2proj_proj.bp' -- Split effects - for k, v in FxFragEffect do - CreateEmitterAtEntity(self, self:GetArmy(), v) + for _, v in FxFragEffect do + CreateEmitterAtEntity(self, self.Army, v) self:Destroy() end @@ -48,7 +46,6 @@ BROT3BTBOTproj = Class(AeonBROT3BTBOTproj){ proj:SetVelocity(velocity) proj:PassDamageData(self.DamageData) end - local pos = self:GetPosition() end } diff --git a/units/BROAT1ENGINEERDRONE/BROAT1ENGINEERDRONE_script.lua b/units/BROAT1ENGINEERDRONE/BROAT1ENGINEERDRONE_script.lua index ac4a0f5..90ea358 100644 --- a/units/BROAT1ENGINEERDRONE/BROAT1ENGINEERDRONE_script.lua +++ b/units/BROAT1ENGINEERDRONE/BROAT1ENGINEERDRONE_script.lua @@ -11,24 +11,38 @@ local TConstructionUnit = import('/lua/terranunits.lua').TConstructionUnit local EffectTemplate = import('/lua/EffectTemplates.lua') +---@class BROAT1ENGINEERDRONE : TConstructionUnit BROAT1ENGINEERDRONE = Class(TConstructionUnit){ + + ---@param self BROAT1ENGINEERDRONE OnCreate = function(self) TConstructionUnit.OnCreate(self) self.docked = true self.returning = false self:CreatTheEffects() end, + + ---@param self BROAT1ENGINEERDRONE + ---@param parent Unit + ---@param podName string SetParent = function(self, parent, podName) self.Parent = parent self.PodName = podName self:SetCreator(parent) end, + + ---@param self BROAT1ENGINEERDRONE CreatTheEffects = function(self) - local army = self:GetArmy() - for k, v in EffectTemplate['SIFInainoPlumeFxTrails01'] do + local army = self.Army + for _, v in EffectTemplate['SIFInainoPlumeFxTrails01'] do CreateAttachedEmitter(self, 'AttachPoint', army, v):ScaleEmitter(0.22) end end, + + ---@param self BROAT1ENGINEERDRONE + ---@param instigator Unit + ---@param type string + ---@param overkillRatio number OnKilled = function(self, instigator, type, overkillRatio) if self.Parent and not self.Parent.Dead then self.Parent:NotifyOfPodDeath(self.PodName) @@ -36,18 +50,31 @@ BROAT1ENGINEERDRONE = Class(TConstructionUnit){ end TConstructionUnit.OnKilled(self, instigator, type, overkillRatio) end, + + ---@param self BROAT1ENGINEERDRONE + ---@param unitBeingBuilt Unit + ---@param order string OnStartBuild = function(self, unitBeingBuilt, order) TConstructionUnit.OnStartBuild(self, unitBeingBuilt, order) self.returning = false end, + + ---@param self BROAT1ENGINEERDRONE + ---@param unitBuilding Unit OnStopBuild = function(self, unitBuilding) TConstructionUnit.OnStopBuild(self, unitBuilding) self.ReturnHome(self) end, + + ---@param self BROAT1ENGINEERDRONE OnFailedToBuild = function(self) TConstructionUnit.OnFailedToBuild(self) self.ReturnHome(self) end, + + ---@param self BROAT1ENGINEERDRONE + ---@param new string + ---@param old string OnMotionHorzEventChange = function(self, new, old) if self and not self.Dead then if self.Parent and not self.Parent.Dead then @@ -68,6 +95,8 @@ BROAT1ENGINEERDRONE = Class(TConstructionUnit){ end end end, + + ---@param self BROAT1ENGINEERDRONE ReturnHome = function(self) local parentPosition = self.Parent:GetPosition(self.Parent.PodData[self.PodName].PodAttachpoint) self.returning = true