kloot wrote:you don't seem to understand what returning false from AllowWeaponTarget does and does not do...
since there are no references to the callin in the changelog (other than the fixes in more recent versions) and the Wiki only mentions that the return value is expected to be "targetAllowed, targetPriority"
What this says to me is that:
a) if I 'return false,number' that weapon will completely ignore that target as a possible target
b)if I 'return true,priority' i can use some sort of logic to adjust the default priority value to make a unit prefer to attack certain target unitdefs (or whatever) first (something like a hypothetical 'preferredtargetcategory'), or conversely prefer to shoot anything other than a certain target first (iow badtargetcategory)
since there does not appear to be anything written down (changelog,wiki,source comments) anywhere other than the mantis comment, there is no way for us to know what it does or how to use it.
kloot wrote:IT DOES:
* block a specific target from being considered during a weapon's periodic auto-targeting sweep
great!
kloot wrote:IT DOES NOT:
* prevent a weapon from auto-generating a target for itself (that's the job of the AllowWeaponTargetCheck callin / commandfire WeaponDef key / unit states other than fire-at-will), unless false is always returned for all targets
And if it is returning false for all targets? As far as I could tell units would gleefully shoot at anything in range even if the entire gadget consisted of GetInfo and:
Code: Select all
function gadget:AllowWeaponTarget(attID, tarID, attWepNum, attWePDefID, defPri)
return false,0
end
kloot wrote:* prevent a unit from returning fire at its last attacker (that's what the hold-fire unit state is for)
* prevent a unit's command "AI" from picking a target when the unit is idle (which is again controlled by a unit's fire- and movestate)
Imo it should be up to the game maker/gadget writer to impliment this properly, I don't think it's the engine's job to protect us from bad game design. (I could easily add a gadget to BA that randomly explodes metalmakers as nuclear explosions

. Possible? Yes. A good idea? Probably not. But
nothing is stopping me from doing it.)
Examples:
1) Use AllowWeapontarget to impliment a minimum range. Minimum range is minimum range, it doesn't matter what the potential target is doing, I'm too close, so I cant shoot at it.
2) Game F has a unit that when given a custom command by the user becomes invulnerable, I dont want units wasting time shooting something that can't be hurt anyway, they should ignore it, or run away (or whatever, it's up to me to code behaviours for this)
3) Game U has massive radar wobble, I don't want my sharpshooter units shooting at things unless its in los *even if the radar blip is shooting at the sharpshooter* because it's a waste of time/metal/energy/whatever because the chance of the shots actually hitting is miniscule. Again, it should be up to me as the game dev to write in behaviours to manage this.