@Sprouto Thank you very much, I solve the issue and presently for all factions Nukes with MIRVs are running fine. FYKI, due to ballistic trajectory the ICBMs are slightly different to make them split by compare with classic missiles or artillery projects. AGW the revised Antares Unit Pack mode shall be available this spring ...
Latest posts made by AntaresOne
-
RE: ModNUKEs - MIRVs
-
ModNUKEs - MIRVs
Hi everybody! Appreciate the assistance to fix my intention for create a new projectile - UEF MIRV Nuke, any guideline is welcome, thank you very much.
The idea is to launch a nuke that splits into several MIRVs before impact, by a circular radius pattern (and not a fan radius pattern).
So far, despite various attempts I encountered some difficulties with correct script - latest template below.
local TIFMissileNuke = import('/lua/terranprojectiles.lua').TIFMissileNuke
local EffectTemplate = import('/lua/EffectTemplates.lua')
local RandomFloat = import('/lua/utilities.lua').GetRandomFloat
local VizMarker = import('/lua/sim/VizMarker.lua').VizMarker---@ UEF Main MIRV Missile
TIFMissileNuke25 = Class(TIFMissileNuke) {InitialEffects = {'/effects/emitters/nuke_munition_launch_trail_02_emit.bp',}, LaunchEffects = { '/effects/emitters/nuke_munition_launch_trail_03_emit.bp', '/effects/emitters/nuke_munition_launch_trail_05_emit.bp', '/effects/emitters/nuke_munition_launch_trail_07_emit.bp', }, ThrustEffects = {'/effects/emitters/nuke_munition_launch_trail_04_emit.bp', '/effects/emitters/nuke_munition_launch_trail_06_emit.bp', }, OnCreate = function(self) TIFMissileNuke.OnCreate(self) self:SetCollisionShape('Sphere', 0, 0, 0, 2.0) self:LauncherCallbacks() self.MoveThread = self:ForkThread(self.MovementThread) end, CreateEffects = function( self, EffectTable, army, scale) for k, v in EffectTable do self.Trash:Add(CreateAttachedEmitter(self, -1, army, v):ScaleEmitter(scale)) end end, MovementThread = function(self) local army = self:GetArmy() local launcher = self:GetLauncher() self.CreateEffects( self, self.InitialEffects, army, 1 ) self:TrackTarget(false) WaitTicks(8) -- Height self:SetCollision(true) self.CreateEffects( self, self.LaunchEffects, army, 1 ) WaitTicks(20) self.CreateEffects( self, self.ThrustEffects, army, 1 ) self:TrackTarget(true) -- Turn ~90 degrees towards target self:SetDestroyOnWater(true) self:SetTurnRate(47.36) WaitTicks(20) -- Now set turn rate to zero so nuke flies straight self:SetTurnRate(0) self:SetAcceleration(0.001) self.WaitTime = 5 while not self:BeenDestroyed() do self:SetTurnRateByDist() WaitTicks(self.WaitTime) end end, SetTurnRateByDist = function(self) local dist = self:GetDistanceToTarget() -- Get the nuke as close to 90 deg as possible if dist > 150 then -- Freeze the turn rate as to prevent steep angles at long distance targets self:SetTurnRate(0) elseif dist > 75 and dist <= 150 then self.WaitTime = 3 elseif dist > 32 and dist <= 75 then self.WaitTime = 1 elseif dist < 15 then self:SetTurnRate(95) end end, OnImpact = function(self, TargetType, TargetEntity) local FxFragEffect = EffectTemplate.TFragmentationSensorShellFrag local ChildProjectileBP = '/mods/Antares Unit Pack/projectiles/TIFMissileNuke12/TIFMissileNuke12_proj.bp' # Split effects for k, v in FxFragEffect do CreateEmitterAtEntity( self, self:GetArmy(), v ) end local vx, vy, vz = self:GetVelocity() local velocity = 6 # One initial projectile following same directional path as the original self:CreateChildProjectile(ChildProjectileBP):SetVelocity(vx, vy, vz):SetVelocity(velocity):PassDamageData(self.DamageData) # Create several other projectiles in a dispersal pattern local numProjectiles = 6 local angle = (2*math.pi) / numProjectiles local angleInitial = RandomFloat( 0, angle ) # Randomization of the spread local angleVariation = angle * 0.35 # Adjusts angle variance spread local spreadMul = 2.5 # Adjusts the width of the dispersal local xVec = 0 local yVec = vy local zVec = 0 # Launch projectiles at semi-random angles away from split location for i = 0, (numProjectiles -1) do xVec = vx + (math.sin(angleInitial + (i*angle) + RandomFloat(-angleVariation, angleVariation))) * spreadMul zVec = vz + (math.cos(angleInitial + (i*angle) + RandomFloat(-angleVariation, angleVariation))) * spreadMul local proj = self:CreateChildProjectile(ChildProjectileBP) proj:SetVelocity(xVec,yVec,zVec) proj:SetVelocity(velocity) proj:PassDamageData(self.DamageData) end self:Destroy() TIFMissileNuke.OnImpact(self, TargetType, TargetEntity) end, PassDamageData = function(self, damageData) TIFMissileNuke.PassDamageData(self,damageData) local launcherbp = self:GetLauncher():GetBlueprint() self.ChildDamageData = table.copy(self.DamageData) end, GetDistanceToTarget = function(self) local tpos = self:GetCurrentTargetPosition() local mpos = self:GetPosition() local dist = VDist2(mpos[1], mpos[3], tpos[1], tpos[3]) return dist end,}
TypeClass = TIFMissileNuke25