#Sniper fight command

1 messages · Page 1 of 1 (latest)

hot blaze
#

Why my snipers like to do die - I fight command them they just walk into enemy mammoths instead of staying at range

stuck plank
undone sun
#

You have manuver/roam enabled and Mammoth is retreating?

Standard behaviour is to 'chase' a retreating unit to keep it in range.

Hold pos fixes your issue.

#

You can have different move states per unit type. Type /widgetselector and filter 'pref states' make that green, then click sniper and ctrl-click manuver/roam to hold pos, you now made snipers permanently hold pos when been built.

stuck plank
#

if so never ever tell people to go to /widgetselector
as they may brick something\

undone sun
#

Ive not seen it in settings at least. But ya you can ctrl-click manuver/roam first and see if text pops up at the top saying its been changed. If it does pref states already enabled.

stuck plank
#

thats a bug report then

#

widget selector has resulted in a number of people bricking something in their game

#

which is why i gave the warning

undone sun
#

Fair fair ure right

#

There is also a setting 'default units to hold pos' or something like that, which makes all ground unit buildings set to hold pos and units being built copies this state.

torpid flintBOT
#

Set a reminder in 10 hours from now (<t:1724081291:f>)
View reminders with the reminders command

torpid flintBOT
#

Reminder for @stuck plank

Reminder from YAGPDB

bug report this

hot blaze
#

I'm not sure why they defaulted to hold fire, but i had target set on all the mammys and used fight command and they just kept walking

undone sun
#

Its hold pos that stops em from moving on their own

hot blaze
#

they we on hold pos and hold fire. But I did set target on mammys then used fight command behind the mammys thiinking they'd chase but stop if in range to shoot

stuck plank
#

its a feature probablyt

undone sun
#

Ya drivver is right, hold fire + fight command is simply a move command, set target doesnt make units pause in range

#

Fire at will + set target (priority targets) + hold pos + fight command

#

I understand you wanna have a smart AI here not firing ticks, but that would make snipers very strong.

deep cypress
#

when you tell something to fight, it should override hold fire and fight

#

or at least stop where it would have otherwise stopped

hot blaze
#

I do think fight command should be consistent regardless of firing states, but alas

this may be part of my larger frustration with hold fire seemingly randomly engaged on different units like janus and sniper. I want fire at will on all units always and not sure there's a simple way to default that. I can still make snipers fairly op by targeting units when on fire at will

#

but thanks all for looking into this

deep cypress
#

Floris has enlightened me before

#
function widget:GetInfo()
    return {
        name      = "Auto Fire at Will",
        desc      = "Automatically sets all units to fire at will mode",
        author    = "YourName",
        date      = "2024-08-19",
        license   = "GPLv2",
        layer     = 0,
        enabled   = true  --  loaded by default?
    }
end

local spGetMyTeamID = Spring.GetMyTeamID
local spGetTeamUnits = Spring.GetTeamUnits
local spGiveOrderToUnit = Spring.GiveOrderToUnit
local CMD_FIRE_STATE = CMD.FIRE_STATE

function widget:UnitCreated(unitID, unitDefID, teamID)
    local myTeamID = spGetMyTeamID()
    if teamID == myTeamID then
        spGiveOrderToUnit(unitID, CMD_FIRE_STATE, {2}, 0)
    end
end

function widget:UnitGiven(unitID, unitDefID, oldTeamID, newTeamID)
    local myTeamID = spGetMyTeamID()
    if newTeamID == myTeamID then
        spGiveOrderToUnit(unitID, CMD_FIRE_STATE, {2}, 0)
    end
end

function widget:GameFrame(frame)
    if frame % 30 == 0 then -- Check every second (30 frames)
        local myTeamID = spGetMyTeamID()
        local units = spGetTeamUnits(myTeamID)
        for _, unitID in ipairs(units) do
            spGiveOrderToUnit(unitID, CMD_FIRE_STATE, {2}, 0)
        end
    end
end
#

looks alright from a glance

hot blaze
#

that's insane - so how do I use that

deep cypress
#

#❓|how-to-install-mods message
once you verify it works (because I didn't aside from reading it), post it in #1113845509891829810 , because those are the rules.

hot blaze
#

Sorry last q - how to turn that code into a lua file