Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Changes #51

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
85 changes: 26 additions & 59 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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
}
32 changes: 28 additions & 4 deletions hook/lua/editor/UnitCountBuildConditions.lua
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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())
Expand Down
10 changes: 4 additions & 6 deletions hook/lua/sim/defaultweapons.lua
Original file line number Diff line number Diff line change
@@ -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,
}
5 changes: 4 additions & 1 deletion projectiles/BRNAT1ADVFIGproj/BRNAT1ADVFIGproj_script.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
local UefBRNAT1ADVFIGproj = import('/mods/fa-total-mayhem/lua/TMavaprojectiles.lua').UefBRNAT1ADVFIGproj
local TrashBagAdd = TrashBag.Add


---@class BRNAT1ADVFIGproj : UefBRNAT1ADVFIGproj
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
Expand Down
4 changes: 3 additions & 1 deletion projectiles/BRNAT2FIGHTERproj/BRNAT2FIGHTERproj_script.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
local UefBRNAT2FIGHTERproj = import('/mods/fa-total-mayhem/lua/TMavaprojectiles.lua').UefBRNAT2FIGHTERproj
local TrashBagAdd = TrashBag.Add

---@class BRNAT2FIGHTERproj : UefBRNAT2FIGHTERproj
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
Expand Down
5 changes: 4 additions & 1 deletion projectiles/BRNT2EXM2proj/BRNT2EXM2proj_script.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
local UefBRNT2EXM2proj = import('/mods/fa-total-mayhem/lua/TMprojectiles.lua').UefBRNT2EXM2proj
local TrashBagAdd = TrashBag.Add

---@class BRNT2EXM2proj : UefBRNT2EXM2proj
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
Expand Down
9 changes: 3 additions & 6 deletions projectiles/BROT1EXMOBARTproj/BROT1EXMOBARTproj_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -48,7 +46,6 @@ BROT1EXMOBARTproj = Class(AeonBROT1EXMOBARTproj){
proj:SetVelocity(velocity)
proj:PassDamageData(self.DamageData)
end
local pos = self:GetPosition()
end
}

Expand Down
9 changes: 3 additions & 6 deletions projectiles/BROT3BTBOTproj/BROT3BTBOTproj_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -48,7 +46,6 @@ BROT3BTBOTproj = Class(AeonBROT3BTBOTproj){
proj:SetVelocity(velocity)
proj:PassDamageData(self.DamageData)
end
local pos = self:GetPosition()
end
}

Expand Down
33 changes: 31 additions & 2 deletions units/BROAT1ENGINEERDRONE/BROAT1ENGINEERDRONE_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,70 @@
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)
self.Parent = nil
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
Expand All @@ -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
Expand Down