Yes, it's the primary weapon. There's no onlyTargetCategory; there is a noChaseCategory, but commenting it out doesn't solve the problem. And no, the unit isn't on Hold Position.
Here's the unit files, if they help.
Unitdefs:
Code: Select all
local unitName = "gcflycannon"
local unitDef =
{
-- Internal settings
BuildPic = "gcflycannon.bmp",
Category = "GC UNIT NOTAIR ALL",
Name = "GC Mosquito",
ObjectName = "gcflycannon.s3o",
Side = "GC",
TEDClass = "TANK",
UnitName = "gcflycannon",
script = "gcflycannon.lua",
-- Unit limitations and properties
ActivateWhenBuilt = 1,
BuildTime = 2500,
Description = "Medium Attack Unit",
MaxDamage = 200,
RadarDistance = 0,
SightDistance = 300,
SoundCategory = "GC_FLY",
Upright = 1,
-- Energy and metal related
BuildCostEnergy = 250,
BuildCostMetal = 250,
-- Pathfinding and related
Acceleration = 0.2,
BrakeRate = 0.05,
movementclass = "Hover2x2",
canhover = 1,
FootprintX = 2,
FootprintZ = 2,
MaxSlope = 50,
MaxVelocity = 5.0,
MaxWaterDepth = 12,
TurnRate = 1000,
turret = false,
-- Abilities
Builder = 0,
Reclaimable = 0,
CanAttack = 1,
CanGuard = 1,
CanMove = 1,
CanPatrol = 1,
LeaveTracks = 0,
-- Abilities new to Spring
-- Weapons and related
weapons =
{
--"aim",
"gcredpulse",
"gcredpulse",
},
ExplodeAs = "GCFLYDEATH",
SelfDestructAs = "GCFLYDEATH",
SelfDestructCountdown = 5,
NoChaseCategory = "VTOL",
sfxtypes =
{
explosiongenerators =
{
"custom:GCREDPULSE_FLARE",
},
},
}
unitDef.weaponDefs = weaponDefs
return lowerkeys({ [unitName] = unitDef })
Weapondef:
Code: Select all
local weaponDef =
{
gcredpulse =
{
name = [[gcredpulse]],
accuracy = 10,
alphaDecay = 0.7,
areaOfEffect = 275,
burnblow = true,
craterBoost = 0,
craterMult = 0,
cylindertargetting = 0,
edgeEffectiveness = 0.4,
explosionGenerator = [[custom:GCREDPULSE_FX]],
firestarter = 70,
impulseBoost = 0,
impulseFactor = 0,
intensity = 0.7,
interceptedByShieldType = 1,
lineOfSight = true,
noSelfDamage = true,
range = 200,
reloadtime = 1,
renderType = 4,
rgbColor = [[1 0.4 0.4]],
size = 3.5,
separation = 1.5,
stages = 10,
targetMoveError = 0.001,
texture1 = "fireball",
turret = false,
weaponType = [[Cannon]],
weaponVelocity = 300,
damage =
{
default = 175,
SCOUTARMOUR = 5,
VTOLARMOUR = 7,
},
}
}
return weaponDef
Unit animation, with kludgy turret=true hacks commented out:
Code: Select all
include "smokeunit.lua"
local body = piece "body"
local bodyfalse = piece "bodyfalse"
local rgun = piece "rgun"
local rflare = piece "rflare"
local lgun = piece "lgun"
local lflare = piece "lflare"
local smokePieces = { piece "body" }
local SIG_AIM1 = 1
local SIG_AIM2 = 2
local RESTORE_DELAY = Spring.UnitScript.GetLongestReloadTime(unitID) * 0.5
local function RestoreAfterDelay()
Sleep(RESTORE_DELAY)
Turn(body, y_axis, 0, math.rad(190))
end
local function RestoreAfterFalse()
Sleep(RESTORE_DELAY)
Turn(bodyfalse, y_axis, 0, math.rad(190))
end
function script.Create()
StartThread(SmokeUnit, smokePieces)
end
function script.AimWeapon1(heading, pitch)
Signal(SIG_AIM1)
SetSignalMask(SIG_AIM1)
-- Turn(body, y_axis, heading, math.rad(90))
-- WaitForTurn(body, y_axis)
-- EmitSfx(1024, lflare)
-- StartThread(RestoreAfterDelay)
return true
end
function script.AimWeapon2(heading, pitch)
Signal(SIG_AIM2)
SetSignalMask(SIG_AIM2)
-- Turn(bodyfalse, y_axis, heading, math.rad(90))
-- WaitForTurn(bodyfalse, y_axis)
-- EmitSfx(1024, rflare)
-- StartThread(RestoreAfterFalse)
return true
end
function script.AimFromWeapon1() return lgun end
function script.AimFromWeapon2() return rgun end
function script.QueryWeapon1() return lflare end
function script.QueryWeapon2() return rflare end
function script.Killed(recentDamage, maxHealth)
return 0
end