Get ranged unit to use melee on "melee"

Skajaquada

Crazy Engineer
Joined
Mar 4, 2007
Messages
134
It's simple enough what I'm going for. I want a unit to engage in melee, that is run forward and start hitting, when it's attacking one hex away. Then when it's bombarding, that is when the red arrow appear and you're attacking over multiple hexes, that it stands still and fires. I'm aware you need to click the attack-icon for it to use it's melee-attack one hex away too.

This is what my unit looks like in the unitmembers-file:

Code:
 <UnitMemberArtInfo>
    <Type>ART_DEF_UNIT_MEMBER_HELLFIRE_DREAD</Type>
    <fScale>6</fScale>
    <Granny>Hellfire_dread.fxsxml</Granny>
	  <Combat>
		  <Defaults>ART_DEF_TEMPLATE_SOLDIER</Defaults>
		  <bReformBeforeCombat>1</bReformBeforeCombat>
		  <bHasLongRangedAttack>1</bHasLongRangedAttack>
		  <Weapon>
			  <fHitEffectScale>0.2</fHitEffectScale>
			  <bContinuousFire>1</bContinuousFire>
			  <fHitRadius>15.0</fHitRadius>
			  <fVisKillStrengthMin>1.0</fVisKillStrengthMin>
			  <fVisKillStrengthMax>1.0</fVisKillStrengthMax>
			  <WeaponTypeTag>BULLETHC</WeaponTypeTag>
			  <WeaponTypeSoundOverrideTag>BULLETHC</WeaponTypeSoundOverrideTag>
			  <HitEffect>ART_DEF_VEFFECT_GUNSHIP_MACHINE_GUN_HIT_$(TERRAIN)</HitEffect>
		  </Weapon>
		  <Weapon>
			  <WeaponTypeTag>BLUNT</WeaponTypeTag>
			  <WeaponTypeSoundOverrideTag>BLUNT</WeaponTypeSoundOverrideTag>
		  </Weapon>
	  </Combat>
    <Domain>Land</Domain>
    <MaterialTypeTag>CLOTH</MaterialTypeTag>
    <MaterialTypeSoundOverrideTag>FLESH</MaterialTypeSoundOverrideTag>
  </UnitMemberArtInfo>

Then I've defined all the effects and ec-values in the FTXML to use a fire-animation and effects on bombard and city-attack, then punch on the normal attacks.

I'm guessing from looking at the original units that bHasShortRangedAttack means the unit stands still doing the attack-animation when you're attacking one hex away. The Infantry for example have this, but no bHasLongRangedAttack which the Catapult or Archer have got, so I think that means it've got a bombard-attack. All units which have a bHasLongRangedAttack have also got a bHasShortRangedAttack. It also appear to have a real function as removing bHasLongRangedAttack while still having a range-value in the unit-xml causes the unit to walk the entire bombard-stretch and sucker-punch the target :)

There's no defining attribute for melee-units though. They all simply use the warrior-template, which looks like this in unitmembertemplates-file:

Code:
  <UnitMemberArtInfo>
    <Type>ART_DEF_TEMPLATE_WARRIOR</Type>
    <Combat>
      <Defaults>ART_DEF_TEMPLATE_SOLDIER</Defaults>
      <Weapon>
        <WeaponTypeTag>BLUNT</WeaponTypeTag>
        <WeaponTypeSoundOverrideTag>BLUNT</WeaponTypeSoundOverrideTag>
      </Weapon>
      <Weapon>
        <Usage>Vs_City ShortRange</Usage>
        <fVisKillStrengthMin>10.0</fVisKillStrengthMin>
        <fVisKillStrengthMax>20.0</fVisKillStrengthMax>
        <WeaponTypeTag>FLAMING_ARROW</WeaponTypeTag>
      </Weapon>
    </Combat>
  </UnitMemberArtInfo>

The result I'm getting is a unit which uses the ranged-attack on bombard and when it attacks cities. However when it attacks a unit one hex away, with the attack-button, it just stands still doing the melee-animation. The last thing isn't really important, I've simply linked the melee-animation to the normal attack and my bombard-animation to the bombard- and city-attack. The problem is that the model isn't engaging in melee, or walks up to the target.

Then I was thinking perhaps through the magic of the FTXML-file I could define a action-trigger action="2" that would correspond to the second attack, the melee-attack. Then link it to all the ec-values for normal attacks. I had one problem before where no hit-effects would display if I didn't define action-triggers for the bombard and city-attack ec-values with action="1". Then in Nexus it says "Attack1" under ActionCode, where ActionCodeValue is 1. Though it didn't fix the problem it wouldn't be far-fetched to assume the FTXML-file have got something todo with linking the weapon-sets wit the ec-values (1100, 1180, 1140 etc.).

One thing to note is that if I set action="1" on all the normal attacks it does indeed show the hit-effect of the range-weapon. It was a little confusing perhaps that the unit used the melee-animation (I mean I couldn't be 100% sure he wasn't accidently using a stationary-melee) but this proves the unit is indeed unable to use the melee-weapon attack when the unit have got a ranged weapon. Also changing the order of the weapon-attributes made the hit-effects disappear, though the unit didn't start to engage in melee, it seem bHasLongRangedAttack completes locks out melee-behavior. Furthermore changing setting action="2" for the bombard ec-values when the weapon-attributes where switched didn't make the hit-effects appear, which is strange but probably unrelated to this.

I've also been playing around with the Usage-attribute hoping "<Usage>Vs_City LongRange</Usage>" could somehow lock the ranged attack to city and long-range, though I think it only comes into play when a unit have got multiple range-attacks looking in the unitmember-file. Though that warrior-template seem to have it defined as such with only one range-attack.

Anyway, anyone got any idea or suggestion where to look? I originally intended to ask what the bHasShortRangedAttack could be but I figured that out as I was typing. Now I'm stuck again. It really seem strange if a unit like this wouldn't work, though the Archer for example isn't drawing up it's knife in melee but fires the arrow while they're being hit in the face, so I'm a little afraid this is indeed not possible.
 
Back
Top Bottom