Loading...
  OR  Zero-K Name:    Password:   

Post edit history

AA interaction with landed units

To display differences between versions, select one or more edits in the list using checkboxes and click "diff selected"
Post edit history
Date Editor Before After
7/8/2020 10:01:04 PMPLrankAdminSprung before revert after revert
7/8/2020 12:23:50 PMPLrankAdminSprung before revert after revert
7/8/2020 12:21:43 PMPLrankAdminSprung before revert after revert
7/8/2020 12:17:26 PMPLrankAdminSprung before revert after revert
Before After
1 It should be a fairly simple change, here's some pseudocode if somebody wants to try hacking it in 1 It should be a fairly simple change, here's some pseudocode if somebody wants to try hacking it in
2 \n 2 \n
3 {{{ 3 {{{
4 local aaWeaponDefIDs = { fill somehow } 4 local aaWeaponDefIDs = { fill somehow }
5 local aircraftUnitDefIDs = { ditto } 5 local aircraftUnitDefIDs = { ditto }
6 \n 6 \n
7 function gadget:AllowWeaponTarget(shooterID, targetID, weaponNum, weaponDefID) 7 function gadget:AllowWeaponTarget(shooterID, targetID, weaponNum, weaponDefID)
8 if not aircraftUnitDefIDs[targetID] or not aaWeaponDefIDs[weaponDefID] then 8 if not aircraftUnitDefIDs[targetID] or not aaWeaponDefIDs[weaponDefID] then
9 return true 9 return true
10 end 10 end
11 \n 11 \n
12 -- should be a decent heuristic with far less overhead; takes care of pads/construction as well 12 -- should be a decent heuristic with far less overhead; takes care of pads/construction as well
13 local _, _, _, v = Spring.GetUnitVelocity(targetID) 13 local _, _, _, v = Spring.GetUnitVelocity(targetID)
14 return v > 0 -- might need to be 0.01 due to float inaccuracies? 14 return v > 0 -- might need to be 0.01 due to float inaccuracies?
15 end 15 end
16 }}} 16 }}}
17 \n 17 \n
18 Alternatively, instead of the velocity check (this one is a bit sad because it is more expensive: 3 calls, one of which creates a bigass table filled with strings, but some of those checks might be needed for some edge case) 18 Alternatively, instead of the velocity check (this one is a bit sad because it is more expensive: 3 calls, one of which creates a bigass table filled with strings, but some of those checks might be needed for some edge case)
19 \n 19 \n
20 {{{ 20 {{{
21 if Spring.GetUnitRulesParam(targetID, "reammoProgress") then -- sitting on airpad 21 if Spring.GetUnitRulesParam(targetID, "reammoProgress") then -- sitting on airpad
22 return false 22 return false
23 end 23 end
24 \n 24 \n
25 local _, _, _, _, buildProgress = Spring. GetUnitHealth( targetID) -- maybe those are "landed" by default and taken care of by the test below? would need testing 25 -- Most likely this check is not needed.
26 -- Units being built are probably "landed" by default
27 -- and handled by the check below.
28 -- Also what if somebody reclaims an inbound unit?
29 local _, _, _, _, buildProgress = Spring.GetUnitHealth(targetID)
26 if buildProgress < 1 then 30 if buildProgress < 1 then
27 return false 31 return false
28 end 32 end
29 \n 33 \n
30 return Spring.GetUnitMoveTypeData(targetID).aircraftState ~= "landed" 34 return Spring.GetUnitMoveTypeData(targetID).aircraftState ~= "landed"
31 }}} 35 }}}