mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge pull request #1012 from FlightControl-Master/FF/Develop
Warehouse v0.5.6
This commit is contained in:
commit
0bb62ce43f
@ -597,8 +597,15 @@ ARTY={
|
||||
autorelocateonroad=false,
|
||||
}
|
||||
|
||||
--- Weapong type ID. http://wiki.hoggit.us/view/DCS_enum_weapon_flag
|
||||
-- @list WeaponType
|
||||
--- Weapong type ID. See [here](http://wiki.hoggit.us/view/DCS_enum_weapon_flag).
|
||||
-- @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={
|
||||
Auto=1073741822,
|
||||
Cannon=805306368,
|
||||
@ -610,7 +617,7 @@ ARTY.WeaponType={
|
||||
}
|
||||
|
||||
--- Database of common artillery unit properties.
|
||||
-- @list db
|
||||
-- @type ARTY.db
|
||||
ARTY.db={
|
||||
["2B11 mortar"] = { -- type "2B11 mortar"
|
||||
minrange = 500, -- correct?
|
||||
@ -675,7 +682,7 @@ ARTY.id="ARTY | "
|
||||
|
||||
--- Arty script 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
|
||||
|
||||
-- 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.
|
||||
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
|
||||
end
|
||||
|
||||
-- Default is current time if no time was specified.
|
||||
time=time or self:_SecondsToClock(timer.getAbsTime())
|
||||
|
||||
-- Set speed.
|
||||
if speed then
|
||||
-- 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
|
||||
|
||||
-- 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.
|
||||
local _move={name=_name, coord=coord, time=_time, speed=speed, onroad=onroad, cancel=cancel}
|
||||
|
||||
@ -606,6 +606,7 @@
|
||||
-- * "Attacked" --> "Captured" --> "Running" (warehouse was captured by the enemy)
|
||||
-- * "*" --> "AirbaseCaptured" --> "*" (airbase belonging to the warehouse was captured by the enemy)
|
||||
-- * "*" --> "AirbaseRecaptured" --> "*" (airbase was re-captured)
|
||||
-- * "*" --> "AssetDead" --> "*" (a whole asset group is dead)
|
||||
-- * "*" --> "Destroyed" --> "Destroyed" (warehouse was destroyed)
|
||||
-- * "Running" --> "Pause" --> "Paused" (warehouse is paused)
|
||||
-- * "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 :)
|
||||
-- local function DestroyWarehouse()
|
||||
-- warehouse.Batumi.warehouse:GetCoordinate():Explosion(999)
|
||||
-- warehouse.Batumi:GetCoordinate():Explosion(999)
|
||||
-- end
|
||||
-- SCHEDULER:New(nil, DestroyWarehouse, {}, 30)
|
||||
--
|
||||
@ -935,9 +936,9 @@
|
||||
-- -- Get Number of ships at Batumi.
|
||||
-- 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
|
||||
-- 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
|
||||
--
|
||||
-- ## Example 10: Warehouse on Aircraft Carrier
|
||||
@ -1001,7 +1002,6 @@
|
||||
--
|
||||
-- --- Function called after self request
|
||||
-- function warehouse.Stennis:OnAfterSelfRequest(From, Event, To,_groupset, request)
|
||||
--
|
||||
-- local groupset=_groupset --Core.Set#SET_GROUP
|
||||
-- local request=request --Functional.Warehouse#WAREHOUSE.Pendingitem
|
||||
--
|
||||
@ -1216,15 +1216,14 @@
|
||||
-- for _,_group in pairs(groupset:GetSet()) do
|
||||
-- local group=_group --Wrapper.Group#GROUP
|
||||
--
|
||||
-- -- Start uncontrolled aircraft.
|
||||
-- group:StartUncontrolled()
|
||||
-- group:SmokeBlue()
|
||||
--
|
||||
-- -- Target coordinate!
|
||||
-- local ToCoord=warehouse.Sukhumi:GetCoordinate()
|
||||
-- ToCoord.y=5000 -- Adjust altitude
|
||||
-- local ToCoord=warehouse.Sukhumi:GetCoordinate():SetAltitude(5000)
|
||||
--
|
||||
-- local FoCoord=warehouse.Kobuleti:GetCoordinate()
|
||||
-- FoCoord.y=3000 -- Ajust altitude.
|
||||
-- -- Home coordinate.
|
||||
-- local HomeCoord=warehouse.Kobuleti:GetCoordinate():SetAltitude(3000)
|
||||
--
|
||||
-- -- 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)
|
||||
@ -1237,7 +1236,7 @@
|
||||
-- -- Begin bombing run 20 km south of target.
|
||||
-- WayPoints[2]=ToCoord:Translate(20*1000, 180):WaypointAirTurningPoint(nil, 600, {task}, "Bombing Run")
|
||||
-- -- 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.
|
||||
-- WayPoints[4]=warehouse.Kobuleti:GetCoordinate():WaypointAirLanding()
|
||||
--
|
||||
@ -1262,6 +1261,7 @@
|
||||
-- -- 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")))
|
||||
--
|
||||
-- -- Add assets.
|
||||
-- warehouse.Kobuleti:AddAsset("M978", 20)
|
||||
-- warehouse.London:AddAsset("M818", 20)
|
||||
--
|
||||
@ -1275,6 +1275,70 @@
|
||||
-- -- Kobuleti requests all available trucks from London.
|
||||
-- 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
|
||||
WAREHOUSE = {
|
||||
@ -1471,7 +1535,7 @@ WAREHOUSE.db = {
|
||||
|
||||
--- Warehouse class version.
|
||||
-- @field #string version
|
||||
WAREHOUSE.version="0.5.5"
|
||||
WAREHOUSE.version="0.5.6"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO: Warehouse todo list.
|
||||
@ -5236,6 +5300,11 @@ function WAREHOUSE:_CheckConquered()
|
||||
end
|
||||
elseif self:GetCoalition()==coalition.side.NEUTRAL then
|
||||
-- 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
|
||||
|
||||
@ -623,10 +623,8 @@ end
|
||||
-- @return #CONTROLLABLE self
|
||||
function CONTROLLABLE:StartUncontrolled(delay)
|
||||
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)
|
||||
else
|
||||
env.info(string.format("FF %s instant start", self:GetName()))
|
||||
self:SetCommand({id='Start', params={}})
|
||||
end
|
||||
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 also protect that controllable from threats of specified types.
|
||||
-- @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 #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.
|
||||
-- @return DCS#Task The DCS task structure.
|
||||
function CONTROLLABLE:TaskEscort( FollowControllable, Vec3, LastWaypointIndex, EngagementDistance, TargetTypes )
|
||||
@ -1105,6 +1103,8 @@ function CONTROLLABLE:TaskEscort( FollowControllable, Vec3, LastWaypointIndex, E
|
||||
LastWaypointIndexFlag = true
|
||||
end
|
||||
|
||||
TargetTypes=TargetTypes or {}
|
||||
|
||||
local DCSTask
|
||||
DCSTask = { id = 'Escort',
|
||||
params = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user