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

target prioritization proof of concept #4088

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SethDGamre
Copy link
Collaborator

this is for the code quality team to gander at and help cook on what the best format should become

@SethDGamre SethDGamre marked this pull request as draft December 29, 2024 03:50
Copy link
Collaborator

@saurtron saurtron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good, added a couple remarks.

elseif weaponIsAntispam(wDef) then
typeWeights = weaponWeights[WEAPONTYPES.ANTISPAM]
end
weaponDefTypes[wDefID] = typeWeights
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can assign directly to weaponDefTypes[wDefID] inside the if/elseif clauses so you won't have an empty table for unused wDefIDs.

that way also you can return early below when you see weaponDefTypes[attackerWeaponDefID] is nil.

function gadget:AllowWeaponTarget(unitID, targetID, attackerWeaponNum, attackerWeaponDefID, defPriority)
if not targetID then return true, defPriority end

local weaponTypeWeights = weaponDefTypes[attackerWeaponDefID]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after this line you can check if not weaponTypeWeights then return true, defPriority end if you follow the above advice.

local targetDefID = spGetUnitDefID(targetID)
local targetType = unitDefTypes[targetDefID]
if targetType then
local newDefPriority = weaponTypeWeights[targetType] or defPriority
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing tab here before local

@S3KCentrifugal
Copy link
Contributor

Trying to solve this issue with AI as well. I would be nice if we could both rely on the same config wherever it will reside. I was thinking of just adding an armordef for spam lol. For now my solution is just use a custom "SPAM" and "ANTI_SPAM" role I assign to unit defs. For example a pawn is both SPAM/ANTI_SPAM. Since sometimes or all the time the best counter for spam is spam. But I also want to use these roles so larger t3 units (or their weapons) ignore spam. The role is used for both targeting and telling factories what units to produce in my case.

Anyway, my point is we should maybe configure this is one spot and just have AI read base game config (Ideally). Rather than having its own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants