HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Trying to display the total mana burned, help please

03-17-2008, 06:20 AM#1
BoO-
So I made a spell, that, when cast, it takes the total mana of the casting unit, divides it by two and does that much damage on the target. The problem is that it doesn't show how much mana gets burned. It burns 285, then 4 etc. It goes all random, so how can I fix this?

Here is my code btw:

Trigger:
When Casted
Collapse Events
Unit - Mana Burner 0000 <gen> Begins casting an ability
Collapse Conditions
((Casting unit) is A Hero) Equal to True
(Ability being cast) Equal to Mana Wave
Collapse Actions
Set TotalMana = (Mana of (Casting unit))
Set HalfMana = (TotalMana / 2.00)
Unit - Set life of (Target unit of ability being cast) to ((Life of (Target unit of ability being cast)) - HalfMana)
03-17-2008, 07:17 AM#2
Pyrogasm
Well, you've set up your trigger improperly. The way you've done it works... but it would be better (and bug-free) if written like this:
Trigger:
Collapse Events
Unit - A Unit starts the effect of an ability
Collapse Conditions
(Ability Being Cast) equal to Mana Wave
Collapse Actions
Set HalfMana = ((Mana of (Triggering Unit)) / 2.00)
Unit - Cause (Triggering Unit) to damage (Target unit of ability being cast) for HalfMana damage of attack type Chaos and damage type Universal
----- If you want to show how much damage was done, you'll need to use Floating Text -----
Now, a lot of stuff seems changed, and here's why:
  • "Begins Casting an ability" happens before the ability is cast (and is cancelable). "Starts the Effect of an ability" happens the instant the spell is actually cast, the mana used, and the spell cannot be stopped.
  • Your usage of TotalMana was unneeded.
  • When you set the life of a unit it will not reward bounty to the player that "killed" it. When you cause a unit to damage another, the owning player will receive bounty for killing the unit properly.
  • In triggers that run on spell casts, use Triggering Unit instead of Casting Unit; it retains its value through waits and is a direct reference to the unit instead of a wrapper like Casting Unit is.
Now, if what you were trying to do was get the unit's mana before it casts the spell, then this will not work and you'll need a different trigger.
03-17-2008, 02:38 PM#3
Rising_Dusk
If you want to show floating text, you'll need to trigger it. I've got this lovely function in JASS for it, but it can be done in GUI with similar looking functions.
Expand JASS:
03-18-2008, 05:22 AM#4
BoO-
The spell is supposed to take the casters total mana, divide it by two and do that much damage, and also showing the floating text of how much damage it does.

How can I do that, and remove the "-x" text that the original mana burn spell shows, and create floating text of how much damage the spell does?
03-18-2008, 06:40 AM#5
Pyrogasm
You based the spell on mana burn? Doing the damage this way won't affect how much mana is burned by the spell; you'd have to do that manually, like so:
Trigger:
Actions
Set HalfMana = (Min(((Mana of (Triggering Unit)) / 2.00), (Mana of (Target unit of ability being cast))))
----- So that the spell doesn't do more damage than it can burn in mana -----
Unit - Cause (Triggering Unit) to damage (Target unit of ability being cast) for HalfMana damage of attack type Chaos and damage type Universal
Set TempPoint = (Position of (Target unit of ability being cast))
Floating Text - Create floating text that reads (- + String(Integer(HalfMana))) at TempPoint with Z offset 0.00, using font size 10.00, color (100%, 32.15%, 32.15%) and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
Floating Text - Change the fading age of (Last created floating text) to 2.00 seconds
That should mimic the Manaburn text, just make sure the spell you base your spell off of isn't Manaburn.
03-18-2008, 08:04 AM#6
BoO-
Thanks, it works perfectly.
Is this about as efficient as I can get it?:
Trigger:
Combustion
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to |c00ee331cCombustion|r
Collapse Actions
Set HalfMana = ((Mana of (Triggering unit)) / 3.00)
Set HalfManaInt = (Integer(HalfMana))
Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing HalfMana damage of attack type Chaos and damage type Universal
Set TempPoint = (Region centered at (Position of (Target unit of ability being cast)) with size (30.00, 30.00))
Floating Text - Create floating text that reads (- + (String(HalfManaInt))) at (Center of TempPoint) with Z offset 0.00, using font size 10.00, color (32.15%, 32.15%, 100.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
Floating Text - Change the fading age of (Last created floating text) to 2.00 seconds
03-19-2008, 06:05 AM#7
Pyrogasm
You didn't really set up the TempPoint stuff properly... you should have this instead:
Trigger:
Actions
----- ... -----
Set TempPoint = (Position of (Target unit of ability being cast)) <This is a point variable, not a region variable!>
Floating Text - Create floating text that reads (- + (String(HalfManaInt))) at TempPoint with Z offset 0.00, using font size 10.00, color (32.15%, 32.15%, 100.00%), and 0.00% transparency
Custom script: call RemoveLocation(udg_TempPoint)
That'll fix all the memory leaks.