Posted: Thu Aug 25, 2011 7:18 pm Post subject:
Creating an AA-only unit
Creating an anti-air only unit in TS isn't as simple as one might think, since there are a few issues that come along with it. These include being able to force-fire the AA weapon on the ground, and the AA-only unit targetting enemy ground units, even if it can't fire at them. This tutorial covers how to avoid these issues.
; The real weapon
[AAMissile]
Damage=30
ROF=60
Range=15
Projectile=AAHeatSeeker ; The projectile must have AA=yes, and AG=no.
Speed=60
Warhead=AAMissileWH ; Special warhead to prevent force-fire bug
Report=SAMSHOT1
; Real weapon warhead
[AAMissileWH]
Spread=3
Verses=0%,100%,100%,100%,100% ; The first one must be 0% to prevent force-fire bug
InfDeath=3
AnimList=XGRYSML1,XGRYSML2,EXPLOSML
ProneDamage=100%
; The fake weapon
[AAMissileFake]
Damage=0 ; Does not deal damage
ROF=60 ; Same ROF as real weapon to not mess up reload sequence
Range=15 ; Same range as real weapon to make sure real weapon is not fired on ground
MinimumRange=20 ; THIS IS VERY IMPORTANT. Must be higher than Range to make this work.
Projectile=Invisible ; Use projectile that has AA=no, and AG=yes.
Speed=100
Warhead=AAMissileFakeWH
; Fake weapon warhead
[AAMissileFakeWH]
Spread=0
Verses=100%,100%,100%,100%,100% ; Make sure all verses are 100%, so the real weapon is not fired at ground targets.
InfDeath=0
ProneDamage=100%
Few things to note. Since we prevented the force-fire on ground bug by giving the real weapon 0% verses for armor type none, no aircraft or any other air unit can have Armor=none. Otherwise the AA unit won't be able to shoot at them. By default none of the aircraft have Armor=none, and I don't see this really being a problem. Make sure the primary weapon is the real weapon, and the secondary is the fake one. Other way around the unit won't be able to properly shoot at air units.
With this code the unit will automatically target and shoot at enemy air units, and never automatically target ground units. If the unit is fired upon by an enemy ground unit, or manually ordered to attack an enemy ground unit, it will walk towards the enemy, but won't fire either weapon. Wish there was a way to make the unit just stand still or back away if it gets fired upon, but I couldn't find a way to do this. Still, I think this problem is alot smaller than having the AA-only unit constantly targetting ground units, thus ignoring potential air threats unless manually ordered to fire at them.
After some testing I noticed that the MinimumRange has to be bigger than just Range + 1, since the AA-only unit could still target certain buildings with the fake weapon. I played it safe and made it Range + 5, and now the problem is gone. I've updated the original post with this info. _________________ QUICK_EDIT
btw, something you can experiment with is the key SAM=yes. IIRC caused this key the building to forget the last fired target after each shot, thus allowing it to target always the biggest threat. Next to the intended feature of being able to only attack aircrafttypes. _________________ SHP Artist of Twisted Insurrection: Nod buildings
Won't think make the unit fire the primary on its way to the range of the secondary weapon, which is 0? So if you targetted a ground unit, it would walk towards it while firing primary? But if the primary has AG=no, dunno what would happen. Guess I'll just have to test. Though with MinimumRange being greater than Range the unit behaves as if the weapon range was 0, it walks next to the target and never fires the weapon.
Something interesting I discovered is that the primary weapon range and minimumrange override the secondary weapon range and minimumrange. That's why making the fake weapon primary and the real weapon secondary won't work, cause the fake weapons minimunrange will screw up the real weapons targetting.
Lin Kuei Ominae wrote:
btw, something you can experiment with is the key SAM=yes. IIRC caused this key the building to forget the last fired target after each shot, thus allowing it to target always the biggest threat. Next to the intended feature of being able to only attack aircrafttypes.
Hmmm, one more hidden key not listed by westwood? According to ModEnc it only affects BuildingTypes and doesn't target jumpjets? _________________ QUICK_EDIT
At least I've never seen the SAM key used outside BuildingTypes. True, it doesn't target jumpjet units, and FinalSun tends to freeze when trying to place such building (at least it did for me). _________________
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum