Need help with creating a mobile AA gun unit

Trying to create a unit that deploys into an AA gun but I've been having some issues with crashes.

Information and discussion for custom maps and mods.
Post Reply
LeonardMT
Posts: 19
Joined: Tue Jan 12, 2021 2:38 am

Need help with creating a mobile AA gun unit

Post 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
Attachments
exceptionlog.txt
Log
(1.22 KiB) Downloaded 138 times

abcdefg30
Posts: 641
Joined: Mon Aug 18, 2014 6:00 pm

Re: Need help with creating a mobile AA gun unit

Post 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.)

LeonardMT
Posts: 19
Joined: Tue Jan 12, 2021 2:38 am

Re: Need help with creating a mobile AA gun unit

Post by LeonardMT »

Thank you

Post Reply