Ok, after an hour or so of tweaking:
I can tell him to fire the flashbang, and then I get the targeting recticle, and I tell him to fire at the ground or something. He runs up to being in range, but once he gets there he runs in place while firing and keeps running in place until it's reloaded, fires, etc. I want it to be that once he fires he goes back to normal weapons, like the comanche's rocket pods. What's worse, after he's fired his flashbang, the the next ranger I build is in flashbang mode too. I could just leave the flasbang code as it is, but when he switches back to primary mode he wont use his secondary(long range version of primary,) he just runs up to the range of his primary and fires it.
Code:
FactionUnit.ini:
WeaponSet
Conditions = None
Weapon = PRIMARY RangerAdvancedCombatRifleShortRange
Weapon = SECONDARY RangerAdvancedCombatRifleLongRange
End
WeaponSet
Conditions = PLAYER_UPGRADE
Weapon = PRIMARY RangerAdvancedCombatRifle
Weapon = SECONDARY RangerAdvancedCombatRifleLongRange
Weapon = TERTIARY RangerFlashBangGrenadeWeapon
AutoChooseSources = PRIMARY FROM_SCRIPT FROM_AI
AutoChooseSources = SECONDARY FROM_SCRIPT FROM_AI
AutoChooseSources = TERTIARY NONE
Weapon.ini:
Weapon RangerFlashBangGrenadeWeapon
PrimaryDamage = 150.0
PrimaryDamageRadius = 10.0
SecondaryDamage = 100.0
SecondaryDamageRadius = 40.0
AttackRange = 150.0
MinimumAttackRange = 20.0
DamageType = EXPLOSION
DeathType = NORMAL
WeaponSpeed = 120
ProjectileObject = RangerFlashBangGrenade
RadiusDamageAffects = ALLIES ENEMIES NEUTRALS
FireSound = RangerFlashBangWeapon
ScatterRadius = 4 ; This weapon will scatter somewhere within a circle of this radius, instead of hitting someone directly
DelayBetweenShots = 0 ; time between shots, msec
ClipSize = 1 ; how many shots in a Clip (0 == infinite)
ClipReloadTime = 10000 ; how long to reload a Clip, msec
AutoReloadsClip = Yes
ProjectileDetonationFX = WeaponFX_GenericTankShellDetonation
ProjectileCollidesWith = STRUCTURES WALLS
AllowAttackGarrisonedBldgs = Yes
CommandButton.ini:
CommandButton Command_AmericaRangerSwitchToFlagBangGrenades
(yes, "flagbang" is a typo in the inis but it's the same in both commandset and commandbutton)
Command = FIRE_WEAPON
WeaponSlot = TERTIARY
Options = CHECK_LIKE OK_FOR_MULTI_SELECT NEED_UPGRADE NEED_TARGET_POS
Upgrade = Upgrade_AmericaRangerFlashBangGrenade
TextLabel = CONTROLBAR:FlashBangGrenadeMode
ButtonImage = SSFlashbang
ButtonBorderType = ACTION
DescriptLabel = CONTROLBAR:ToolTipSwitchToUSAFlashBang
RadiusCursorType = ATTACK_SCATTER_AREA
InvalidCursorName = GenericInvalid
End