/
XRB2308_script.lua
110 lines (93 loc) · 3.98 KB
/
XRB2308_script.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
-----------------------------------------------------------------
-- File : /cdimage/units/XRB2205/XRB2205_script.lua
-- Author(s): Jessica St. Croix, Gordon Duclos
-- Summary : Cybran Heavy Torpedo Launcher Script
-- Copyright ? 2007 Gas Powered Games, Inc. All rights reserved.
-----------------------------------------------------------------
local CStructureUnit = import("/lua/cybranunits.lua").CStructureUnit
local CKrilTorpedoLauncherWeapon = import("/lua/cybranweapons.lua").CKrilTorpedoLauncherWeapon
local utilities = import("/lua/utilities.lua")
---@class XRB2308 : CStructureUnit
XRB2308 = ClassUnit(CStructureUnit) {
Weapons = {
Turret01 = ClassWeapon(CKrilTorpedoLauncherWeapon) {},
},
OnStopBeingBuilt = function(self, builder, layer)
CStructureUnit.OnStopBeingBuilt(self, builder, layer)
local pos = self:GetPosition()
local armySelf = self.Army
local health = self:GetHealth()
local armies = ListArmies()
local spottedByArmy = {}
local fireState = self:GetFireState()
for _, army in armies do
if not IsAlly(armySelf, army) then
local blip = self:GetBlip(army)
if blip and blip:IsSeenEver(army) then
table.insert(spottedByArmy, ScenarioInfo.ArmySetup[army].ArmyIndex)
end
end
end
if not self:IsIdleState() then
self.Trash:Add(ForkThread(self.CreateNewHarmsWithDelay, armySelf, pos, spottedByArmy, fireState,self))
else
self:Destroy()
local newHARMS = CreateUnitHPR('XRB2309', armySelf, pos[1], pos[2], pos[3], 0, 0, 0)
newHARMS:SetHealth(newHARMS, health)
newHARMS.SpottedByArmy = spottedByArmy
newHARMS:SetFireState(fireState)
end
end,
CreateNewHarmsWithDelay = function(self, armySelf, pos, spottedByArmy, fireState)
WaitTicks(1)
if not self.Dead then
local health = self:GetHealth()
local target = self:GetTargetEntity()
self:Destroy()
local newHARMS = CreateUnitHPR('XRB2309', armySelf, pos[1], pos[2], pos[3], 0, 0, 0)
newHARMS:SetHealth(newHARMS, health)
newHARMS.SpottedByArmy = spottedByArmy
newHARMS:SetFireState(fireState)
if target then
IssueAttack({ newHARMS }, target)
end
end
end,
DeathThread = function(self, overkillRatio, instigator)
local bp = self.Blueprint
local army = self.Army
self.Trash:Add(CreateAttachedEmitter(self, 'xrb2308', army, '/effects/emitters/flash_03_emit.bp'):ScaleEmitter(2))
self.Trash:Add(CreateAttachedEmitter(self, 'xrb2308', army, '/effects/emitters/flash_04_emit.bp'):ScaleEmitter(2))
self:DestroyAllDamageEffects()
self:PlaySound(bp.Audio.Destroyed)
local isNaval = true
local shallSink = true
WaitSeconds(utilities.GetRandomFloat(self.DestructionExplosionWaitDelayMin, self.DestructionExplosionWaitDelayMax))
if self.PlayDestructionEffects then
self:CreateDestructionEffects(overkillRatio)
end
if self.ShowUnitDestructionDebris and overkillRatio then
self:CreateUnitDestructionDebris(true, true, overkillRatio > 2)
end
self.DisallowCollisions = true
self.Trash:Add(ForkThread(self.SinkDestructionEffects,self))
self.overkillRatio = overkillRatio
local this = self
self:StartSinking(
function()
this:DestroyUnit(overkillRatio)
end
)
end,
StartSinking = function(self, callback)
if not self.sinkingFromBuild and self.Bottom then
self.Trash:Add(ForkThread(callback,self))
elseif self.sinkingFromBuild then
self.sinkProjectile.callback = callback
return
else
CStructureUnit.StartSinking(self, callback)
end
end,
}
TypeClass = XRB2308