• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

ability mana percentage

Status
Not open for further replies.
Level 3
Joined
Aug 28, 2005
Messages
48
is there a way to subtract (Units current mana) - (mana equal to a percent of the mana cost of a spell) without setting every single spell to an integer variable? because i have an idea to where if a unit is in this aura, and it casts an ability, it has a percent chance to spend 25% more mana... but i have no idea where to go with this. help would be highly appreciated
 
Level 11
Joined
Jul 12, 2005
Messages
764
Lol, i was thinking on this a bit, and found 3 ways to get the mana cost of the casted spell. :D

No.1:
When we use a trigger with the event 'Unit starts the effect of an ability', the manacost is still not subtracted from the unit's mana pool, but it does a moment later. So we set the mana to a variable (Mana), use a wait, and subtract them from each other.
A simple trigger, but extremely not MUI!! And also you get the mana cost 0.27 sec later. I don't reccomend this one.
Code:
LameWay
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        ((Triggering unit) has buff [Buff]) Equal to True
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                [Chance] Greater than or equal to (Random integer number between 1 and 100)
            Then - Actions
                Set Caster = (Triggering unit)
                Set Mana = (Mana of Caster)
                Wait 0.27 seconds
                Set ManaCost = (Mana - (Mana of Caster))
            Else - Actions

No.2:
Similar to No.1, but here we use a timer. The timer here acts like a 0.01 sec wait. (Needs 2 triggers)
Note that this is still not MUI. For example if you select a unitgroup and order them to cast a spell, it will not work.
But i think this is the best you can do in GUI.
Code:
StartsTheEffect
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                [Chance] Greater than or equal to (Random integer number between 1 and 100)
            Then - Actions
                Set Caster = (Triggering unit)
                Set Mana = (Mana of Caster)
                Countdown Timer - Start Timer as a One-shot timer that will expire in 0.01 seconds
            Else - Actions

//-----------------------------------------------------------------------

DelayTimer
    Events
        Time - Timer expires
    Conditions
    Actions
        Set ManaCost = (Mana - (Mana of Caster))

No.3:
It's the same as No.2 but in JASS. Completely MUI, and we get the mana cost just 0.001 sec later. Tell me if you want, and i'll write the script for you.
 
Level 3
Joined
Aug 28, 2005
Messages
48
this is close to what im looking for but not quite. exactly how much mana does this make the unit lose when it casts a spell? wouldnt it be like double mana lost? if so i can live with that ill just lower the chances per level. Also how would i create a special effect on the casting unit when this happens? every time i try to make a special effect it stays there... but thats probly a different problem
 
Level 11
Joined
Jul 12, 2005
Messages
764
Neither trigger sets the mana, they store the MANACOST of the spell to an integer variable! You can do everything what you'd like with it. If you want the unit to lose double mana, just use
Set Caster's mana to ((Mana of Caster) - Manacost).

For the effect, just create the effect, use a wait, and destroy Last Created Effect. But don't forget this can be extremely buggy if unit inside the aura cast a spell in the same time!!
 
Level 11
Joined
Jul 12, 2005
Messages
764
I would just store the spells cost in an real array, that way you get it MUI.
That is exactly what he wants to avoid...

And also i was thinking about this MUI problem. It could happen when two units are casting a spell in the same time interval, which is 0.01. And only units inside the aura are affected, so it is (nearly) impossible that two units that are owned by different players cast a spell in the same 0.01 second... So I think this problem would occur 1 time in about 1000 games. So you don't need to worry about multi-instancability.
 
Status
Not open for further replies.
Top