Skip to content

Commit

Permalink
Improve effects of the Ahwassa projectile
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas committed Nov 17, 2023
1 parent eb58055 commit d459240
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ProjectileBlueprint {
Display = {
StrategicIconSize = 0,
StrategicIconSize = 1,
},
Physics = {
CollideEntity = false,
CollideEntity = true,
DestroyOnWater = true,
TrackTarget = false,
TurnRate = 360,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,43 @@
-- Summary : Ohwalli Strategic Bomb effect script, non-damaging
-- Copyright © 2007 Gas Powered Games, Inc. All rights reserved.
------------------------------------------------------------------------------

local EmitterProjectile = import("/lua/sim/defaultprojectiles.lua").EmitterProjectile
local EmitterProjectileOnImpact = EmitterProjectile.OnImpact

local EffectTemplate = import("/lua/effecttemplates.lua")

local VisionMarkerOpti = import("/lua/sim/vizmarker.lua").VisionMarkerOpti

--- Ohwalli Strategic Bomb effect script, non-damaging
---@class SBOOhwalliBombEffect01 : EmitterProjectile
SBOOhwalliBombEffect01 = Class(import("/lua/sim/defaultprojectiles.lua").EmitterProjectile) {
SBOOhwalliBombEffect01 = Class(EmitterProjectile) {
FxTrails = EffectTemplate.SOhwalliBombPlumeFxTrails01,

---@param self Projectile
---@param targetType string
---@param targetEntity Unit | Prop
OnImpact = function(self, targetType, targetEntity)
EmitterProjectileOnImpact(self, targetType, targetEntity)

local army = self.Army
local position = self:GetPosition()

-- create vision
local marker = VisionMarkerOpti({ Owner = self })
marker:UpdatePosition(position[1], position[3])
marker:UpdateDuration(6)
marker:UpdateIntel(army, 5, 'Vision', true)

-- create a flash upon impacting
CreateLightParticleIntel(self, -1, army, 3, 5, 'glow_03', 'ramp_antimatter_02')

-- create a bit of fire and additional damage
DamageArea(self, position, 3, 1, "TreeForce", false)
DamageArea(self, position, 3, 1, "TreeFire", false)
DamageArea(self, position, 3, 1, "TreeForce", false)
DamageArea(self, position, 1, 1, 'Disintegrate', false)
DamageArea(self, position, 3, 300, "Normal", false)
end,
}
TypeClass = SBOOhwalliBombEffect01
TypeClass = SBOOhwalliBombEffect01
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
-- Copyright © 2007 Gas Powered Games, Inc. All rights reserved.
------------------------------------------------------------------------------

local EmitterProjectile = import("/lua/sim/defaultprojectiles.lua").EmitterProjectile
local EmitterProjectileOnCreate = EmitterProjectile.OnCreate

--- Ohwalli Strategic Bomb effect script, non-damaging
---@class SBOOhwalliBombEffect03 : EmitterProjectile
SBOOhwalliBombEffect03 = Class(import("/lua/sim/defaultprojectiles.lua").EmitterProjectile) {
SBOOhwalliBombEffect03 = Class(EmitterProjectile) {
FxTrails = import("/lua/effecttemplates.lua").SOhwalliBombHitRingProjectileFxTrails03,
}
TypeClass = SBOOhwalliBombEffect03
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ local NullShell = import("/lua/sim/defaultprojectiles.lua").NullShell
local RandomFloat = import("/lua/utilities.lua").GetRandomFloat
local RandomInt = import("/lua/utilities.lua").GetRandomInt
local EffectTemplate = import("/lua/effecttemplates.lua")
local SOhwalliBombHit01 = EffectTemplate.SOhwalliBombHit01
local ExplosionMediumWater = EffectTemplate.ExplosionMediumWater

-- upvalue scope for performance
local MathSin = math.sin
local MathCos = math.cos
local WaitTicks = WaitTicks
local GetTerrainHeight = GetTerrainHeight
local GetSurfaceHeight = GetSurfaceHeight
local CreateEmitterAtEntity = CreateEmitterAtEntity


local BaseRingRiftEffects = {
'/effects/Entities/SBOOhwalliBombEffect03/SBOOhwalliBombEffect03_proj.bp',
Expand All @@ -27,7 +38,16 @@ SBOOhwalliBombEffectController01 = Class(NullShell) {
---@param self SBOOhwalliBombEffectController01
OnCreate = function( self )
NullShell.OnCreate(self)
local army = self:GetArmy()
local army = self.Army

-- create a water splash effect if we're on water
local position = self:GetPosition()
if GetSurfaceHeight(position[1], position[3]) > GetTerrainHeight(position[1], position[3]) then
for _, effect in ExplosionMediumWater do
local emitter = CreateEmitterAtEntity(self, army, effect)
emitter:ScaleEmitter(1)
end
end

self:ForkThread(self.CreateInitialBuildup, army)
self:ForkThread(self.CreateRifts, army )
Expand All @@ -37,8 +57,8 @@ SBOOhwalliBombEffectController01 = Class(NullShell) {
---@param self SBOOhwalliBombEffectController01
---@param army number
CreateInitialBuildup = function( self, army )
WaitSeconds(1.0)
for k, v in EffectTemplate.SOhwalliBombHit01 do
WaitTicks(11)
for k, v in SOhwalliBombHit01 do
emit = CreateEmitterAtEntity(self,army,v)
end
end,
Expand All @@ -63,8 +83,8 @@ SBOOhwalliBombEffectController01 = Class(NullShell) {
end

for i = 0, (num_projectiles -1) do
xVec = math.sin(angleInitial + (i*horizontal_angle) + RandomFloat(-angleVariation, angleVariation) )
zVec = math.cos(angleInitial + (i*horizontal_angle) + RandomFloat(-angleVariation, angleVariation) )
xVec = MathSin(angleInitial + (i*horizontal_angle) + RandomFloat(-angleVariation, angleVariation) )
zVec = MathCos(angleInitial + (i*horizontal_angle) + RandomFloat(-angleVariation, angleVariation) )

local proj = self:CreateProjectile(BaseRingRiftEffects[RandomInt(1,3)], xVec * 1.2, 2, zVec * 1.2, xVec, 0, zVec)
proj:SetVelocity(velocity * RandomFloat(0.7,1.4))
Expand All @@ -75,7 +95,7 @@ SBOOhwalliBombEffectController01 = Class(NullShell) {
---@param self SBOOhwalliBombEffectController01
---@param army number
MainBlast = function( self, army )
WaitSeconds(2.5)
WaitTicks(26)

-- Create a light for this thing's flash.
CreateLightParticle(self, -1, self:GetArmy(), 80, 14, 'flare_lens_add_03', 'ramp_white_07' )
Expand All @@ -93,7 +113,7 @@ SBOOhwalliBombEffectController01 = Class(NullShell) {
-- self:ShakeCamera( radius, maxShakeEpicenter, minShakeAtRadius, interval )
self:ShakeCamera( 55, 10, 0, 2.5 )

WaitSeconds(0.3)
WaitTicks(4)

-- Create upward moving smoke plume
local plume = self:CreateProjectile('/effects/entities/SBOOhwalliBombEffect02/SBOOhwalliBombEffect02_proj.bp', 0, 3, 0, 0, 0, 0)
Expand All @@ -102,7 +122,6 @@ SBOOhwalliBombEffectController01 = Class(NullShell) {
plume:SetVelocityAlign(true)

-- Create explosion dust ring
local vx, vy, vz = self:GetVelocity()
local num_projectiles = 16
local horizontal_angle = (2*math.pi) / num_projectiles
local angleInitial = RandomFloat( 0, horizontal_angle )
Expand All @@ -111,8 +130,8 @@ SBOOhwalliBombEffectController01 = Class(NullShell) {
local px, pz

for i = 0, (num_projectiles -1) do
xVec = (math.sin(angleInitial + (i*horizontal_angle)))
zVec = (math.cos(angleInitial + (i*horizontal_angle)))
xVec = (MathSin(angleInitial + (i*horizontal_angle)))
zVec = (MathCos(angleInitial + (i*horizontal_angle)))
px = (offsetMultiple*xVec)
pz = (offsetMultiple*zVec)

Expand All @@ -134,9 +153,9 @@ SBOOhwalliBombEffectController01 = Class(NullShell) {
local px, py, pz

for i = 0, (num_projectiles -1) do
xVec = math.sin(angleInitial + (i*horizontal_angle) + RandomFloat(-angleVariation, angleVariation) )
xVec = MathSin(angleInitial + (i*horizontal_angle) + RandomFloat(-angleVariation, angleVariation) )
yVec = RandomFloat( 0.7, 2.8 ) + 2.0
zVec = math.cos(angleInitial + (i*horizontal_angle) + RandomFloat(-angleVariation, angleVariation) )
zVec = MathCos(angleInitial + (i*horizontal_angle) + RandomFloat(-angleVariation, angleVariation) )
px = RandomFloat( 0.5, 1.0 ) * xVec
py = RandomFloat( 0.5, 1.0 ) * yVec
pz = RandomFloat( 0.5, 1.0 ) * zVec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ProjectileBlueprint {
HelpText = 0,
},
Physics = {
CollideEntity = false,
CollideEntity = true,
DestroyOnWater = true,
TrackTarget = false,
TurnRate = 360,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ProjectileBlueprint {
HelpText = 0,
},
Physics = {
CollideEntity = false,
CollideEntity = true,
DestroyOnWater = true,
TrackTarget = false,
TurnRate = 360,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,50 @@
-- Summary : Ohwalli-Strategic Bomb script, used on XSA402
-- Copyright © 2007 Gas Powered Games, Inc. All rights reserved.
-------------------------------------------------------------------------------

local SOhwalliStrategicBombProjectile = import("/lua/seraphimprojectiles.lua").SOhwalliStrategicBombProjectile
local SOhwalliStrategicBombProjectileOnCreate = SOhwalliStrategicBombProjectile.OnCreate

local VisionMarkerOpti = import("/lua/sim/vizmarker.lua").VisionMarkerOpti

-- upvalue scope for performance
local WaitTicks = WaitTicks
local ForkThread = ForkThread
local DamageArea = DamageArea

--- Ohwalli-Strategic Bomb script, used on XSA402
---@class SBOOhwalliStategicBomb01 : SOhwalliStrategicBombProjectile
SBOOhwalliStategicBomb01 = ClassProjectile(SOhwalliStrategicBombProjectile) {

---@param self SBOOhwalliStategicBomb01
---@param inWater boolean
OnCreate = function(self, inWater)
SOhwalliStrategicBombProjectileOnCreate(self, inWater)
CreateLightParticleIntel(self, -1, self.Army, 15, 5, 'flare_lens_add_02', 'ramp_blue_13')
end,

---@param self SBOOhwalliStategicBomb01
---@param targetType string
---@param targetEntity Prop|Unit
OnImpact = function(self, targetType, targetEntity)
local effectController = '/effects/entities/SBOOhwalliBombEffectController01/SBOOhwalliBombEffectController01_proj.bp'
self:CreateProjectile(effectController, 0, 0, 0, 0, 0, 0)

local position = self:GetPosition()

-- create vision
local marker = VisionMarkerOpti({ Owner = self })
marker:UpdatePosition(position[1], position[3])
marker:UpdateDuration(9)
marker:UpdateIntel(self.Army, 12, 'Vision', true)

-- separate damage thread
local data = self.DamageData
local damage = data.DamageAmount
local radius = data.DamageRadius or 0
local instigator = self.Launcher or self
ForkThread(self.DamageThread, self, self:GetPosition(), instigator, damage, radius)
ForkThread(self.DamageThread, self, position, instigator, damage, radius)

self:Destroy()
end,

Expand All @@ -34,16 +59,20 @@ SBOOhwalliStategicBomb01 = ClassProjectile(SOhwalliStrategicBombProjectile) {
-- knock over trees
DamageArea(instigator, position, 0.75 * radius, 1, 'TreeForce', false)
DamageArea(instigator, position, 0.75 * radius, 1, 'TreeForce', false)

-- initial damage
DamageArea(instigator, position, radius, 0.1 * damage, 'Normal', false)
DamageArea(instigator, position, 0.9 * radius, 1, 'TreeFire', false)

-- wait for the full explosion and then deal the remaining damage
WaitTicks(26)
DamageArea(instigator, position, 0.2 * radius, 1, 'Disintegrate', false)
DamageArea(instigator, position, radius, 0.3 * damage, 'Normal', false)
WaitTicks(1)
DamageArea(instigator, position, 0.3 * radius, 1, 'Disintegrate', false)
DamageArea(instigator, position, radius, 0.3 * damage, 'Normal', false)
WaitTicks(1)
DamageArea(instigator, position, 0.4 * radius, 1, 'Disintegrate', false)
DamageArea(instigator, position, radius, 0.3 * damage, 'Normal', false)
end,
}
Expand Down

0 comments on commit d459240

Please sign in to comment.