diff --git a/changelog/3810.md b/changelog/3810.md index d3fe1c3365..64e4a10f97 100644 --- a/changelog/3810.md +++ b/changelog/3810.md @@ -87,6 +87,8 @@ - (#5668, #6066) Rework Seraphim weapon modules +- (#6065) Refactor collision beam modules + - (#6067) Fix a performance issue related to AIs and their transport logic - (#6041, #6055) Clean up the blueprint-files of various structures. diff --git a/engine/Sim.lua b/engine/Sim.lua index a4685b2d52..3a38573d56 100644 --- a/engine/Sim.lua +++ b/engine/Sim.lua @@ -145,7 +145,7 @@ end --- creates a beam, which then needs to be attached to a bone ---@see AttachBeamToEntity(emitter, entity, bone, army) # to attach the beam to an entity bone ---@see CreateBeamEmitterOnEntity(object, tobone, army, blueprint) # to create an attached beam emitter at once ----@param blueprint string +---@param blueprint FileName ---@param army Army ---@return moho.IEffect function CreateBeamEmitter(blueprint, army) @@ -156,7 +156,7 @@ end ---@param object BoneObject ---@param tobone Bone ---@param army Army ----@param blueprint string +---@param blueprint FileName ---@return moho.IEffect function CreateBeamEmitterOnEntity(object, tobone, army, blueprint) end @@ -425,7 +425,7 @@ end --- Creates a unit from a blueprint for an army, at a position with quaternion orientation ---@see CreateUnit2() # simple version ---@see CreateUnitHPR() # heading-pitch-roll version ----@param blueprint string +---@param blueprintId string ---@param army Army ---@param x number ---@param y number @@ -436,20 +436,20 @@ end ---@param qw number ---@param layer? number ---@return Unit -function CreateUnit(blueprint, army, x, y, z, qx, qy, qz, qw, layer) +function CreateUnit(blueprintId, army, x, y, z, qx, qy, qz, qw, layer) end --- Creates a unit from a blueprint for an army, at an X-Z map point with a heading ---@see CreateUnit() # quaternion version ---@see CreateUnitHPR() # heading-pitch-roll version ----@param blueprint string +---@param blueprintId string ---@param army Army ---@param layer? number ---@param x number ---@param z number ---@param heading number ---@return Unit -function CreateUnit2(blueprint, army, layer, x, z, heading) +function CreateUnit2(blueprintId, army, layer, x, z, heading) end --- Creates a unit from a blueprint for an army, at a position with heading, pitch, and roll diff --git a/lua/EffectTemplates.lua b/lua/EffectTemplates.lua index 943f424a8f..1778b44fa3 100644 --- a/lua/EffectTemplates.lua +++ b/lua/EffectTemplates.lua @@ -533,6 +533,7 @@ SeraphimTeleportInWeapon01 = { -- --------------------------------------------------------------- -- -- -- -- UNIT CONSTRUCTION -- -- -- +-- --------------------------------------------------------------- -- --------------------------------------------------------------- -- Build Effects @@ -617,6 +618,7 @@ UpgradeBoneAmbient = { -- --------------------------------------------------------------- -- -- -- -- UNIT TRANSPORT BEAMS -- -- -- +-- --------------------------------------------------------------- -- --------------------------------------------------------------- -- Terran Transport Beam Effects @@ -641,6 +643,7 @@ ACollossusTractorBeamCrush01 = { -- --------------------------------------------------------------- -- -- -- -- UNIT MOVEMENT -- -- -- +-- --------------------------------------------------------------- -- --------------------------------------------------------------- -- Sea Unit Environmental Effects @@ -728,6 +731,7 @@ AeonOpHackACU = { -- --------------------------------------------------------------- -- -- -- -- AEON PROJECTILES -- -- -- +-- --------------------------------------------------------------- AMercyGuidedMissileSplit = { EmtBpPath .. 'aeon_mercy_guided_missile_split_01.bp', @@ -1156,6 +1160,10 @@ AQuarkBombHitUnit01 = AQuarkBombHit01 AQuarkBombHitAirUnit01 = AQuarkBombHit02 AQuarkBombHitLand01 = AQuarkBombHit01 +APhasonLaserBeam = { + EmtBpPath .. 'phason_laser_beam_01_emit.bp', +} + APhasonLaserMuzzle01 = { EmtBpPath .. 'phason_laser_muzzle_01_emit.bp', EmtBpPath .. 'phason_laser_muzzle_02_emit.bp', @@ -1245,6 +1253,7 @@ ATorpedoPolyTrails01 = EmtBpPath .. 'aeon_torpedocluster_polytrail_01_emit.bp' -- --------------------------------------------------------------- -- -- -- -- CYBRAN UNIT AMBIENT EFFECTS -- -- -- +-- --------------------------------------------------------------- CCivilianBuildingInfectionAmbient = { EmtBpPath .. 'cybran_building01_infect_ambient_01_emit.bp', @@ -1311,6 +1320,16 @@ CSoothSayerAmbient = { -- --------------------------------------------------------------- -- -- -- -- CYBRAN PROJECTILES -- -- -- +-- --------------------------------------------------------------- + +CZapperBeam = { + EmtBpPath .. 'zapper_beam_01_emit.bp', +} + +CZapperHit01 = { + EmtBpPath .. 'cannon_muzzle_flash_01_emit.bp', + EmtBpPath .. 'sparks_07_emit.bp', +} CBrackmanCrabPegPodSplit01 = { EmtBpPath .. 'cybran_brackman_crab_pegpod_split_01_emit.bp', @@ -1609,6 +1628,14 @@ CLaserMuzzleFlash03 = { EmtBpPath .. 'cybran_laser_muzzle_flash_04_emit.bp', } +CMicrowaveLaserBeam01 = { + EmtBpPath .. 'microwave_laser_beam_01_emit.bp', +} + +CMicrowaveLaserBeam02 = { -- thinner ACU laser + EmtBpPath .. 'microwave_laser_beam_02_emit.bp', +} + CMicrowaveLaserMuzzle01 = { EmtBpPath .. 'microwave_laser_flash_01_emit.bp', EmtBpPath .. 'microwave_laser_muzzle_01_emit.bp', @@ -1726,6 +1753,15 @@ CParticleCannonHit01 = { EmtBpPath .. 'laserturret_hit_flash_01_emit.bp', } CParticleCannonHitUnit01 = table.concatenate(CParticleCannonHit01, UnitHitShrapnel01) CParticleCannonHitLand01 = table.concatenate(CParticleCannonHit01) +CParticleCannonBeam = { -- For unused particle cannon beam + EmtBpPath .. 'particle_cannon_beam_01_emit.bp', + EmtBpPath .. 'particle_cannon_beam_02_emit.bp', +} +CParticleCannonHit02 = { -- For unused particle cannon beam + EmtBpPath .. 'particle_cannon_end_01_emit.bp', + EmtBpPath .. 'particle_cannon_end_02_emit.bp', +} + CProtonBombHit01 = { EmtBpPath .. 'proton_bomb_hit_01_emit.bp', EmtBpPath .. 'proton_bomb_hit_02_emit.bp', @@ -1846,6 +1882,32 @@ CMobileBeetleExplosion = { -- -- -- -- UEF PROJECTILES (previously Terran) -- -- -- -- --------------------------------------------------------------- +-- ------------------------------------------------------------------------ +-- TERRAN ORBITAL DEATH LASER EMITTERS +-- ------------------------------------------------------------------------ +TOrbitalDeathLaserBeam = { + EmtBpPath .. 'uef_orbital_death_laser_beam_01_emit.bp' +} + +TOrbitalDeathLaserMuzzleFlash01 = { + EmtBpPath .. 'uef_orbital_death_laser_muzzle_01_emit.bp', -- random bright blueish dots + EmtBpPath .. 'uef_orbital_death_laser_muzzle_02_emit.bp', -- molecular, small details + EmtBpPath .. 'uef_orbital_death_laser_muzzle_03_emit.bp', -- darkening lines + EmtBpPath .. 'uef_orbital_death_laser_muzzle_04_emit.bp', -- small downward sparks + EmtBpPath .. 'uef_orbital_death_laser_muzzle_05_emit.bp', -- big glow +} + +TOrbitalDeathLaserHit01 = { + EmtBpPath .. 'uef_orbital_death_laser_end_01_emit.bp', -- big glow + EmtBpPath .. 'uef_orbital_death_laser_end_02_emit.bp', -- random bright blueish dots + EmtBpPath .. 'uef_orbital_death_laser_end_03_emit.bp', -- darkening lines + EmtBpPath .. 'uef_orbital_death_laser_end_04_emit.bp', -- molecular, small details + EmtBpPath .. 'uef_orbital_death_laser_end_05_emit.bp', -- rings + EmtBpPath .. 'uef_orbital_death_laser_end_06_emit.bp', -- upward sparks + EmtBpPath .. 'uef_orbital_death_laser_end_07_emit.bp', -- outward line streaks + EmtBpPath .. 'uef_orbital_death_laser_end_08_emit.bp', -- center glow + EmtBpPath .. 'uef_orbital_death_laser_end_distort_emit.bp', -- screen distortion +} -- ------------------------------------------------------------------------ -- TERRAN ANTI-MATTER SHELL EMITTERS @@ -2111,6 +2173,24 @@ TAAGinsuHitUnit = { EmtBpPath .. 'destruction_unit_hit_shrapnel_01_emit.bp', } +TAAGinsuBeam = { -- unused + EmtBpPath .. 'riot_gun_beam_01_emit.bp', + EmtBpPath .. 'riot_gun_beam_02_emit.bp', +} + +TAAGinsuEndPoint = { -- unused + EmtBpPath .. 'sparks_02_emit.bp', +} + +TAAGinsuHitLand02 = { -- unused + EmtBpPath .. 'destruction_land_hit_puff_01_emit.bp', + EmtBpPath .. 'destruction_explosion_flash_01_emit.bp', +} + +TAAGinsuHitUnit02 = { -- unused + EmtBpPath .. 'riotgun_hit_flash_01_emit.bp', +} + -- ------------------------------------------------------------------------ -- TERRAN HEAVY FRAGMENTATION GRENADE EMITTERS @@ -4328,6 +4408,37 @@ SDFSniperShotPolytrail = { -- -- -- -- -- -- -- AEON PROJECTILES -- -- -- -- -- -- -- --------------------------------------------------------------- +ADisruptorBeamBeam = { + EmtBpPath .. 'disruptor_beam_01_emit.bp', +} + +ADisruptorBeamMuzzleFlash01 = { + EmtBpPath .. 'aeon_commander_disruptor_flash_01_emit.bp', + EmtBpPath .. 'aeon_commander_disruptor_flash_02_emit.bp', +} + +ADisruptorBeamHit01 = { + EmtBpPath .. 'aeon_commander_disruptor_hit_01_emit.bp', + EmtBpPath .. 'aeon_commander_disruptor_hit_02_emit.bp', +} + +AQuantumBeamGeneratorBeam = { + EmtBpPath .. 'quantum_generator_beam_01_emit.bp', +} + +AQuantumBeamGeneratorMuzzleFlash01 = { + EmtBpPath .. 'quantum_generator_01_emit.bp', + EmtBpPath .. 'quantum_generator_02_emit.bp', + EmtBpPath .. 'quantum_generator_04_emit.bp', +} + +AQuantumBeamGeneratorHit01 = { + EmtBpPath .. 'quantum_generator_end_01_emit.bp', + EmtBpPath .. 'quantum_generator_end_03_emit.bp', + EmtBpPath .. 'quantum_generator_end_04_emit.bp', + EmtBpPath .. 'quantum_generator_end_05_emit.bp', + EmtBpPath .. 'quantum_generator_end_06_emit.bp', +} Aeon_QuadLightLaserCannonMuzzleFlash = { EmtBpPath .. 'aeon_dualquantum_cannon_muzzle_flash_emit.bp', diff --git a/lua/defaultcollisionbeams.lua b/lua/defaultcollisionbeams.lua index 29877420a0..72e48f1cb7 100644 --- a/lua/defaultcollisionbeams.lua +++ b/lua/defaultcollisionbeams.lua @@ -1,680 +1,60 @@ ------------------------------------------------------------- --- --- File : /lua/defaultcollisionbeams.lua --- Author(s): Gordon Duclos --- --- Summary : Default definitions collision beams --- --- Copyright © 2005 Gas Powered Games, Inc. All rights reserved. ------------------------------------------------------------- +--********************************************************************************** +--** Copyright (c) 2024 FAForever +--** +--** Permission is hereby granted, free of charge, to any person obtaining a copy +--** of this software and associated documentation files (the "Software"), to deal +--** in the Software without restriction, including without limitation the rights +--** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +--** copies of the Software, and to permit persons to whom the Software is +--** furnished to do so, subject to the following conditions: +--** +--** The above copyright notice and this permission notice shall be included in all +--** copies or substantial portions of the Software. +--** +--** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +--** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +--** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +--** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +--** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +--** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +--** SOFTWARE. +--********************************************************************************** + +-- Base beam that defines default effects +SCCollisionBeam = import("/lua/sim/collisionBeams/SCCollisionBeam.lua").SCCollisionBeam + +-- UEF +TDFHiroCollisionBeam = import("/lua/sim/collisionBeams/TDFHiroCollisionBeam.lua").TDFHiroCollisionBeam +OrbitalDeathLaserCollisionBeam = import("/lua/sim/collisionBeams/OrbitalDeathLaserCollisionBeam.lua").OrbitalDeathLaserCollisionBeam +-- Cybran +ZapperCollisionBeam = import("/lua/sim/collisionBeams/ZapperCollisionBeam.lua").ZapperCollisionBeam +MicrowaveLaserCollisionBeam01 = import("/lua/sim/collisionBeams/MicrowaveLaserCollisionBeam01.lua").MicrowaveLaserCollisionBeam01 +MicrowaveLaserCollisionBeam02 = import("/lua/sim/collisionBeams/MicrowaveLaserCollisionBeam02.lua").MicrowaveLaserCollisionBeam02 +-- Aeon +QuantumBeamGeneratorCollisionBeam = import("/lua/sim/collisionBeams/QuantumBeamGeneratorCollisionBeam.lua").QuantumBeamGeneratorCollisionBeam +PhasonLaserCollisionBeam = import("/lua/sim/collisionBeams/PhasonLaserCollisionBeam.lua").PhasonLaserCollisionBeam +-- Seraphim +UnstablePhasonLaserCollisionBeam = import("/lua/sim/collisionBeams/UnstablePhasonLaserCollisionBeam.lua").UnstablePhasonLaserCollisionBeam +UltraChromaticBeamGeneratorCollisionBeam = import("/lua/sim/collisionBeams/UltraChromaticBeamGeneratorCollisionBeam.lua").UltraChromaticBeamGeneratorCollisionBeam +UltraChromaticBeamGeneratorCollisionBeam02 = import("/lua/sim/collisionBeams/UltraChromaticBeamGeneratorCollisionBeam02.lua").UltraChromaticBeamGeneratorCollisionBeam02 + +-- Unused Beams +-- UEF +GinsuCollisionBeam = import("/lua/sim/collisionBeams/GinsuCollisionBeam.lua").GinsuCollisionBeam +-- Cybran +ParticleCannonCollisionBeam = import("/lua/sim/collisionBeams/ParticleCannonCollisionBeam.lua").ParticleCannonCollisionBeam +-- Aeon +DisruptorBeamCollisionBeam = import("/lua/sim/collisionBeams/DisruptorBeamCollisionBeam.lua").DisruptorBeamCollisionBeam +TractorClawCollisionBeam = import("/lua/sim/collisionBeams/TractorClawCollisionBeam.lua").TractorClawCollisionBeam +-- Seraphim +ExperimentalPhasonLaserCollisionBeam = import("/lua/sim/collisionBeams/ExperimentalPhasonLaserCollisionBeam.lua").ExperimentalPhasonLaserCollisionBeam + +--#region Backwards compatibility local CollisionBeam = import("/lua/sim/collisionbeam.lua").CollisionBeam local EffectTemplate = import("/lua/effecttemplates.lua") local VisionMarkerOpti = import("/lua/sim/VizMarker.lua").VisionMarkerOpti local Util = import("/lua/utilities.lua") -------------------------------- --- Base class that defines supreme commander specific defaults -------------------------------- ----@class SCCollisionBeam : CollisionBeam -SCCollisionBeam = Class(CollisionBeam) { - FxImpactUnit = EffectTemplate.DefaultProjectileLandUnitImpact, - FxImpactLand = { },-- EffectTemplate.DefaultProjectileLandImpact, - FxImpactWater = EffectTemplate.DefaultProjectileWaterImpact, - FxImpactUnderWater = EffectTemplate.DefaultProjectileUnderWaterImpact, - FxImpactAirUnit = EffectTemplate.DefaultProjectileAirUnitImpact, - FxImpactProp = { }, - FxImpactShield = { }, - FxImpactNone = { }, -} -------------------------------- --- Ginsu COLLISION BEAM -------------------------------- ----@class GinsuCollisionBeam : SCCollisionBeam -GinsuCollisionBeam = Class(SCCollisionBeam) { - FxBeam = {'/effects/emitters/riot_gun_beam_01_emit.bp', - '/effects/emitters/riot_gun_beam_02_emit.bp',}, - FxBeamEndPoint = {'/effects/emitters/sparks_02_emit.bp',}, - - - FxImpactUnit = {'/effects/emitters/riotgun_hit_flash_01_emit.bp',}, - FxUnitHitScale = 0.125, - FxImpactLand = {'/effects/emitters/destruction_land_hit_puff_01_emit.bp', - '/effects/emitters/destruction_explosion_flash_01_emit.bp'}, - FxLandHitScale = 0.1625, -} - ------------------------------------- --- PARTICLE CANNON COLLISION BEAM ------------------------------------- ----@class ParticleCannonCollisionBeam : SCCollisionBeam -ParticleCannonCollisionBeam = Class(SCCollisionBeam) { - FxBeam = { - '/effects/emitters/particle_cannon_beam_01_emit.bp', - '/effects/emitters/particle_cannon_beam_02_emit.bp' - }, - FxBeamEndPoint = { - '/effects/emitters/particle_cannon_end_01_emit.bp', - '/effects/emitters/particle_cannon_end_02_emit.bp', - }, - FxBeamEndPointScale = 1, -} - ------------------------------------- --- ZAPPER COLLISION BEAM ------------------------------------- ----@class ZapperCollisionBeam : SCCollisionBeam -ZapperCollisionBeam = Class(SCCollisionBeam) { - FxBeam = {'/effects/emitters/zapper_beam_01_emit.bp'}, - FxBeamEndPoint = {'/effects/emitters/cannon_muzzle_flash_01_emit.bp', - '/effects/emitters/sparks_07_emit.bp',}, -} - ------------------------------------- --- QUANTUM BEAM GENERATOR COLLISION BEAM ------------------------------------- ---- used by CZAR ----@class QuantumBeamGeneratorCollisionBeam : SCCollisionBeam -QuantumBeamGeneratorCollisionBeam = Class(SCCollisionBeam) { - TerrainImpactType = 'LargeBeam02', - TerrainImpactScale = 1, - - FxBeam = {'/effects/emitters/quantum_generator_beam_01_emit.bp'}, - FxBeamEndPoint = { - '/effects/emitters/quantum_generator_end_01_emit.bp', - '/effects/emitters/quantum_generator_end_03_emit.bp', - '/effects/emitters/quantum_generator_end_04_emit.bp', - '/effects/emitters/quantum_generator_end_05_emit.bp', - '/effects/emitters/quantum_generator_end_06_emit.bp', - }, - FxBeamStartPoint = { - '/effects/emitters/quantum_generator_01_emit.bp', - '/effects/emitters/quantum_generator_02_emit.bp', - '/effects/emitters/quantum_generator_04_emit.bp', - }, - - SplatTexture = 'czar_mark01_albedo', - ScorchSplatDropTime = 0.5, - - ---@param self QuantumBeamGeneratorCollisionBeam - ---@param impactType string - ---@param targetEntity? Prop|Unit - OnImpact = function(self, impactType, targetEntity) - if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then - if self.Scorching == nil then - self.Scorching = self:ForkThread( self.ScorchThread ) - end - else - KillThread(self.Scorching) - self.Scorching = nil - end - CollisionBeam.OnImpact(self, impactType, targetEntity) - end, - - ---@param self QuantumBeamGeneratorCollisionBeam - OnDisable = function( self ) - CollisionBeam.OnDisable(self) - KillThread(self.Scorching) - self.Scorching = nil - end, - - ---@param self QuantumBeamGeneratorCollisionBeam - ScorchThread = function(self) - local army = self:GetArmy() - local size = 3.5 + (Random() * 3.5) - local CurrentPosition = self:GetPosition(1) - local LastPosition = Vector(0,0,0) - local skipCount = 1 - -- local FriendlyFire = self.DamageData.DamageFriendly - - while true do - if Util.GetDistanceBetweenTwoVectors( CurrentPosition, LastPosition ) > 0.25 or skipCount > 100 then - CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 200, 150, army ) - LastPosition = CurrentPosition - skipCount = 1 - - -- commented due to hard-crash potential - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - else - skipCount = skipCount + self.ScorchSplatDropTime - end - - WaitSeconds( self.ScorchSplatDropTime ) - size = 3.2 + (Random() * 3.5) - CurrentPosition = self:GetPosition(1) - end - end, -} - ----@class DisruptorBeamCollisionBeam : SCCollisionBeam -DisruptorBeamCollisionBeam = Class(SCCollisionBeam) { - - FxBeam = {'/effects/emitters/disruptor_beam_01_emit.bp'}, - FxBeamEndPoint = { - '/effects/emitters/aeon_commander_disruptor_hit_01_emit.bp', - '/effects/emitters/aeon_commander_disruptor_hit_02_emit.bp', - }, - FxBeamEndPointScale = 1.0, - - FxBeamStartPoint = { - '/effects/emitters/aeon_commander_disruptor_flash_01_emit.bp', - '/effects/emitters/aeon_commander_disruptor_flash_02_emit.bp', - }, - - -} ---- used by ML & cyb ACU ----@class MicrowaveLaserCollisionBeam01 : SCCollisionBeam -MicrowaveLaserCollisionBeam01 = Class(SCCollisionBeam) { - - TerrainImpactType = 'LargeBeam01', - TerrainImpactScale = 1, - FxBeamStartPoint = EffectTemplate.CMicrowaveLaserMuzzle01, - FxBeam = {'/effects/emitters/microwave_laser_beam_01_emit.bp'}, - FxBeamEndPoint = EffectTemplate.CMicrowaveLaserEndPoint01, - SplatTexture = 'czar_mark01_albedo', - ScorchSplatDropTime = 0.25, - - ---@param self MicrowaveLaserCollisionBeam01 - ---@param impactType string - ---@param targetEntity? Prop|Unit - OnImpact = function(self, impactType, targetEntity) - if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then - if self.Scorching == nil then - self.Scorching = self:ForkThread( self.ScorchThread ) - end - else - KillThread(self.Scorching) - self.Scorching = nil - end - CollisionBeam.OnImpact(self, impactType, targetEntity) - end, - - ---@param self MicrowaveLaserCollisionBeam01 - OnDisable = function( self ) - CollisionBeam.OnDisable(self) - KillThread(self.Scorching) - self.Scorching = nil - end, - - ---@param self MicrowaveLaserCollisionBeam01 - ScorchThread = function(self) - local army = self:GetArmy() - local size = 1.5 + (Random() * 1.5) - local CurrentPosition = self:GetPosition(1) - local LastPosition = Vector(0,0,0) - local skipCount = 1 - -- local FriendlyFire = self.DamageData.DamageFriendly - - while true do - if Util.GetDistanceBetweenTwoVectors( CurrentPosition, LastPosition ) > 0.25 or skipCount > 100 then - CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 200, 100, army ) - LastPosition = CurrentPosition - skipCount = 1 - - -- commented due to hard-crash potential - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - else - skipCount = skipCount + self.ScorchSplatDropTime - end - - WaitSeconds( self.ScorchSplatDropTime ) - size = 1.2 + (Random() * 1.5) - CurrentPosition = self:GetPosition(1) - end - end, -} - ----@class MicrowaveLaserCollisionBeam02 : MicrowaveLaserCollisionBeam01 -MicrowaveLaserCollisionBeam02 = Class(MicrowaveLaserCollisionBeam01) { - TerrainImpactScale = 1, - FxBeamStartPoint = EffectTemplate.CMicrowaveLaserMuzzle01, - FxBeam = {'/effects/emitters/microwave_laser_beam_02_emit.bp'}, - FxBeamEndPoint = EffectTemplate.CMicrowaveLaserEndPoint01, -} - ----@class PhasonLaserCollisionBeam : SCCollisionBeam -PhasonLaserCollisionBeam = Class(SCCollisionBeam) { - -- used by GC - - TerrainImpactType = 'LargeBeam01', - TerrainImpactScale = 1, - FxBeamStartPoint = EffectTemplate.APhasonLaserMuzzle01, - FxBeam = {'/effects/emitters/phason_laser_beam_01_emit.bp'}, - FxBeamEndPoint = EffectTemplate.APhasonLaserImpact01, - SplatTexture = 'czar_mark01_albedo', - ScorchSplatDropTime = 0.25, - - ---@param self PhasonLaserCollisionBeam - ---@param impactType string - ---@param targetEntity? Prop|Unit - OnImpact = function(self, impactType, targetEntity) - if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then - if self.Scorching == nil then - self.Scorching = self:ForkThread( self.ScorchThread ) - end - else - KillThread(self.Scorching) - self.Scorching = nil - end - CollisionBeam.OnImpact(self, impactType, targetEntity) - end, - - ---@param self PhasonLaserCollisionBeam - OnDisable = function( self ) - CollisionBeam.OnDisable(self) - KillThread(self.Scorching) - self.Scorching = nil - end, - - ---@param self PhasonLaserCollisionBeam - ScorchThread = function(self) - local army = self:GetArmy() - local size = 1.5 + (Random() * 1.5) - local CurrentPosition = self:GetPosition(1) - local LastPosition = Vector(0,0,0) - local skipCount = 1 - -- local FriendlyFire = self.DamageData.DamageFriendly - - while true do - if Util.GetDistanceBetweenTwoVectors( CurrentPosition, LastPosition ) > 0.25 or skipCount > 100 then - CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 200, 100, army ) - LastPosition = CurrentPosition - skipCount = 1 - - -- commented due to hard-crash potential - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - else - skipCount = skipCount + self.ScorchSplatDropTime - end - - WaitSeconds( self.ScorchSplatDropTime ) - size = 1.2 + (Random() * 1.5) - CurrentPosition = self:GetPosition(1) - end - end, -} - ----@class TractorClawCollisionBeam : CollisionBeam -TractorClawCollisionBeam = Class(CollisionBeam) { - - FxBeam = {EffectTemplate.ACollossusTractorBeam01}, - FxBeamEndPoint = {EffectTemplate.ACollossusTractorBeamGlow02}, - FxBeamEndPointScale = 1.0, - FxBeamStartPoint = { EffectTemplate.ACollossusTractorBeamGlow01 }, -} - ------------------------------------- --- QUANTUM BEAM GENERATOR COLLISION BEAM ------------------------------------- ---- unknown unit (big size though) ----@class ExperimentalPhasonLaserCollisionBeam : SCCollisionBeam ----@field BeamEffectsBag TrashBag ----@field Trash TrashBag -ExperimentalPhasonLaserCollisionBeam = Class(SCCollisionBeam) { - - TerrainImpactType = 'LargeBeam01', - TerrainImpactScale = 1, - FxBeamStartPoint = EffectTemplate.SExperimentalPhasonLaserMuzzle01, - FxBeam = EffectTemplate.SExperimentalPhasonLaserBeam, - FxBeamEndPoint = EffectTemplate.SExperimentalPhasonLaserHitLand, - SplatTexture = 'scorch_004_albedo', - ScorchSplatDropTime = 0.1, - - ---@param self ExperimentalPhasonLaserCollisionBeam - ---@param impactType string - ---@param targetEntity? Prop|Unit - OnImpact = function(self, impactType, targetEntity) - if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then - if self.Scorching == nil then - self.Scorching = self:ForkThread( self.ScorchThread ) - end - else - KillThread(self.Scorching) - self.Scorching = nil - end - CollisionBeam.OnImpact(self, impactType, targetEntity) - end, - - ---@param self ExperimentalPhasonLaserCollisionBeam - OnDisable = function( self ) - CollisionBeam.OnDisable(self) - KillThread(self.Scorching) - self.Scorching = nil - end, - - ---@param self ExperimentalPhasonLaserCollisionBeam - ScorchThread = function(self) - local army = self:GetArmy() - local size = 4.0 + (Random() * 1.0) - local CurrentPosition = self:GetPosition(1) - local LastPosition = Vector(0,0,0) - local skipCount = 1 - -- local FriendlyFire = self.DamageData.DamageFriendly - - while true do - if Util.GetDistanceBetweenTwoVectors( CurrentPosition, LastPosition ) > 0.25 or skipCount > 100 then - CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 100, 100, army ) - LastPosition = CurrentPosition - skipCount = 1 - - -- commented due to hard-crash potential - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - else - skipCount = skipCount + self.ScorchSplatDropTime - end - - WaitSeconds( self.ScorchSplatDropTime ) - size = 4.0 + (Random() * 1.0) - CurrentPosition = self:GetPosition(1) - end - end, - - ---@param self ExperimentalPhasonLaserCollisionBeam - CreateBeamEffects = function(self) - SCCollisionBeam.CreateBeamEffects(self) - for k, v in EffectTemplate.SExperimentalPhasonLaserBeam do - local fxBeam = CreateBeamEntityToEntity(self, 0, self, 1, self:GetArmy(), v ) - table.insert( self.BeamEffectsBag, fxBeam ) - self.Trash:Add(fxBeam) - end - -- local fxBeam = CreateBeamEntityToEntity(self, 0, self, 1, self:GetArmy(), '/effects/emitters/seraphim_expirimental_laser_beam_02_emit.bp' ) - end, -} - ----@class UnstablePhasonLaserCollisionBeam : SCCollisionBeam -UnstablePhasonLaserCollisionBeam = Class(SCCollisionBeam) { - -- ythota death energy ball - - TerrainImpactType = 'LargeBeam01', - TerrainImpactScale = 1, - FxBeamStartPoint = EffectTemplate.SExperimentalUnstablePhasonLaserMuzzle01, - FxBeam = EffectTemplate.OthuyElectricityStrikeBeam, - FxBeamEndPoint = EffectTemplate.OthuyElectricityStrikeHit, - SplatTexture = 'czar_mark01_albedo', - ScorchSplatDropTime = 0.25, - - ---@param self ExperimentalPhasonLaserCollisionBeam - ---@param impactType string - ---@param targetEntity? Prop|Unit - OnImpact = function(self, impactType, targetEntity) - if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then - if self.Scorching == nil then - self.Scorching = self:ForkThread( self.ScorchThread ) - end - else - KillThread(self.Scorching) - self.Scorching = nil - end - - -- add vision to make sure we can see the impact effect - local position = self:GetPosition(1) - if position then - local marker = VisionMarkerOpti({Owner = self.unit}) - marker:UpdatePosition(position[1], position[3]) - marker:UpdateDuration(1) - marker:UpdateIntel(self.Army, 4, 'Vision', true) - end - - CollisionBeam.OnImpact(self, impactType, targetEntity) - end, - - ---@param self ExperimentalPhasonLaserCollisionBeam - OnDisable = function( self ) - CollisionBeam.OnDisable(self) - KillThread(self.Scorching) - self.Scorching = nil - end, - - ---@param self ExperimentalPhasonLaserCollisionBeam - ScorchThread = function(self) - local army = self:GetArmy() - local size = 1.5 + (Random() * 1.5) - local CurrentPosition = self:GetPosition(1) - local LastPosition = Vector(0,0,0) - local skipCount = 1 - -- local FriendlyFire = self.DamageData.DamageFriendly - - while true do - if Util.GetDistanceBetweenTwoVectors( CurrentPosition, LastPosition ) > 0.25 or skipCount > 100 then - CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 250, 100, army ) - LastPosition = CurrentPosition - skipCount = 1 - - -- commented due to hard-crash potential - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - else - skipCount = skipCount + self.ScorchSplatDropTime - end - - WaitSeconds( self.ScorchSplatDropTime ) - size = 1.2 + (Random() * 1.5) - CurrentPosition = self:GetPosition(1) - end - end, -} - --- This is for sera destro and sera T2 point defense. ----@class UltraChromaticBeamGeneratorCollisionBeam : SCCollisionBeam -UltraChromaticBeamGeneratorCollisionBeam = Class(SCCollisionBeam) { - - TerrainImpactType = 'LargeBeam01', - TerrainImpactScale = 1, - FxBeamStartPoint = EffectTemplate.SUltraChromaticBeamGeneratorMuzzle01, - FxBeam = EffectTemplate.SUltraChromaticBeamGeneratorBeam, - FxBeamEndPoint = EffectTemplate.SUltraChromaticBeamGeneratorHitLand, - SplatTexture = 'czar_mark01_albedo', - ScorchSplatDropTime = 0.25, - - ---@param self UltraChromaticBeamGeneratorCollisionBeam - ---@param impactType string - ---@param targetEntity? Prop|Unit - OnImpact = function(self, impactType, targetEntity) - if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then - if self.Scorching == nil then - self.Scorching = self:ForkThread( self.ScorchThread ) - end - else - KillThread(self.Scorching) - self.Scorching = nil - end - CollisionBeam.OnImpact(self, impactType, targetEntity) - end, - - ---@param self UltraChromaticBeamGeneratorCollisionBeam - OnDisable = function( self ) - CollisionBeam.OnDisable(self) - KillThread(self.Scorching) - self.Scorching = nil - end, - - ---@param self UltraChromaticBeamGeneratorCollisionBeam - ScorchThread = function(self) - local army = self:GetArmy() - local size = 1 + (Random() * 1) - local CurrentPosition = self:GetPosition(1) - local LastPosition = Vector(0,0,0) - local skipCount = 1 - -- local FriendlyFire = self.DamageData.DamageFriendly - - while true do - if Util.GetDistanceBetweenTwoVectors( CurrentPosition, LastPosition ) > 0.25 or skipCount > 100 then - CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 70, 50, army ) - LastPosition = CurrentPosition - skipCount = 1 - - -- commented due to hard-crash potential - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - else - skipCount = skipCount + self.ScorchSplatDropTime - end - - WaitSeconds( self.ScorchSplatDropTime ) - size = 1 + (Random() * 1) - CurrentPosition = self:GetPosition(1) - end - end, -} - --- This is for sera destro and sera T2 point defense. (adjustment for ship muzzleflash) ----@class UltraChromaticBeamGeneratorCollisionBeam02 : UltraChromaticBeamGeneratorCollisionBeam -UltraChromaticBeamGeneratorCollisionBeam02 = Class(UltraChromaticBeamGeneratorCollisionBeam) { - FxBeamStartPoint = EffectTemplate.SUltraChromaticBeamGeneratorMuzzle02, -} - ------------------------------------- --- HIRO LASER COLLISION BEAM ------------------------------------- ----@class TDFHiroCollisionBeam : CollisionBeam -TDFHiroCollisionBeam = Class(CollisionBeam) { - -- used by UEF battlecruser - - TerrainImpactType = 'LargeBeam01', - TerrainImpactScale = 1, - FxBeamStartPoint = EffectTemplate.TDFHiroGeneratorMuzzle01, - FxBeam = EffectTemplate.TDFHiroGeneratorBeam, - FxBeamEndPoint = EffectTemplate.TDFHiroGeneratorHitLand, - SplatTexture = 'czar_mark01_albedo', - ScorchSplatDropTime = 0.25, - - ---@param self TDFHiroCollisionBeam - ---@param impactType string - ---@param targetEntity? Prop|Unit - OnImpact = function(self, impactType, targetEntity) - if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then - if self.Scorching == nil then - self.Scorching = self:ForkThread( self.ScorchThread ) - end - else - KillThread(self.Scorching) - self.Scorching = nil - end - CollisionBeam.OnImpact(self, impactType, targetEntity) - end, - - ---@param self TDFHiroCollisionBeam - OnDisable = function( self ) - CollisionBeam.OnDisable(self) - KillThread(self.Scorching) - self.Scorching = nil - end, - - ---@param self TDFHiroCollisionBeam - ScorchThread = function(self) - local army = self:GetArmy() - local size = 1.5 + (Random() * 1.5) - local CurrentPosition = self:GetPosition(1) - local LastPosition = Vector(0,0,0) - local skipCount = 1 - -- local FriendlyFire = self.DamageData.DamageFriendly - - while true do - if Util.GetDistanceBetweenTwoVectors( CurrentPosition, LastPosition ) > 0.25 or skipCount > 100 then - CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 100, 70, army ) - LastPosition = CurrentPosition - skipCount = 1 - - -- commented due to hard-crash potential - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - else - skipCount = skipCount + self.ScorchSplatDropTime - end - - WaitSeconds( self.ScorchSplatDropTime ) - size = 1.2 + (Random() * 1.5) - CurrentPosition = self:GetPosition(1) - end - end, -} - ------------------------------------- --- ORBITAL DEATH LASER COLLISION BEAM ------------------------------------- ----@class OrbitalDeathLaserCollisionBeam : SCCollisionBeam -OrbitalDeathLaserCollisionBeam = Class(SCCollisionBeam) { - -- used by satellite - TerrainImpactType = 'LargeBeam02', - TerrainImpactScale = 1, - - FxBeam = {'/effects/emitters/uef_orbital_death_laser_beam_01_emit.bp'}, - FxBeamEndPoint = { - '/effects/emitters/uef_orbital_death_laser_end_01_emit.bp', -- big glow - '/effects/emitters/uef_orbital_death_laser_end_02_emit.bp', -- random bright blueish dots - '/effects/emitters/uef_orbital_death_laser_end_03_emit.bp', -- darkening lines - '/effects/emitters/uef_orbital_death_laser_end_04_emit.bp', -- molecular, small details - '/effects/emitters/uef_orbital_death_laser_end_05_emit.bp', -- rings - '/effects/emitters/uef_orbital_death_laser_end_06_emit.bp', -- upward sparks - '/effects/emitters/uef_orbital_death_laser_end_07_emit.bp', -- outward line streaks - '/effects/emitters/uef_orbital_death_laser_end_08_emit.bp', -- center glow - '/effects/emitters/uef_orbital_death_laser_end_distort_emit.bp', -- screen distortion - }, - FxBeamStartPoint = { - '/effects/emitters/uef_orbital_death_laser_muzzle_01_emit.bp', -- random bright blueish dots - '/effects/emitters/uef_orbital_death_laser_muzzle_02_emit.bp', -- molecular, small details - '/effects/emitters/uef_orbital_death_laser_muzzle_03_emit.bp', -- darkening lines - '/effects/emitters/uef_orbital_death_laser_muzzle_04_emit.bp', -- small downward sparks - '/effects/emitters/uef_orbital_death_laser_muzzle_05_emit.bp', -- big glow - }, - - SplatTexture = 'czar_mark01_albedo', - ScorchSplatDropTime = 0.5, - - ---@param self OrbitalDeathLaserCollisionBeam - ---@param impactType string - ---@param targetEntity? Prop|Unit - OnImpact = function(self, impactType, targetEntity) - if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then - if self.Scorching == nil then - self.Scorching = self:ForkThread( self.ScorchThread ) - end - else - KillThread(self.Scorching) - self.Scorching = nil - end - CollisionBeam.OnImpact(self, impactType, targetEntity) - end, - - ---@param self OrbitalDeathLaserCollisionBeam - OnDisable = function( self ) - CollisionBeam.OnDisable(self) - KillThread(self.Scorching) - self.Scorching = nil - end, - - ---@param self OrbitalDeathLaserCollisionBeam - ScorchThread = function(self) - local army = self:GetArmy() - local size = 3.5 + (Random() * 3.5) - local CurrentPosition = self:GetPosition(1) - local LastPosition = Vector(0,0,0) - local skipCount = 1 - -- local FriendlyFire = self.DamageData.DamageFriendly - - while true do - if Util.GetDistanceBetweenTwoVectors( CurrentPosition, LastPosition ) > 0.25 or skipCount > 100 then - CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 250, 100, army ) - LastPosition = CurrentPosition - skipCount = 1 - - -- commented due to hard-crash potential - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) - - else - skipCount = skipCount + self.ScorchSplatDropTime - end - - WaitSeconds( self.ScorchSplatDropTime ) - size = 3.2 + (Random() * 3.5) - CurrentPosition = self:GetPosition(1) - end - end, -} \ No newline at end of file +--#endregion diff --git a/lua/sim/CollisionBeam.lua b/lua/sim/CollisionBeam.lua index 88c0fd9ac1..e02acbe725 100644 --- a/lua/sim/CollisionBeam.lua +++ b/lua/sim/CollisionBeam.lua @@ -14,6 +14,10 @@ local DefaultDamage = import("/lua/sim/defaultdamage.lua") local ScenarioFramework = import("/lua/scenarioframework.lua") +-- terrain interaction +local GetTerrainType = GetTerrainType +local DefaultTerrainType = GetTerrainType(-1, -1) + ---@class CollisionBeam : moho.CollisionBeamEntity ---@field Trash TrashBag CollisionBeam = Class(moho.CollisionBeamEntity) { @@ -218,14 +222,17 @@ CollisionBeam = Class(moho.CollisionBeamEntity) { UpdateTerrainCollisionEffects = function(self, TargetType) local pos = self:GetPosition(1) local TerrainType = nil + local TerrainImpactType = self.TerrainImpactType - if self.TerrainImpactType ~= 'Default' then + if TerrainImpactType ~= 'Default' then TerrainType = GetTerrainType(pos.x,pos.z) else - TerrainType = GetTerrainType(-1, -1) + TerrainType = DefaultTerrainType end - local TerrainEffects = TerrainType.FXImpact[TargetType][self.TerrainImpactType] or nil + local TerrainEffects = TerrainType.FXImpact[TargetType][TerrainImpactType] + or DefaultTerrainType.FXImpact[TargetType][TerrainImpactType] + or nil if TerrainEffects and (self.LastTerrainType ~= TerrainType) then self:DestroyTerrainEffects() diff --git a/lua/sim/DefaultProjectiles.lua b/lua/sim/DefaultProjectiles.lua index 2ae659adce..eeb593aa40 100644 --- a/lua/sim/DefaultProjectiles.lua +++ b/lua/sim/DefaultProjectiles.lua @@ -63,4 +63,4 @@ local DummyProjectile = import("/lua/sim/projectile.lua").DummyProjectile local UnitsInSphere = import("/lua/utilities.lua").GetTrueEnemyUnitsInSphere local GetDistanceBetweenTwoEntities = import("/lua/utilities.lua").GetDistanceBetweenTwoEntities ---#endregion \ No newline at end of file +--#endregion diff --git a/lua/sim/collisionBeams/DisruptorBeamCollisionBeam.lua b/lua/sim/collisionBeams/DisruptorBeamCollisionBeam.lua new file mode 100644 index 0000000000..f0c52ecd3c --- /dev/null +++ b/lua/sim/collisionBeams/DisruptorBeamCollisionBeam.lua @@ -0,0 +1,16 @@ +local EffectTemplate = import("/lua/effecttemplates.lua") + +local SCCollisionBeam = import("/lua/sim/collisionBeams/SCCollisionBeam.lua").SCCollisionBeam + +-- Not used. Aeon style beam sized for a small unit +---@class DisruptorBeamCollisionBeam : SCCollisionBeam +DisruptorBeamCollisionBeam = Class(SCCollisionBeam) { + + FxBeam = EffectTemplate.ADisruptorBeamBeam, + FxBeamEndPoint = EffectTemplate.ADisruptorBeamHit01, -- These effects could be improved, they do not repeat + FxBeamEndPointScale = 1.0, + + FxBeamStartPoint = EffectTemplate.ADisruptorBeamMuzzleFlash01, + + +} diff --git a/lua/sim/collisionBeams/ExperimentalPhasonLaserCollisionBeam.lua b/lua/sim/collisionBeams/ExperimentalPhasonLaserCollisionBeam.lua new file mode 100644 index 0000000000..2822092b94 --- /dev/null +++ b/lua/sim/collisionBeams/ExperimentalPhasonLaserCollisionBeam.lua @@ -0,0 +1,81 @@ +local EffectTemplate = import("/lua/effecttemplates.lua") +local Util = import("/lua/utilities.lua") + +local CollisionBeam = import("/lua/sim/collisionbeam.lua").CollisionBeam +local SCCollisionBeam = import("/lua/sim/collisionBeams/SCCollisionBeam.lua").SCCollisionBeam + +-- Not used. Seraphim style experimental-sized beam, like the Galactic Colossus's beam +---@class ExperimentalPhasonLaserCollisionBeam : SCCollisionBeam +---@field BeamEffectsBag TrashBag +---@field Trash TrashBag +ExperimentalPhasonLaserCollisionBeam = Class(SCCollisionBeam) { + TerrainImpactType = 'LargeBeam01', + TerrainImpactScale = 1, + FxBeamStartPoint = EffectTemplate.SExperimentalPhasonLaserMuzzle01, + FxBeam = EffectTemplate.SExperimentalPhasonLaserBeam, + FxBeamEndPoint = EffectTemplate.SExperimentalPhasonLaserHitLand, + SplatTexture = 'scorch_004_albedo', + ScorchSplatDropTime = 0.1, + + ---@param self ExperimentalPhasonLaserCollisionBeam + ---@param impactType ImpactType + ---@param targetEntity? Prop|Unit + OnImpact = function(self, impactType, targetEntity) + if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then + if self.Scorching == nil then + self.Scorching = self:ForkThread( self.ScorchThread ) + end + else + KillThread(self.Scorching) + self.Scorching = nil + end + CollisionBeam.OnImpact(self, impactType, targetEntity) + end, + + ---@param self ExperimentalPhasonLaserCollisionBeam + OnDisable = function(self) + CollisionBeam.OnDisable(self) + KillThread(self.Scorching) + self.Scorching = nil + end, + + ---@param self ExperimentalPhasonLaserCollisionBeam + ScorchThread = function(self) + local army = self:GetArmy() + local size = 4.0 + (Random() * 1.0) + local CurrentPosition = self:GetPosition(1) + local LastPosition = Vector(0,0,0) + local skipCount = 1 + -- local FriendlyFire = self.DamageData.DamageFriendly + + while true do + if Util.GetDistanceBetweenTwoVectors(CurrentPosition, LastPosition) > 0.25 or skipCount > 100 then + CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 100, 100, army ) + LastPosition = CurrentPosition + skipCount = 1 + + -- commented due to hard-crash potential + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + else + skipCount = skipCount + self.ScorchSplatDropTime + end + + WaitSeconds(self.ScorchSplatDropTime) + size = 4.0 + (Random() * 1.0) + CurrentPosition = self:GetPosition(1) + end + end, + + ---@param self ExperimentalPhasonLaserCollisionBeam + CreateBeamEffects = function(self) + SCCollisionBeam.CreateBeamEffects(self) + for k, v in EffectTemplate.SExperimentalPhasonLaserBeam do + local fxBeam = CreateBeamEntityToEntity(self, 0, self, 1, self:GetArmy(), v) + table.insert(self.BeamEffectsBag, fxBeam) + self.Trash:Add(fxBeam) + end + -- local fxBeam = CreateBeamEntityToEntity(self, 0, self, 1, self:GetArmy(), '/effects/emitters/seraphim_expirimental_laser_beam_02_emit.bp' ) + end, +} + diff --git a/lua/sim/collisionBeams/GinsuCollisionBeam.lua b/lua/sim/collisionBeams/GinsuCollisionBeam.lua new file mode 100644 index 0000000000..cd12647b60 --- /dev/null +++ b/lua/sim/collisionBeams/GinsuCollisionBeam.lua @@ -0,0 +1,14 @@ +local EffectTemplate = import("/lua/effecttemplates.lua") + +local SCCollisionBeam = import("/lua/sim/collisionBeams/SCCollisionBeam.lua").SCCollisionBeam + +-- Not used. Barely visible, gray, unimpressive beam. +---@class GinsuCollisionBeam : SCCollisionBeam +GinsuCollisionBeam = Class(SCCollisionBeam) { + FxBeam = EffectTemplate.TAAGinsuBeam, + FxBeamEndPoint = EffectTemplate.TAAGinsuEndPoint, + FxImpactUnit = EffectTemplate.TAAGinsuHitUnit02, + FxUnitHitScale = 0.125, + FxImpactLand = EffectTemplate.TAAGinsuHitLand02, + FxLandHitScale = 0.1625, +} diff --git a/lua/sim/collisionBeams/MicrowaveLaserCollisionBeam01.lua b/lua/sim/collisionBeams/MicrowaveLaserCollisionBeam01.lua new file mode 100644 index 0000000000..96be04005b --- /dev/null +++ b/lua/sim/collisionBeams/MicrowaveLaserCollisionBeam01.lua @@ -0,0 +1,68 @@ +local EffectTemplate = import("/lua/effecttemplates.lua") +local Util = import("/lua/utilities.lua") + +local CollisionBeam = import("/lua/sim/collisionbeam.lua").CollisionBeam +local SCCollisionBeam = import("/lua/sim/collisionBeams/SCCollisionBeam.lua").SCCollisionBeam + +-- Used by Cybran Monkeylord URL0402's CDFHeavyMicrowaveLaserGenerator +-- Also is the base class for Cybran ACU's Microwave Laser's collision beam +---@class MicrowaveLaserCollisionBeam01 : SCCollisionBeam +MicrowaveLaserCollisionBeam01 = Class(SCCollisionBeam) { + TerrainImpactType = 'LargeBeam01', + TerrainImpactScale = 1, + FxBeamStartPoint = EffectTemplate.CMicrowaveLaserMuzzle01, + FxBeam = EffectTemplate.CMicrowaveLaserBeam01, + FxBeamEndPoint = EffectTemplate.CMicrowaveLaserEndPoint01, + SplatTexture = 'czar_mark01_albedo', + ScorchSplatDropTime = 0.25, + + ---@param self MicrowaveLaserCollisionBeam01 + ---@param impactType ImpactType + ---@param targetEntity? Prop|Unit + OnImpact = function(self, impactType, targetEntity) + if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then + if self.Scorching == nil then + self.Scorching = self:ForkThread(self.ScorchThread) + end + else + KillThread(self.Scorching) + self.Scorching = nil + end + CollisionBeam.OnImpact(self, impactType, targetEntity) + end, + + ---@param self MicrowaveLaserCollisionBeam01 + OnDisable = function(self) + CollisionBeam.OnDisable(self) + KillThread(self.Scorching) + self.Scorching = nil + end, + + ---@param self MicrowaveLaserCollisionBeam01 + ScorchThread = function(self) + local army = self:GetArmy() + local size = 1.5 + (Random() * 1.5) + local CurrentPosition = self:GetPosition(1) + local LastPosition = Vector(0,0,0) + local skipCount = 1 + -- local FriendlyFire = self.DamageData.DamageFriendly + + while true do + if Util.GetDistanceBetweenTwoVectors(CurrentPosition, LastPosition) > 0.25 or skipCount > 100 then + CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 200, 100, army ) + LastPosition = CurrentPosition + skipCount = 1 + + -- commented due to hard-crash potential + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + else + skipCount = skipCount + self.ScorchSplatDropTime + end + + WaitSeconds(self.ScorchSplatDropTime) + size = 1.2 + (Random() * 1.5) + CurrentPosition = self:GetPosition(1) + end + end, +} diff --git a/lua/sim/collisionBeams/MicrowaveLaserCollisionBeam02.lua b/lua/sim/collisionBeams/MicrowaveLaserCollisionBeam02.lua new file mode 100644 index 0000000000..d72c8f65c8 --- /dev/null +++ b/lua/sim/collisionBeams/MicrowaveLaserCollisionBeam02.lua @@ -0,0 +1,12 @@ +local EffectTemplate = import("/lua/effecttemplates.lua") + +local MicrowaveLaserCollisionBeam01 = import("/lua/sim/collisionBeams/MicrowaveLaserCollisionBeam01.lua").MicrowaveLaserCollisionBeam01 + +-- Smaller MicrowaveLaser used by Cybran ACU URL0001's CDFHeavyMicrowaveLaserGeneratorCom +---@class MicrowaveLaserCollisionBeam02 : MicrowaveLaserCollisionBeam01 +MicrowaveLaserCollisionBeam02 = Class(MicrowaveLaserCollisionBeam01) { + TerrainImpactScale = 1, + FxBeamStartPoint = EffectTemplate.CMicrowaveLaserMuzzle01, + FxBeam = EffectTemplate.CMicrowaveLaserBeam02, + FxBeamEndPoint = EffectTemplate.CMicrowaveLaserEndPoint01, +} diff --git a/lua/sim/collisionBeams/OrbitalDeathLaserCollisionBeam.lua b/lua/sim/collisionBeams/OrbitalDeathLaserCollisionBeam.lua new file mode 100644 index 0000000000..344dce2117 --- /dev/null +++ b/lua/sim/collisionBeams/OrbitalDeathLaserCollisionBeam.lua @@ -0,0 +1,70 @@ +local CollisionBeam = import("/lua/sim/collisionbeam.lua").CollisionBeam +local EffectTemplate = import("/lua/effecttemplates.lua") +local Util = import("/lua/utilities.lua") + +local SCCollisionBeam = import("/lua/sim/collisionBeams/SCCollisionBeam.lua").SCCollisionBeam + +-- Used by Novax Defense Satellite XEA0002's TOrbitalDeathLaserBeamWeapon +---@class OrbitalDeathLaserCollisionBeam : SCCollisionBeam +OrbitalDeathLaserCollisionBeam = Class(SCCollisionBeam) { + TerrainImpactType = 'LargeBeam02', + TerrainImpactScale = 1, + + FxBeam = EffectTemplate.TOrbitalDeathLaserBeam, + FxBeamEndPoint = EffectTemplate.TOrbitalDeathLaserMuzzleFlash01, + FxBeamStartPoint = EffectTemplate.TOrbitalDeathLaserHit01, + + SplatTexture = 'czar_mark01_albedo', + ScorchSplatDropTime = 0.5, + + ---@param self OrbitalDeathLaserCollisionBeam + ---@param impactType ImpactType + ---@param targetEntity? Prop|Unit + OnImpact = function(self, impactType, targetEntity) + if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then + if self.Scorching == nil then + self.Scorching = self:ForkThread(self.ScorchThread) + end + else + KillThread(self.Scorching) + self.Scorching = nil + end + CollisionBeam.OnImpact(self, impactType, targetEntity) + end, + + ---@param self OrbitalDeathLaserCollisionBeam + OnDisable = function(self) + CollisionBeam.OnDisable(self) + KillThread(self.Scorching) + self.Scorching = nil + end, + + ---@param self OrbitalDeathLaserCollisionBeam + ScorchThread = function(self) + local army = self:GetArmy() + local size = 3.5 + (Random() * 3.5) + local CurrentPosition = self:GetPosition(1) + local LastPosition = Vector(0,0,0) + local skipCount = 1 + -- local FriendlyFire = self.DamageData.DamageFriendly + + while true do + if Util.GetDistanceBetweenTwoVectors(CurrentPosition, LastPosition) > 0.25 or skipCount > 100 then + CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 250, 100, army) + LastPosition = CurrentPosition + skipCount = 1 + + -- commented due to hard-crash potential + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + + else + skipCount = skipCount + self.ScorchSplatDropTime + end + + WaitSeconds(self.ScorchSplatDropTime) + size = 3.2 + (Random() * 3.5) + CurrentPosition = self:GetPosition(1) + end + end, +} \ No newline at end of file diff --git a/lua/sim/collisionBeams/ParticleCannonCollisionBeam.lua b/lua/sim/collisionBeams/ParticleCannonCollisionBeam.lua new file mode 100644 index 0000000000..cc9b4aff2d --- /dev/null +++ b/lua/sim/collisionBeams/ParticleCannonCollisionBeam.lua @@ -0,0 +1,11 @@ +local EffectTemplate = import("/lua/effecttemplates.lua") + +local SCCollisionBeam = import("/lua/sim/collisionBeams/SCCollisionBeam.lua").SCCollisionBeam + +-- Not used anymore. Tiny Cybran pulsing beam previously used by Cerberus and Rhino CDFParticleCannon +---@class ParticleCannonCollisionBeam : SCCollisionBeam +ParticleCannonCollisionBeam = Class(SCCollisionBeam) { + FxBeam = EffectTemplate.CParticleCannonBeam, + FxBeamEndPoint = EffectTemplate.CParticleCannonHit02, + FxBeamEndPointScale = 1, +} diff --git a/lua/sim/collisionBeams/PhasonLaserCollisionBeam.lua b/lua/sim/collisionBeams/PhasonLaserCollisionBeam.lua new file mode 100644 index 0000000000..d347325398 --- /dev/null +++ b/lua/sim/collisionBeams/PhasonLaserCollisionBeam.lua @@ -0,0 +1,67 @@ +local EffectTemplate = import("/lua/effecttemplates.lua") +local Util = import("/lua/utilities.lua") + +local CollisionBeam = import("/lua/sim/collisionbeam.lua").CollisionBeam +local SCCollisionBeam = import("/lua/sim/collisionBeams/SCCollisionBeam.lua").SCCollisionBeam + +-- Used by Aeon Galactic Colossus UAL0401's ADFPhasonLaser +---@class PhasonLaserCollisionBeam : SCCollisionBeam +PhasonLaserCollisionBeam = Class(SCCollisionBeam) { + TerrainImpactType = 'LargeBeam01', + TerrainImpactScale = 1, + FxBeamStartPoint = EffectTemplate.APhasonLaserMuzzle01, + FxBeam = EffectTemplate.APhasonLaserBeam, + FxBeamEndPoint = EffectTemplate.APhasonLaserImpact01, + SplatTexture = 'czar_mark01_albedo', + ScorchSplatDropTime = 0.25, + + ---@param self PhasonLaserCollisionBeam + ---@param impactType ImpactType + ---@param targetEntity? Prop|Unit + OnImpact = function(self, impactType, targetEntity) + if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then + if self.Scorching == nil then + self.Scorching = self:ForkThread(self.ScorchThread) + end + else + KillThread(self.Scorching) + self.Scorching = nil + end + CollisionBeam.OnImpact(self, impactType, targetEntity) + end, + + ---@param self PhasonLaserCollisionBeam + OnDisable = function(self) + CollisionBeam.OnDisable(self) + KillThread(self.Scorching) + self.Scorching = nil + end, + + ---@param self PhasonLaserCollisionBeam + ScorchThread = function(self) + local army = self:GetArmy() + local size = 1.5 + (Random() * 1.5) + local CurrentPosition = self:GetPosition(1) + local LastPosition = Vector(0,0,0) + local skipCount = 1 + -- local FriendlyFire = self.DamageData.DamageFriendly + + while true do + if Util.GetDistanceBetweenTwoVectors(CurrentPosition, LastPosition) > 0.25 or skipCount > 100 then + CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 200, 100, army ) + LastPosition = CurrentPosition + skipCount = 1 + + -- commented due to hard-crash potential + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + else + skipCount = skipCount + self.ScorchSplatDropTime + end + + WaitSeconds(self.ScorchSplatDropTime) + size = 1.2 + (Random() * 1.5) + CurrentPosition = self:GetPosition(1) + end + end, +} diff --git a/lua/sim/collisionBeams/QuantumBeamGeneratorCollisionBeam.lua b/lua/sim/collisionBeams/QuantumBeamGeneratorCollisionBeam.lua new file mode 100644 index 0000000000..a49fddb1ff --- /dev/null +++ b/lua/sim/collisionBeams/QuantumBeamGeneratorCollisionBeam.lua @@ -0,0 +1,69 @@ +local EffectTemplate = import("/lua/effecttemplates.lua") +local Util = import("/lua/utilities.lua") + +local CollisionBeam = import("/lua/sim/collisionbeam.lua").CollisionBeam +local SCCollisionBeam = import("/lua/sim/collisionBeams/SCCollisionBeam.lua").SCCollisionBeam + +-- Used by Aeon CZAR UAA0310's AQuantumBeamGenerator +---@class QuantumBeamGeneratorCollisionBeam : SCCollisionBeam +QuantumBeamGeneratorCollisionBeam = Class(SCCollisionBeam) { + TerrainImpactType = 'LargeBeam02', + TerrainImpactScale = 1, + + FxBeam = EffectTemplate.AQuantumBeamGeneratorBeam, + FxBeamEndPoint = EffectTemplate.AQuantumBeamGeneratorMuzzleFlash01, + FxBeamStartPoint = EffectTemplate.AQuantumBeamGeneratorHit01, + + SplatTexture = 'czar_mark01_albedo', + ScorchSplatDropTime = 0.5, + + ---@param self QuantumBeamGeneratorCollisionBeam + ---@param impactType ImpactType + ---@param targetEntity? Prop|Unit + OnImpact = function(self, impactType, targetEntity) + if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then + if self.Scorching == nil then + self.Scorching = self:ForkThread(self.ScorchThread) + end + else + KillThread(self.Scorching) + self.Scorching = nil + end + CollisionBeam.OnImpact(self, impactType, targetEntity) + end, + + ---@param self QuantumBeamGeneratorCollisionBeam + OnDisable = function(self) + CollisionBeam.OnDisable(self) + KillThread(self.Scorching) + self.Scorching = nil + end, + + ---@param self QuantumBeamGeneratorCollisionBeam + ScorchThread = function(self) + local army = self:GetArmy() + local size = 3.5 + (Random() * 3.5) + local CurrentPosition = self:GetPosition(1) + local LastPosition = Vector(0,0,0) + local skipCount = 1 + -- local FriendlyFire = self.DamageData.DamageFriendly + + while true do + if Util.GetDistanceBetweenTwoVectors(CurrentPosition, LastPosition) > 0.25 or skipCount > 100 then + CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 200, 150, army ) + LastPosition = CurrentPosition + skipCount = 1 + + -- commented due to hard-crash potential + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + else + skipCount = skipCount + self.ScorchSplatDropTime + end + + WaitSeconds(self.ScorchSplatDropTime) + size = 3.2 + (Random() * 3.5) + CurrentPosition = self:GetPosition(1) + end + end, +} diff --git a/lua/sim/collisionBeams/SCCollisionBeam.lua b/lua/sim/collisionBeams/SCCollisionBeam.lua new file mode 100644 index 0000000000..bfa7b5ad46 --- /dev/null +++ b/lua/sim/collisionBeams/SCCollisionBeam.lua @@ -0,0 +1,16 @@ +local CollisionBeam = import("/lua/sim/collisionbeam.lua").CollisionBeam +local EffectTemplate = import("/lua/effecttemplates.lua") + + +-- Base class that defines Supreme Commander specific defaults +---@class SCCollisionBeam : CollisionBeam +SCCollisionBeam = Class(CollisionBeam) { + FxImpactUnit = EffectTemplate.DefaultProjectileLandUnitImpact, + FxImpactLand = { },-- EffectTemplate.DefaultProjectileLandImpact, + FxImpactWater = EffectTemplate.DefaultProjectileWaterImpact, + FxImpactUnderWater = EffectTemplate.DefaultProjectileUnderWaterImpact, + FxImpactAirUnit = EffectTemplate.DefaultProjectileAirUnitImpact, + FxImpactProp = { }, + FxImpactShield = { }, + FxImpactNone = { }, +} diff --git a/lua/sim/collisionBeams/TDFHiroCollisionBeam.lua b/lua/sim/collisionBeams/TDFHiroCollisionBeam.lua new file mode 100644 index 0000000000..fa1abc3a04 --- /dev/null +++ b/lua/sim/collisionBeams/TDFHiroCollisionBeam.lua @@ -0,0 +1,67 @@ +local EffectTemplate = import("/lua/effecttemplates.lua") +local Util = import("/lua/utilities.lua") + +local CollisionBeam = import("/lua/sim/collisionbeam.lua").CollisionBeam + +-- Used by UEF Battlecruiser XES0307's TDFHiroPlasmaCannon +---@class TDFHiroCollisionBeam : CollisionBeam +TDFHiroCollisionBeam = Class(CollisionBeam) { + TerrainImpactType = 'LargeBeam01', + TerrainImpactScale = 1, + FxBeamStartPoint = EffectTemplate.TDFHiroGeneratorMuzzle01, + FxBeam = EffectTemplate.TDFHiroGeneratorBeam, + FxBeamEndPoint = EffectTemplate.TDFHiroGeneratorHitLand, + SplatTexture = 'czar_mark01_albedo', + ScorchSplatDropTime = 0.25, + + ---@param self TDFHiroCollisionBeam + ---@param impactType string + ---@param targetEntity? Prop|Unit + OnImpact = function(self, impactType, targetEntity) + if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then + if self.Scorching == nil then + self.Scorching = self:ForkThread(self.ScorchThread) + end + else + KillThread(self.Scorching) + self.Scorching = nil + end + CollisionBeam.OnImpact(self, impactType, targetEntity) + end, + + ---@param self TDFHiroCollisionBeam + OnDisable = function(self) + CollisionBeam.OnDisable(self) + KillThread(self.Scorching) + self.Scorching = nil + end, + + ---@param self TDFHiroCollisionBeam + ScorchThread = function(self) + local army = self:GetArmy() + local size = 1.5 + (Random() * 1.5) + local CurrentPosition = self:GetPosition(1) + local LastPosition = Vector(0,0,0) + local skipCount = 1 + -- local FriendlyFire = self.DamageData.DamageFriendly + + while true do + if Util.GetDistanceBetweenTwoVectors(CurrentPosition, LastPosition) > 0.25 or skipCount > 100 then + CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 100, 70, army ) + LastPosition = CurrentPosition + skipCount = 1 + + -- commented due to hard-crash potential + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + else + skipCount = skipCount + self.ScorchSplatDropTime + end + + WaitSeconds(self.ScorchSplatDropTime) + size = 1.2 + (Random() * 1.5) + CurrentPosition = self:GetPosition(1) + end + end, +} + diff --git a/lua/sim/collisionBeams/TractorClawCollisionBeam.lua b/lua/sim/collisionBeams/TractorClawCollisionBeam.lua new file mode 100644 index 0000000000..3eedd6cea8 --- /dev/null +++ b/lua/sim/collisionBeams/TractorClawCollisionBeam.lua @@ -0,0 +1,13 @@ +local EffectTemplate = import("/lua/effecttemplates.lua") + +local CollisionBeam = import("/lua/sim/collisionbeam.lua").CollisionBeam + +-- Old beam for Aeon Galactic Colossus's Tractor Claws before rework by FAF +---@class TractorClawCollisionBeam : CollisionBeam +TractorClawCollisionBeam = Class(CollisionBeam) { + + FxBeam = { EffectTemplate.ACollossusTractorBeam01 }, + FxBeamEndPoint = { EffectTemplate.ACollossusTractorBeamGlow02 }, + FxBeamEndPointScale = 1.0, + FxBeamStartPoint = { EffectTemplate.ACollossusTractorBeamGlow01 }, +} diff --git a/lua/sim/collisionBeams/UltraChromaticBeamGeneratorCollisionBeam.lua b/lua/sim/collisionBeams/UltraChromaticBeamGeneratorCollisionBeam.lua new file mode 100644 index 0000000000..1e78f6bb07 --- /dev/null +++ b/lua/sim/collisionBeams/UltraChromaticBeamGeneratorCollisionBeam.lua @@ -0,0 +1,69 @@ +local EffectTemplate = import("/lua/effecttemplates.lua") +local Util = import("/lua/utilities.lua") + +local CollisionBeam = import("/lua/sim/collisionbeam.lua").CollisionBeam +local SCCollisionBeam = import("/lua/sim/collisionBeams/SCCollisionBeam.lua").SCCollisionBeam + +-- Used by Seraphim T2 Point Defense XSB2301's SDFUltraChromaticBeamGenerator +-- Also is the base class for Seraphim Destroyer's beam generators' collision beam +---@class UltraChromaticBeamGeneratorCollisionBeam : SCCollisionBeam +UltraChromaticBeamGeneratorCollisionBeam = Class(SCCollisionBeam) { + TerrainImpactType = 'LargeBeam01', + TerrainImpactScale = 1, + FxBeamStartPoint = EffectTemplate.SUltraChromaticBeamGeneratorMuzzle01, + FxBeam = EffectTemplate.SUltraChromaticBeamGeneratorBeam, + FxBeamEndPoint = EffectTemplate.SUltraChromaticBeamGeneratorHitLand, + SplatTexture = 'czar_mark01_albedo', + ScorchSplatDropTime = 0.25, + + ---@param self UltraChromaticBeamGeneratorCollisionBeam + ---@param impactType ImpactType + ---@param targetEntity? Prop|Unit + OnImpact = function(self, impactType, targetEntity) + if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then + if self.Scorching == nil then + self.Scorching = self:ForkThread(self.ScorchThread) + end + else + KillThread(self.Scorching) + self.Scorching = nil + end + CollisionBeam.OnImpact(self, impactType, targetEntity) + end, + + ---@param self UltraChromaticBeamGeneratorCollisionBeam + OnDisable = function(self) + CollisionBeam.OnDisable(self) + KillThread(self.Scorching) + self.Scorching = nil + end, + + ---@param self UltraChromaticBeamGeneratorCollisionBeam + ScorchThread = function(self) + local army = self:GetArmy() + local size = 1 + (Random() * 1) + local CurrentPosition = self:GetPosition(1) + local LastPosition = Vector(0,0,0) + local skipCount = 1 + -- local FriendlyFire = self.DamageData.DamageFriendly + + while true do + if Util.GetDistanceBetweenTwoVectors(CurrentPosition, LastPosition) > 0.25 or skipCount > 100 then + CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 70, 50, army ) + LastPosition = CurrentPosition + skipCount = 1 + + -- commented due to hard-crash potential + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + else + skipCount = skipCount + self.ScorchSplatDropTime + end + + WaitSeconds(self.ScorchSplatDropTime) + size = 1 + (Random() * 1) + CurrentPosition = self:GetPosition(1) + end + end, +} + diff --git a/lua/sim/collisionBeams/UltraChromaticBeamGeneratorCollisionBeam02.lua b/lua/sim/collisionBeams/UltraChromaticBeamGeneratorCollisionBeam02.lua new file mode 100644 index 0000000000..a2aa970b21 --- /dev/null +++ b/lua/sim/collisionBeams/UltraChromaticBeamGeneratorCollisionBeam02.lua @@ -0,0 +1,9 @@ +local EffectTemplate = import("/lua/effecttemplates.lua") + +local UltraChromaticBeamGeneratorCollisionBeam = import("/lua/sim/collisionBeams/UltraChromaticBeamGeneratorCollisionBeam.lua").UltraChromaticBeamGeneratorCollisionBeam + +-- Used by Seraphim Destroyer XSS0201's SDFUltraChromaticBeamGenerator02 +---@class UltraChromaticBeamGeneratorCollisionBeam02 : UltraChromaticBeamGeneratorCollisionBeam +UltraChromaticBeamGeneratorCollisionBeam02 = Class(UltraChromaticBeamGeneratorCollisionBeam) { + FxBeamStartPoint = EffectTemplate.SUltraChromaticBeamGeneratorMuzzle02, +} diff --git a/lua/sim/collisionBeams/UnstablePhasonLaserCollisionBeam.lua b/lua/sim/collisionBeams/UnstablePhasonLaserCollisionBeam.lua new file mode 100644 index 0000000000..ebdbcf05f2 --- /dev/null +++ b/lua/sim/collisionBeams/UnstablePhasonLaserCollisionBeam.lua @@ -0,0 +1,79 @@ +local EffectTemplate = import("/lua/effecttemplates.lua") +local VisionMarkerOpti = import("/lua/sim/VizMarker.lua").VisionMarkerOpti +local Util = import("/lua/utilities.lua") + +local CollisionBeam = import("/lua/sim/collisionbeam.lua").CollisionBeam +local SCCollisionBeam = import("/lua/sim/collisionBeams/SCCollisionBeam.lua").SCCollisionBeam + +-- Used by Seraphim Othuy (Ythotha's lightning storm) XSL0402's SDFUnstablePhasonBeam +---@class UnstablePhasonLaserCollisionBeam : SCCollisionBeam +UnstablePhasonLaserCollisionBeam = Class(SCCollisionBeam) { + TerrainImpactType = 'LargeBeam01', + TerrainImpactScale = 1, + FxBeamStartPoint = EffectTemplate.SExperimentalUnstablePhasonLaserMuzzle01, + FxBeam = EffectTemplate.OthuyElectricityStrikeBeam, + FxBeamEndPoint = EffectTemplate.OthuyElectricityStrikeHit, + SplatTexture = 'czar_mark01_albedo', + ScorchSplatDropTime = 0.25, + + ---@param self ExperimentalPhasonLaserCollisionBeam + ---@param impactType ImpactType + ---@param targetEntity? Prop|Unit + OnImpact = function(self, impactType, targetEntity) + if impactType ~= 'Shield' and impactType ~= 'Water' and impactType ~= 'Air' and impactType ~= 'UnitAir' and impactType ~= 'Projectile' then + if self.Scorching == nil then + self.Scorching = self:ForkThread(self.ScorchThread) + end + else + KillThread(self.Scorching) + self.Scorching = nil + end + + -- add vision to make sure we can see the impact effect + local position = self:GetPosition(1) + if position then + local marker = VisionMarkerOpti({Owner = self.unit}) + marker:UpdatePosition(position[1], position[3]) + marker:UpdateDuration(1) + marker:UpdateIntel(self.Army, 4, 'Vision', true) + end + + CollisionBeam.OnImpact(self, impactType, targetEntity) + end, + + ---@param self ExperimentalPhasonLaserCollisionBeam + OnDisable = function(self) + CollisionBeam.OnDisable(self) + KillThread(self.Scorching) + self.Scorching = nil + end, + + ---@param self ExperimentalPhasonLaserCollisionBeam + ScorchThread = function(self) + local army = self:GetArmy() + local size = 1.5 + (Random() * 1.5) + local CurrentPosition = self:GetPosition(1) + local LastPosition = Vector(0,0,0) + local skipCount = 1 + -- local FriendlyFire = self.DamageData.DamageFriendly + + while true do + if Util.GetDistanceBetweenTwoVectors(CurrentPosition, LastPosition) > 0.25 or skipCount > 100 then + CreateSplat( CurrentPosition, Util.GetRandomFloat(0,2*math.pi), self.SplatTexture, size, size, 250, 100, army ) + LastPosition = CurrentPosition + skipCount = 1 + + -- commented due to hard-crash potential + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + -- DamageArea(self, CurrentPosition, size, 1, 'Force', FriendlyFire) + else + skipCount = skipCount + self.ScorchSplatDropTime + end + + WaitSeconds(self.ScorchSplatDropTime) + size = 1.2 + (Random() * 1.5) + CurrentPosition = self:GetPosition(1) + end + end, +} + diff --git a/lua/sim/collisionBeams/ZapperCollisionBeam.lua b/lua/sim/collisionBeams/ZapperCollisionBeam.lua new file mode 100644 index 0000000000..bdcfc1cad3 --- /dev/null +++ b/lua/sim/collisionBeams/ZapperCollisionBeam.lua @@ -0,0 +1,10 @@ +local EffectTemplate = import("/lua/effecttemplates.lua") + +local SCCollisionBeam = import("/lua/sim/collisionBeams/SCCollisionBeam.lua").SCCollisionBeam + +-- Used by Cybran Tactical Missile Defense URB4201's CAMZapperWeapon +---@class ZapperCollisionBeam : SCCollisionBeam +ZapperCollisionBeam = Class(SCCollisionBeam) { + FxBeam = EffectTemplate.CZapperBeam, + FxBeamEndPoint = EffectTemplate.CZapperHit01, +}