Merge pull request #1012 from FlightControl-Master/FF/Develop

Warehouse v0.5.6
This commit is contained in:
FlightControl 2018-10-03 21:57:46 +02:00 committed by GitHub
commit 0bb62ce43f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 112 additions and 25 deletions

View File

@ -597,8 +597,15 @@ ARTY={
autorelocateonroad=false, autorelocateonroad=false,
} }
--- Weapong type ID. http://wiki.hoggit.us/view/DCS_enum_weapon_flag --- Weapong type ID. See [here](http://wiki.hoggit.us/view/DCS_enum_weapon_flag).
-- @list WeaponType -- @type ARTY.WeaponType
-- @field #number Auto Automatic selection of weapon type.
-- @field #number Cannon Cannons using conventional shells.
-- @field #number Rockets Unguided rockets.
-- @field #number CruiseMissile Cruise missiles.
-- @field #number TacticalNukes Tactical nuclear shells (simulated).
-- @field #number IlluminationShells Illumination shells (simulated).
-- @field #number SmokeShells Smoke shells (simulated).
ARTY.WeaponType={ ARTY.WeaponType={
Auto=1073741822, Auto=1073741822,
Cannon=805306368, Cannon=805306368,
@ -610,7 +617,7 @@ ARTY.WeaponType={
} }
--- Database of common artillery unit properties. --- Database of common artillery unit properties.
-- @list db -- @type ARTY.db
ARTY.db={ ARTY.db={
["2B11 mortar"] = { -- type "2B11 mortar" ["2B11 mortar"] = { -- type "2B11 mortar"
minrange = 500, -- correct? minrange = 500, -- correct?
@ -675,7 +682,7 @@ ARTY.id="ARTY | "
--- Arty script version. --- Arty script version.
-- @field #string version -- @field #string version
ARTY.version="1.0.5" ARTY.version="1.0.6"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ -1189,7 +1196,14 @@ function ARTY:AssignTargetCoord(coord, prio, radius, nshells, maxengage, time, w
end end
-- Time in seconds. -- Time in seconds.
local _time=self:_ClockToSeconds(time) local _time
if type(time)=="string" then
_time=self:_ClockToSeconds(time)
elseif type(time)=="number" then
_time=timer.getAbsTime()+time
else
_time=timer.getAbsTime()
end
-- Prepare target array. -- Prepare target array.
local _target={name=_name, coord=coord, radius=radius, nshells=nshells, engaged=0, underfire=false, prio=prio, maxengage=maxengage, time=_time, weapontype=weapontype} local _target={name=_name, coord=coord, radius=radius, nshells=nshells, engaged=0, underfire=false, prio=prio, maxengage=maxengage, time=_time, weapontype=weapontype}
@ -1240,9 +1254,6 @@ function ARTY:AssignMoveCoord(coord, time, speed, onroad, cancel, name, unique)
return nil return nil
end end
-- Default is current time if no time was specified.
time=time or self:_SecondsToClock(timer.getAbsTime())
-- Set speed. -- Set speed.
if speed then if speed then
-- Make sure, given speed is less than max physiaclly possible speed of group. -- Make sure, given speed is less than max physiaclly possible speed of group.
@ -1264,7 +1275,14 @@ function ARTY:AssignMoveCoord(coord, time, speed, onroad, cancel, name, unique)
end end
-- Time in seconds. -- Time in seconds.
local _time=self:_ClockToSeconds(time) local _time
if type(time)=="string" then
_time=self:_ClockToSeconds(time)
elseif type(time)=="number" then
_time=timer.getAbsTime()+time
else
_time=timer.getAbsTime()
end
-- Prepare move array. -- Prepare move array.
local _move={name=_name, coord=coord, time=_time, speed=speed, onroad=onroad, cancel=cancel} local _move={name=_name, coord=coord, time=_time, speed=speed, onroad=onroad, cancel=cancel}

View File

@ -606,6 +606,7 @@
-- * "Attacked" --> "Captured" --> "Running" (warehouse was captured by the enemy) -- * "Attacked" --> "Captured" --> "Running" (warehouse was captured by the enemy)
-- * "*" --> "AirbaseCaptured" --> "*" (airbase belonging to the warehouse was captured by the enemy) -- * "*" --> "AirbaseCaptured" --> "*" (airbase belonging to the warehouse was captured by the enemy)
-- * "*" --> "AirbaseRecaptured" --> "*" (airbase was re-captured) -- * "*" --> "AirbaseRecaptured" --> "*" (airbase was re-captured)
-- * "*" --> "AssetDead" --> "*" (a whole asset group is dead)
-- * "*" --> "Destroyed" --> "Destroyed" (warehouse was destroyed) -- * "*" --> "Destroyed" --> "Destroyed" (warehouse was destroyed)
-- * "Running" --> "Pause" --> "Paused" (warehouse is paused) -- * "Running" --> "Pause" --> "Paused" (warehouse is paused)
-- * "Paused" --> "Unpause" --> "Running" (warehouse is unpaused) -- * "Paused" --> "Unpause" --> "Running" (warehouse is unpaused)
@ -872,7 +873,7 @@
-- --
-- -- Big explosion at the warehose. It has a very nice damage model by the way :) -- -- Big explosion at the warehose. It has a very nice damage model by the way :)
-- local function DestroyWarehouse() -- local function DestroyWarehouse()
-- warehouse.Batumi.warehouse:GetCoordinate():Explosion(999) -- warehouse.Batumi:GetCoordinate():Explosion(999)
-- end -- end
-- SCHEDULER:New(nil, DestroyWarehouse, {}, 30) -- SCHEDULER:New(nil, DestroyWarehouse, {}, 30)
-- --
@ -935,9 +936,9 @@
-- -- Get Number of ships at Batumi. -- -- Get Number of ships at Batumi.
-- local nships=warehouse.Batumi:GetNumberOfAssets(WAREHOUSE.Descriptor.CATEGORY, Group.Category.SHIP) -- local nships=warehouse.Batumi:GetNumberOfAssets(WAREHOUSE.Descriptor.CATEGORY, Group.Category.SHIP)
-- --
-- -- Send one ship every 5 minutes. -- -- Send one ship every 3 minutes (ships do not evade each other well, so we need a bit space between them).
-- for i=1, nships do -- for i=1, nships do
-- warehouse.Batumi:__AddRequest(300*(i-1)+10, warehouse.Kobuleti, WAREHOUSE.Descriptor.CATEGORY, Group.Category.SHIP, 1) -- warehouse.Batumi:__AddRequest(180*(i-1)+10, warehouse.Kobuleti, WAREHOUSE.Descriptor.CATEGORY, Group.Category.SHIP, 1)
-- end -- end
-- --
-- ## Example 10: Warehouse on Aircraft Carrier -- ## Example 10: Warehouse on Aircraft Carrier
@ -1000,8 +1001,7 @@
-- warehouse.Stennis:__AddRequest(45, warehouse.Stennis, WAREHOUSE.Descriptor.ATTRIBUTE, WAREHOUSE.Attribute.NAVAL_ARMEDSHIP, 5, nil, nil, nil, "Speedboats Right") -- warehouse.Stennis:__AddRequest(45, warehouse.Stennis, WAREHOUSE.Descriptor.ATTRIBUTE, WAREHOUSE.Attribute.NAVAL_ARMEDSHIP, 5, nil, nil, nil, "Speedboats Right")
-- --
-- --- Function called after self request -- --- Function called after self request
-- function warehouse.Stennis:OnAfterSelfRequest(From, Event, To,_groupset, request) -- function warehouse.Stennis:OnAfterSelfRequest(From, Event, To,_groupset, request)
--
-- local groupset=_groupset --Core.Set#SET_GROUP -- local groupset=_groupset --Core.Set#SET_GROUP
-- local request=request --Functional.Warehouse#WAREHOUSE.Pendingitem -- local request=request --Functional.Warehouse#WAREHOUSE.Pendingitem
-- --
@ -1216,15 +1216,14 @@
-- for _,_group in pairs(groupset:GetSet()) do -- for _,_group in pairs(groupset:GetSet()) do
-- local group=_group --Wrapper.Group#GROUP -- local group=_group --Wrapper.Group#GROUP
-- --
-- -- Start uncontrolled aircraft.
-- group:StartUncontrolled() -- group:StartUncontrolled()
-- group:SmokeBlue()
-- --
-- -- Target coordinate! -- -- Target coordinate!
-- local ToCoord=warehouse.Sukhumi:GetCoordinate() -- local ToCoord=warehouse.Sukhumi:GetCoordinate():SetAltitude(5000)
-- ToCoord.y=5000 -- Adjust altitude
-- --
-- local FoCoord=warehouse.Kobuleti:GetCoordinate() -- -- Home coordinate.
-- FoCoord.y=3000 -- Ajust altitude. -- local HomeCoord=warehouse.Kobuleti:GetCoordinate():SetAltitude(3000)
-- --
-- -- Task bomb Sukhumi warehouse using all bombs (2032) from direction 180 at altitude 5000 m. -- -- Task bomb Sukhumi warehouse using all bombs (2032) from direction 180 at altitude 5000 m.
-- local task=group:TaskBombing(warehouse.Sukhumi:GetCoordinate():GetVec2(), false, "All", nil , 180, 5000, 2032) -- local task=group:TaskBombing(warehouse.Sukhumi:GetCoordinate():GetVec2(), false, "All", nil , 180, 5000, 2032)
@ -1237,7 +1236,7 @@
-- -- Begin bombing run 20 km south of target. -- -- Begin bombing run 20 km south of target.
-- WayPoints[2]=ToCoord:Translate(20*1000, 180):WaypointAirTurningPoint(nil, 600, {task}, "Bombing Run") -- WayPoints[2]=ToCoord:Translate(20*1000, 180):WaypointAirTurningPoint(nil, 600, {task}, "Bombing Run")
-- -- Return to base. -- -- Return to base.
-- WayPoints[3]=FoCoord:WaypointAirTurningPoint() -- WayPoints[3]=HomeCoord:WaypointAirTurningPoint()
-- -- Land at homebase. Bombers are added back to stock and can be employed in later assignments. -- -- Land at homebase. Bombers are added back to stock and can be employed in later assignments.
-- WayPoints[4]=warehouse.Kobuleti:GetCoordinate():WaypointAirLanding() -- WayPoints[4]=warehouse.Kobuleti:GetCoordinate():WaypointAirLanding()
-- --
@ -1262,6 +1261,7 @@
-- -- Define a polygon zone as spawn zone at Kobuleti. -- -- Define a polygon zone as spawn zone at Kobuleti.
-- warehouse.Kobuleti:SetSpawnZone(ZONE_POLYGON:New("Warehouse Kobuleti Spawn Zone", GROUP:FindByName("Warehouse Kobuleti Spawn Zone"))) -- warehouse.Kobuleti:SetSpawnZone(ZONE_POLYGON:New("Warehouse Kobuleti Spawn Zone", GROUP:FindByName("Warehouse Kobuleti Spawn Zone")))
-- --
-- -- Add assets.
-- warehouse.Kobuleti:AddAsset("M978", 20) -- warehouse.Kobuleti:AddAsset("M978", 20)
-- warehouse.London:AddAsset("M818", 20) -- warehouse.London:AddAsset("M818", 20)
-- --
@ -1275,6 +1275,70 @@
-- -- Kobuleti requests all available trucks from London. -- -- Kobuleti requests all available trucks from London.
-- warehouse.London:AddRequest(warehouse.Kobuleti, WAREHOUSE.Descriptor.ATTRIBUTE, WAREHOUSE.Attribute.GROUND_TRUCK, WAREHOUSE.Quantity.HALF) -- warehouse.London:AddRequest(warehouse.Kobuleti, WAREHOUSE.Descriptor.ATTRIBUTE, WAREHOUSE.Attribute.GROUND_TRUCK, WAREHOUSE.Quantity.HALF)
-- --
--## Example 16 Resupply of Dead Assets
--
-- Warehouse at FARP Berlin is located at the front line and sends infantry groups to the battle zone.
-- Whenever a group dies, a new group is send from the warehouse to the battle zone.
-- Additionally, for each dead group, Berlin requests resupply from Batumi.
--
-- -- Start warehouses.
-- warehouse.Batumi:Start()
-- warehouse.Berlin:Start()
--
-- -- Front line warehouse.
-- warehouse.Berlin:AddAsset("Infantry Platoon Alpha", 6)
--
-- -- Resupply warehouse.
-- warehouse.Batumi:AddAsset("Infantry Platoon Alpha", 50)
--
-- -- Battle zone near FARP Berlin. This is where the action is!
-- local BattleZone=ZONE:New("Virtual Battle Zone")
--
-- -- Send infantry groups to the battle zone. Two groups every ~60 seconds.
-- for i=1,2 do
-- local time=(i-1)*60+10
-- warehouse.Berlin:__AddRequest(time, warehouse.Berlin, WAREHOUSE.Descriptor.ATTRIBUTE, WAREHOUSE.Attribute.GROUND_INFANTRY, 2, nil, nil, nil, "To Battle Zone")
-- end
--
-- -- Take care of the spawned units.
-- function warehouse.Berlin:OnAfterSelfRequest(From,Event,To,groupset,request)
-- local groupset=groupset --Core.Set#SET_GROUP
-- local request=request --Functional.Warehouse#WAREHOUSE.Pendingitem
--
-- -- Get assignment of this request.
-- local assignment=warehouse.Berlin:GetAssignment(request)
--
-- if assignment=="To Battle Zone" then
--
-- for _,group in pairs(groupset:GetSet()) do
-- local group=group --Wrapper.Group#GROUP
--
-- -- Route group to Battle zone.
-- local ToCoord=BattleZone:GetRandomCoordinate()
-- group:RouteGroundOnRoad(ToCoord, group:GetSpeedMax()*0.8)
--
-- -- After 3-5 minutes we create an explosion to destroy the group.
-- SCHEDULER:New(nil, Explosion, {group, 50}, math.random(180, 300))
-- end
--
-- end
--
-- end
--
-- -- An asset has died ==> request resupply for it.
-- function warehouse.Berlin:OnAfterAssetDead(From, Event, To, asset, request)
-- local asset=asset --Functional.Warehouse#WAREHOUSE.Assetitem
-- local request=request --Functional.Warehouse#WAREHOUSE.Pendingitem
--
-- -- Get assignment.
-- local assignment=warehouse.Berlin:GetAssignment(request)
--
-- -- Request resupply for dead asset from Batumi.
-- warehouse.Batumi:AddRequest(warehouse.Berlin, WAREHOUSE.Descriptor.ATTRIBUTE, asset.attribute, nil, nil, nil, nil, "Resupply")
--
-- -- Send asset to Battle zone either now or when they arrive.
-- warehouse.Berlin:AddRequest(warehouse.Berlin, WAREHOUSE.Descriptor.ATTRIBUTE, asset.attribute, 1, nil, nil, nil, assignment)
-- end
-- --
-- @field #WAREHOUSE -- @field #WAREHOUSE
WAREHOUSE = { WAREHOUSE = {
@ -1471,7 +1535,7 @@ WAREHOUSE.db = {
--- Warehouse class version. --- Warehouse class version.
-- @field #string version -- @field #string version
WAREHOUSE.version="0.5.5" WAREHOUSE.version="0.5.6"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO: Warehouse todo list. -- TODO: Warehouse todo list.
@ -5236,6 +5300,11 @@ function WAREHOUSE:_CheckConquered()
end end
elseif self:GetCoalition()==coalition.side.NEUTRAL then elseif self:GetCoalition()==coalition.side.NEUTRAL then
-- Neutrals dont attack! -- Neutrals dont attack!
if self:IsRunning() and Nred>0 then
self:Attacked(coalition.side.RED, CountryRed)
elseif self:IsRunning() and Nblue>0 then
self:Attacked(coalition.side.BLUE, CountryBlue)
end
end end
end end

View File

@ -623,10 +623,8 @@ end
-- @return #CONTROLLABLE self -- @return #CONTROLLABLE self
function CONTROLLABLE:StartUncontrolled(delay) function CONTROLLABLE:StartUncontrolled(delay)
if delay and delay>0 then if delay and delay>0 then
env.info(string.format("FF %s delayed start after %d seconds", self:GetName(), delay))
SCHEDULER:New(nil, CONTROLLABLE.StartUncontrolled, {self}, delay) SCHEDULER:New(nil, CONTROLLABLE.StartUncontrolled, {self}, delay)
else else
env.info(string.format("FF %s instant start", self:GetName()))
self:SetCommand({id='Start', params={}}) self:SetCommand({id='Start', params={}})
end end
return self return self
@ -1079,10 +1077,10 @@ end
-- The unit / controllable will follow lead unit of another controllable, wingmens of both controllables will continue following their leaders. -- The unit / controllable will follow lead unit of another controllable, wingmens of both controllables will continue following their leaders.
-- The unit / controllable will also protect that controllable from threats of specified types. -- The unit / controllable will also protect that controllable from threats of specified types.
-- @param #CONTROLLABLE self -- @param #CONTROLLABLE self
-- @param Wrapper.Controllable#CONTROLLABLE EscortControllable The controllable to be escorted. -- @param Wrapper.Controllable#CONTROLLABLE FollowControllable The controllable to be escorted.
-- @param DCS#Vec3 Vec3 Position of the unit / lead unit of the controllable relative lead unit of another controllable in frame reference oriented by course of lead unit of another controllable. If another controllable is on land the unit / controllable will orbit around. -- @param DCS#Vec3 Vec3 Position of the unit / lead unit of the controllable relative lead unit of another controllable in frame reference oriented by course of lead unit of another controllable. If another controllable is on land the unit / controllable will orbit around.
-- @param #number LastWaypointIndex Detach waypoint of another controllable. Once reached the unit / controllable Follow task is finished. -- @param #number LastWaypointIndex Detach waypoint of another controllable. Once reached the unit / controllable Follow task is finished.
-- @param #number EngagementDistanceMax Maximal distance from escorted controllable to threat. If the threat is already engaged by escort escort will disengage if the distance becomes greater than 1.5 * engagementDistMax. -- @param #number EngagementDistance Maximal distance from escorted controllable to threat. If the threat is already engaged by escort escort will disengage if the distance becomes greater than 1.5 * engagementDistMax.
-- @param DCS#AttributeNameArray TargetTypes Array of AttributeName that is contains threat categories allowed to engage. -- @param DCS#AttributeNameArray TargetTypes Array of AttributeName that is contains threat categories allowed to engage.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskEscort( FollowControllable, Vec3, LastWaypointIndex, EngagementDistance, TargetTypes ) function CONTROLLABLE:TaskEscort( FollowControllable, Vec3, LastWaypointIndex, EngagementDistance, TargetTypes )
@ -1105,6 +1103,8 @@ function CONTROLLABLE:TaskEscort( FollowControllable, Vec3, LastWaypointIndex, E
LastWaypointIndexFlag = true LastWaypointIndexFlag = true
end end
TargetTypes=TargetTypes or {}
local DCSTask local DCSTask
DCSTask = { id = 'Escort', DCSTask = { id = 'Escort',
params = { params = {