Tinkered here and there with no success, so I’m going to post my code to see if anyone has an idea what could go wrong.
This is the code in lib.lua, it covers what the “missiles”, fuel, decoys and torpedoes will do:
function Fuel_Strikecraft(CustomGroup, playerID, shipID, fuel_max)
--print("Fuel")
--print(shipID)
dofilepath("data:scripts/lib/custom/shiptable.lua")
local b = shipID
--print("Test 1")
--print(b)
-- --print(ships[b].weapon.ammo)
local ca = ships[b].fuel.fuel
if ca == -10 then
if SobGroup_Selected(CustomGroup) == 1 then
UI_SetTextLabelText("NewTaskbar", "MaxFuel", "N/A")
end
else
--print(ships[b].fuel.fuel)
--print(ca)
local c = ca/fuel_max
--print(c)
local cc = floor(c*100)
--print(c)
--print(ca)
--print(fuel_max)
if ca>0 and SobGroup_GetActualSpeed(CustomGroup)>5 then
ships[b].fuel.fuel = ca-1 -- let's burn a bit more fuel, baby!
--print(ships[b].fuel.fuel)
ships[b].fuel.RTB = 1 -- I still have fuel
--SobGroup_SetHardPointHealth(CustomGroup,'FUELTANK',c)
if SobGroup_Selected(CustomGroup) == 1 then
UI_SetTextLabelText("NewTaskbar", "MaxFuel", ""..cc)
end
end
if ca>0 then
if SobGroup_Selected(CustomGroup) == 1 then
UI_SetTextLabelText("NewTaskbar", "MaxFuel", ""..cc)
end
--print(cc)
else
ships[b].fuel.RTB = 0 -- I am Bingo Fuel, out of fuel, let's Return To Base
if SobGroup_Selected(CustomGroup) == 1 then
UI_SetTextLabelText("NewTaskbar", "MaxFuel", "OUT")
end
end
end
end
function Display_Stats(screen,stat1,check1,stat2,check2,stat3,check3,stat4,check4)
local check = check1 + check2 + check3 + check4
if check > 1 then
UI_SetElementPosition(screen, "shipstatsframe", 11, 0);
elseif check > 0 then
UI_SetElementPosition(screen, "shipstatsframe", 32, 0);
else
UI_SetElementPosition(screen, "shipstatsframe", 50, 0);
end
if check1 > 0 then
UI_SetElementSize(screen, stat1, 40, 10);
UI_SetElementVisible(screen, stat1, check1)
else
UI_SetElementSize(screen, stat1, 0, 0);
UI_SetElementVisible(screen, stat1, check1)
end
if check2 > 0 then
UI_SetElementSize(screen, stat2, 40, 10);
UI_SetElementVisible(screen, stat2, check2)
else
UI_SetElementSize(screen, stat2, 0, 0);
UI_SetElementVisible(screen, stat2, check2)
end
if check3 > 0 then
UI_SetElementSize(screen, stat3, 40, 10);
UI_SetElementVisible(screen, stat3, check3)
else
UI_SetElementSize(screen, stat3, 0, 0);
UI_SetElementVisible(screen, stat3, check3)
end
if check4 > 0 then
UI_SetElementSize(screen, stat4, 40, 10);
UI_SetElementVisible(screen, stat4, check4)
else
UI_SetElementSize(screen, stat4, 0, 0);
UI_SetElementVisible(screen, stat4, check4)
end
end
function Missile_Surface_To_Air(CustomGroup, playerID, shipID, ammo_tubes, missile_recharge, missile_reload_max)
--print("Start Script Missile")
-- Algorithm:
-- I want to check if my missile is ready to launch.
-- If it is not, I will add a tick to the reload cycle.
-- I want to check now if I am attacking.
-- If I am attacking, am I attacking a valid target?
-- If I am attacking a valid target, then I will select pseudo-randomly a single target among the valid ones.
-- I will launch my missile.
-- My missile will attack my target.
-- I will update the readiness cycle.
-- Whatever happens, I will update the displayed values for the UI.
-- The variables allowing me to check the current status of the craft.
local b = shipID
local e = ships[b].weapon.missile_reload
-- Is my missile ready to launch?
if e<missile_reload_max then -- my missile is not ready to launch, I will go further in the rearming cycle.
ships[b].weapon.missile_reload = e+1
else -- My missile is ready to launch.
-- Am I attacking anyone?
if (SobGroup_GetCurrentOrder(CustomGroup)==COMMAND_Attack) then
SobGroup_CreateIfNotExist("AttackTargetTempGroup")
SobGroup_Clear("AttackTargetTempGroup")
SobGroup_GetCommandTargets("AttackTargetTempGroup", CustomGroup, COMMAND_Attack) -- This is the SobGroup with the targets of my ship.
SobGroup_CreateIfNotExist("SingleTargetTempGroup")
SobGroup_Clear("SingleTargetTempGroup")
-- I am now checking if my craft is attacking a valid target.
if SobGroup_AreAnyFromTheseAttackFamilies("AttackTargetTempGroup", "Capturer, Fighter, Corvette, Utility, ResourceLarge, Resource")==1 then
NumberInitialTargets=SobGroup_Count("AttackTargetTempGroup") -- Here is how many targets are being attacked.
SobGroup_CreateIfNotExist("ProximityCheckTempGroup")
SobGroup_Clear("ProximityCheckTempGroup")
-- Does my craft attack several targets, needing a selection?
if NumberInitialTargets==1 then -- No, the craft is attacking a single target.
-- Is this single target within firing range?
SobGroup_FillProximitySobGroup("ProximityCheckTempGroup", "AttackTargetTempGroup" , CustomGroup , 4500)
if SobGroup_Count("ProximityCheckTempGroup")==1 then
SobGroup_FillUnion("SingleTargetTempGroup","SingleTargetTempGroup","AttackTargetTempGroup") -- I now have a SobGroup with the desired name and a single target.
end -- This is the end of the if loop checking if the single target is within firing range.
else -- Yes, the craft is attacking several target, I need to select a single one now.
local shipIndex = mod(b/16,NumberInitialTargets)+1 -- This is a pseudo-random starting point for the selection loop, based on the shipID of my craft and the size of the attacked group. Note that the shipID is always a multiple of 16 in game.
local Reference = shipIndex-1 -- This will be my reference to check when I have done a full loop.
local TargetLock = 0 -- This is the variable to check when I have achieved a lock on a valid unit.
while TargetLock<1 do
SobGroup_CreateIfNotExist("SingleTargetCheckGroup")
SobGroup_Clear("SingleTargetCheckGroup")
-- I will create a group with a single ship using the index.
SobGroup_FillShipsByIndexRange("SingleTargetCheckGroup", "AttackTargetTempGroup", shipIndex, 1)
-- Is the target of a correct type?
CheckTargetType = SobGroup_AreAnyFromTheseAttackFamilies("SingleTargetCheckGroup", "Capturer, Fighter, Corvette, Utility, ResourceLarge, Resource")
SobGroup_FillProximitySobGroup("ProximityCheckTempGroup", "SingleTargetCheckGroup" , CustomGroup , 4500)
-- Is the target within firing range?
CheckTargetRange = SobGroup_Count("ProximityCheckTempGroup")
-- Check if both conditions are fit.
if CheckTargetType*CheckTargetRange>0 then
SobGroup_FillUnion("SingleTargetTempGroup","SingleTargetTempGroup","SingleTargetCheckGroup") -- I now have a SobGroup with the desired name and a single target.
TargetLock=1
else
shipIndex=shipIndex+1
if shipIndex>NumberInitialTargets then
shipIndex=1
end
end -- This is the end of the if loop finding whether the currently scanned target is correct in type and range.
if shipIndex-1==Reference then -- I did a full loop.
TargetLock=1 -- Let's stop the loop, with or without target.
end
end -- This is the end of the while loop finding a valid target to attack.
end -- This is the end of the if loop checking if my craft is attacking a single target.
-- I am attacking a valid type of target, and I have gone through the loop checking whether or not I am attacking a valid target and, if so, I now have a dedicated group for a single target.
if SobGroup_Count("SingleTargetTempGroup")==1 then
-- I now have a single good target, I can launch my missile on it.
SobGroup_CreateIfNotExist("MissileTempGroup"..shipID)
SobGroup_Clear("MissileTempGroup"..shipID)
Volume_AddSphere("LaunchPositionVolume", SobGroup_GetPosition(CustomGroup), 0) -- The missile will appear in this location.
for i = 1,ammo_tubes,1 do -- The craft will launch as many missiles at it has tubes.
SobGroup_SpawnNewShipInSobGroup(playerID, "Msl_Spiculim_"..i, "Msl_Spiculim_"..i.."Tir"..shipID..d, "MissileTempGroup"..shipID, "LaunchPositionVolume") --replace [msl_Spiculim]..i by your torpedo unit's ship name
-- The huge amount of parameters for the Squadron Name is to ensure that no two missiles have the same squadron name. I don't know if it can cause issues but I do not want to test.
end -- This is the end of the for loop launching as many missiles as the craft has tubes.
Volume_Delete("LaunchPositionVolume")
SobGroup_ParadeSobGroup("MissileTempGroup"..shipID, CustomGroup, 2) -- We are now teleporting the created missiles to their "launch positions".
local EnemyPlayer = SobGroup_OwnedBy("SingleTargetTempGroup") -- This is the player being attacked.
SobGroup_AvoidanceIgnore("MissileTempGroup"..shipID, "Player_Ships"..playerID)
if EnemyPlayer > -1 then -- Let's avoid some crash.
SobGroup_AvoidanceIgnore("MissileTempGroup"..shipID, "Player_Ships"..EnemyPlayer)
end -- This is the end of the if loop made to avoid a crash during the avoidance ignoring script.
SobGroup_Attack(playerID,"MissileTempGroup"..shipID, "SingleTargetTempGroup") -- The missile will attack the single target.
SobGroup_MakeSelectable("MissileTempGroup"..shipID,0) -- The missile cannot be selected anymore by the player.
SobGroup_Clear("MissileTempGroup"..shipID) -- There is nothing we need to do anymore with the missile.
ships[b].weapon.missile_reload = 0 -- We reset the launch sequence.
end -- This is the end of the if loop checking if my craft is attacking a valid target and can launch the missile.
end -- This is the end of the if loop checking if my craft is attacking a valid type of target.
end -- This is the end of the if loop checking if my craft is attacking anyone.
end -- This is the end of the if loop checking if my missile is ready to launch.
-- Let's update the UI with the remaining missiles.
if SobGroup_Selected(CustomGroup) == 1 then
UI_SetTextLabelText("NewTaskbar", "MaxMissile", ""..d)
end -- This is the end of the if loop updating the UI.
--print("End Script Missile")
end -- This is the end of the Missile_Air_To_Air function.
-- -- -- -- -- function Missile_Surface_To_Air(CustomGroup, playerID, shipID, ammo_tubes, missile_recharge, missile_reload_max)
-- -- -- -- -- dofilepath("data:scripts/lib/custom/shiptable.lua")
-- -- -- -- -- local b = shipID
-- -- -- -- -- --print("Munitions pour vaisseau :")
-- -- -- -- -- --print(d)
-- -- -- -- -- local e = ships[b].weapon.missile_reload
-- -- -- -- -- if e<missile_reload_max then
-- -- -- -- -- ships[b].weapon.missile_reload = e + missile_recharge -- if my torpedo is not ready, let's keep readying it by adding the ticks
-- -- -- -- -- end
-- -- -- -- -- if e==missile_reload_max then -- I have torpedoes AND one of them is ready, so we can go with the torpedo attack script
-- -- -- -- -- if(SobGroup_GetCurrentOrder(CustomGroup)==COMMAND_Attack)then -- Am I actually attacking?
-- -- -- -- -- SobGroup_CreateIfNotExist("TorpedoAttackerTargetTempGroup")
-- -- -- -- -- SobGroup_Clear("TorpedoAttackerTargetTempGroup")
-- -- -- -- -- SobGroup_GetCommandTargets("TorpedoAttackerTargetTempGroup", CustomGroup, COMMAND_Attack) -- Here is my target!
-- -- -- -- -- if(SobGroup_Count("TorpedoAttackerTargetTempGroup")>0)then -- I am actually attacking someone
-- -- -- -- -- if(SobGroup_AreAnyFromTheseAttackFamilies("TorpedoAttackerTargetTempGroup", "Capturer, Fighter, Corvette, Utility, ResourceLarge, Resource")==1)then--edit the attack families the attacker can attack, or simply copy this from the attacker's .ship file
-- -- -- -- -- SobGroup_CreateIfNotExist("TorpedoAttackerTargetTempGroup2") -- So, my target is a big boy, let's arm the torpedo, then!
-- -- -- -- -- SobGroup_Clear("TorpedoAttackerTargetTempGroup2")
-- -- -- -- -- SobGroup_FillProximitySobGroup("TorpedoAttackerTargetTempGroup2", "TorpedoAttackerTargetTempGroup" , CustomGroup , 4500)--edit the firerange of the torpedo, how far the attack will fire upon the target
-- -- -- -- -- if(SobGroup_Empty("TorpedoAttackerTargetTempGroup2")==0)then -- I am in weapon range, my torpedo is ready, let's unleash hell!
-- -- -- -- -- --print("I'm in range!")
-- -- -- -- -- SobGroup_CreateIfNotExist("MissileTempGroup"..shipID) -- the torpedo will be there
-- -- -- -- -- --print("A")
-- -- -- -- -- SobGroup_Clear("MissileTempGroup"..shipID)
-- -- -- -- -- --print("B")
-- -- -- -- -- Volume_AddSphere("AttackerPositionVolume", SobGroup_GetPosition(CustomGroup), 0) -- it will appear in this location
-- -- -- -- -- --print("C")
-- -- -- -- -- for i = 1,ammo_tubes,1 do
-- -- -- -- -- SobGroup_SpawnNewShipInSobGroup(playerID, "Msl_Spiculim_"..i, "Msl_Spiculim_"..i..shipID, "MissileTempGroup"..shipID, "AttackerPositionVolume")--replace [msl_torpedo] by your torpedo unit's ship name
-- -- -- -- -- --SobGroup_SpawnNewShipInSobGroup(playerID, "msl_torpedo_2", "msl_torpedo_2"..shipID, "MissileTempGroup"..shipID, "AttackerPositionVolume")--replace [msl_torpedo] by your torpedo unit's ship name
-- -- -- -- -- --SobGroup_AvoidanceIgnore("MissileTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
-- -- -- -- -- --print("D")
-- -- -- -- -- end
-- -- -- -- -- Volume_Delete("AttackerPositionVolume")
-- -- -- -- -- --print("E")
-- -- -- -- -- SobGroup_ParadeSobGroup("MissileTempGroup"..shipID, CustomGroup, 2)
-- -- -- -- -- local ya = SobGroup_OwnedBy("TorpedoAttackerTargetTempGroup")
-- -- -- -- -- if ya<0 then
-- -- -- -- -- else
-- -- -- -- -- SobGroup_AvoidanceIgnore("MissileTempGroup"..shipID, "Player_Ships"..ya)
-- -- -- -- -- end
-- -- -- -- -- SobGroup_AvoidanceIgnore("MissileTempGroup"..shipID, "Player_Ships"..playerID)
-- -- -- -- -- --SobGroup_ParadeSobGroup("MissileTempGroup"..shipID, CustomGroup, 2)
-- -- -- -- -- --print("F")
-- -- -- -- -- --SobGroup_Attack(PlayerIndex, "MissileTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
-- -- -- -- -- --print("G")
-- -- -- -- -- SobGroup_Attack(playerID,"MissileTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
-- -- -- -- -- --SobGroup_Kamikaze("MissileTempGroup"..shipID, "TorpedoAttackerTargetTempGroup") -- Tora! Tora! Tora!
-- -- -- -- -- --print("H")
-- -- -- -- -- SobGroup_MakeSelectable("MissileTempGroup"..shipID,0) -- Good bye, my little torpedo, you will be missed, but please do not miss.
-- -- -- -- -- --print("I")
-- -- -- -- -- SobGroup_Clear("MissileTempGroup"..shipID)
-- -- -- -- -- ships[b].weapon.missile_reload = 0 -- Yay, let's go through another reload cycle!
-- -- -- -- -- --print("J")
-- -- -- -- -- -- aa = GetShipId("msl_torpedo")
-- -- -- -- -- -- --print("ID du missile tiré")
-- -- -- -- -- -- --print(aa)
-- -- -- -- -- -- missile = aa
-- -- -- -- -- -- target
-- -- -- -- -- --SobGroup_SetHealth("MissileTempGroup"..shipID, 0)
-- -- -- -- -- else
-- -- -- -- -- --print("Almost in range...") -- Are we theeeeeere yet? No, kids.
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
function Missile_Air_To_Air(CustomGroup, playerID, shipID, ammo_max, ammo_tubes, ammo_use, missile_recharge, missile_reload_max)
--print("Start Script Missile")
-- Algorithm:
-- I want to check if I still have any missile left.
-- If I do, then I will go to the following step.
-- I want to check if my missile is ready to launch.
-- If it is not, I will add a tick to the reload cycle.
-- I want to check now if I am attacking.
-- If I am attacking, am I attacking a valid target?
-- If I am attacking a valid target, then I will select pseudo-randomly a single target among the valid ones.
-- I will launch my missile.
-- My missile will attack my target.
-- I will update the readiness cycle and the number of missiles left in my craft.
-- Whatever happens, I will update the displayed values for the UI.
-- The variables allowing me to check the current status of the craft.
local b = shipID
local d = ships[b].weapon.ammo
local e = ships[b].weapon.missile_reload
-- Do I have any missile left?
if d > 0 then
-- Is my missile ready to launch?
if e<missile_reload_max then -- my missile is not ready to launch, I will go further in the rearming cycle.
ships[b].weapon.missile_reload = e+1
else -- My missile is ready to launch.
-- Am I attacking anyone?
if (SobGroup_GetCurrentOrder(CustomGroup)==COMMAND_Attack) then
SobGroup_CreateIfNotExist("AttackTargetTempGroup")
SobGroup_Clear("AttackTargetTempGroup")
SobGroup_GetCommandTargets("AttackTargetTempGroup", CustomGroup, COMMAND_Attack) -- This is the SobGroup with the targets of my ship.
SobGroup_CreateIfNotExist("SingleTargetTempGroup")
SobGroup_Clear("SingleTargetTempGroup")
-- I am now checking if my craft is attacking a valid target.
if SobGroup_AreAnyFromTheseAttackFamilies("AttackTargetTempGroup", "Capturer, Fighter, Corvette, Utility, ResourceLarge, Resource")==1 then
NumberInitialTargets=SobGroup_Count("AttackTargetTempGroup") -- Here is how many targets are being attacked.
SobGroup_CreateIfNotExist("ProximityCheckTempGroup")
SobGroup_Clear("ProximityCheckTempGroup")
-- Does my craft attack several targets, needing a selection?
if NumberInitialTargets==1 then -- No, the craft is attacking a single target.
-- Is this single target within firing range?
SobGroup_FillProximitySobGroup("ProximityCheckTempGroup", "AttackTargetTempGroup" , CustomGroup , 4500)
if SobGroup_Count("ProximityCheckTempGroup")==1 then
SobGroup_FillUnion("SingleTargetTempGroup","SingleTargetTempGroup","AttackTargetTempGroup") -- I now have a SobGroup with the desired name and a single target.
end -- This is the end of the if loop checking if the single target is within firing range.
else -- Yes, the craft is attacking several target, I need to select a single one now.
local shipIndex = mod(b/16,NumberInitialTargets)+1 -- This is a pseudo-random starting point for the selection loop, based on the shipID of my craft and the size of the attacked group. Note that the shipID is always a multiple of 16 in game.
local Reference = shipIndex-1 -- This will be my reference to check when I have done a full loop.
local TargetLock = 0 -- This is the variable to check when I have achieved a lock on a valid unit.
while TargetLock<1 do
SobGroup_CreateIfNotExist("SingleTargetCheckGroup")
SobGroup_Clear("SingleTargetCheckGroup")
-- I will create a group with a single ship using the index.
SobGroup_FillShipsByIndexRange("SingleTargetCheckGroup", "AttackTargetTempGroup", shipIndex, 1)
-- Is the target of a correct type?
CheckTargetType = SobGroup_AreAnyFromTheseAttackFamilies("SingleTargetCheckGroup", "Capturer, Fighter, Corvette, Utility, ResourceLarge, Resource")
SobGroup_FillProximitySobGroup("ProximityCheckTempGroup", "SingleTargetCheckGroup" , CustomGroup , 4500)
-- Is the target within firing range?
CheckTargetRange = SobGroup_Count("ProximityCheckTempGroup")
-- Check if both conditions are fit.
if CheckTargetType*CheckTargetRange>0 then
SobGroup_FillUnion("SingleTargetTempGroup","SingleTargetTempGroup","SingleTargetCheckGroup") -- I now have a SobGroup with the desired name and a single target.
TargetLock=1
else
shipIndex=shipIndex+1
if shipIndex>NumberInitialTargets then
shipIndex=1
end
end -- This is the end of the if loop finding whether the currently scanned target is correct in type and range.
if shipIndex-1==Reference then -- I did a full loop.
TargetLock=1 -- Let's stop the loop, with or without target.
end
end -- This is the end of the while loop finding a valid target to attack.
end -- This is the end of the if loop checking if my craft is attacking a single target.
-- I am attacking a valid type of target, and I have gone through the loop checking whether or not I am attacking a valid target and, if so, I now have a dedicated group for a single target.
if SobGroup_Count("SingleTargetTempGroup")==1 then
-- I now have a single good target, I can launch my missile on it.
SobGroup_CreateIfNotExist("MissileTempGroup"..shipID)
SobGroup_Clear("MissileTempGroup"..shipID)
Volume_AddSphere("LaunchPositionVolume", SobGroup_GetPosition(CustomGroup), 0) -- The missile will appear in this location.
for i = 1,ammo_tubes,1 do -- The craft will launch as many missiles at it has tubes.
SobGroup_SpawnNewShipInSobGroup(playerID, "Msl_Spiculim_"..i, "Msl_Spiculim_"..i.."Tir"..shipID..d, "MissileTempGroup"..shipID, "LaunchPositionVolume") --replace [msl_Spiculim]..i by your torpedo unit's ship name
-- The huge amount of parameters for the Squadron Name is to ensure that no two missiles have the same squadron name. I don't know if it can cause issues but I do not want to test.
end -- This is the end of the for loop launching as many missiles as the craft has tubes.
Volume_Delete("LaunchPositionVolume")
SobGroup_ParadeSobGroup("MissileTempGroup"..shipID, CustomGroup, 2) -- We are now teleporting the created missiles to their "launch positions".
local EnemyPlayer = SobGroup_OwnedBy("SingleTargetTempGroup") -- This is the player being attacked.
SobGroup_AvoidanceIgnore("MissileTempGroup"..shipID, "Player_Ships"..playerID)
if EnemyPlayer > -1 then -- Let's avoid some crash.
SobGroup_AvoidanceIgnore("MissileTempGroup"..shipID, "Player_Ships"..EnemyPlayer)
end -- This is the end of the if loop made to avoid a crash during the avoidance ignoring script.
SobGroup_Attack(playerID,"MissileTempGroup"..shipID, "SingleTargetTempGroup") -- The missile will attack the single target.
SobGroup_MakeSelectable("MissileTempGroup"..shipID,0) -- The missile cannot be selected anymore by the player.
SobGroup_Clear("MissileTempGroup"..shipID) -- There is nothing we need to do anymore with the missile.
ships[b].weapon.missile_reload = 0 -- We reset the launch sequence.
ships[b].weapon.ammo = d-ammo_use -- We remove one or several missiles.
end -- This is the end of the if loop checking if my craft is attacking a valid target and can launch the missile.
end -- This is the end of the if loop checking if my craft is attacking a valid type of target.
end -- This is the end of the if loop checking if my craft is attacking anyone.
end -- This is the end of the if loop checking if my missile is ready to launch.
end -- This is the end of the if loop checking if I have any missile left.
-- Let's update the UI with the remaining missiles.
if SobGroup_Selected(CustomGroup) == 1 then
UI_SetTextLabelText("NewTaskbar", "MaxMissile", ""..d)
end -- This is the end of the if loop updating the UI.
--print("End Script Missile")
end -- This is the end of the Missile_Air_To_Air function.
-- -- -- -- -- function Missile_Air_To_Air(CustomGroup, playerID, shipID, ammo_max, ammo_tubes, ammo_use, missile_recharge, missile_reload_max)
-- -- -- -- -- dofilepath("data:scripts/lib/custom/shiptable.lua")
-- -- -- -- -- local b = shipID
-- -- -- -- -- local d = ships[b].weapon.ammo
-- -- -- -- -- if SobGroup_Selected(CustomGroup) == 1 then
-- -- -- -- -- UI_SetTextLabelText("NewTaskbar", "MaxMissile", ""..d)
-- -- -- -- -- end
-- -- -- -- -- --print("Munitions pour vaisseau :")
-- -- -- -- -- --print(d)
-- -- -- -- -- local e = ships[b].weapon.missile_reload
-- -- -- -- -- if e<missile_reload_max then
-- -- -- -- -- ships[b].weapon.missile_reload = e + missile_recharge -- if my torpedo is not ready, let's keep readying it by adding the ticks
-- -- -- -- -- end
-- -- -- -- -- if d>0 and e==missile_reload_max then -- I have torpedoes AND one of them is ready, so we can go with the torpedo attack script
-- -- -- -- -- if(SobGroup_GetCurrentOrder(CustomGroup)==COMMAND_Attack)then -- Am I actually attacking?
-- -- -- -- -- SobGroup_CreateIfNotExist("IncomingTempGroup")
-- -- -- -- -- SobGroup_Clear("IncomingTempGroup")
-- -- -- -- -- SobGroup_GetCommandTargets("IncomingTempGroup", CustomGroup, COMMAND_Attack) -- Here is my target!
-- -- -- -- -- if(SobGroup_Count("IncomingTempGroup")>0)then -- I am actually attacking someone
-- -- -- -- -- -- Script de sélection de cible unique.
-- -- -- -- -- local shipCount = SobGroup_Count("IncomingTempGroup")
-- -- -- -- -- local shipIndex = mod(b,shipCount)+1 -- sélection pseudo-aléatoire des cibles du groupe
-- -- -- -- -- local DeLock = shipIndex -- Cette variable va me permettre de détecter si je n'ai aucune cible verrouillable.
-- -- -- -- -- -- print("Variables :")
-- -- -- -- -- -- print(shipCount)
-- -- -- -- -- -- print(shipIndex)
-- -- -- -- -- -- print(DeLock)
-- -- -- -- -- local verrouillage = 0
-- -- -- -- -- --while (shipIndex < shipCount) do
-- -- -- -- -- while verrouillage < 1 do
-- -- -- -- -- -- print("Test :")
-- -- -- -- -- -- print(verrouillage)
-- -- -- -- -- -- print(shipIndex)
-- -- -- -- -- --print("Inbound missile #")
-- -- -- -- -- --print(shipIndex)
-- -- -- -- -- SobGroup_CreateIfNotExist("MissileCheck")
-- -- -- -- -- SobGroup_Clear("MissileCheck")
-- -- -- -- -- SobGroup_FillShipsByIndexRange("MissileCheck", "IncomingTempGroup", shipIndex, 1) -- Je crée un groupe individuel appelé MissileCheck et contenant le vaisseau numéro shipIndex de IncomingTempGroup.
-- -- -- -- -- SobGroup_CreateIfNotExist("ProximityCheckTempGroup")
-- -- -- -- -- SobGroup_Clear("ProximityCheckTempGroup")
-- -- -- -- -- SobGroup_FillProximitySobGroup("ProximityCheckTempGroup", "MissileCheck" , CustomGroup , 4500)
-- -- -- -- -- -- print(SobGroup_Count("IncomingTempGroup"))
-- -- -- -- -- -- print(SobGroup_Count("ProximityCheckTempGroup"))
-- -- -- -- -- -- print(SobGroup_AreAnyFromTheseAttackFamilies("MissileCheck", "Capturer, Fighter, Corvette, Utility, ResourceLarge, Resource"))
-- -- -- -- -- shipIndex = shipIndex + 1 -- Je me prépare à tester une cible suivante
-- -- -- -- -- if shipIndex>shipCount then
-- -- -- -- -- shipIndex=shipIndex-shipCount
-- -- -- -- -- end
-- -- -- -- -- if (SobGroup_Count("ProximityCheckTempGroup")*SobGroup_AreAnyFromTheseAttackFamilies("MissileCheck", "Capturer, Fighter, Corvette, Utility, ResourceLarge, Resource") > 0) then
-- -- -- -- -- verrouillage = 1 -- J'ai une cible correcte et à portée de tir, on peut passer à la suite !
-- -- -- -- -- end
-- -- -- -- -- if shipIndex == DeLock and verrouillage < 1 then -- Je suis revenu à la case départ sans avoir trouvé de cible correcte.
-- -- -- -- -- SobGroup_Clear("MissileCheck")
-- -- -- -- -- verrouillage = 1 -- Je n'ai pas trouvé de cible correcte après avoir vérifié chaque cible potentielle et on passe à la suite avec un groupe de verrouillage vide.
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- -- Script de sélection de cible unique.
-- -- -- -- -- --if(SobGroup_AreAnyFromTheseAttackFamilies("TorpedoAttackerTargetTempGroup", "Capturer, Fighter, Corvette, Utility, ResourceLarge, Resource")==1)then--edit the attack families the attacker can attack, or simply copy this from the attacker's .ship file
-- -- -- -- -- --SobGroup_CreateIfNotExist("TorpedoAttackerTargetTempGroup2") -- So, my target is a big boy, let's arm the torpedo, then!
-- -- -- -- -- --SobGroup_Clear("TorpedoAttackerTargetTempGroup2")
-- -- -- -- -- --SobGroup_FillProximitySobGroup("TorpedoAttackerTargetTempGroup2", "TorpedoAttackerTargetTempGroup" , CustomGroup , 4500)--edit the firerange of the torpedo, how far the attack will fire upon the target
-- -- -- -- -- if(SobGroup_Empty("MissileCheck")==0)then -- I am in weapon range, my torpedo is ready, let's unleash hell!
-- -- -- -- -- --print("I'm in range!")
-- -- -- -- -- SobGroup_CreateIfNotExist("MissileTempGroup"..shipID) -- the torpedo will be there
-- -- -- -- -- --print("A")
-- -- -- -- -- SobGroup_Clear("MissileTempGroup"..shipID)
-- -- -- -- -- --print("B")
-- -- -- -- -- Volume_AddSphere("AttackerPositionVolume", SobGroup_GetPosition(CustomGroup), 0) -- it will appear in this location
-- -- -- -- -- --print("C")
-- -- -- -- -- for i = 1,ammo_tubes,1 do
-- -- -- -- -- SobGroup_SpawnNewShipInSobGroup(playerID, "Msl_Spiculim_"..i, "Msl_Spiculim_"..i..shipID, "MissileTempGroup"..shipID, "AttackerPositionVolume")--replace [msl_torpedo] by your torpedo unit's ship name
-- -- -- -- -- --SobGroup_SpawnNewShipInSobGroup(playerID, "msl_torpedo_2", "msl_torpedo_2"..shipID, "MissileTempGroup"..shipID, "AttackerPositionVolume")--replace [msl_torpedo] by your torpedo unit's ship name
-- -- -- -- -- --SobGroup_AvoidanceIgnore("MissileTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
-- -- -- -- -- --print("D")
-- -- -- -- -- end
-- -- -- -- -- Volume_Delete("AttackerPositionVolume")
-- -- -- -- -- --print("E")
-- -- -- -- -- SobGroup_ParadeSobGroup("MissileTempGroup"..shipID, CustomGroup, 2)
-- -- -- -- -- local ya = SobGroup_OwnedBy("MissileCheck")
-- -- -- -- -- if ya<0 then
-- -- -- -- -- else
-- -- -- -- -- SobGroup_AvoidanceIgnore("MissileTempGroup"..shipID, "Player_Ships"..ya)
-- -- -- -- -- end
-- -- -- -- -- SobGroup_AvoidanceIgnore("MissileTempGroup"..shipID, "Player_Ships"..playerID)
-- -- -- -- -- --SobGroup_ParadeSobGroup("MissileTempGroup"..shipID, CustomGroup, 2)
-- -- -- -- -- --print("F")
-- -- -- -- -- --SobGroup_Attack(PlayerIndex, "MissileTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
-- -- -- -- -- --print("G")
-- -- -- -- -- SobGroup_Attack(playerID,"MissileTempGroup"..shipID, "MissileCheck")
-- -- -- -- -- --SobGroup_Kamikaze("MissileTempGroup"..shipID, "TorpedoAttackerTargetTempGroup") -- Tora! Tora! Tora!
-- -- -- -- -- --print("H")
-- -- -- -- -- SobGroup_MakeSelectable("MissileTempGroup"..shipID,0) -- Good bye, my little torpedo, you will be missed, but please do not miss.
-- -- -- -- -- --print("I")
-- -- -- -- -- SobGroup_Clear("MissileTempGroup"..shipID)
-- -- -- -- -- ships[b].weapon.missile_reload = 0 -- Yay, let's go through another reload cycle!
-- -- -- -- -- --print("J")
-- -- -- -- -- -- aa = GetShipId("msl_torpedo")
-- -- -- -- -- -- --print("ID du missile tiré")
-- -- -- -- -- -- --print(aa)
-- -- -- -- -- -- missile = aa
-- -- -- -- -- -- target
-- -- -- -- -- local b = shipID
-- -- -- -- -- ships[b].weapon.ammo = d-ammo_use -- let's consume a torpedo from the reserve
-- -- -- -- -- --SobGroup_SetHealth("MissileTempGroup"..shipID, 0)
-- -- -- -- -- else
-- -- -- -- -- --print("Almost in range...") -- Are we theeeeeere yet? No, kids.
-- -- -- -- -- end
-- -- -- -- -- --end
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
function Torpedo_Strikecraft(CustomGroup, playerID, shipID, torpedo_max, torpedo_tubes, torpedo_use, torpedo_recharge, torpedo_reload_max)
--print("Start Script Torpedo")
-- Algorithm:
-- I want to check if I still have any torpedo left.
-- If I do, then I will go to the following step.
-- I want to check if my torpedo is ready to launch.
-- If it is not, I will add a tick to the reload cycle.
-- I want to check now if I am attacking.
-- If I am attacking, am I attacking a valid target?
-- If I am attacking a valid target, then I will select pseudo-randomly a single target among the valid ones.
-- I will launch my torpedo.
-- My torpedo will attack my target.
-- I will update the readiness cycle and the number of torpedoes left in my craft.
-- Whatever happens, I will update the displayed values for the UI.
-- The variables allowing me to check the current status of the craft.
local b = shipID
if torpedo_max == 0 then
if SobGroup_Selected(CustomGroup) == 1 then
UI_SetTextLabelText("NewTaskbar", "MaxTorpedo", "NO")
end
else
local f = ships[b].weapon.torpedo
local e = ships[b].weapon.torpedo_reload
-- Do I have any torpedo left?
if f > 0 then
ships[b].weapon.RTB = 1
-- Is my torpedo ready to launch?
if e<torpedo_reload_max then -- my torpedo is not ready to launch, I will go further in the rearming cycle.
ships[b].weapon.torpedo_reload = e+1
else -- My torpedo is ready to launch.
-- Am I attacking anyone?
if (SobGroup_GetCurrentOrder(CustomGroup)==COMMAND_Attack) then
SobGroup_CreateIfNotExist("AttackTargetTempGroup")
SobGroup_Clear("AttackTargetTempGroup")
SobGroup_GetCommandTargets("AttackTargetTempGroup", CustomGroup, COMMAND_Attack) -- This is the SobGroup with the targets of my ship.
SobGroup_CreateIfNotExist("SingleTargetTempGroup")
SobGroup_Clear("SingleTargetTempGroup")
-- I am now checking if my craft is attacking a valid target.
if SobGroup_AreAnyFromTheseAttackFamilies("AttackTargetTempGroup", "Capturer, Frigate, SmallCapitalShip, BigCapitalShip, Mothership, Utility, ResourceLarge")==1 then
NumberInitialTargets=SobGroup_Count("AttackTargetTempGroup") -- Here is how many targets are being attacked.
SobGroup_CreateIfNotExist("ProximityCheckTempGroup")
SobGroup_Clear("ProximityCheckTempGroup")
-- Does my craft attack several targets, needing a selection?
if NumberInitialTargets==1 then -- No, the craft is attacking a single target.
-- Is this single target within firing range?
SobGroup_FillProximitySobGroup("ProximityCheckTempGroup", "AttackTargetTempGroup" , CustomGroup , 4500)
if SobGroup_Count("ProximityCheckTempGroup")==1 then
SobGroup_FillUnion("SingleTargetTempGroup","SingleTargetTempGroup","AttackTargetTempGroup") -- I now have a SobGroup with the desired name and a single target.
end -- This is the end of the if loop checking if the single target is within firing range.
else -- Yes, the craft is attacking several target, I need to select a single one now.
local shipIndex = mod(b/16,NumberInitialTargets)+1 -- This is a pseudo-random starting point for the selection loop, based on the shipID of my craft and the size of the attacked group. Note that the shipID is always a multiple of 16 in game.
local Reference = shipIndex-1 -- This will be my reference to check when I have done a full loop.
local TargetLock = 0 -- This is the variable to check when I have achieved a lock on a valid unit.
while TargetLock<1 do
SobGroup_CreateIfNotExist("SingleTargetCheckGroup")
SobGroup_Clear("SingleTargetCheckGroup")
-- I will create a group with a single ship using the index.
SobGroup_FillShipsByIndexRange("SingleTargetCheckGroup", "AttackTargetTempGroup", shipIndex, 1)
-- Is the target of a correct type?
CheckTargetType = SobGroup_AreAnyFromTheseAttackFamilies("SingleTargetCheckGroup", "Capturer, Frigate, SmallCapitalShip, BigCapitalShip, Mothership, Utility, ResourceLarge")
SobGroup_FillProximitySobGroup("ProximityCheckTempGroup", "SingleTargetCheckGroup" , CustomGroup , 4500)
-- Is the target within firing range?
CheckTargetRange = SobGroup_Count("ProximityCheckTempGroup")
-- Check if both conditions are fit.
if CheckTargetType*CheckTargetRange>0 then
SobGroup_FillUnion("SingleTargetTempGroup","SingleTargetTempGroup","SingleTargetCheckGroup") -- I now have a SobGroup with the desired name and a single target.
TargetLock=1
else
shipIndex=shipIndex+1
if shipIndex>NumberInitialTargets then
shipIndex=1
end
end -- This is the end of the if loop finding whether the currently scanned target is correct in type and range.
if shipIndex-1==Reference then -- I did a full loop.
TargetLock=1 -- Let's stop the loop, with or without target.
end
end -- This is the end of the while loop finding a valid target to attack.
end -- This is the end of the if loop checking if my craft is attacking a single target.
-- I am attacking a valid type of target, and I have gone through the loop checking whether or not I am attacking a valid target and, if so, I now have a dedicated group for a single target.
if SobGroup_Count("SingleTargetTempGroup")==1 then
-- I now have a single good target, I can launch my torpedo on it.
SobGroup_CreateIfNotExist("torpedoTempGroup"..shipID)
SobGroup_Clear("torpedoTempGroup"..shipID)
Volume_AddSphere("LaunchPositionVolume", SobGroup_GetPosition(CustomGroup), 0) -- The torpedo will appear in this location.
for i = 1,ammo_tubes,1 do -- The craft will launch as many torpedos at it has tubes.
SobGroup_SpawnNewShipInSobGroup(playerID, "msl_torpedo_"..i, "msl_torpedo_"..i.."Tir"..shipID..d, "torpedoTempGroup"..shipID, "LaunchPositionVolume") --replace [msl_Spiculim]..i by your torpedo unit's ship name
-- The huge amount of parameters for the Squadron Name is to ensure that no two torpedos have the same squadron name. I don't know if it can cause issues but I do not want to test.
end -- This is the end of the for loop launching as many torpedos as the craft has tubes.
Volume_Delete("LaunchPositionVolume")
SobGroup_ParadeSobGroup("torpedoTempGroup"..shipID, CustomGroup, 2) -- We are now teleporting the created torpedos to their "launch positions".
local EnemyPlayer = SobGroup_OwnedBy("SingleTargetTempGroup") -- This is the player being attacked.
SobGroup_AvoidanceIgnore("torpedoTempGroup"..shipID, "Player_Ships"..playerID)
if EnemyPlayer > -1 then -- Let's avoid some crash.
SobGroup_AvoidanceIgnore("torpedoTempGroup"..shipID, "Player_Ships"..EnemyPlayer)
end -- This is the end of the if loop made to avoid a crash during the avoidance ignoring script.
SobGroup_Attack(playerID,"torpedoTempGroup"..shipID, "SingleTargetTempGroup") -- The torpedo will attack the single target.
SobGroup_MakeSelectable("torpedoTempGroup"..shipID,0) -- The torpedo cannot be selected anymore by the player.
SobGroup_Clear("torpedoTempGroup"..shipID) -- There is nothing we need to do anymore with the torpedo.
ships[b].weapon.torpedo_reload = 0 -- We reset the launch sequence.
ships[b].weapon.torpedo = f-torpedo_use -- We remove one or several torpedos.
end -- This is the end of the if loop checking if my craft is attacking a valid target and can launch the torpedo.
end -- This is the end of the if loop checking if my craft is attacking a valid type of target.
end -- This is the end of the if loop checking if my craft is attacking anyone.
end -- This is the end of the if loop checking if my torpedo is ready to launch.
else
ships[b].weapon.RTB = 0 -- I am Winchester, out of ammunition, let's Return To Base
end -- This is the end of the if loop checking if I have any torpedo left.
-- Let's update the UI with the remaining torpedos.
if SobGroup_Selected(CustomGroup) == 1 then
UI_SetTextLabelText("NewTaskbar", "MaxTorpedo", ""..f)
end -- This is the end of the if loop updating the UI.
end -- This is the end of the if loop checking if I actually am a torpedo bomber.
--print("End Script torpedo")
end -- This is the end of the Torpedo_Strikecraft function.
-- -- -- -- -- function Torpedo_Strikecraft(CustomGroup, playerID, shipID, torpedo_max, torpedo_tubes, torpedo_use, torpedo_recharge, torpedo_reload_max)
-- -- -- -- -- dofilepath("data:scripts/lib/custom/shiptable.lua")
-- -- -- -- -- local b = shipID
-- -- -- -- -- if torpedo_max == 0 then
-- -- -- -- -- if SobGroup_Selected(CustomGroup) == 1 then
-- -- -- -- -- UI_SetTextLabelText("NewTaskbar", "MaxTorpedo", "NO")
-- -- -- -- -- end
-- -- -- -- -- else
-- -- -- -- -- --print("Torpilles pour vaisseau :")
-- -- -- -- -- --print(f)
-- -- -- -- -- local f = ships[b].weapon.torpedo
-- -- -- -- -- if SobGroup_Selected(CustomGroup) == 1 and torpedo_max > -10 then
-- -- -- -- -- UI_SetTextLabelText("NewTaskbar", "MaxTorpedo", ""..f)
-- -- -- -- -- end
-- -- -- -- -- -- Checking if we are out of torpedoes (if we are out of missiles, it's less important).
-- -- -- -- -- if f>0 then
-- -- -- -- -- ships[b].weapon.RTB = 1 -- I still have torpedoes
-- -- -- -- -- else
-- -- -- -- -- ships[b].weapon.RTB = 0 -- I am Winchester, out of ammunition, let's Return To Base
-- -- -- -- -- end
-- -- -- -- -- local h = ships[b].weapon.torpedo_reload
-- -- -- -- -- if h<torpedo_reload_max then
-- -- -- -- -- ships[b].weapon.torpedo_reload = h + torpedo_recharge -- if my torpedo is not ready, let's keep readying it by adding the ticks
-- -- -- -- -- end
-- -- -- -- -- --print("Cycle de rechargement torpille pour vaisseau :")
-- -- -- -- -- --print(h)
-- -- -- -- -- if f>0 and h==torpedo_reload_max then -- I have torpedoes AND one of them is ready, so we can go with the torpedo attack script
-- -- -- -- -- if(SobGroup_GetCurrentOrder(CustomGroup)==COMMAND_Attack)then -- Am I actually attacking?
-- -- -- -- -- SobGroup_CreateIfNotExist("TorpedoAttackerTargetTempGroup")
-- -- -- -- -- SobGroup_Clear("TorpedoAttackerTargetTempGroup")
-- -- -- -- -- SobGroup_GetCommandTargets("TorpedoAttackerTargetTempGroup", CustomGroup, COMMAND_Attack) -- Here is my target!
-- -- -- -- -- if(SobGroup_Count("TorpedoAttackerTargetTempGroup")>0)then -- I am actually attacking someone
-- -- -- -- -- if(SobGroup_AreAnyFromTheseAttackFamilies("TorpedoAttackerTargetTempGroup", "Capturer, Frigate, SmallCapitalShip, BigCapitalShip, Mothership, Utility, ResourceLarge")==1)then--edit the attack families the attacker can attack, or simply copy this from the attacker's .ship file
-- -- -- -- -- SobGroup_CreateIfNotExist("TorpedoAttackerTargetTempGroup2") -- So, my target is a big boy, let's arm the torpedo, then!
-- -- -- -- -- SobGroup_Clear("TorpedoAttackerTargetTempGroup2")
-- -- -- -- -- SobGroup_FillProximitySobGroup("TorpedoAttackerTargetTempGroup2", "TorpedoAttackerTargetTempGroup" , CustomGroup , 2500)--edit the firerange of the torpedo, how far the attack will fire upon the target
-- -- -- -- -- if(SobGroup_Empty("TorpedoAttackerTargetTempGroup2")==0)then -- I am in weapon range, my torpedo is ready, let's unleash hell!
-- -- -- -- -- --print("I'm in range!")
-- -- -- -- -- SobGroup_CreateIfNotExist("TorpedoTempGroup"..shipID) -- the torpedo will be there
-- -- -- -- -- --print("A")
-- -- -- -- -- SobGroup_Clear("TorpedoTempGroup"..shipID)
-- -- -- -- -- --print("B")
-- -- -- -- -- Volume_AddSphere("AttackerPositionVolume", SobGroup_GetPosition(CustomGroup), 0) -- it will appear in this location
-- -- -- -- -- --print("C")
-- -- -- -- -- local j = 1
-- -- -- -- -- for j = 1,torpedo_tubes,1 do
-- -- -- -- -- SobGroup_SpawnNewShipInSobGroup(playerID, "msl_torpedo_"..j, "msl_torpedo_"..j..shipID, "TorpedoTempGroup"..shipID, "AttackerPositionVolume")--replace [msl_torpedo] by your torpedo unit's ship name
-- -- -- -- -- --SobGroup_AvoidanceIgnore("TorpedoTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
-- -- -- -- -- end
-- -- -- -- -- --print("D")
-- -- -- -- -- Volume_Delete("AttackerPositionVolume")
-- -- -- -- -- --print("E")
-- -- -- -- -- SobGroup_ParadeSobGroup("TorpedoTempGroup"..shipID, CustomGroup, 2)
-- -- -- -- -- --SobGroup_ParadeSobGroup("TorpedoTempGroup"..shipID, CustomGroup, 2)
-- -- -- -- -- --print("F")
-- -- -- -- -- --SobGroup_Attack(PlayerIndex, "TorpedoTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
-- -- -- -- -- --print("G")
-- -- -- -- -- SobGroup_Attack(playerID,"TorpedoTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
-- -- -- -- -- --SobGroup_Kamikaze("TorpedoTempGroup"..shipID, "TorpedoAttackerTargetTempGroup") -- Tora! Tora! Tora!
-- -- -- -- -- --print("H")
-- -- -- -- -- SobGroup_MakeSelectable("TorpedoTempGroup"..shipID,0) -- Good bye, my little torpedo, you will be missed, but please do not miss.
-- -- -- -- -- --print("I")
-- -- -- -- -- ships[b].weapon.torpedo_reload = 0 -- Yay, let's go through another reload cycle!
-- -- -- -- -- --print("J")
-- -- -- -- -- -- aa = GetShipId("msl_torpedo")
-- -- -- -- -- -- --print("ID du missile tiré")
-- -- -- -- -- -- --print(aa)
-- -- -- -- -- -- missile = aa
-- -- -- -- -- -- target
-- -- -- -- -- if torpedo_max == -10 then
-- -- -- -- -- else
-- -- -- -- -- ships[b].weapon.torpedo = f-torpedo_use -- let's consume a torpedo from the reserve
-- -- -- -- -- end
-- -- -- -- -- --SobGroup_SetHealth("TorpedoTempGroup"..shipID, 0)
-- -- -- -- -- else
-- -- -- -- -- --print("Almost in range...") -- Are we theeeeeere yet? No, kids.
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
function Torpedo_Epee_Strikecraft(CustomGroup, playerID, shipID, torpedo_max, torpedo_tubes, torpedo_use, torpedo_recharge, torpedo_reload_max)
--print("Start Script Torpedo")
-- Algorithm:
-- I want to check if I still have any torpedo left.
-- If I do, then I will go to the following step.
-- I want to check if my torpedo is ready to launch.
-- If it is not, I will add a tick to the reload cycle.
-- I want to check now if I am attacking.
-- If I am attacking, am I attacking a valid target?
-- If I am attacking a valid target, then I will select pseudo-randomly a single target among the valid ones.
-- I will launch my torpedo.
-- My torpedo will attack my target.
-- I will update the readiness cycle and the number of torpedoes left in my craft.
-- Whatever happens, I will update the displayed values for the UI.
-- The variables allowing me to check the current status of the craft.
local b = shipID
if torpedo_max == 0 then
if SobGroup_Selected(CustomGroup) == 1 then
UI_SetTextLabelText("NewTaskbar", "MaxTorpedo", "NO")
end
else
local f = ships[b].weapon.torpedo
local e = ships[b].weapon.torpedo_reload
-- Do I have any torpedo left?
if f > 0 then
ships[b].weapon.RTB = 1
-- Is my torpedo ready to launch?
if e<torpedo_reload_max then -- my torpedo is not ready to launch, I will go further in the rearming cycle.
ships[b].weapon.torpedo_reload = e+1
else -- My torpedo is ready to launch.
-- Am I attacking anyone?
if (SobGroup_GetCurrentOrder(CustomGroup)==COMMAND_Attack) then
SobGroup_CreateIfNotExist("AttackTargetTempGroup")
SobGroup_Clear("AttackTargetTempGroup")
SobGroup_GetCommandTargets("AttackTargetTempGroup", CustomGroup, COMMAND_Attack) -- This is the SobGroup with the targets of my ship.
SobGroup_CreateIfNotExist("SingleTargetTempGroup")
SobGroup_Clear("SingleTargetTempGroup")
-- I am now checking if my craft is attacking a valid target.
if SobGroup_AreAnyFromTheseAttackFamilies("AttackTargetTempGroup", "Capturer, Frigate, SmallCapitalShip, BigCapitalShip, Mothership, Utility, ResourceLarge")==1 then
NumberInitialTargets=SobGroup_Count("AttackTargetTempGroup") -- Here is how many targets are being attacked.
SobGroup_CreateIfNotExist("ProximityCheckTempGroup")
SobGroup_Clear("ProximityCheckTempGroup")
-- Does my craft attack several targets, needing a selection?
if NumberInitialTargets==1 then -- No, the craft is attacking a single target.
-- Is this single target within firing range?
SobGroup_FillProximitySobGroup("ProximityCheckTempGroup", "AttackTargetTempGroup" , CustomGroup , 4500)
if SobGroup_Count("ProximityCheckTempGroup")==1 then
SobGroup_FillUnion("SingleTargetTempGroup","SingleTargetTempGroup","AttackTargetTempGroup") -- I now have a SobGroup with the desired name and a single target.
end -- This is the end of the if loop checking if the single target is within firing range.
else -- Yes, the craft is attacking several target, I need to select a single one now.
local shipIndex = mod(b/16,NumberInitialTargets)+1 -- This is a pseudo-random starting point for the selection loop, based on the shipID of my craft and the size of the attacked group. Note that the shipID is always a multiple of 16 in game.
local Reference = shipIndex-1 -- This will be my reference to check when I have done a full loop.
local TargetLock = 0 -- This is the variable to check when I have achieved a lock on a valid unit.
while TargetLock<1 do
SobGroup_CreateIfNotExist("SingleTargetCheckGroup")
SobGroup_Clear("SingleTargetCheckGroup")
-- I will create a group with a single ship using the index.
SobGroup_FillShipsByIndexRange("SingleTargetCheckGroup", "AttackTargetTempGroup", shipIndex, 1)
-- Is the target of a correct type?
CheckTargetType = SobGroup_AreAnyFromTheseAttackFamilies("SingleTargetCheckGroup", "Capturer, Frigate, SmallCapitalShip, BigCapitalShip, Mothership, Utility, ResourceLarge")
SobGroup_FillProximitySobGroup("ProximityCheckTempGroup", "SingleTargetCheckGroup" , CustomGroup , 4500)
-- Is the target within firing range?
CheckTargetRange = SobGroup_Count("ProximityCheckTempGroup")
-- Check if both conditions are fit.
if CheckTargetType*CheckTargetRange>0 then
SobGroup_FillUnion("SingleTargetTempGroup","SingleTargetTempGroup","SingleTargetCheckGroup") -- I now have a SobGroup with the desired name and a single target.
TargetLock=1
else
shipIndex=shipIndex+1
if shipIndex>NumberInitialTargets then
shipIndex=1
end
end -- This is the end of the if loop finding whether the currently scanned target is correct in type and range.
if shipIndex-1==Reference then -- I did a full loop.
TargetLock=1 -- Let's stop the loop, with or without target.
end
end -- This is the end of the while loop finding a valid target to attack.
end -- This is the end of the if loop checking if my craft is attacking a single target.
-- I am attacking a valid type of target, and I have gone through the loop checking whether or not I am attacking a valid target and, if so, I now have a dedicated group for a single target.
if SobGroup_Count("SingleTargetTempGroup")==1 then
-- I now have a single good target, I can launch my torpedo on it.
SobGroup_CreateIfNotExist("torpedoTempGroup"..shipID)
SobGroup_Clear("torpedoTempGroup"..shipID)
Volume_AddSphere("LaunchPositionVolume", SobGroup_GetPosition(CustomGroup), 0) -- The torpedo will appear in this location.
for i = 1,ammo_tubes,1 do -- The craft will launch as many torpedos at it has tubes.
SobGroup_SpawnNewShipInSobGroup(playerID, "msl_light_torpedo_"..i, "msl_light_torpedo_"..i.."Tir"..shipID..d, "torpedoTempGroup"..shipID, "LaunchPositionVolume") --replace [msl_Spiculim]..i by your torpedo unit's ship name
-- The huge amount of parameters for the Squadron Name is to ensure that no two torpedos have the same squadron name. I don't know if it can cause issues but I do not want to test.
end -- This is the end of the for loop launching as many torpedos as the craft has tubes.
Volume_Delete("LaunchPositionVolume")
SobGroup_ParadeSobGroup("torpedoTempGroup"..shipID, CustomGroup, 2) -- We are now teleporting the created torpedos to their "launch positions".
local EnemyPlayer = SobGroup_OwnedBy("SingleTargetTempGroup") -- This is the player being attacked.
SobGroup_AvoidanceIgnore("torpedoTempGroup"..shipID, "Player_Ships"..playerID)
if EnemyPlayer > -1 then -- Let's avoid some crash.
SobGroup_AvoidanceIgnore("torpedoTempGroup"..shipID, "Player_Ships"..EnemyPlayer)
end -- This is the end of the if loop made to avoid a crash during the avoidance ignoring script.
SobGroup_Attack(playerID,"torpedoTempGroup"..shipID, "SingleTargetTempGroup") -- The torpedo will attack the single target.
SobGroup_MakeSelectable("torpedoTempGroup"..shipID,0) -- The torpedo cannot be selected anymore by the player.
SobGroup_Clear("torpedoTempGroup"..shipID) -- There is nothing we need to do anymore with the torpedo.
ships[b].weapon.torpedo_reload = 0 -- We reset the launch sequence.
ships[b].weapon.torpedo = f-torpedo_use -- We remove one or several torpedos.
end -- This is the end of the if loop checking if my craft is attacking a valid target and can launch the torpedo.
end -- This is the end of the if loop checking if my craft is attacking a valid type of target.
end -- This is the end of the if loop checking if my craft is attacking anyone.
end -- This is the end of the if loop checking if my torpedo is ready to launch.
else
ships[b].weapon.RTB = 0 -- I am Winchester, out of ammunition, let's Return To Base
end -- This is the end of the if loop checking if I have any torpedo left.
-- Let's update the UI with the remaining torpedos.
if SobGroup_Selected(CustomGroup) == 1 then
UI_SetTextLabelText("NewTaskbar", "MaxTorpedo", ""..f)
end -- This is the end of the if loop updating the UI.
end -- This is the end of the if loop checking if I actually am a torpedo bomber.
--print("End Script torpedo")
end -- This is the end of the Torpedo_Strikecraft function.
-- -- -- -- function Torpedo_Epee_Strikecraft(CustomGroup, playerID, shipID, torpedo_max, torpedo_tubes, torpedo_use, torpedo_recharge, torpedo_reload_max)
-- -- -- -- dofilepath("data:scripts/lib/custom/shiptable.lua")
-- -- -- -- local b = shipID
-- -- -- -- if torpedo_max == 0 then
-- -- -- -- if SobGroup_Selected(CustomGroup) == 1 then
-- -- -- -- UI_SetTextLabelText("NewTaskbar", "MaxTorpedo", "NO")
-- -- -- -- end
-- -- -- -- else
-- -- -- -- --print("Torpilles pour vaisseau :")
-- -- -- -- --print(f)
-- -- -- -- local f = ships[b].weapon.torpedo
-- -- -- -- if SobGroup_Selected(CustomGroup) == 1 and torpedo_max > -10 then
-- -- -- -- UI_SetTextLabelText("NewTaskbar", "MaxTorpedo", ""..f)
-- -- -- -- end
-- -- -- -- -- Checking if we are out of torpedoes (if we are out of missiles, it's less important).
-- -- -- -- if f>0 then
-- -- -- -- ships[b].weapon.RTB = 1 -- I still have torpedoes
-- -- -- -- else
-- -- -- -- ships[b].weapon.RTB = 0 -- I am Winchester, out of ammunition, let's Return To Base
-- -- -- -- end
-- -- -- -- local h = ships[b].weapon.torpedo_reload
-- -- -- -- if h<torpedo_reload_max then
-- -- -- -- ships[b].weapon.torpedo_reload = h + torpedo_recharge -- if my torpedo is not ready, let's keep readying it by adding the ticks
-- -- -- -- end
-- -- -- -- --print("Cycle de rechargement torpille pour vaisseau :")
-- -- -- -- --print(h)
-- -- -- -- if f>0 and h==torpedo_reload_max then -- I have torpedoes AND one of them is ready, so we can go with the torpedo attack script
-- -- -- -- if(SobGroup_GetCurrentOrder(CustomGroup)==COMMAND_Attack)then -- Am I actually attacking?
-- -- -- -- SobGroup_CreateIfNotExist("TorpedoAttackerTargetTempGroup")
-- -- -- -- SobGroup_Clear("TorpedoAttackerTargetTempGroup")
-- -- -- -- SobGroup_GetCommandTargets("TorpedoAttackerTargetTempGroup", CustomGroup, COMMAND_Attack) -- Here is my target!
-- -- -- -- if(SobGroup_Count("TorpedoAttackerTargetTempGroup")>0)then -- I am actually attacking someone
-- -- -- -- if(SobGroup_AreAnyFromTheseAttackFamilies("TorpedoAttackerTargetTempGroup", "Capturer, Frigate, SmallCapitalShip, BigCapitalShip, Mothership, Utility, ResourceLarge")==1)then--edit the attack families the attacker can attack, or simply copy this from the attacker's .ship file
-- -- -- -- SobGroup_CreateIfNotExist("TorpedoAttackerTargetTempGroup2") -- So, my target is a big boy, let's arm the torpedo, then!
-- -- -- -- SobGroup_Clear("TorpedoAttackerTargetTempGroup2")
-- -- -- -- SobGroup_FillProximitySobGroup("TorpedoAttackerTargetTempGroup2", "TorpedoAttackerTargetTempGroup" , CustomGroup , 2500)--edit the firerange of the torpedo, how far the attack will fire upon the target
-- -- -- -- if(SobGroup_Empty("TorpedoAttackerTargetTempGroup2")==0)then -- I am in weapon range, my torpedo is ready, let's unleash hell!
-- -- -- -- --print("I'm in range!")
-- -- -- -- SobGroup_CreateIfNotExist("TorpedoTempGroup"..shipID) -- the torpedo will be there
-- -- -- -- --print("A")
-- -- -- -- SobGroup_Clear("TorpedoTempGroup"..shipID)
-- -- -- -- --print("B")
-- -- -- -- Volume_AddSphere("AttackerPositionVolume", SobGroup_GetPosition(CustomGroup), 0) -- it will appear in this location
-- -- -- -- --print("C")
-- -- -- -- local j = 1
-- -- -- -- for j = 1,torpedo_tubes,1 do
-- -- -- -- SobGroup_SpawnNewShipInSobGroup(playerID, "msl_light_torpedo_"..j, "msl_light_torpedo_"..j..shipID, "TorpedoTempGroup"..shipID, "AttackerPositionVolume")--replace [msl_torpedo] by your torpedo unit's ship name
-- -- -- -- --SobGroup_AvoidanceIgnore("TorpedoTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
-- -- -- -- end
-- -- -- -- --print("D")
-- -- -- -- Volume_Delete("AttackerPositionVolume")
-- -- -- -- --print("E")
-- -- -- -- SobGroup_ParadeSobGroup("TorpedoTempGroup"..shipID, CustomGroup, 2)
-- -- -- -- --SobGroup_ParadeSobGroup("TorpedoTempGroup"..shipID, CustomGroup, 2)
-- -- -- -- --print("F")
-- -- -- -- --SobGroup_Attack(PlayerIndex, "TorpedoTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
-- -- -- -- --print("G")
-- -- -- -- SobGroup_Attack(playerID,"TorpedoTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
-- -- -- -- --SobGroup_Kamikaze("TorpedoTempGroup"..shipID, "TorpedoAttackerTargetTempGroup") -- Tora! Tora! Tora!
-- -- -- -- --print("H")
-- -- -- -- SobGroup_MakeSelectable("TorpedoTempGroup"..shipID,0) -- Good bye, my little torpedo, you will be missed, but please do not miss.
-- -- -- -- --print("I")
-- -- -- -- ships[b].weapon.torpedo_reload = 0 -- Yay, let's go through another reload cycle!
-- -- -- -- --print("J")
-- -- -- -- -- aa = GetShipId("msl_torpedo")
-- -- -- -- -- --print("ID du missile tiré")
-- -- -- -- -- --print(aa)
-- -- -- -- -- missile = aa
-- -- -- -- -- target
-- -- -- -- if torpedo_max == -10 then
-- -- -- -- else
-- -- -- -- ships[b].weapon.torpedo = f-torpedo_use -- let's consume a torpedo from the reserve
-- -- -- -- end
-- -- -- -- --SobGroup_SetHealth("TorpedoTempGroup"..shipID, 0)
-- -- -- -- else
-- -- -- -- --print("Almost in range...") -- Are we theeeeeere yet? No, kids.
-- -- -- -- end
-- -- -- -- end
-- -- -- -- end
-- -- -- -- end
-- -- -- -- end
-- -- -- -- end
-- -- -- -- end
function Torpedo_Ship(CustomGroup, playerID, shipID, torpedo_max, torpedo_tubes, torpedo_use, torpedo_recharge, torpedo_reload_max,range)
--print("Start Script Torpedo")
-- Algorithm:
-- I want to check if I still have any torpedo left.
-- If I do, then I will go to the following step.
-- I want to check if my torpedo is ready to launch.
-- If it is not, I will add a tick to the reload cycle.
-- I want to check now if I am attacking.
-- If I am attacking, am I attacking a valid target?
-- If I am attacking a valid target, then I will select pseudo-randomly a single target among the valid ones.
-- I will launch my torpedo.
-- My torpedo will attack my target.
-- I will update the readiness cycle and the number of torpedoes left in my craft.
-- Whatever happens, I will update the displayed values for the UI.
-- The variables allowing me to check the current status of the craft.
local b = shipID
-- if torpedo_max == 0 then
-- if SobGroup_Selected(CustomGroup) == 1 then
-- UI_SetTextLabelText("NewTaskbar", "MaxTorpedo", "NO")
-- end
-- else
-- local f = ships[b].weapon.torpedo
local e = ships[b].weapon.torpedo_reload
-- Do I have any torpedo left?
-- if f > 0 then
ships[b].weapon.RTB = 1
-- Is my torpedo ready to launch?
if e<torpedo_reload_max then -- my torpedo is not ready to launch, I will go further in the rearming cycle.
ships[b].weapon.torpedo_reload = e+1
else -- My torpedo is ready to launch.
-- Am I attacking anyone?
if (SobGroup_GetCurrentOrder(CustomGroup)==COMMAND_Attack) then
SobGroup_CreateIfNotExist("AttackTargetTempGroup")
SobGroup_Clear("AttackTargetTempGroup")
SobGroup_GetCommandTargets("AttackTargetTempGroup", CustomGroup, COMMAND_Attack) -- This is the SobGroup with the targets of my ship.
SobGroup_CreateIfNotExist("SingleTargetTempGroup")
SobGroup_Clear("SingleTargetTempGroup")
-- I am now checking if my craft is attacking a valid target.
if SobGroup_AreAnyFromTheseAttackFamilies("AttackTargetTempGroup", "Capturer, Frigate, SmallCapitalShip, BigCapitalShip, Mothership, Utility, ResourceLarge")==1 then
NumberInitialTargets=SobGroup_Count("AttackTargetTempGroup") -- Here is how many targets are being attacked.
SobGroup_CreateIfNotExist("ProximityCheckTempGroup")
SobGroup_Clear("ProximityCheckTempGroup")
-- Does my craft attack several targets, needing a selection?
if NumberInitialTargets==1 then -- No, the craft is attacking a single target.
-- Is this single target within firing range?
SobGroup_FillProximitySobGroup("ProximityCheckTempGroup", "AttackTargetTempGroup" , CustomGroup , range)
if SobGroup_Count("ProximityCheckTempGroup")==1 then
SobGroup_FillUnion("SingleTargetTempGroup","SingleTargetTempGroup","AttackTargetTempGroup") -- I now have a SobGroup with the desired name and a single target.
end -- This is the end of the if loop checking if the single target is within firing range.
else -- Yes, the craft is attacking several target, I need to select a single one now.
local shipIndex = mod(b/16,NumberInitialTargets)+1 -- This is a pseudo-random starting point for the selection loop, based on the shipID of my craft and the size of the attacked group. Note that the shipID is always a multiple of 16 in game.
local Reference = shipIndex-1 -- This will be my reference to check when I have done a full loop.
local TargetLock = 0 -- This is the variable to check when I have achieved a lock on a valid unit.
while TargetLock<1 do
SobGroup_CreateIfNotExist("SingleTargetCheckGroup")
SobGroup_Clear("SingleTargetCheckGroup")
-- I will create a group with a single ship using the index.
SobGroup_FillShipsByIndexRange("SingleTargetCheckGroup", "AttackTargetTempGroup", shipIndex, 1)
-- Is the target of a correct type?
CheckTargetType = SobGroup_AreAnyFromTheseAttackFamilies("SingleTargetCheckGroup", "Capturer, Frigate, SmallCapitalShip, BigCapitalShip, Mothership, Utility, ResourceLarge")
SobGroup_FillProximitySobGroup("ProximityCheckTempGroup", "SingleTargetCheckGroup" , CustomGroup , range)
-- Is the target within firing range?
CheckTargetRange = SobGroup_Count("ProximityCheckTempGroup")
-- Check if both conditions are fit.
if CheckTargetType*CheckTargetRange>0 then
SobGroup_FillUnion("SingleTargetTempGroup","SingleTargetTempGroup","SingleTargetCheckGroup") -- I now have a SobGroup with the desired name and a single target.
TargetLock=1
else
shipIndex=shipIndex+1
if shipIndex>NumberInitialTargets then
shipIndex=1
end
end -- This is the end of the if loop finding whether the currently scanned target is correct in type and range.
if shipIndex-1==Reference then -- I did a full loop.
TargetLock=1 -- Let's stop the loop, with or without target.
end
end -- This is the end of the while loop finding a valid target to attack.
end -- This is the end of the if loop checking if my craft is attacking a single target.
-- I am attacking a valid type of target, and I have gone through the loop checking whether or not I am attacking a valid target and, if so, I now have a dedicated group for a single target.
if SobGroup_Count("SingleTargetTempGroup")==1 then
-- I now have a single good target, I can launch my torpedo on it.
SobGroup_CreateIfNotExist("torpedoTempGroup"..shipID)
SobGroup_Clear("torpedoTempGroup"..shipID)
Volume_AddSphere("LaunchPositionVolume", SobGroup_GetPosition(CustomGroup), 0) -- The torpedo will appear in this location.
for i = 1,ammo_tubes,1 do -- The craft will launch as many torpedos at it has tubes.
SobGroup_SpawnNewShipInSobGroup(playerID, "msl_torpedo_"..i, "msl_torpedo_"..i.."Tir"..shipID..d, "torpedoTempGroup"..shipID, "LaunchPositionVolume") --replace [msl_Spiculim]..i by your torpedo unit's ship name
-- The huge amount of parameters for the Squadron Name is to ensure that no two torpedos have the same squadron name. I don't know if it can cause issues but I do not want to test.
end -- This is the end of the for loop launching as many torpedos as the craft has tubes.
Volume_Delete("LaunchPositionVolume")
SobGroup_ParadeSobGroup("torpedoTempGroup"..shipID, CustomGroup, 2) -- We are now teleporting the created torpedos to their "launch positions".
local EnemyPlayer = SobGroup_OwnedBy("SingleTargetTempGroup") -- This is the player being attacked.
SobGroup_AvoidanceIgnore("torpedoTempGroup"..shipID, "Player_Ships"..playerID)
if EnemyPlayer > -1 then -- Let's avoid some crash.
SobGroup_AvoidanceIgnore("torpedoTempGroup"..shipID, "Player_Ships"..EnemyPlayer)
end -- This is the end of the if loop made to avoid a crash during the avoidance ignoring script.
SobGroup_Attack(playerID,"torpedoTempGroup"..shipID, "SingleTargetTempGroup") -- The torpedo will attack the single target.
SobGroup_MakeSelectable("torpedoTempGroup"..shipID,0) -- The torpedo cannot be selected anymore by the player.
SobGroup_Clear("torpedoTempGroup"..shipID) -- There is nothing we need to do anymore with the torpedo.
ships[b].weapon.torpedo_reload = 0 -- We reset the launch sequence.
ships[b].weapon.torpedo = f-torpedo_use -- We remove one or several torpedos.
end -- This is the end of the if loop checking if my craft is attacking a valid target and can launch the torpedo.
end -- This is the end of the if loop checking if my craft is attacking a valid type of target.
end -- This is the end of the if loop checking if my craft is attacking anyone.
end -- This is the end of the if loop checking if my torpedo is ready to launch.
-- else
-- ships[b].weapon.RTB = 0 -- I am Winchester, out of ammunition, let's Return To Base
-- end -- This is the end of the if loop checking if I have any torpedo left.
-- Let's update the UI with the remaining torpedos.
-- if SobGroup_Selected(CustomGroup) == 1 then
-- UI_SetTextLabelText("NewTaskbar", "MaxTorpedo", ""..f)
-- end -- This is the end of the if loop updating the UI.
-- end -- This is the end of the if loop checking if I actually am a torpedo bomber.
--print("End Script torpedo")
end -- This is the end of the Torpedo_Ship function.
-- -- -- -- -- function Torpedo_Ship(CustomGroup, playerID, shipID, Torpedo_Research_1, torpedo_tubes, torpedo_use, torpedo_recharge, torpedo_reload_max, range)
-- -- -- -- -- dofilepath("data:scripts/lib/custom/shiptable.lua")
-- -- -- -- -- local b = shipID
-- -- -- -- -- -- Checking if we are out of torpedoes (if we are out of missiles, it's less important).
-- -- -- -- -- if Player_HasResearch(playerID, Torpedo_Research_1)==1 then
-- -- -- -- -- local f = ships[b].weapon.torpedo
-- -- -- -- -- local h = ships[b].weapon.torpedo_reload
-- -- -- -- -- if h<torpedo_reload_max then
-- -- -- -- -- ships[b].weapon.torpedo_reload = h + torpedo_recharge -- if my torpedo is not ready, let's keep readying it by adding the ticks
-- -- -- -- -- end
-- -- -- -- -- --print("Cycle de rechargement torpille pour vaisseau :")
-- -- -- -- -- --print(h)
-- -- -- -- -- if f>0 and h==torpedo_reload_max then -- I have torpedoes AND one of them is ready, so we can go with the torpedo attack script
-- -- -- -- -- if(SobGroup_GetCurrentOrder(CustomGroup)==COMMAND_Attack)then -- Am I actually attacking?
-- -- -- -- -- SobGroup_CreateIfNotExist("TorpedoAttackerTargetTempGroup")
-- -- -- -- -- SobGroup_Clear("TorpedoAttackerTargetTempGroup")
-- -- -- -- -- SobGroup_GetCommandTargets("TorpedoAttackerTargetTempGroup", CustomGroup, COMMAND_Attack) -- Here is my target!
-- -- -- -- -- if(SobGroup_Count("TorpedoAttackerTargetTempGroup")>0)then -- I am actually attacking someone
-- -- -- -- -- if(SobGroup_AreAnyFromTheseAttackFamilies("TorpedoAttackerTargetTempGroup", "Capturer, Frigate, SmallCapitalShip, BigCapitalShip, Mothership, Utility, ResourceLarge")==1)then--edit the attack families the attacker can attack, or simply copy this from the attacker's .ship file
-- -- -- -- -- SobGroup_CreateIfNotExist("TorpedoAttackerTargetTempGroup2") -- So, my target is a big boy, let's arm the torpedo, then!
-- -- -- -- -- SobGroup_Clear("TorpedoAttackerTargetTempGroup2")
-- -- -- -- -- SobGroup_FillProximitySobGroup("TorpedoAttackerTargetTempGroup2", "TorpedoAttackerTargetTempGroup" , CustomGroup , range)--edit the firerange of the torpedo, how far the attack will fire upon the target
-- -- -- -- -- if(SobGroup_Empty("TorpedoAttackerTargetTempGroup2")==0)then -- I am in weapon range, my torpedo is ready, let's unleash hell!
-- -- -- -- -- --print("I'm in range!")
-- -- -- -- -- SobGroup_CreateIfNotExist("TorpedoTempGroup"..shipID) -- the torpedo will be there
-- -- -- -- -- --print("A")
-- -- -- -- -- SobGroup_Clear("TorpedoTempGroup"..shipID)
-- -- -- -- -- --print("B")
-- -- -- -- -- Volume_AddSphere("AttackerPositionVolume", SobGroup_GetPosition(CustomGroup), 0) -- it will appear in this location
-- -- -- -- -- --print("C")
-- -- -- -- -- local j = 1
-- -- -- -- -- for j = 1,torpedo_tubes,1 do
-- -- -- -- -- SobGroup_SpawnNewShipInSobGroup(playerID, "msl_torpedo_"..j, "msl_torpedo_"..j..shipID, "TorpedoTempGroup"..shipID, "AttackerPositionVolume")--replace [msl_torpedo] by your torpedo unit's ship name
-- -- -- -- -- --SobGroup_AvoidanceIgnore("TorpedoTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
-- -- -- -- -- end
-- -- -- -- -- --print("D")
-- -- -- -- -- Volume_Delete("AttackerPositionVolume")
-- -- -- -- -- --print("E")
-- -- -- -- -- SobGroup_ParadeSobGroup("TorpedoTempGroup"..shipID, CustomGroup, 2)
-- -- -- -- -- --SobGroup_ParadeSobGroup("TorpedoTempGroup"..shipID, CustomGroup, 2)
-- -- -- -- -- --print("F")
-- -- -- -- -- --SobGroup_Attack(PlayerIndex, "TorpedoTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
-- -- -- -- -- --print("G")
-- -- -- -- -- SobGroup_Attack(playerID,"TorpedoTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
-- -- -- -- -- --SobGroup_Kamikaze("TorpedoTempGroup"..shipID, "TorpedoAttackerTargetTempGroup") -- Tora! Tora! Tora!
-- -- -- -- -- --print("H")
-- -- -- -- -- SobGroup_MakeSelectable("TorpedoTempGroup"..shipID,0) -- Good bye, my little torpedo, you will be missed, but please do not miss.
-- -- -- -- -- --print("I")
-- -- -- -- -- ships[b].weapon.torpedo_reload = 0 -- Yay, let's go through another reload cycle!
-- -- -- -- -- --print("J")
-- -- -- -- -- -- aa = GetShipId("msl_torpedo")
-- -- -- -- -- -- --print("ID du missile tiré")
-- -- -- -- -- -- --print(aa)
-- -- -- -- -- -- missile = aa
-- -- -- -- -- -- target
-- -- -- -- -- --SobGroup_SetHealth("TorpedoTempGroup"..shipID, 0)
-- -- -- -- -- else
-- -- -- -- -- --print("Almost in range...") -- Are we theeeeeere yet? No, kids.
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
-- -- -- -- -- end
-- Problème : si quelqu'un attaque un groupe de vaisseaux comprenant celui qui a le leurre, il se
-- considérera comme attaqué même si les missiles ne vont pas sur lui.
-- Solution 1 : il faut pouvoir distinguer la cible précise du missile en approche.
-- Solution 2 : il faut que le missile n'attaque qu'une seule cible à la fois.
-- Problème probable : si on attaque un groupe de vaisseaux avec au moins une cible valide pour les torpilles,
-- la torpille pourra être lancée sur n'importe qui, qu'importe la validité individuelle de la cible.
-- Solution : il faut que la torpille n'attaque qu'une cible à la fois.
-- Méthode : il faut que le groupe attaqué soit ramené à une seule cible.
function Decoy_Strikecraft(CustomGroup, playerID, shipID, decoy_max, decoy_use, decoy_recharge, decoy_reload_max)
dofilepath("data:scripts/lib/custom/shiptable.lua")
NumJoueurs = GlobalStats.NumPlayers
local b = shipID
local g = ships[b].weapon.decoy
local i = ships[b].weapon.decoy_reload
if i<decoy_reload_max then
ships[b].weapon.decoy_reload = i + decoy_recharge -- if my decoy is not ready, let's keep readying it by adding the ticks
end
SobGroup_CreateIfNotExist("Missiles_Total")
if SobGroup_Count("Missiles_Total")>0 then
if i==decoy_reload_max and g>0 then
SobGroup_CreateIfNotExist("AttackerTempGroup")
SobGroup_Clear("AttackerTempGroup")
SobGroup_CreateIfNotExist("Myself")
SobGroup_Clear("Myself")
SobGroup_SobGroupAdd("Myself", CustomGroup)
SobGroup_GetAttackers("Myself", "AttackerTempGroup")
k=SobGroup_Count("AttackerTempGroup")
print("Nombre d'attaquants :")
print(k)
if k>0 then
-- l=SobGroup_AreAnyOfTheseTypes("AttackerTempGroup", "Msl_Spiculim_1, Msl_Spiculim_2, Msl_Spiculim_3, Msl_Spiculim_4, Msl_Spiculim_5, Msl_Spiculim_6, Msl_Spiculim_7, Msl_Spiculim_8")
-- -- --print("Y a-t-il un missile ?")
-- -- --print(l)
-- m=SobGroup_AreAnyFromTheseAttackFamilies("AttackerTempGroup", "Fighter")
-- -- --print("Chasseur ?")
-- -- --print(m)
-- SobGroup_CreateIfNotExist("IncomingTempGroup1")
-- SobGroup_CreateIfNotExist("IncomingTempGroup2")
-- if SobGroup_Count("AttackerTempGroup")>0 then
-- y = SobGroup_OwnedBy("AttackerTempGroup")
-- --print("Possesseur :")
-- --print(y)
-- SobGroup_Clear("IncomingTempGroup1")
-- SobGroup_Clear("IncomingTempGroup2")
-- SobGroup_FillProximitySobGroup("IncomingTempGroup1", "Player_Ships"..y, CustomGroup, 5000)
-- --print("En approche ?")
-- --print(SobGroup_Count("IncomingTempGroup1"))
-- SobGroup_FillShipsByType("IncomingTempGroup2", "IncomingTempGroup1", "Msl_Spiculim_1")
-- --print(SobGroup_Count("IncomingTempGroup2"))
-- end
SobGroup_CreateIfNotExist("Missiles_"..playerID)
SobGroup_CreateIfNotExist("IncomingTempGroup1")
SobGroup_CreateIfNotExist("IncomingTempGroup2")
SobGroup_CreateIfNotExist("IncomingTempGroup")
SobGroup_CreateIfNotExist("IncomingTempGroupDanger")
SobGroup_CreateIfNotExist("MissileDanger")
SobGroup_CreateIfNotExist("MissileCheck")
SobGroup_Clear("IncomingTempGroup1")
SobGroup_Clear("IncomingTempGroup2")
SobGroup_Clear("IncomingTempGroup")
SobGroup_Clear("IncomingTempGroupDanger")
SobGroup_Clear("MissileDanger")
SobGroup_Clear("MissileCheck")
SobGroup_FillProximitySobGroup("IncomingTempGroup1", "Missiles_"..playerID, CustomGroup, 2500) -- Mes missiles.
--print("Missile Check :")
--print(SobGroup_Count("IncomingTempGroup1"))
SobGroup_FillProximitySobGroup("IncomingTempGroup2", "Missiles_Total", CustomGroup, 2500) -- Tous les missiles.
--print(SobGroup_Count("IncomingTempGroup2"))
--SobGroup_FillSubstract("IncomingTempGroup", "Missiles_Total", "Missiles_"..playerID)
SobGroup_FillSubstract("IncomingTempGroup", "IncomingTempGroup2", "IncomingTempGroup1") -- Tous les missiles sauf les miens.
--print(SobGroup_Count("IncomingTempGroup"))
local Danger = 0
local missileCount = SobGroup_Count("IncomingTempGroup")
local missileIndex = 0
while (missileIndex < missileCount) do
--print("Inbound missile #")
--print(missileIndex)
SobGroup_Clear("MissileCheck")
SobGroup_FillShipsByIndexRange("MissileCheck", "IncomingTempGroup", missileIndex, 1)
missileIndex = missileIndex + 1
-- if (SobGroup_Count("MissileCheck") > 0) then
-- missileIndex = missileIndex + (SobGroup_Count("MissileCheck")- 1)
-- end
SobGroup_CreateIfNotExist("Target")
SobGroup_Clear("Target")
SobGroup_GetCommandTargets("Target", "MissileCheck", COMMAND_Attack)
--local Danger = SobGroup_GroupInGroup("Target", "Myself")
local Danger = SobGroup_GroupInGroup("MissileCheck", "AttackerTempGroup")
--print("Is the missile targeting me ?")
--print(Danger)
if Danger == 1 then
SobGroup_CreateIfNotExist("MissileDanger")
SobGroup_SobGroupAdd("MissileDanger", "MissileCheck") -- if I want to decoy all missiles at once
--print("I am targeted by this many missiles :")
--print(SobGroup_Count("MissileDanger"))
SobGroup_CreateIfNotExist("MissileDecoy")
SobGroup_Clear("MissileDecoy")
SobGroup_SobGroupAdd("MissileDecoy", "MissileCheck") -- if I want to decoy just the last missile found
end
end
--print("Cycle de rechargement pour leurres :")
--print(i)
if SobGroup_Count("MissileDecoy")>0 then
-- SobGroup_CreateIfNotExist("Target")
-- SobGroup_Clear("Target")
-- SobGroup_GetCommandTargets("Target", "IncomingTempGroup2", COMMAND_Attack)
--print("Cibles Missiles :")
--print(SobGroup_Count("Target"))
-- if SobGroup_GroupInGroup("Target", CustomGroup) then
SobGroup_CreateIfNotExist("DecoyTempGroup"..shipID) -- the decoy will be there
-- SobGroup_CreateIfNotExist("MissileTempGroup") -- the enemy missiles will be there
--print("A1")
--SobGroup_Clear("DecoyTempGroup")
--SobGroup_Clear("MissileTempGroup")
--print("B1")
--SobGroup_FillShipsByType("MissileTempGroup", "AttackerTempGroup", "Msl_Spiculim_1, Msl_Spiculim_2, Msl_Spiculim_3, Msl_Spiculim_4, Msl_Spiculim_5, Msl_Spiculim_6, Msl_Spiculim_7, Msl_Spiculim_8")
Volume_AddSphere("AttackerPositionVolume", SobGroup_GetPosition(CustomGroup), 0) -- it will appear in this location
--print("C1")
SobGroup_SpawnNewShipInSobGroup(playerID, "Msl_Decoy_1", "Msl_Decoy_1"..shipID, "DecoyTempGroup"..shipID, "AttackerPositionVolume")--replace [msl_torpedo] by your torpedo unit's ship name
--SobGroup_SpawnNewShipInSobGroup(playerID, "msl_torpedo_2", "msl_torpedo_2"..shipID, "DecoyTempGroup"..shipID, "AttackerPositionVolume")--replace [msl_torpedo] by your torpedo unit's ship name
--SobGroup_AvoidanceIgnore("DecoyTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
--print("D1")
--print("Largage Leurre")
Volume_Delete("AttackerPositionVolume")
--print("E1")
SobGroup_ParadeSobGroup("DecoyTempGroup"..shipID, CustomGroup, 2)
local ya = SobGroup_OwnedBy("MissileDecoy")
SobGroup_AvoidanceIgnore("DecoyTempGroup"..shipID, "Player_Ships"..playerID)
if ya<0 then
else
SobGroup_AvoidanceIgnore("DecoyTempGroup"..shipID, "Player_Ships"..ya)
end
--SobGroup_ParadeSobGroup("DecoyTempGroup"..shipID, CustomGroup, 2)
--print("F1")
--SobGroup_Attack(PlayerIndex, "DecoyTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
--print("G1")
SobGroup_Attack(playerID,"DecoyTempGroup"..shipID, "MissileDecoy") --SobGroup_ParadeSobGroup("DecoyTempGroup"..shipID, CustomGroup, 2)
--print("F")
Position=SobGroup_GetPosition(CustomGroup)[1]
if cos(Position)>0 then
local z = SobGroup_OwnedBy("MissileDecoy")
SobGroup_Attack(z, "MissileDecoy", "DecoyTempGroup"..shipID)
--print("Leurre Succès")
else
--print("Leurre Raté")
end
--SobGroup_Attack(PlayerIndex, "DecoyTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
--print("G")
--SobGroup_Attack(playerID,"DecoyTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
--SobGroup_Kamikaze("DecoyTempGroup"..shipID, "MissileDanger") -- Tora! Tora! Tora!
--print("H1")
SobGroup_MakeSelectable("DecoyTempGroup"..shipID,0) -- Good bye, my little torpedo, you will be missed, but please do not miss.
SobGroup_Clear("DecoyTempGroup"..shipID)
--print("I1")
ships[b].weapon.decoy_reload = 0 -- Yay, let's go through another reload cycle!
--print("J1")
-- aa = GetShipId("msl_torpedo")
-- --print("ID du missile tiré")
-- --print(aa)
-- missile = aa
-- target
ships[b].weapon.decoy = g-decoy_recharge -- let's consume a torpedo from the reserve
-- end
end
end
end
end
if SobGroup_Selected(CustomGroup) == 1 then
UI_SetTextLabelText("NewTaskbar", "MaxDecoy", ""..g)
end
end
function Capship_Missiles(CustomGroup, playerID, shipID, capship_max, capship_tubes, capship_use, capship_recharge, capship_reload_max, range, Research_1, Research_2)
dofilepath("data:scripts/lib/custom/shiptable.lua")
b = shipID
if Player_HasResearch(playerID, Research_1)==1 then
e = ships[b].weapon.capship_reload
if e<capship_reload_max then
ships[b].weapon.capship_reload = e + capship_recharge -- if my torpedo is not ready, let's keep readying it by adding the ticks
end
--print("Cycle de rechargement pour vaisseau :")
--print(e)
if e==capship_reload_max then -- I have torpedoes AND one of them is ready, so we can go with the torpedo attack script
if(SobGroup_GetCurrentOrder(CustomGroup)==COMMAND_Attack)then -- Am I actually attacking?
SobGroup_CreateIfNotExist("TorpedoAttackerTargetTempGroup")
SobGroup_Clear("TorpedoAttackerTargetTempGroup")
SobGroup_GetCommandTargets("TorpedoAttackerTargetTempGroup", CustomGroup, COMMAND_Attack) -- Here is my target!
if(SobGroup_Count("TorpedoAttackerTargetTempGroup")>0)then -- I am actually attacking someone
if(SobGroup_AreAnyFromTheseAttackFamilies("TorpedoAttackerTargetTempGroup", "Capturer, Frigate, SmallCapitalShip, BigCapitalShip, Mothership, Utility")==1)then--edit the attack families the attacker can attack, or simply copy this from the attacker's .ship file
SobGroup_CreateIfNotExist("TorpedoAttackerTargetTempGroup2") -- So, my target is a big boy, let's arm the torpedo, then!
SobGroup_Clear("TorpedoAttackerTargetTempGroup2")
SobGroup_FillProximitySobGroup("TorpedoAttackerTargetTempGroup2", "TorpedoAttackerTargetTempGroup" , CustomGroup , range)--edit the firerange of the torpedo, how far the attack will fire upon the target
if(SobGroup_Empty("TorpedoAttackerTargetTempGroup2")==0)then -- I am in weapon range, my torpedo is ready, let's unleash hell!
--print("I'm in range!")
SobGroup_CreateIfNotExist("CapShipMissileTempGroup"..shipID) -- the torpedo will be there
--print("A")
SobGroup_Clear("CapShipMissileTempGroup"..shipID)
--print("B")
Volume_AddSphere("AttackerPositionVolume", SobGroup_GetPosition(CustomGroup), 0) -- it will appear in this location
--print("C")
if Player_HasResearch(playerID, Research_2)==0 then
for j = 1,capship_tubes,1 do
SobGroup_SpawnNewShipInSobGroup(playerID, "msl_klr_cruise_missile", "msl_klr_cruise_missile"..shipID, "CapShipMissileTempGroup"..shipID, "AttackerPositionVolume")--replace [msl_torpedo] by your torpedo unit's ship name
end
else
-- SobGroup_SpawnNewShipInSobGroup(playerID, "msl_klr_cruise_missile", "msl_klr_cruise_missile"..shipID, "CapShipMissileTempGroup"..shipID, "AttackerPositionVolume")--replace [msl_torpedo] by your torpedo unit's ship name
for j = 1,capship_tubes,1 do
SobGroup_SpawnNewShipInSobGroup(playerID, "msl_skipper", "msl_skipper"..shipID, "CapShipMissileTempGroup"..shipID, "AttackerPositionVolume")--replace [msl_torpedo] by your torpedo unit's ship name
end
end
--SobGroup_AvoidanceIgnore("CapShipMissileTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
--print("D")
Volume_Delete("AttackerPositionVolume")
--print("E")
SobGroup_ParadeSobGroup("CapShipMissileTempGroup"..shipID, CustomGroup, 2)
--SobGroup_ParadeSobGroup("CapShipMissileTempGroup"..shipID, CustomGroup, 2)
--print("F")
--SobGroup_Attack(PlayerIndex, "CapShipMissileTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
--print("G")
SobGroup_Attack(playerID,"CapShipMissileTempGroup"..shipID, "TorpedoAttackerTargetTempGroup")
--SobGroup_Kamikaze("CapShipMissileTempGroup"..shipID, "TorpedoAttackerTargetTempGroup") -- Tora! Tora! Tora!
--print("H")
SobGroup_MakeSelectable("CapShipMissileTempGroup"..shipID,0) -- Good bye, my little torpedo, you will be missed, but please do not miss.
--print("I")
ships[b].weapon.capship_reload = 0 -- Yay, let's go through another reload cycle!
--print("J")
-- aa = GetShipId("msl_torpedo")
-- --print("ID du missile tiré")
-- --print(aa)
-- missile = aa
-- target
--ships[b].weapon.ammo = d-1 -- let's consume a torpedo from the reserve
--SobGroup_SetHealth("CapShipMissileTempGroup"..shipID, 0)
else
--print("Almost in range...") -- Are we theeeeeere yet? No, kids.
end
end
end
end
end
end
end
function Return_To_Base(CustomGroup, playerID, shipID, fuel_max, ammo_max, decoy_max, torpedo_max)
local b = shipID
local RTBTorp = ships[b].weapon.RTB
local RTBFuel = ships[b].fuel.RTB
local Corvette = ships[b].weapon.bomber
local RTB = RTBTorp*RTBFuel
--print("RTB :")
--print(RTBTorp)
--print(RTBFuel)
--print(RTB)
if RTB == 0 then -- I want to return to base
SobGroup_FillProximitySobGroup("Test1", "Player_Ships"..playerID, CustomGroup, 1500) -- Who is around me, me included?
SobGroup_FillProximitySobGroup("OwnShip", "Player_Ships"..playerID, CustomGroup, 5) -- Me!
SobGroup_FillSubstract("Test2", "Test1", "OwnShip") -- Who is around me, me NOT included. Useful, you'll see why later.
if Corvette == 1 then
if SobGroup_AreAnyOfTheseTypes("Test2", "cfd_carrier, cfd_confederation, cfd_jutland, cfd_lexington, cfd_mothership, cfd_naval_base, cfd_savannah, cfd_victory, klr_bhantkara, klr_dubav, klr_hvarkann, klr_shipyard, klr_starbase, ubw_carrier, ubw_mothership, ubw_shipyard")==1 then -- there's a carrier in proximity, let's not go all over the map for nothing, shall we? Replace this by a list of your carrier-capable units.
--print("CV found near me.")
SobGroup_CreateIfNotExist("Carrier")
SobGroup_Clear("Carrier")
SobGroup_FillShipsByType("Carrier", "Test2", "cfd_carrier, cfd_confederation, cfd_jutland, cfd_lexington, cfd_mothership, cfd_naval_base, cfd_savannah, cfd_victory, klr_bhantkara, klr_dubav, klr_hvarkann, klr_shipyard, klr_starbase, ubw_carrier, ubw_mothership, ubw_shipyard")
if SobGroup_IsDoingAbility("Test2", AB_Dock)==1 then
--print("No Priority")
SobGroup_GuardSobGroup(CustomGroup, "Carrier") -- there are other ships waiting to land on the carrier near me, I'll guard my carrier instead of sitting like a target
else
--print("Priority") -- looks like noone is waiting to land, the sky is empty or everyone else is on guard, so it's my turn to land
-- what happened is that when you are RTB near a carrier, you will want to land. The first one to run the script in proximity to the carrier will land. Everyone after will see that landing plane and will get in guard position. When the plane landed, the next RTB plane to run the script will not see anyone landing and will start landing, etc., keeping only one plane on the landing pattern at all times!
SobGroup_DockSobGroup(CustomGroup, "Carrier")
end
else
--print("No CV found around me.") -- no carrier around, I'll land on a random friendly carrier
SobGroup_DockSobGroup(CustomGroup, "AllShips")
end
else
if SobGroup_AreAnyOfTheseTypes("Test2", "cfd_ajax, cfd_battlecruiser, cfd_carrier, cfd_confederation, cfd_eagle, cfd_jutland, cfd_lexington, cfd_mothership, cfd_naval_base, cfd_savannah, cfd_tarawa, cfd_victory, klr_bhantkara, klr_dubav, klr_fralath, klr_fralthi_ii, klr_fralthra, klr_hvarkann, klr_ralarrad, klr_ralaxath, klr_shipyard, klr_starbase, ubw_battlecruiser, ubw_carrier, ubw_mothership, ubw_shipyard")==1 then
--print("CV trouvé")
SobGroup_CreateIfNotExist("Carrier")
SobGroup_Clear("Carrier")
SobGroup_FillShipsByType("Carrier","Test2","cfd_ajax, cfd_battlecruiser, cfd_carrier, cfd_confederation, cfd_eagle, cfd_jutland, cfd_lexington, cfd_mothership, cfd_naval_base, cfd_savannah, cfd_tarawa, cfd_victory, klr_bhantkara, klr_dubav, klr_fralath, klr_fralthi_ii, klr_fralthra, klr_hvarkann, klr_ralarrad, klr_ralaxath, klr_shipyard, klr_starbase, ubw_battlecruiser, ubw_carrier, ubw_mothership, ubw_shipyard")
if SobGroup_IsDoingAbility("Test2", AB_Dock)==1 then
--print("Pas en priorité")
SobGroup_GuardSobGroup(CustomGroup, "Carrier")
else
--print("A la priorité")
SobGroup_DockSobGroup(CustomGroup, "Carrier")
end
else
--print("Pas de CV trouvé")
SobGroup_DockSobGroup(CustomGroup, "AllShips")
end
end
-- Reloading missiles, fuel, torpedoes and decoys.
end
if SobGroup_IsDocked(CustomGroup)==1 then
ships[b].weapon.ammo = ammo_max -- I got my ammunition reloaded by the ground crews
--ships[b].weapon.torpedo = weapon.torpedo_max -- I got my ammunition reloaded by the ground crews
ships[b].weapon.decoy = decoy_max -- I got my ammunition reloaded by the ground crews
ships[b].fuel.fuel = fuel_max -- I got my fuel reloaded by the ground crews
--SobGroup_SetHardPointHealth(CustomGroup,'FUELTANK',1)
ships[b].fuel.RTB = 1
ships[b].weapon.RTB = 1
if Corvette == 1 then
ships[b].weapon.torpedo = torpedo_max -- I got my ammunition reloaded by the ground crews
end
end
end
(continued in next post)