Code: Select all
local unitName = "base"
local unitDef =
{
-- Internal settings
BuildPic = "base.bmp",
Category = "BUILDING",
ObjectName = "base2.s3o",
Side = "TANK",
TEDClass = "PLANT",
script = "base.lua",
-- Unit limitations and properties
ActivateWhenBuilt = true,
BuildTime = 1000,
commander = true,
Description = "Builds buildings",
MaxDamage = 1500,
Name = "Base",
RadarDistance = 0,
SightDistance = 400,
SoundCategory = "BUILDING",
Upright = 1,
levelground = 1,
-- Energy and metal related
BuildCostmetal = 0,
BuildCostEnergy = 0,
EnergyStorage = 0,
EnergyUse = 0,
MetalStorage = 0,
EnergyMake = 0,
MakesMetal = 0,
MetalMake = 0,
-- Pathfinding and related
FootprintX = 4,
FootprintZ = 4,
MaxSlope = 10,
MaxWaterDepth = 0,
YardMap = "cccc cccc cccc cccc",
-- Abilities
Builder = 1,
BuildDistance = 1000,
WorkerTime = 1,
Reclaimable = 0,
ShowNanoSpray = 0,
CanBeAssisted = 0,
buildoptions =
{
"powerplant",
},
-- Abilities new to Spring
-- Weapons and related
ExplodeAs = "BUILDINGLARGEDEATH",
SelfDestructAs = "BUILDINGLARGEDEATH",
SelfDestructCountdown = 5,
}
return lowerkeys({ [unitName] = unitDef })
Code: Select all
local building, platform, nanopoint = piece "building", piece "platform", piece "nanopoint"
-- declares all the pieces we'll be using.
local SIG_BUILD = 2
-- local RESTORE_DELAY = Spring.UnitScript.GetLongestReloadTime(unitID) * 2
function script.Create()
return 0
end
function script.StartBuilding()
--called whenever construction begins.
Signal(SIG_BUILD)
SetSignalMask(SIG_BUILD)
-- Stops the unit from "building" and "not building" at the same time. This would be confusing.
--Start building!
SetUnitValue(COB.INBUILDSTANCE, 1)
return 1
end
function script.StopBuilding()
Signal(SIG_BUILD)
SetSignalMask(SIG_BUILD)
-- Stops the unit from "building" and "not building" at the same time. This would be confusing.
SetUnitValue(COB.INBUILDSTANCE, 0)
--Stops building!
Sleep(1)
return 0
end
function script.Killed(recentDamage, maxHealth)
return 0
end
function script.HitByWeapon(x,z,weaponDef,damage)
-- This stops the unit being damaged if it's not been built yet.
if GetUnitValue(COB.BUILD_PERCENT_LEFT)>2 then return 0
else return damage
end
end
Also, as a secondary question, can more than one script be attached to a unit?