Setting the Mana Cost of an ability through trigger.

Hello, and greetings to all moderators. I am in need of your expertise.

I have set the mana cost of an ability in object editor to zero because I used a trigger instead to deduct 20% of the unit's mana per cast. However, I want to counter this spell with Mana Flare. But Mana Flare only deals damage to units that uses spells with mana cost in the object editor. Is there a way to work this out in the trigger. I am not used to using JASS script still learning from it. And I have only just began understanding and using Custom Script.

Please help, badly need it.

BTW, I have read some threads with regards to issues like this, however, the functions they used are available in 1.31 only.
 
Last edited:
Level 12
Joined
Jul 5, 2014
Messages
551
I'm not a moderator but my first guess would be using the "set mana" option. You can set it to the current mana of caster - the amount you want.

You can set up an if/then/else trigger to check if the caster has a minimum requirement.

  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to YourSpell
    • Actions
      • Unit - Set mana of (Casting unit) to ((Mana of (Casting unit)) - 20.00)%
 
Last edited:
I'm not a moderator but my first guess would be using the "set mana" option. You can set it to the current mana of caster - the amount you want.

You can set up an if/then/else trigger to check if the caster has a minimum requirement.

  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to YourSpell
    • Actions
      • Unit - Set mana of (Casting unit) to ((Mana of (Casting unit)) - 20.00)%

I've actually done the same trigger, the mana is set right (reduced by 20%) after casting, however mana flare doesn't deal damage or cast it's effect to the caster equal to the mana cost.
 
Level 12
Joined
Jul 5, 2014
Messages
551
I've actually done the same trigger, the mana is set right (reduced by 20%) after casting, however mana flare doesn't deal damage or cast it's effect to the caster equal to the mana cost.
By default, mana flare has damage cap. Did you push that up? I'm not sure about the context you're using the mana flare. If it's just the 20% mana thing, you can adjust the damage/mana rate. However, I think you should find out the settings that were used in the Sentinel Campaign. The naga summoners were doing something (maybe based on Channel) and when mana flare was used on them, it dealt like 300 damage.
 
I've actually tweaked Mana Flare, I've set the maximum damage to 99,999. I also know what the other data in the ability do. It's just that, when you set the mana cost of an ability to Zero (0) in the world editor, Mana Flare doesn't fire its effect and damage to the caster. I do have another idea how to damage the caster that uses 20% mana using mana flare, but I have to set a specific amount of mana cost into it, but I'm not going to do it just yet. Unless there is no solution. I still want to change the mana cost field data of the ability using a trigger may it be in custom script or GUI.
 
Level 12
Joined
Jul 5, 2014
Messages
551
I've actually tweaked Mana Flare, I've set the maximum damage to 99,999. I also know what the other data in the ability do. It's just that, when you set the mana cost of an ability to Zero (0) in the world editor, Mana Flare doesn't fire its effect and damage to the caster. I do have another idea how to damage the caster that uses 20% mana using mana flare, but I have to set a specific amount of mana cost into it, but I'm not going to do it just yet. Unless there is no solution. I still want to change the mana cost field data of the ability using a trigger may it be in custom script or GUI.
That's why I suggested the campaign. I don't know if the naga summoners actually use mana to get so much damage. If they don't, then there's a trigger solution Blizzard used.

The problem here is that 20% mana is not constant enough so you can't easily tell the mana flare how much damage it should do.
 
If you're on an older patch, your best bet is to probably trigger the mana flare effect yourself. For example, you'd want to check when your spell is cast, enumerate any units nearby that have the Mana Flare buff, and then create the lightning effect + apply damage.

I have a sample map below that is tweaked to work pretty accurately (using patch 1.26). I've edited the archmage's "summon water elemental" to cost 20% of the unit's max mana. The triggers are shown below, but I've left out the "TimedLightningBetweenUnits" trigger as it is pretty long:
  • Water Elemental Cast
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Summon Water Elemental
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Percentage mana of (Triggering unit)) Greater than or equal to 20.00
        • Then - Actions
          • Unit - Set mana of (Triggering unit) to ((Percentage mana of (Triggering unit)) - 20.00)%
        • Else - Actions
          • Unit - Pause (Triggering unit)
          • Unit - Order (Triggering unit) to Stop
          • Unit - Unpause (Triggering unit)
          • Custom script: call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 5, "|cffffcc00Not enough mana.|r")
          • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
          • Sound - Play Error <gen>
          • Custom script: endif
  • Water Elemental Effect
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Summon Water Elemental
    • Actions
      • Set CasterPosition = (Position of (Triggering unit))
      • Set ManaFlareGroup = (Units within 750.00 of CasterPosition matching ((((Matching unit) has buff Mana Flare) Equal to True) and (((Matching unit) belongs to an enemy of (Triggering player)) Equal to True)))
      • Custom script: set udg_ManaFlareUnit = FirstOfGroup(udg_ManaFlareGroup)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ManaFlareUnit Not equal to No unit
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) is A Hero) Equal to True
            • Then - Actions
              • Set ManaFlareDamage = (Min(((Max mana of (Triggering unit)) x 0.20), 50.00))
            • Else - Actions
              • Set ManaFlareDamage = (Min((((Max mana of (Triggering unit)) x 0.20) x 3.00), 90.00))
          • Unit - Cause ManaFlareUnit to damage (Triggering unit), dealing ManaFlareDamage damage of attack type Spells and damage type Magic
          • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Human\ManaFlare\ManaFlareBoltImpact.mdl
          • Special Effect - Destroy (Last created special effect)
          • Set TimedLightning_SourceUnit = ManaFlareUnit
          • Set TimedLightning_TargetUnit = (Triggering unit)
          • Set TimedLightning_LightningType = Mana Flare
          • Set TimedLightning_Duration = 1.00
          • Trigger - Run TimedLightningBetweenUnits <gen> (ignoring conditions)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_CasterPosition)
      • Custom script: call DestroyGroup(udg_ManaFlareGroup)
