for Nr1:
I would create the building, define the (firing) primary weapon, say we call it BuildingWeapon01 and then copy the weapon's entry in the weapon.ini and create another weapon called BuildingWeapon02.
I would then remove the damage parameters, all the fx and so on so that the weapon actually "exists" but is not able to cause any pain to your enemies. Than I would copy and change the ranger's code for the building and define a primary AND a secondary weapon in the FactionBuilding.ini. So that the program is able to really switch the weapons.
I may show it with the code from the US Strategy Center:
Code:
FactionBuilding.ini:
Object AmericaStrategyCenter
DefaultConditionState
Model = ABStrategy_A8
WeaponLaunchBone = PRIMARY Muzzle
WeaponMuzzleFlash = PRIMARY MuzzleFX
WeaponRecoilBone = PRIMARY Barrel
WeaponLaunchBone = SECONDARY Muzzle
WeaponMuzzleFlash = SECONDARY MuzzleFX
WeaponRecoilBone = SECONDARY Barrel
Turret = Turret01
TurretPitch = TurretEL
HideSubObject = Chassis
End
WeaponSet
Conditions = None
Weapon = PRIMARY StrategyCenterGun
AutoChooseSources = PRIMARY NONE
Weapon = SECONDARY StrategyCenterGun2
AutoChooseSources = SECONDARY NONE
End
Weapon.ini:
;------------------------------------------------------------------------------
Weapon StrategyCenterGun
PrimaryDamage = 200.0
PrimaryDamageRadius = 25.0
ScatterRadius = 15.0
ScatterRadiusVsInfantry = 15.0 ;When this weapon is used against infantry, it can randomly miss by as much as this distance.
AttackRange = 400.0
MinimumAttackRange = 100.0
MinTargetPitch = 45 ; we may not target anything outside of this pitch range
MaxTargetPitch = 80 ; ditto
DamageType = EXPLOSION
DeathType = EXPLODED
WeaponSpeed = 150 ; dist/sec
WeaponRecoil = 5 ; angle to deflect the model when firing
ProjectileObject = StrategyCenterArtilleryShell
FireFX = WeaponFX_GenericTankGunNoTracer
ProjectileDetonationFX = FX_ArtilleryBarrage
FireSound = StrategyCenter_ArtilleryRound
RadiusDamageAffects = ALLIES ENEMIES NEUTRALS
DelayBetweenShots = 7000 ; time between shots, msec
ShotsPerBarrel = 1 ; By default, shoot one shot per barrel
ClipSize = 0 ; how many shots in a Clip (0 == infinite)
WeaponBonus = PLAYER_UPGRADE DAMAGE 125% ; UraniumShells
; note, these only apply to units that aren't the explicit target
; (ie, units that just happen to "get in the way"... projectiles
; always collide with the Designated Target, regardless of these flags
ProjectileCollidesWith = STRUCTURES WALLS
End
;------------------------------------------------------------------------------
Weapon StrategyCenterGun2
PrimaryDamage = 0.0
PrimaryDamageRadius = 0.0
ScatterRadius = 0.0
ScatterRadiusVsInfantry = 0.0 ;When this weapon is used against infantry, it can randomly miss by as much as this distance.
AttackRange = 0.0
MinimumAttackRange = 0.0
MinTargetPitch = 45 ; we may not target anything outside of this pitch range
MaxTargetPitch = 80 ; ditto
DamageType = EXPLOSION
DeathType = EXPLODED
WeaponSpeed = 150 ; dist/sec
WeaponRecoil = 5 ; angle to deflect the model when firing
;ProjectileObject = StrategyCenterArtilleryShell
;FireFX = WeaponFX_GenericTankGunNoTracer
;ProjectileDetonationFX = FX_ArtilleryBarrage
;FireSound = StrategyCenter_ArtilleryRound
RadiusDamageAffects = ALLIES ENEMIES NEUTRALS
DelayBetweenShots = 7000 ; time between shots, msec
ShotsPerBarrel = 1 ; By default, shoot one shot per barrel
ClipSize = 0 ; how many shots in a Clip (0 == infinite)
;WeaponBonus = PLAYER_UPGRADE DAMAGE 125% ; UraniumShells
; note, these only apply to units that aren't the explicit target
; (ie, units that just happen to "get in the way"... projectiles
; always collide with the Designated Target, regardless of these flags
ProjectileCollidesWith = STRUCTURES WALLS
End
Then you need to add the buttons to your commandset.ini and commandbutton.ini.
You may try to disable the damage parameters also with an ";" but I don't now whether that is possible. If it crashes look at the "ReleaseCrashInfo.txt". Simply search for it using the search tool of windows. It often tells you where to look for INI errors.
for Nr2:
again take a look at the Strategy Center's code:
Code:
ArmorSet
Conditions = None
Armor = StructureArmor
DamageFX = StructureDamageFXNoShake
End
you see the line Conditions = None? Copy the code and insert FIRING_A so that when the building fires with its primary weapon it has another Armorset:
Code:
ArmorSet
Conditions = FIRING_A
Armor = StructureArmor_FIRING
DamageFX = StructureDamageFXNoShake
End
ArmorSet
Conditions = None
Armor = StructureArmor
DamageFX = StructureDamageFXNoShake
End
You need to define a new Armor in the armor.ini called StructureArmor_FIRING or so and change the parameters.
I hope my tips help you but I must say I did not test them so good luck!