• 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.

Mana cost issue

Status
Not open for further replies.
Level 4
Joined
Nov 18, 2007
Messages
79
Okay, so I'm having this really weird problem with my spells.

I cast the spell for the first time in the game. Everything works fine. The Hero loses the correct amount of 175 mana.:thumbs_up:

The second and all times after that the mana cost gets cut to 50. And I have no clue why. I've even tried running it while the trigger that assist the spell is disabled. Everything else works perfectly just that the mana cost gets reduced to 50 after the first cast and I can't for the life of me figure out why.:confused:
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
It definitely has something to do with the spell used. Please be more specific which spell you've used as a base spell, and if it is more complex than a single spell, specify (in terms of object editing, as you said you disabled all triggers related to the spell).

Note: the problem is most likely caused by the spell being replaced or level of the spell modified. ;)

-Mihai
 
Level 4
Joined
Nov 18, 2007
Messages
79
The base spell is the war stomp spell. There are no other spells tied to it. However, the funny thing is is that it worked before I started to create the actual map. I built my heroes and their special abilities before I started to actually put stuff into the map, and that's when it started screwing up.

I just tested all the other hero abilities, and they work fine. Just this one is being fussy. And the level of the spell being modified can't be a problem because the mana cost of all the levels of the spell are greater than 100.

:EDIT: Okay, so apparently there are only two spells that screw up in this fashion. Both these spells work in generally the same way, except one is single target, and the other is an AoE. First is based off Firebolt, second is based off War Stomp. I don't have problems with other custom spells based off these two. I just tested the game again with triggers off and it works, so here's my trigger spell code, there's something wrong with it but I can't figure it out. It's a spell that requires both life and mana to cast. It checks whether the unit has enough life, and if so, casts the spell. Otherwise, returns the mana cost of the spell, since you have to first cast the spell to initiate the trigger.

  • Misbehaving Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to genericClass
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Misbehaving Spell
          • (Life of (Triggering unit)) Greater than (35.00 + (15.00 x (Real((Level of (Ability being cast) for (Triggering unit))))))
        • Then - Actions
          • Unit - Cause (Triggering unit) to damage (Triggering unit), dealing (35.00 + (15.00 x (Real((Level of (Ability being cast) for (Triggering unit)))))) damage of attack type Spells and damage type Fire
        • Else - Actions
          • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + (65.00 + (10.00 x (Real((Level of (Ability being cast) for (Triggering unit)))))))
Data from my tests runs indicate that it seems to be running both the "Then" and the "Else" statements, though I don't know why.

Few more results:
- Using "Starts the effect of an ability" causes the mana count to (you can actually see this happening) increase first then decrease upon clicking the ability to cast, resulting in a net loss of only 50 mana. This is why the first cast works, because the unit has full mana at the start of the test.
- Using "Finishes the casting of an ability" causes the mana count to only decrease, but still only results in a loss of 50 mana.

The trigger may seem odd at first glance but there's a method to the madness, I assure you.

:EDIT: Okay, I fixed it. Dumbest error ever. Take a look at the second 'if' statement and it's corresponding 'else' statement. It checks for a spell match and life. If one is false, it adds mana. Now, the trigger itself runs whenever a spell is cast by that genericClass-type unit. Since there are two versions of this same trigger, one for the single target, and one for the AoE, every time that genericClass-type unit casts a spell both will run. One will register as false, and run the 'else' statement, giving the unit mana, while the other will register as true, and run correctly. Stupid error, but hard to find.:ugly:
 
Last edited:
Status
Not open for further replies.
Top