One problem is that the Machineguns are at the center of the model instead of at the designated pieces.
Another problem is that only the Machineguns fire, not the Missile.
Finally, all weapons are pointing directly at the target instead of them staying still and the Plane doing the aiming (i tried fixing this with MainDir and MaxAngleDif).
Here is the Unitdef:
Code: Select all
local unitName = "raven"
local unitDef = {
--Internal settings
BuildPic = "Default.png",
Category = " SMALL AIR ",
ObjectName = "Raven.s3o",
name = "Raven",
Side = "TANKS",
TEDClass = "TANK",
UnitName = "Raven",
script = "Ravenscript.lua",
--Unit limitations and properties
BuildTime = 1000,
Description = "Air Superiority Fighter",
MaxDamage = 500,
RadarDistance = 0,
SightDistance = 800,
SoundCategory = "TANK",
Upright = 0,
--Energy and metal related
BuildCostEnergy = 100,
BuildCostMetal = 50,
--Pathfinding and related
Acceleration = 0.4,
BrakeRate = 0.5,
FootprintX = 2,
FootprintZ = 2,
MaxSlope = 15,
MaxVelocity = 4.5,
MaxWaterDepth = 20,
MovementClass = "Aircraft2x2",
TurnRate = 2700,
--Abilities
Builder = 0,
CanAttack = 1,
CanGuard = 1,
CanMove = 1,
CanPatrol = 1,
CanStop = 1,
LeaveTracks = 0,
Reclaimable = 0,
--Aircraft
canFly = 1,
cruiseAlt = 50,
canLoopbackAttack = 1,
MaxAileron = 0.003,
MaxRudder = 0.02,
MaxElevator = 0.04,
MaxAcc = 0.1,
--Hitbox
-- collisionVolumeOffsets = "0 0 0",
-- collisionVolumeScales = "20 20 20",
-- collisionVolumeTest = 1,
-- collisionVolumeType = "box",
--Weapons and related
weapons = {
[1]={
name = "NTMachineGun",
maxAngleDif = 15,
mainDir = [[0 0 1]],
},
[2]={
name = "NTMachineGun",
maxAngleDif = 15,
slaveTo = 1,
mainDir = [[0 0 1]],
},
[3]={
name = "AtAMissile",
maxAngleDif = 15,
slaveTo = 1,
mainDir = [[0 0 1]],
},
}
return lowerkeys({ [unitName] = unitDef })
Code: Select all
local Plane = piece "Plane"
local Left_Flare = piece "Left_Flare"
local Right_Flare = piece "Right_Flare"
local Left_1stFlare = piece "Left_1stFlare"
local Left_2dFlare = piece "Left_2dFlare"
local Left_3dFlare = piece "Left_3dFlare"
local Right_1stFlare = piece "Right_1stFlare"
local Right_2dFlare = piece "Right_2dFlare"
local Right_3dFlare = piece "Right_3dFlare"
local Left_1stMissile = piece "Left_1stMissile"
local Left_2dMissile = piece "Left_2dMissile"
local Left_3dMissile = piece "Left_3dMissile"
local Right_1stMissile = piece "Right_1stMissile"
local Right_2dMissile = piece "Right_2dMissile"
local Right_3dMissile = piece "Right_3dMissile"
local SIG_AIM = 2
function script.Create()
end
function script.FireWeapon1(weaponID)
end
function script.QueryWeapon1() return Left_Flare end
function script.QueryWeapon2() return Right_Flare end
function script.QueryWeapon3() return Left_1stFlare end
function script.AimFromWeapon1() return Left_Flare end
function script.AimFromWeapon2() return Right_Flare end
function script.AimFromWeapon3() return Left_1stMissile end
function script.Killed(recentDamage, maxHealth)
return 0
end
Code: Select all
local weaponName = "NTMachineGun"
local weaponDef = {
name = "Machine Gun",
weaponType = [[Cannon]],
--damage
damage = {
default = 10,
},
Burst = 16,
salvoSize = 16,
BurstRate = 0.2,
salvoDelay = 0.2,
areaOfEffect = 8,
weaponVelocity = 300,
reloadtime = 0.2,
range = 350,
sprayAngle = 300,
tolerance = 8000,
lineOfSight = true,
turret = false,
craterMult = 0,
accuracy = 0.5,
rgbColor = [[0.5 0.5 0.5]],
size = 0.5,
stages = 20,
separation = 4,
highTrajectory = 2,
heightBoostFactor = 0,
}
return lowerkeys({[weaponName] = weaponDef})
Code: Select all
local weaponName="AtaMissile"
local weaponDef={
name="Air to Air Missile",
weaponType=[[MissileLauncher]],
Accuracy=2000,
--Physic/flight path
range=800,
reloadtime=10,
weaponVelocity=1000,
startVelocity=250,
weaponAcceleration=200,
flightTime=2.5,
dance=0,
wobble=0,
tolerance=16000,
tracks=true,
Turnrate=16000,
collideFriendly=true,
----APPEARANCE
model="AtAMissile.s3o",
smokeTrail=true,
--texture2="Smoketrail.tga",
----TARGETING
turret=false,
avoidFeature=false,
avoidFriendly=false,
--commandfire=true,
----DAMAGE
damage={
default=150,
},
areaOfEffect=100,
craterMult=0,
lineOfSight=true,
}
return lowerkeys ({[weaponName]=weaponDef})