HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to make my spells also burn mana

12-22-2011, 01:34 AM#1
Exoudar
Hello there,

I am trying to make a tower that has a special; enemy units who got hit by its spells also burn 1 point of mana.

I tried
Trigger:
Spell burns mana
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Chain Lightning (Spell Tower)
Collapse Actions
Unit - Set mana of (Target unit of ability being cast) to ((Mana of (Target unit of ability being cast)) - 1.00)

However it only burn mana from the first target.

It doesnt need to be something like chain mana burn, just any spell , breath of fire for example but any enemy unit who got hit will lose 1 mana.


Any help ?
01-03-2012, 08:53 AM#2
Anitarf
There is no simple way of doing this since there is no direct way to detect other targets that are hit by an area or chain spell. I can think of two ways this could be done indirectly:
  • Detect the damage dealt by the spell. This way, you can detect every target that gets hit rather than just the first. Since there is no generic unit takes damage event, you will need a damage detection system that simulates such a generic event by using a specific unit event for each unit.
    You will also need a way to tell if the damage was caused by your spell or something else. You could add the caster of the spell to a unit group when the spell is cast and remove him from that group after a short interval, that way when you detect damage you can check if the damage source is in your group, if it is then the damage was dealt by your spell.
    If you do this, you have to make sure that the time interval is long enough for the spell to damage all its targets, but short enough that the caster is not able to deal additional damage in that time with attacks or other spells.
  • Perhaps a better method would be to trigger your spell entirely. Instead of relying on an ingame chain spell, write a trigger that simulates it, same for line and area spells. If you have some experience, triggering such spells isn't really that hard and the end result is much more robust than the one you get with the method suggested above.