Hide odin technical range in LUS#5794
Conversation
| @@ -129,10 +142,23 @@ function script.FireWeapon(num) | |||
| end | |||
|
|
|||
| function script.BlockShot(num, targetID) | |||
There was a problem hiding this comment.
Check for style in this function
|
Why not make a customparam that adjusts any projectile range? |
|
9001 is a meme number, previously it was 3000. I don't think the number really matters, just that it is larger than any potential travel distance. I did manage to make an unrealistically high mountain and drop a bomb in an unreasonable pit and watch it expire before hitting it's target, so I just bumped the number. It could be a custom parameter, but I don't think it's any useful information. |
|
The advantage of customparam is that a modder would be able to put thermite on some other bomber. Even if the numerical value is arbitrary in this case, accepting a number is useful for decoupling targeting range from expiration range to deliberately introduce overshoot for some "regular" weapons (at least I remember @GoogleFrog made a mantis ticket about 10 years ago with the request). |
- in weapondef customparams.fake_range_override - assorted cleanup
|
With customparam, true range should be a gadget that handles units generally, rather than in any specific unit's LUS. The fake range probably stays in LUS because I assume it's some bomber-specific nonsense. LUS FireWeapon and EndBurst are available to gadgets as ScriptFireWeapon and ScriptEndBurst. So something like: local rangeDefs = {} -- [unitDefID][weaponNum] = {trueRange, nominalWeapondefRange}
for unitDefID, unitDef in pairs(UnitDefs) do
for weaponNum = 1, #unitDef.weapons do
local weaponDef = WeaponDefs[unitDef.weapons[i].weaponDef]
local trueRange = weaponDef.customParams.truerange
if trueRange then
rangeDefs[unitDefID] = rangeDefs[unitDefID] or {}
rangeDefs[unitDefID][weaponNum] = {truerange, weaponDef.range}
end
end
end
function gadget:ScriptFireWeapon(unitID, unitDefID, weaponNum)
local rangeDef = rangeDefs[unitDefID]
if not rangeDef then
return
end
local weaponRanges = rangeDef[weaponNum]
if not weaponRanges then
return
end
Spring.SetUnitWeaponState(unitID, weaponNum, "range", weaponRanges[1])
end
function gadget:ScriptEndBurst(unitID, unitDefID, weaponNum)
local rangeDef = rangeDefs[unitDefID]
if not rangeDef then
return
end
local weaponRanges = rangeDef[weaponNum]
if not weaponRanges then
return
end
Spring.SetUnitWeaponState(unitID, weaponNum, "range", weaponRanges[2])
end |
fix for #5587