Statistics: Posted by dstojkov — 24 Oct 2013, 23:03
Statistics: Posted by utterbob — 02 Oct 2013, 14:32
function CreateWreckageProp( self, overkillRatio )
local bp = self:GetBlueprint()
local wreck = bp.Wreckage.Blueprint
local pos = self:GetPosition()
local mass = bp.Economy.BuildCostMass * (bp.Wreckage.MassMult or 0)
local energy = bp.Economy.BuildCostEnergy * (bp.Wreckage.EnergyMult or 0)
local time = (bp.Wreckage.ReclaimTimeMultiplier or 1)
--pos[2] = GetTerrainHeight(pos[1], pos[3]) + GetTerrainTypeOffset(pos[1], pos[3])
local prop = CreateProp( pos, wreck )
prop:SetScale(bp.Display.UniformScale)
prop:SetOrientation(self:GetOrientation(), true)
prop:SetPropCollision('Box', bp.CollisionOffsetX, bp.CollisionOffsetY, bp.CollisionOffsetZ, bp.SizeX* 0.5, bp.SizeY* 0.5, bp.SizeZ * 0.5)
prop:SetMaxReclaimValues(time, time, mass, energy)
mass = (mass - (mass * (overkillRatio or 1))) * self:GetFractionComplete()
energy = (energy - (energy * (overkillRatio or 1))) * self:GetFractionComplete()
time = time - (time * (overkillRatio or 1))
prop:SetReclaimValues(time, time, mass, energy)
prop:SetMaxHealth(bp.Defense.Health)
prop:SetHealth(self, bp.Defense.Health * (bp.Wreckage.HealthMult or 1))
if not bp.Wreckage.UseCustomMesh then
prop:SetMesh(bp.Display.MeshBlueprintWrecked)
end
TryCopyPose(self,prop,false)
prop.AssociatedBP = self:GetBlueprint().BlueprintId
return prop
end
local Unit = import('sim/unit.lua').Unit
local Shield = import('shield.lua').Shield
local explosion = import('defaultexplosions.lua')
local Util = import('utilities.lua')
local
EffectUtil = import('EffectUtilities.lua')
local EffectTemplate = import('EffectTemplates.lua')
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local EffectUtil = import('EffectUtilities.lua')
local CreateBuildCubeThread = EffectUtil.CreateBuildCubeThread
local CreateAeonBuildBaseThread = EffectUtil.CreateAeonBuildBaseThread
local Entity = import('sim/entity.lua').Entity
local OldSeaUnit = SeaUnit
local function CreateScaledBoom(unit, overkill, bone)
explosion.CreateDefaultHitExplosionAtBone(
unit,
bone or 0,
explosion.CreateUnitExplosionEntity(unit, overkill).Spec.BoundingXZRadius
)
end
**Naval units class hooks here (SeaUnit & SubUnit) - both work**
local OldHoverLandUnit = HoverLandUnit
HoverLandUnit = startClass(OldHoverLandUnit)
DeathThread = function(self, overkillRatio, instigator)
if self:GetCurrentLayer() == 'Water' then
CreateScaledBoom(self, overkillRatio)
local sx, sy, sz = self:GetUnitSizes()
local vol = sx * sy * sz
local army = self:GetArmy()
local pos = self:GetPosition()
local seafloor = GetTerrainHeight(pos[1], pos[3]) + GetTerrainTypeOffset(pos[1], pos[3])
local DaveyJones = (seafloor - pos[2])*20
local numBones = self:GetBoneCount()-1
self:ForkThread(function()
##LOG("Sinker thread created")
local pos = self:GetPosition()
local seafloor = GetTerrainHeight(pos[1], pos[3]) + GetTerrainTypeOffset(pos[1], pos[3])
while self:GetPosition(1)[2] > (seafloor) do #added 2 because they were sinking into the seafloor
WaitSeconds(0.1)
##LOG("Sinker: ", repr(self:GetPosition()))
end
CreateScaledBoom(self, overkillRatio, watchBone)
self:CreateWreckage(overkillRatio, instigator)
self:Destroy()
end)
self:ForkThread(function()
local i = 0
while true do
local rx, ry, rz = self:GetRandomOffset(0.25)
local rs = Random(vol/2, vol*2) / (vol*2)
local randBone = Util.GetRandomInt( 0, numBones)
CreateEmitterAtBone( self, randBone, army, '/effects/emitters/destruction_underwater_explosion_flash_01_emit.bp')
:ScaleEmitter(sx)
:OffsetEmitter(rx, ry, rz)
CreateEmitterAtBone( self, randBone, army, '/effects/emitters/destruction_underwater_sinking_wash_01_emit.bp')
:ScaleEmitter(sx/2)
:OffsetEmitter(rx, ry, rz)
local rd = Util.GetRandomFloat( 0.4+i, 1.0+i)
WaitSeconds(rd)
i = i + 0.3
end
end)
#what does this even do I have no idea
local slider = CreateSlider(self, 0)
slider:SetGoal(0, DaveyJones+10, 0) #changed from +5 to +10
slider:SetSpeed(8)
WaitFor(slider)
slider:Destroy()
CreateScaledBoom(self, overkillRatio)
self:CreateWreckage(overkillRatio, instigator)
self:Destroy()
else
MobileUnit.DeathThread(self, overkillRatio, instigator)
end
end
function CreateWreckageProp( self, overkillRatio )
local bp = self:GetBlueprint()
local wreck = bp.Wreckage.Blueprint
local pos = self:GetPosition()
local mass = bp.Economy.BuildCostMass * (bp.Wreckage.MassMult or 0)
local energy = bp.Economy.BuildCostEnergy * (bp.Wreckage.EnergyMult or 0)
local time = (bp.Wreckage.ReclaimTimeMultiplier or 1)
--pos[2] = GetTerrainHeight(pos[1], pos[3]) + GetTerrainTypeOffset(pos[1], pos[3])
local prop = CreateProp( pos, wreck )
prop:SetScale(bp.Display.UniformScale)
prop:SetOrientation(self:GetOrientation(), true)
prop:SetPropCollision('Box', bp.CollisionOffsetX, bp.CollisionOffsetY, bp.CollisionOffsetZ, bp.SizeX* 0.5, bp.SizeY* 0.5, bp.SizeZ * 0.5)
prop:SetMaxReclaimValues(time, time, mass, energy)
mass = (mass - (mass * (overkillRatio or 1))) * self:GetFractionComplete()
energy = (energy - (energy * (overkillRatio or 1))) * self:GetFractionComplete()
time = time - (time * (overkillRatio or 1))
prop:SetReclaimValues(time, time, mass, energy)
prop:SetMaxHealth(bp.Defense.Health)
prop:SetHealth(self, bp.Defense.Health * (bp.Wreckage.HealthMult or 1))
if not bp.Wreckage.UseCustomMesh then
prop:SetMesh(bp.Display.MeshBlueprintWrecked)
end
TryCopyPose(self,prop,false)
prop.AssociatedBP = self:GetBlueprint().BlueprintId
return prop
end
endClass()
Statistics: Posted by utterbob — 29 Sep 2013, 11:26