Page 1 of 1
Widget for range increase on specific units.
Posted: 28 May 2011, 19:12
by Heisenbergg
I've noticed that some units (eg. samson, banisher, rocko) can double or triple their range if they are used in first person mode. Would it be possible to make a widget to take advantage of this without the use of first person mode and for multiple units at a time?
Re: Widget for range increase on specific units.
Posted: 28 May 2011, 19:19
by TheFatController
Here you go
Code: Select all
function widget:GetInfo()
return {
name = "AttackGroundHax",
desc = "Play nice",
author = "TheFatController",
date = "16 April, 2009",
license = "GNU GPL, v2 or later",
layer = 0,
enabled = true -- loaded by default?
}
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local GetSelectedUnits = Spring.GetSelectedUnits
local GiveOrderToUnit = Spring.GiveOrderToUnit
local GetGroundHeight = Spring.GetGroundHeight
local hOrder = false
function widget:CommandNotify(id, params, options)
if (id == CMD.ATTACK) and params[3] and (not hOrder) then
local selUnits = GetSelectedUnits()
hOrder = true
local y = GetGroundHeight(params[1],params[3])
for _,unitID in ipairs(selUnits) do
GiveOrderToUnit(unitID,CMD.ATTACK,{params[1],y+24,params[3]},options.coded)
--GiveOrderToUnit(unitID,CMD.INSERT, {0, CMD.ATTACK, CMD.OPT_SHIFT, params[1],y+24,params[3]}, CMD.OPT_ALT)
end
hOrder = false
return true
else
return false
end
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Won't work in BA tho
Re: Widget for range increase on specific units.
Posted: 28 May 2011, 19:54
by Heisenbergg
I tried to understand the code, but I couldn't:p And if it doesn't work in BA what will it work with? Is that kind of thing disabled, as it rightly should be?
Re: Widget for range increase on specific units.
Posted: 28 May 2011, 20:16
by TheFatController
It overrides attack commands vs the ground and adds 24 height to them, so the attack is made in the air and the projectile overshoots (as in FPS mode).
BA has a gadget which ensures any floating attack commands issued in this way are locked to the ground and the above was a proof of concept I wrote when others were using a similar widget to overshoot units so I would reccomend any modders take similar action and disallow it too. (tho in BA's case I never minded people using it on the allowed FPSable units cause that requires extra attention).
Re: Widget for range increase on specific units.
Posted: 28 May 2011, 20:23
by Heisenbergg
Oh alright awesome, so I guess it doesn't work in the manner I thought (manually directing the turrets of applicable units beyond what they would automatically do), rather, it acts as if it missed the unit it was aiming at, and the projectile continues moving.