[BUG?] ApplyIfSpellTargetKilled + Summon Weirdness

I'm trying to use <ApplyIfSpellTargetKilled> in conjunction with a Summon spell (like Touch of Entropy), except targeting Self, or FriendlyUnit.

 

After a lot of tweaking and trying different things, I've managed to get it to cast the summon spell when the unit dies... Only the summon always dies instantly! Regardless of the summon's HP (I tried summoning them at level 100: they summon with 600+ HP, then die instantly). Regardless of what creature I try to summon. Has anyone else run into this or have any ideas what could be causing it?

 

My chain of events is as follows

1. City Enchantment that triggers an autocast battle spell that is an AllFriendlyUnit spell (unfortunately there doesn't seem to be a way to target all units except sovereigns and champions...)

 

2. Autocast spell gives every friendly unit an enchantment that uses MeleeDefenseAppliesSpell to cast another spell whenever they are hit in melee (unfortunately there doesn't seem to be a way to trigger off of anything except melee attacks...)

 

3. Spell that gets cast on melee hits does 0 damage to the caster (otherwise it doesn't even seem to check the ApplyIfSpellTargetKilled condition), and casts a summon spell using the ApplyIfSpellTargetKilled tag.

 

So far I've tried toggling a bunch of different tags, trying different target call-outs for the last summon spell, applying damage or healing... Using the ApplyIfSpellTargetKilled in different modifiers or spells in this chain...

 

Below is the XML if interested:

 

Code: xml
  1. &lt;SpellDef InternalName="NC_UndyingLoyalty"&gt;
  2. &lt;DisplayName&gt;Undying Loyalty&lt;/DisplayName&gt;
  3. &lt;Description&gt;Places a curse on the city&#39;s defenders that does not allow them to die. If they are struck down in melee combat, they are reanimated where they once stood. Only when their skeletal remains are destroyed will they know peace.&lt;/Description&gt;
  4. &lt;Image&gt;S_BloodRage_Painting.png&lt;/Image&gt;
  5. &lt;IconFG&gt;S_BloogSigil_Icon.png&lt;/IconFG&gt;
  6. &lt;AutoUnlock&gt;1&lt;/AutoUnlock&gt;
  7. &lt;SpellBookSortCategory&gt;City&lt;/SpellBookSortCategory&gt;
  8. &lt;SpellBookSortSubCategory&gt;CityEnchantment&lt;/SpellBookSortSubCategory&gt;
  9. &lt;SpellType&gt;Strategic&lt;/SpellType&gt;
  10. &lt;SpellClass&gt;Defensive&lt;/SpellClass&gt;
  11. &lt;SpellSubClass&gt;Other&lt;/SpellSubClass&gt;
  12. &lt;SpellTargetType&gt;FriendlyCity&lt;/SpellTargetType&gt;
  13. &lt;Prereq&gt;
  14. &lt;Type&gt;AbilityBonusOption&lt;/Type&gt;
  15. &lt;Attribute&gt;NecromanticCompendium&lt;/Attribute&gt;
  16. &lt;Target&gt;Player&lt;/Target&gt;
  17. &lt;/Prereq&gt;
  18. &lt;!--
  19. &lt;Prereq&gt;
  20. &lt;Type&gt;AbilityBonusOption&lt;/Type&gt;
  21. &lt;Attribute&gt;NC_MasterNecromancy&lt;/Attribute&gt;
  22. &lt;/Prereq&gt;
  23. --&gt;
  24. &lt;SpellResourceCost&gt;
  25. &lt;Resource&gt;Mana&lt;/Resource&gt;
  26. &lt;Amount&gt;1&lt;/Amount&gt;
  27. &lt;/SpellResourceCost&gt;
  28. &lt;GameModifier&gt;
  29. &lt;ModType&gt;City&lt;/ModType&gt;
  30. &lt;Attribute&gt;BattleAutoCastSpell&lt;/Attribute&gt;
  31. &lt;StrVal&gt;NC_Militia_Curse_Autocast&lt;/StrVal&gt;
  32. &lt;Duration&gt;-1&lt;/Duration&gt;
  33. &lt;/GameModifier&gt;
  34. &lt;!--
  35. &lt;GameModifier&gt;
  36. &lt;ModType&gt;City&lt;/ModType&gt;
  37. &lt;Attribute&gt;BattleAutoCastSpell&lt;/Attribute&gt;
  38. &lt;StrVal&gt;NC_Archer_Curse_Autocast&lt;/StrVal&gt;
  39. &lt;Duration&gt;-1&lt;/Duration&gt;
  40. &lt;/GameModifier&gt;
  41. --&gt;
  42. &lt;AIData AIPersonality="AI_General"&gt;
  43. &lt;AIPriority&gt;10&lt;/AIPriority&gt;
  44. &lt;/AIData&gt;
  45. &lt;HitSoundFX&gt;Spell_Beserk_01&lt;/HitSoundFX&gt;
  46. &lt;SpellDefEffect&gt;
  47. &lt;EffectName&gt;T_Berserk_Particle&lt;/EffectName&gt;
  48. &lt;LocalPosition&gt;0,35,0&lt;/LocalPosition&gt;
  49. &lt;EffectScale&gt;0.7&lt;/EffectScale&gt;
  50. &lt;EffectDelay&gt;0&lt;/EffectDelay&gt;
  51. &lt;SnapToTerrain&gt;1&lt;/SnapToTerrain&gt;
  52. &lt;/SpellDefEffect&gt;
  53. &lt;/SpellDef&gt;
  54. &lt;SpellDef InternalName="NC_Militia_Curse_Autocast"&gt;
  55. &lt;DisplayName&gt;Undying Loyalty&lt;/DisplayName&gt;
  56. &lt;Description&gt;This unit has been cursed, and if slain will rise again and continue fighting.&lt;/Description&gt;
  57. &lt;Image&gt;T_Wither_Painting.png&lt;/Image&gt;
  58. &lt;IconFG&gt;T_Wither_Icon.png&lt;/IconFG&gt;
  59. &lt;CanStack&gt;0&lt;/CanStack&gt;
  60. &lt;SpellBookSortCategory&gt;Unit&lt;/SpellBookSortCategory&gt;
  61. &lt;SpellBookSortSubCategory&gt;Other&lt;/SpellBookSortSubCategory&gt;
  62. &lt;SpellType&gt;Tactical&lt;/SpellType&gt;
  63. &lt;SpellClass&gt;Defensive&lt;/SpellClass&gt;
  64. &lt;SpellSubClass&gt;Other&lt;/SpellSubClass&gt;
  65. &lt;SpellTargetType&gt;AllFriendlyUnits&lt;/SpellTargetType&gt;
  66. &lt;HideInHiergamenon&gt;1&lt;/HideInHiergamenon&gt;
  67. &lt;IsCastable&gt;0&lt;/IsCastable&gt;
  68. &lt;IsResistable&gt;0&lt;/IsResistable&gt;
  69. &lt;GameModifier&gt;
  70. &lt;ModType&gt;Unit&lt;/ModType&gt;
  71. &lt;Attribute&gt;MeleeDefenseAppliesSpell&lt;/Attribute&gt;
  72. &lt;StrVal&gt;NC_Militia_Curse_Effect&lt;/StrVal&gt;
  73. &lt;Duration&gt;-1&lt;/Duration&gt;
  74. &lt;/GameModifier&gt;
  75. &lt;AIData AIPersonality="AI_General"&gt;
  76. &lt;AIPriority&gt;10&lt;/AIPriority&gt;
  77. &lt;/AIData&gt;
  78. &lt;HitSoundFX&gt;Spell_Wither_01&lt;/HitSoundFX&gt;
  79. &lt;SpellDefEffect&gt;
  80. &lt;EffectName&gt;T_Wither_Particle&lt;/EffectName&gt;
  81. &lt;LocalPosition&gt;0,30,0&lt;/LocalPosition&gt;
  82. &lt;EffectScale&gt;.75&lt;/EffectScale&gt;
  83. &lt;EffectDelay&gt;0&lt;/EffectDelay&gt;
  84. &lt;SnapToTerrain&gt;1&lt;/SnapToTerrain&gt;
  85. &lt;/SpellDefEffect&gt;
  86. &lt;/SpellDef&gt;
  87. &lt;SpellDef InternalName="NC_Militia_Curse_Effect"&gt;
  88. &lt;DisplayName&gt;Undying Loyalty&lt;/DisplayName&gt;
  89. &lt;Image&gt;T_Wither_Painting.png&lt;/Image&gt;
  90. &lt;IconFG&gt;T_Wither_Icon.png&lt;/IconFG&gt;
  91. &lt;CanStack&gt;0&lt;/CanStack&gt;
  92. &lt;SpellBookSortCategory&gt;Unit&lt;/SpellBookSortCategory&gt;
  93. &lt;SpellBookSortSubCategory&gt;Other&lt;/SpellBookSortSubCategory&gt;
  94. &lt;SpellType&gt;Tactical&lt;/SpellType&gt;
  95. &lt;SpellClass&gt;Defensive&lt;/SpellClass&gt;
  96. &lt;SpellSubClass&gt;Other&lt;/SpellSubClass&gt;
  97. &lt;SpellTargetType&gt;Self&lt;/SpellTargetType&gt;
  98. &lt;HideInHiergamenon&gt;1&lt;/HideInHiergamenon&gt;
  99. &lt;IsCastable&gt;0&lt;/IsCastable&gt;
  100. &lt;IsResistable&gt;0&lt;/IsResistable&gt;
  101. &lt;Range&gt;0&lt;/Range&gt;
  102. &lt;IgnoreInvalidTargetsInRadius&gt;0&lt;/IgnoreInvalidTargetsInRadius&gt;
  103. &lt;GameModifier&gt;
  104. &lt;ModType&gt;Unit&lt;/ModType&gt;
  105. &lt;Attribute&gt;CurHealth&lt;/Attribute&gt;
  106. &lt;ApplyToCaster&gt;1&lt;/ApplyToCaster&gt;
  107. &lt;/GameModifier&gt;
  108. &lt;GameModifier&gt;
  109. &lt;ModType&gt;Unit&lt;/ModType&gt;
  110. &lt;Attribute&gt;SummonUnit&lt;/Attribute&gt;
  111. &lt;StrVal&gt;Skeletons&lt;/StrVal&gt;
  112. &lt;ApplyIfSpellTargetKilled&gt;1&lt;/ApplyIfSpellTargetKilled&gt;
  113. &lt;UnitClass&gt;NC_Militia_Skeleton&lt;/UnitClass&gt;
  114. &lt;!--
  115. &lt;Calculate InternalName="Calc" ValueOwner="CastingUnit"&gt;
  116. &lt;Expression&gt;&lt;![CDATA[[Unit_GetLevel]]]&gt;&lt;/Expression&gt;
  117. &lt;/Calculate&gt;
  118. &lt;Calculate InternalName="Value"&gt;
  119. &lt;Expression&gt;&lt;![CDATA[[Calc]]]&gt;&lt;/Expression&gt;
  120. &lt;/Calculate&gt;
  121. --&gt;
  122. &lt;Value&gt;100&lt;/Value&gt;
  123. &lt;Duration&gt;-1&lt;/Duration&gt;
  124. &lt;/GameModifier&gt;
  125. &lt;AIData AIPersonality="AI_General"&gt;
  126. &lt;AIPriority&gt;10&lt;/AIPriority&gt;
  127. &lt;/AIData&gt;
  128. &lt;HitSoundFX&gt;Spell_Wither_01&lt;/HitSoundFX&gt;
  129. &lt;SpellDefEffect&gt;
  130. &lt;EffectName&gt;T_Wither_Particle&lt;/EffectName&gt;
  131. &lt;LocalPosition&gt;0,30,0&lt;/LocalPosition&gt;
  132. &lt;EffectScale&gt;.75&lt;/EffectScale&gt;
  133. &lt;EffectDelay&gt;0&lt;/EffectDelay&gt;
  134. &lt;SnapToTerrain&gt;1&lt;/SnapToTerrain&gt;
  135. &lt;/SpellDefEffect&gt;
  136. &lt;/SpellDef&gt;

8,312 views 4 replies
Reply #1 Top

I haven't tested this in-game, but.

When a unit summons another unit in tactical battle, and the summoner dies, the summoned unit vanishes. That's probably what you are seeing. Unless I'm thoroughly mistaken, you can make it ignore this check by leaving out <Duration>-1</Duration> from the final summon. This should make the summon unrelated to the summoner.

Reply #2 Top

Note: -- I did not read all the code --

Under my understanding of summons, if the person who summoned the creature dies, then the summoned creature disappears. Is the creature you summoning coming from the character that just died, and if so, wouldn't that mean that the summons would just die next turn?

I think to circumvent this problem, try out using graveward within your spell. I recall doing this for a summons that I did and the summons stayed until the end of battle. Although, graveward implies that your troops do not actually die in battle anymore.

Reply #3 Top

Haha! You guys beat each other to it!

 

I didn't even think about that since I haven't really had a summoner die, but it makes sense that that would be a feature.

 

Heavenfall: I've tried removing the Duration tag and it didn't seem to help, but I'll mess around with it a little more and see if I can get some results.

 

parrotttmath:  I'll try incorporating graveward in there to keep it alive.

 

It's tough doing this stuff since the triggers are so limited (I wish there were more triggers!!!!), and the flags are all grouped together (AllFriendlyUnits... That's three conditions being checked in one! It would be much cleaner if there were <TargetType>{Unit,City,etc.}, <TargetAlignment>{Friendly,Enemy,Neutral,etc.}, <TargetScope>{Single,All,InRange,etc.}, <AddTargetSource>{Trained,Champion,Sovereign,etc}) Wishful thinking...

 

Anyways, thanks for the input guys! It is much appreciated!

Reply #4 Top

Duration trick didn't work (no summon appears)... Now to try to cast deathward on a summon from within its own summoning spell (considers hanging himself instead).