Page 1 of 1

Need help with creating a mobile AA gun unit

Posted: Sun Aug 15, 2021 7:43 pm
by LeonardMT
Here's the code:

Code: Select all

MAGUN:
	Inherits: ^Vehicle
	Inherits@selection: ^SelectableSupportUnit
	Buildable:
		Queue: Vehicle
		BuildPaletteOrder: 210
		Prerequisites: dome, ~techlevel.medium
		BuildDurationModifier: 50
		Description: Deploys into an AA gun.
	Valued:
		Cost: 1350
	Tooltip:
		Name: Mobile AA Gun
	Selectable:
		DecorationBounds: 42,42
	SelectionDecorations:
	Health:
		HP: 11000
	Armor:
		Type: Light
	Mobile:
		Speed: 128
	RevealsShroud:
		Range: 4c0
	Transforms:
		IntoActor: magun.deployed
		Offset: 0,0
	SpawnActorOnDeath:
		Actor: magun.deployed

MAGUN.Deployed: 
	Inherits: ^Defense
	Inherits@IDISABLE: ^DisableOnLowPowerOrPowerDown
	Inherits@AUTOTARGET: ^AutoTargetAir
	Buildable:
		Queue: Defense
		BuildPaletteOrder: 90
		Prerequisites: ~disabled
		Description: Anti-Air base defense.\nRequires power to operate.\n  Strong vs Aircraft\n  Weak vs Ground units
	Valued:
		Cost: 800
	Tooltip:
		Name: AA Gun
	Selectable:
		Bounds: 24,24
		DecorationBounds: 24,32,0,-4
	SelectionDecorations:
	Health:
		HP: 40000
	Armor:
		Type: Heavy
	RevealsShroud:
		MinRange: 5c0
		Range: 6c0
		RevealGeneratedShroud: False
	RevealsShroud@GAPGEN:
		Range: 5c0
	WithBuildingBib:
		HasMinibib: true
	Turreted:
		TurnSpeed: 60
		InitialFacing: 832
		RealignDelay: -1
		RequiresCondition: !build-incomplete
	WithSpriteTurret:
		RequiresCondition: !build-incomplete
		Recoils: false
	Armament:
		Weapon: ZSU-23
		LocalOffset: 520,100,450, 520,-150,450
		MuzzleSequence: muzzle
	AttackTurreted:
		RequiresCondition: !build-incomplete
		PauseOnCondition: disabled
	WithMuzzleOverlay:
	RenderRangeCircle:
		RangeCircleType: aa
	Power:
		Amount: -50
	ClassicFacingBodyOrientation:
	Transforms:
		IntoActor: magun
		Offset: 0,0
Sequences:

magun.deployed:
	idle: gunmake # Empty first frame (agunmake has no empty frames). We need WithSpriteBody for the make anim, and WSB needs at least a placeholder default sequence to work
	make: agunmake
		Length: *
		Offset: 0,-13
	turret:
		Facings: 32
		UseClassicFacings: True
		Offset: 0,-13
	recoil:
		Start: 32
		Facings: 32
		UseClassicFacings: True
		Offset: 0,-13
	damaged-turret:
		Start: 64
		Facings: 32
		UseClassicFacings: True
		Offset: 0,-13
	damaged-recoil:
		Start: 96
		Facings: 32
		UseClassicFacings: True
		Offset: 0,-13
	muzzle: gunfire2
		Start: 1
		Length: 4
	bib: mbAGUN
		Length: *
		UseTilesetExtension: true
	icon: agunicon

magun:
	idle: truk
		Facings: 32
		UseClassicFacings: True
	icon: agunicon

Re: Need help with creating a mobile AA gun unit

Posted: Mon Aug 16, 2021 6:05 pm
by abcdefg30
If you want to use ClassicFacingBodyOrientation, you have to remove BodyOrientation (inherited from ^Defense) like the following:

Code: Select all

	-BodyOrientation:
	ClassicFacingBodyOrientation:
(See https://github.com/OpenRA/OpenRA/blob/f ... #L634-L635 for another example.)

Re: Need help with creating a mobile AA gun unit

Posted: Tue Aug 17, 2021 8:20 pm
by LeonardMT
Thank you