2019-09-16 13:09 CEST

View Issue Details Jump to Notes ] Related Changesets ]
IDProjectCategoryView StatusLast Update
0006096Spring engineLuapublic2018-12-10 00:48
Reporterraaar 
Assigned ToKloot 
PrioritynormalSeveritymajorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version104.0 
Target VersionFixed in Version 
Summary0006096: allowWeaponTarget not preventing the weapon from aiming and firing at targets
DescriptionI'm trying to get reliable ways for units to not fire at targets in certain conditions (example: torpedo fires at unit if it's on or above water, but not if it's over land)

The allowweapontarget seems to not prevent the weapon from aiming and firing regardless of the return value and priority i set. I'm returning false,0, but tried false,nil and false,9999999

--- this extreme example should apparently block all auto-targeting, but it does nothing

function gadget:Initialize()
    for weaponID,_ in pairs(WeaponDefs) do
        Script.SetWatchWeapon(weaponID, true)
        Spring.Echo("WEAPON "..weaponID.." BLOCKED")
    end
end

-- weapon target check
function gadget:AllowWeaponTarget(attackerID, targetID, attackerWeaponNum, attackerWeaponDefID, defaultPriority)
    Spring.Echo("BLOCKED! "..Spring.GetGameFrame())
    return false,0
end
TagsNo tags attached.
Checked infolog.txt for lua Errors
Attached Files

-Relationships
+Relationships

-Notes

~0019595

raaar (reporter)

the "BLOCKED!" is printed as the weapon is aiming at an enemy spawned within range and the unit fires, but it shouldn't aim or fire.

~0019596

raaar (reporter)

note that I'm testing how the unit behaves by itself, no manual orders were given.

~0019597

raaar (reporter)

This can be reproduced on MF v1.03. There's a gadget that tries to prevent most torpedoes from firing from water at land targets. In such cases the AllowWeaponTarget returns false,99999999

An example unit is the aven_commander when underwater, firing at an enemy aven_radar_tower spawned near the shore.

Even if it's in range of the radar, as long as the commander is moving it won't fire. If it stops moving and becomes idle, the engine adds in an attack order even if no manual attack order is given, and then it tries to fire.
(the torpedoes will generally explode a few elmos above water level before reaching the target but that's another gadget-enforced feature)

~0019598

Kloot (developer)

Fix 82add77b48ceadac5d72d4f49817ef2db41ee8ec committed to develop branch: fix 0006096 0006093

call AllowWeaponTarget when auto-generating CAI attack commands
when targetID=-1 and weaponNum=-1 targetPriority determines the
target search radius; targetPriority=nil accompanies any actual
target being considered, repo: spring changeset id: 11188

~0019600

Kloot (developer)

Fix 198e315d4d7c736794223d3c8aece278909ac967 committed to maintenance branch: fix 0006096 0006093

call AllowWeaponTarget when auto-generating CAI attack commands
when targetID=-1 and weaponNum=-1 targetPriority determines the
target search radius; targetPriority=nil accompanies any actual
target being considered, repo: spring changeset id: 11189
+Notes

+Related Changesets

-Issue History
Date Modified Username Field Change
2018-12-09 01:04 raaar New Issue
2018-12-09 01:06 raaar Note Added: 0019595
2018-12-09 01:49 raaar Note Added: 0019596
2018-12-09 08:28 raaar Note Added: 0019597
2018-12-10 00:47 Kloot Changeset attached => spring develop 82add77b
2018-12-10 00:47 Kloot Note Added: 0019598
2018-12-10 00:47 Kloot Assigned To => Kloot
2018-12-10 00:47 Kloot Status new => resolved
2018-12-10 00:47 Kloot Resolution open => fixed
2018-12-10 00:48 Kloot Changeset attached => spring maintenance 198e315d
2018-12-10 00:48 Kloot Note Added: 0019600
+Issue History