Fix/cas mission (#40)
* fixes * fixed and made weapons more random --------- Co-authored-by: dutchie032 <dutchie032>
This commit is contained in:
committed by
GitHub
co-authored by
dutchie032 <dutchie032>
parent
f61c7b5657
commit
c2121d0e70
Binary file not shown.
@@ -659,12 +659,23 @@ function Database:loadMissionzoneUnits()
|
|||||||
|
|
||||||
local groups = Spearhead.DcsUtil.getGroupsInZone(all_groups, missionZoneName)
|
local groups = Spearhead.DcsUtil.getGroupsInZone(all_groups, missionZoneName)
|
||||||
for _, groupName in pairs(groups) do
|
for _, groupName in pairs(groups) do
|
||||||
|
if Spearhead.DcsUtil.IsGroupStatic(groupName) == true then
|
||||||
|
local object = StaticObject.getByName(groupName)
|
||||||
|
|
||||||
|
if object and object:getCoalition() == coalition.side.RED then
|
||||||
|
table.insert(self._tables.MissionZoneData[missionZoneName].RedGroups, groupName)
|
||||||
|
elseif object then
|
||||||
|
table.insert(self._tables.MissionZoneData[missionZoneName].BlueGroups, groupName)
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
local group = Group.getByName(groupName)
|
local group = Group.getByName(groupName)
|
||||||
if group and group:getCoalition() == coalition.side.RED then
|
if group and group:getCoalition() == coalition.side.RED then
|
||||||
table.insert(self._tables.MissionZoneData[missionZoneName].RedGroups, groupName)
|
table.insert(self._tables.MissionZoneData[missionZoneName].RedGroups, groupName)
|
||||||
elseif group and group:getCoalition() == coalition.side.BLUE then
|
elseif group then
|
||||||
table.insert(self._tables.MissionZoneData[missionZoneName].BlueGroups, groupName)
|
table.insert(self._tables.MissionZoneData[missionZoneName].BlueGroups, groupName)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
is_group_taken[groupName] = true
|
is_group_taken[groupName] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -680,13 +691,23 @@ function Database:loadRandomMissionzoneUnits()
|
|||||||
}
|
}
|
||||||
local groups = Spearhead.DcsUtil.getGroupsInZone(all_groups, missionZoneName)
|
local groups = Spearhead.DcsUtil.getGroupsInZone(all_groups, missionZoneName)
|
||||||
for _, groupName in pairs(groups) do
|
for _, groupName in pairs(groups) do
|
||||||
local group = Group.getByName(groupName)
|
if Spearhead.DcsUtil.IsGroupStatic(groupName) == true then
|
||||||
if group and group:getCoalition() == coalition.side.RED then
|
local object = StaticObject.getByName(groupName)
|
||||||
|
|
||||||
|
if object and object:getCoalition() == coalition.side.RED then
|
||||||
table.insert(self._tables.MissionZoneData[missionZoneName].RedGroups, groupName)
|
table.insert(self._tables.MissionZoneData[missionZoneName].RedGroups, groupName)
|
||||||
elseif group and group:getCoalition() == coalition.side.BLUE then
|
elseif object then
|
||||||
table.insert(self._tables.MissionZoneData[missionZoneName].BlueGroups, groupName)
|
table.insert(self._tables.MissionZoneData[missionZoneName].BlueGroups, groupName)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
local group = Group.getByName(groupName)
|
||||||
|
if group and group:getCoalition() == coalition.side.RED then
|
||||||
|
table.insert(self._tables.MissionZoneData[missionZoneName].RedGroups, groupName)
|
||||||
|
elseif group then
|
||||||
|
table.insert(self._tables.MissionZoneData[missionZoneName].BlueGroups, groupName)
|
||||||
|
end
|
||||||
|
end
|
||||||
is_group_taken[groupName] = true
|
is_group_taken[groupName] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -153,19 +153,14 @@ function BattleManager:LetUnitsShoot(groups, targetGroups)
|
|||||||
local point = self:GetRandomPoint({x = unitPos.x, y = unitPos.z }, targetGroups)
|
local point = self:GetRandomPoint({x = unitPos.x, y = unitPos.z }, targetGroups)
|
||||||
if point then
|
if point then
|
||||||
|
|
||||||
local qty = 1
|
local ammo, qty = self:getBestAmmo(unit)
|
||||||
local ammo = unit:getAmmo()
|
|
||||||
|
|
||||||
if ammo and ammo[1] then
|
|
||||||
qty = math.ceil((ammo[1].count or 1) / 50)
|
|
||||||
end
|
|
||||||
|
|
||||||
local shootTask = {
|
local shootTask = {
|
||||||
id = "FireAtPoint",
|
id = "FireAtPoint",
|
||||||
params = {
|
params = {
|
||||||
point = point,
|
point = point,
|
||||||
radius = 1,
|
radius = 1,
|
||||||
expendQty = qty,
|
expendQty = qty,
|
||||||
|
weaponType = ammo,
|
||||||
expendQtyEnabled = true,
|
expendQtyEnabled = true,
|
||||||
counterbattaryRadius = math.random(5, 10)
|
counterbattaryRadius = math.random(5, 10)
|
||||||
}
|
}
|
||||||
@@ -184,6 +179,41 @@ function BattleManager:LetUnitsShoot(groups, targetGroups)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param unit Unit
|
||||||
|
---@return number
|
||||||
|
---@return number
|
||||||
|
function BattleManager:getBestAmmo(unit)
|
||||||
|
|
||||||
|
if unit:getName() == "Ground-32-1" then
|
||||||
|
env.info(Spearhead.Util.toString(unit:getAmmo()))
|
||||||
|
end
|
||||||
|
|
||||||
|
local ammo = unit:getAmmo()
|
||||||
|
|
||||||
|
if not ammo then return 3221225470, 1 end -- Default ammo if no ammo is found
|
||||||
|
|
||||||
|
local shells = {}
|
||||||
|
|
||||||
|
for _, entry in pairs(ammo) do
|
||||||
|
if entry.count and entry.count > 0 then
|
||||||
|
if entry.desc.category == Weapon.Category.SHELL then
|
||||||
|
table.insert(shells, entry)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local entry = Spearhead.Util.randomFromList(shells)
|
||||||
|
if entry.desc.warhead then
|
||||||
|
local caliber = entry.desc.warhead.caliber
|
||||||
|
if caliber > 50 then
|
||||||
|
return 258503344128, 1
|
||||||
|
else
|
||||||
|
return 258503344129, 25
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return 3221225470, 1
|
||||||
|
end
|
||||||
|
|
||||||
---@private
|
---@private
|
||||||
---@param unit Unit
|
---@param unit Unit
|
||||||
---@return boolean
|
---@return boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user