-
Notifications
You must be signed in to change notification settings - Fork 334
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
base: master
Are you sure you want to change the base?
target prioritization proof of concept #4088
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
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. |
this is for the code quality team to gander at and help cook on what the best format should become