Several issues with multiple weapons

Several issues with multiple weapons

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
peapod
Posts: 8
Joined: 09 Jun 2014, 16:49

Several issues with multiple weapons

Post by peapod »

I have got several issues with a unit that has got 3 weapons; 2 fixed Machineguns and one Missile that changes from where it's firing every shot.
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 })
Here is the Scriptfile:

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
I'm not sure if the Weapondefs are an issue, but here they are:

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})
Any help is appreciated!!
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Several issues with multiple weapons

Post by FLOZi »

Quick first question; Are you sure lua unit scripts are enabled? Requires a gadget.
peapod
Posts: 8
Joined: 09 Jun 2014, 16:49

Re: Several issues with multiple weapons

Post by peapod »

Unitscripts are enabled since they work at other units if that's what you mean.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Several issues with multiple weapons

Post by FLOZi »

Second quick question; pastebin.com your infolog.txt ?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Several issues with multiple weapons

Post by knorke »

Your script has no AimWeapon1,2,3() functions.
Even if you do not want to animate your weapons (usually turning towards target) it must still return true.
peapod
Posts: 8
Joined: 09 Jun 2014, 16:49

Re: Several issues with multiple weapons

Post by peapod »

Adding AimWeapon() fixed the positioning of the weapons and made all 3 of them fire, but
the weapons still aim at the target. What i want is basically that the Machineguns don't aim
at the enemy, but that the Plane aims at the enemy and the weapons fire without rotating.
(i also noticed a missing } in the Unitdef, fixed now)
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: Several issues with multiple weapons

Post by SinbadEV »

peapod wrote:Adding AimWeapon() fixed the positioning of the weapons and made all 3 of them fire, but
the weapons still aim at the target. What i want is basically that the Machineguns don't aim
at the enemy, but that the Plane aims at the enemy and the weapons fire without rotating.
(i also noticed a missing } in the Unitdef, fixed now)
Are you saying you don't want the machine guns to fire unless they are pointed at their target or for them to fire at their target no matter what they are aimed at?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Several issues with multiple weapons

Post by FLOZi »

I considered the AimWeapon but thought that if it were a problem, the MGs wouldn't fire either, how strange.

Anyway it sounds like you want the MG's to fire straight ahead in a fixed direction rather than aiming at units, there are a couple of ways to do it. The old way would be to emit the weapons from the script, the new way would be to control the projectiles themselves.

Neither are great solutions imo.
peapod
Posts: 8
Joined: 09 Jun 2014, 16:49

Re: Several issues with multiple weapons

Post by peapod »

Sorry for the confusion...
the way i originally wanted it to be is like FLOZi said, but now i think
i will have them aim in small cones which overlap slightly (using MainDir
and MaxDiff), but that wouldn't fix the issue of direct aiming.
LordMuffe
Posts: 286
Joined: 13 Mar 2005, 15:39

Re: Several issues with multiple weapons

Post by LordMuffe »

might be completely wrong here, since i don't know anything about .lua unit scripts, but isn't it wrong to just have one sig_aim for three weapons? in my .cob scripts for similar units (static weapons+non static weapons) there is still a unique sig_aim for every weapon (sig_aim1 = 2, sig_aim2 =4, sig_aim3 = 8). might be unnecessary, but thats just something that irritates me while looking at your script.

Another thing might be the used tolerance in your weapondef, 8000 seems a bit high. I use 800 for weapons which aim with the unit and it works.

Not sure if thats helpful. hope you can fix it :)
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Several issues with multiple weapons

Post by knorke »

try: fixedlauncher=true
might be completely wrong here, since i don't know anything about .lua unit scripts, but isn't it wrong to just have one sig_aim for three weapons?
Hm signals are not really needed for this (and not used in his script) so the one local SIG_AIM = 2 looks more like a leftover.
LordMuffe
Posts: 286
Joined: 13 Mar 2005, 15:39

Re: Several issues with multiple weapons

Post by LordMuffe »

would that mean that "function script.FireWeapon1(weaponID)" is useless, too?

And is fixedlauncher not only for missiles/torpedoes ?
Post Reply

Return to “Game Development”