If you want to import it into your map:
  1. First, in the editor, go to File > Preferences > Checkmark "Automatically create unknown variables while pasting trigger data"
  2. Copy the Timed Lightning folder and paste it in your map
  3. Copy the Sample Spell and paste it in your map
  4. Change the water elemental triggers as needed, i.e. change the conditions and change the "ManaFlareDamage" as needed. It is currently using the default damage caps in the object editor
If you end up having multiple spells like this, it might make sense to extract the mana flare logic into its own trigger that you can run. Hopefully this helps you get a start on it!
 

Attachments

  • ManaFlare1.26.w3x
    22.1 KB · Views: 4
If you're on an older patch, your best bet is to probably trigger the mana flare effect yourself. For example, you'd want to check when your spell is cast, enumerate any units nearby that have the Mana Flare buff, and then create the lightning effect + apply damage.

I have a sample map below that is tweaked to work pretty accurately (using patch 1.26). I've edited the archmage's "summon water elemental" to cost 20% of the unit's max mana. The triggers are shown below, but I've left out the "TimedLightningBetweenUnits" trigger as it is pretty long:
  • Water Elemental Cast
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Summon Water Elemental
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Percentage mana of (Triggering unit)) Greater than or equal to 20.00
        • Then - Actions
          • Unit - Set mana of (Triggering unit) to ((Percentage mana of (Triggering unit)) - 20.00)%
        • Else - Actions
          • Unit - Pause (Triggering unit)
          • Unit - Order (Triggering unit) to Stop
          • Unit - Unpause (Triggering unit)
          • Custom script: call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 5, "|cffffcc00Not enough mana.|r")
          • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
          • Sound - Play Error <gen>
          • Custom script: endif
  • Water Elemental Effect
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Summon Water Elemental
    • Actions
      • Set CasterPosition = (Position of (Triggering unit))
      • Set ManaFlareGroup = (Units within 750.00 of CasterPosition matching ((((Matching unit) has buff Mana Flare) Equal to True) and (((Matching unit) belongs to an enemy of (Triggering player)) Equal to True)))
      • Custom script: set udg_ManaFlareUnit = FirstOfGroup(udg_ManaFlareGroup)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ManaFlareUnit Not equal to No unit
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) is A Hero) Equal to True
            • Then - Actions
              • Set ManaFlareDamage = (Min(((Max mana of (Triggering unit)) x 0.20), 50.00))
            • Else - Actions
              • Set ManaFlareDamage = (Min((((Max mana of (Triggering unit)) x 0.20) x 3.00), 90.00))
          • Unit - Cause ManaFlareUnit to damage (Triggering unit), dealing ManaFlareDamage damage of attack type Spells and damage type Magic
          • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Human\ManaFlare\ManaFlareBoltImpact.mdl
          • Special Effect - Destroy (Last created special effect)
          • Set TimedLightning_SourceUnit = ManaFlareUnit
          • Set TimedLightning_TargetUnit = (Triggering unit)
          • Set TimedLightning_LightningType = Mana Flare
          • Set TimedLightning_Duration = 1.00
          • Trigger - Run TimedLightningBetweenUnits <gen> (ignoring conditions)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_CasterPosition)
      • Custom script: call DestroyGroup(udg_ManaFlareGroup)
If you want to import it into your map:
  1. First, in the editor, go to File > Preferences > Checkmark "Automatically create unknown variables while pasting trigger data"
  2. Copy the Timed Lightning folder and paste it in your map
  3. Copy the Sample Spell and paste it in your map
  4. Change the water elemental triggers as needed, i.e. change the conditions and change the "ManaFlareDamage" as needed. It is currently using the default damage caps in the object editor
If you end up having multiple spells like this, it might make sense to extract the mana flare logic into its own trigger that you can run. Hopefully this helps you get a start on it!

Thank you so much for this Trigger, I could get lots of use for this. I might just use this trigger instead.
 
Top