• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Destroying mana percent of current mana?

Status
Not open for further replies.
Level 25
Joined
Mar 23, 2008
Messages
1,813
Hi.
I have a spell like this:
The Faceless Being bursts out a wave of energy in an area, destroying mana and exploding corpses, dealing damage to all enemies inside the target area. Damage per corpse 20xlevel. Current mana burned (%) 5xlevel.
My trigger looks like this, and i need someone to check if this will explode corpses and deal damage in area around the exploded corpse. I also need someone to tell me how i make a trigger that removes 5%xlevel of the current mana (not the maximum mana). This is how the trigger looks now, without any manaburn, only the action to pick the units that should lose mana.
  • Overdrive
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Overdrive
    • Actions
      • Set OverDrivePoint = (Target point of ability being cast)
      • Unit Group - Pick every unit in (Units within ((Real((Level of Overdrive for (Casting unit)))) x 50.00) of OverDrivePoint matching ((((Picked unit) is A structure) Equal to False) and (((Picked player) is an enemy of (Owner of (Casting unit))) Equal to True))) and do (Actions)
        • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked unit) is dead) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in (Units within 250.00 of (Position of (Picked unit)) matching ((((Picked unit) is alive) Equal to True) and ((((Triggering unit) is A structure) Equal to False) and (((Picked unit) belongs to an enemy of (Owner of (Casting unit))) Equal to True)))) and do (Actions)
            • Loop - Actions
              • Unit - Cause (Casting unit) to damage (Picked unit), dealing ((Real((Level of Overdrive for (Casting unit)))) x 20.00) damage of attack type Spells and damage type Normal
          • Unit - Explode (Picked unit)
        • Else - Actions
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
Your unit group function is wrong; it should be Matching unit instead of Picked unit. The condition for checking the unit is owned by an enemy player is also wrong. You should also use Triggering unit instead of casting unit since it's faster.
Example for first one:
  • Unit Group - Pick every unit in (Units within ((Real((Level of Overdrive for (Casting unit)))) x 50.00) of OverDrivePoint matching ((((Matching unit) is A structure) Equal to False) and ((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True
    • and do (Actions)
For this case, you could also use Triggering player instead of Owner of (Triggering unit) since it refers to the same thing and is a bit faster.

Mana burn could be done like this:
  • Unit - Set mana of (Picked unit) to ((Percentage mana of (Picked unit)) - (5.00 x (Real((Level of Overdrive for (Triggering unit))))))%
There are location leaks. Check out Things That Leak to deal with them if you don't know how to.

It might be better to use a global variable for Triggering unit since you will refer to it a lot in this trigger.
 
Level 25
Joined
Mar 23, 2008
Messages
1,813
Thanks for pointing that out, about the matching unit, forgot that. And thanks for the mana burn, will try it out. And i'm aware of the leaks, will take care of them, wanted to finish the trigger first.

Edit: The mana didn't work. nothing happens.
  • Unit - Set mana of (Picked unit) to ((Percentage mana of (Picked unit)) - (5.00 x (Real((Level of Overdrive for (Triggering unit))))))%
Isn't this correct?
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
It looks like it should work. You are using Percentages, right? I'll test this too to check if it works.
Edit 1: It works fine for me when I tested this with Mana Burn.
  • Unit - Set mana of (Target unit of ability being cast) to ((Percentage mana of (Target unit of ability being cast)) - (5.00 x (Real((Level of Mana Burn for (Triggering unit))))))%
And you're using the function Unit - Set Mana (To Percentage), not Unit - Set Mana (To Value)?

Edit 2: It seems I might have misunderstood you. Don't pay attention to anything I said so far about your mana burn.
 
Level 25
Joined
Mar 23, 2008
Messages
1,813
Aww, yea i used the percentage, not value, but i changed it now, still doesn't work. Is it still something wrong with my unit group condition trigger maybe?
Looks like this now:
  • Overdrive
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Overdrive
    • Actions
      • Set OverDrivePoint = (Target point of ability being cast)
      • Unit Group - Pick every unit in (Units within ((Real((Level of Overdrive for (Triggering unit)))) x 50.00) of OverDrivePoint matching ((((Matching unit) is A structure) Equal to False) and (((Matching player) is an enemy of (Owner of (Triggering unit))) Equal to True))) and do (Actions)
        • Loop - Actions
          • Unit - Set mana of (Picked unit) to ((Percentage mana of (Picked unit)) - (5.00 x (Real((Level of Overdrive for (Triggering unit))))))
Edit: Oh, i think i found out what was the problem.
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
  • (((Matching player) is an enemy of (Owner of (Triggering unit))) Equal to True)))
Matching player doesn't refer to the owner of the matching unit. It would be better if you use
  • ((Matching unit) belongs to an enemy of (Owner of (Triggering unit)
Anyway, I gave you wrong calculations for the mana burn.
This should work:
  • Set MyTarget = (Picked unit)
  • Set CurrentMana = (Mana of MyTarget)
  • Set DepleteMana = (CurrentMana x (0.05 x (Real((Level of Overdrive for (Triggering unit))))))
  • Unit - Set mana of (MyTarget) to (CurrentMana - DepleteMana)
I only used variables to save my eyes.
 
Level 25
Joined
Mar 23, 2008
Messages
1,813
Yea found out that i forgot to change the matching player condition, and yes, those calulations was wrong, it burnt a hell of a lot mana :p Trying that way now.
This didnt work:
  • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - ((Mana of (Picked unit)) x (5.00 x (Real((Level of Overdrive for (Triggering unit)))))))
Hope you got some patient with me:hohum:
 
Level 11
Joined
Jan 25, 2009
Messages
572
Offtopic, You leak both the Unit Groups. Fix that would improve you'r trigger =)

EDIT: Also now i see a big problem. Some actions isn't in the Loops of the Unit groups. That could be a problem.

EDIT2: You see, if you put the If the else handle into the first unit group the spell will work more properly.

EDIT3: I will create this for you. I will attach the test map into the "EDIT4" when i'm done. This will not take long time xD

EDIT4: Here's the map, This should work. If you want some nice SFX, just tell me because i'm epic at SFX ;) Map = View attachment Overdrive v. 1.0.w3x

EDIT5: Here's the whole trigger:
  • Overdrive
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Overdrive
    • Actions
      • Set O_Group = (Units within (50.00 x (Real((Level of Overdrive for (Triggering unit))))) of (Center of (Playable map area)) matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is Magic Immune) Equal to False) and (((Matching unit) belongs to
      • Unit Group - Pick every unit in O_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • Set O_ManaToBurn = ((Percentage mana of (Picked unit)) - (5.00 x (Real((Level of Overdrive for (Triggering unit))))))
              • Set O_Damage = (20.00 x (Real((Level of Overdrive for (Triggering unit)))))
              • Unit - Set mana of (Picked unit) to O_ManaToBurn%
              • Unit - Cause (Triggering unit) to damage (Picked unit), dealing O_Damage damage of attack type Spells and damage type Normal
            • Else - Actions
              • Unit - Explode (Picked unit)
      • Custom script: call DestroyGroup (udg_O_Group)
EDIT6: Hehe many Edits but now i see that i've done something wrong because in the unit group change the location to a location variable and destroy it using the custom script "call RemoveLocation (udg_YourLocvariable_name)"
 
Last edited:
Level 25
Joined
Mar 23, 2008
Messages
1,813
  • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - ((Mana of (Picked unit)) x (0.05 x (Real((Level of Overdrive for (Triggering unit)))))))
It's 0.05, not 5. :p
Oh, i see. :)

Offtopic, You leak both the Unit Groups. Fix that would improve you'r trigger =)

EDIT: Also now i see a big problem. Some actions isn't in the Loops of the Unit groups. That could be a problem.

EDIT2: You see, if you put the If the else handle into the first unit group the spell will work more properly.

EDIT3: I will create this for you. I will attach the test map into the "EDIT4" when i'm done. This will not take long time xD
I am aware of the leaks in the trigger, as stated earlier.
1/2: I can't have them in the same loop since one of the loops is for the units alive, that should have their mana destroyed, and the other loop is for the dead units, that should explode, i don't want the living ones to explode.
3: Thanks for your effort but i got it all working now :)
 
Level 11
Joined
Jan 25, 2009
Messages
572
Thats the thing! You'rs is using two unit groups and that means that urs is doubbeling the RAM memory used for that spell.
And i think i have a bit more knowledge in triggering that you have ;) If you check my spell called Charpen Shuriken you can see my knowledge ;)
 
Level 25
Joined
Mar 23, 2008
Messages
1,813
So that "if unit is alive do this" "else" explode them, will it trigger only on corpses if i use that? In that case, i can agree with you that yours is better.
And this is the whole trigger done, (except the leaks)
  • Overdrive
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Overdrive
    • Actions
      • Set OverDrivePoint = (Target point of ability being cast)
      • Special Effect - Create a special effect at OverDrivePoint using Objects\Spawnmodels\Undead\UDeathMedium\UDeath.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit Group - Pick every unit in (Units within ((Real((Level of Overdrive for (Triggering unit)))) x 50.00) of OverDrivePoint matching ((((Matching unit) is A structure) Equal to False) and (((Owner of (Matching unit)) is an enemy of (Owner of (Triggering unit))) Equal to True))) and do (Actions)
        • Loop - Actions
          • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - ((Mana of (Picked unit)) x (0.05 x (Real((Level of Overdrive for (Triggering unit)))))))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is dead) Equal to True
            • Then - Actions
              • Unit - Remove (Picked unit) from the game
              • Special Effect - Create a special effect at (Position of (Picked unit)) using Objects\Spawnmodels\NightElf\NEDeathSmall\NEDeathSmall.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit Group - Pick every unit in (Units within 250.00 of (Position of (Picked unit)) matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is A structure) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of (Casting unit))) Equal to True)))) and do (Actions)
                • Loop - Actions
                  • Unit - Cause (Casting unit) to damage (Picked unit), dealing ((Real((Level of Overdrive for (Casting unit)))) x 20.00) damage of attack type Spells and damage type Normal
            • Else - Actions
 
Level 11
Joined
Jan 25, 2009
Messages
572
Ehm... now i understand you. So if the unit is dead the unit will explode and every unit in range will be damaged! Ah now i see! I thought it would just damage and do some mana drain in an aoe and explode everyone in the AOE. Sorry. You'rs is right now. Except the leaks xD Remember, you need a point variable for the group variable also.
 
Status
Not open for further replies.
Top