function gadget:AllowWeaponTarget(aID, tID, aWN, aWDID, dP) local tDID = Spring.GetUnitDefID(tID) if UnitDefs[tDID].name == "resourcepoint" then Spring.Echo(foo) return false, 0 end Spring.Echo("bar") return false, 0 --return true, dP end
does nothing, the echos print out fine, but otherwise does nothing.
I don't think that function works in the way we think it does, and I'm not sure on what the intended effect was. http://springrts.com/mantis/view.php?id=3219 That got closed early, and it would perhaps be better if we discussed it here after all, it might be explained in more detail, and it seems I'm not the only one having trouble grasping it.
What is the point of that function if not to prevent units targeting other units? How else can we prevent specific units from firing at each other? PS: I'm returning false for all calls of AllowWeaponTarget, and I was returning true for all calls of AllowWeaponTargetCheck, which I assumed would allow calling of AllowWeaponTarget.
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.
* block a specific target from being considered during a weapon's periodic auto-targeting sweep
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:
function gadget:AllowWeaponTarget(attID, tarID, attWepNum, attWePDefID, defPri) return false,0 end
* 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.
The point is it shouldn't be painful. You should just be able to hit the "Don't shoot at radar blips" button in your gadget and the unit should just not shoot at radar blips.
Then you can just add functionality in the gadget to let it shoot at its last attacker if it is set to return fire/fire at will (easy), and/or move to a position it can see the unit from (a bit tricker) but imo it should all be able to be done gadget-side.
Users browsing this forum: No registered users and 1 guest
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum