| 07-21-2004, 04:20 AM | #1 |
Hi, Someone know how i can drain mana of a unit using a dummy spell ( i need know what spell to use ) or using some function like the vexorian´s DamageUnitTimed ? |
| 07-21-2004, 04:41 AM | #2 | |
Quote:
I think you can simply use Siphon Mana, unless your adding other effects. |
| 07-21-2004, 06:42 AM | #3 |
In true. I need to add a mana maintenace cost for the Berseek abillity. |
| 07-21-2004, 06:53 AM | #4 | |
Quote:
Mana maintenance cost? Maybe I'm just a little sleepy... what? |
| 07-21-2004, 08:17 AM | #5 |
You mean mana drained per second when you activate berserk? If so, then make a trigger with event of a unit using berserk spell, and effect activating another trigger, the other trigger would be periodic and would run every 1 second, setting unit's mana to units mana - the mana cost per second, the unit can be stored in a variable so the trigger knows which unit to remove the mana from, you could use local variables to allow many units to be able to use berserk at once without interferance. Anyway, there should also be a trigger to turn off the mana drain trigger once berserk expires. If this is not what you asked for then I would ask the same question as HexenLordX. |
| 07-21-2004, 08:17 AM | #6 |
hm...i cant see what you mean after all but if u want berserk take mana every cast then u can do this Event:a unit begin casting an ability Condition:ability being cast equal to berserk Action: -If level of berserk for triggering equal to 1 then set mana of triggering unit to -X -If level of berserk for triggering equal to 2 then set mana of triggering unit to -X .................. I think it work well because i use to create some trigger spell with those event and condition :8 |
| 07-21-2004, 04:27 PM | #7 |
Use a trigger like this: Code:
Events
Unit - A unit Begins casting an ability
Conditions
(Ability being cast) Equal to Berserk
Actions
For each (Integer A) from 1 to 30, do (Actions)
Loop - Actions
Unit - Set mana of (Casting unit) to ((Mana of (Casting unit)) - 1.00)
Wait 1.00 seconds |
| 07-21-2004, 05:30 PM | #8 |
Shimrra it won't work, wait is buggy when used in loops, it makes the loop stop prematurely, it also apparently causes memory leaks when inside a loop because when I tried it on my map a while ago, about a minute after the loop started even though it never finished and stopped on 4 instead of 20 it was supposed to get to, the game got extremely laggy and then crashed without error. |
| 07-21-2004, 06:28 PM | #9 |
Perhaps a loop with a wait could work if, for the loop integer, it used a local variable. However, there are other concerns, "casting unit" works globaly and will get reset with each new cast; a solution would be to set the casting unit to a local variable as well, or, if it's some different spell than the one we are discussing here, and it doesn't really matter what the dummy spell for it is, then use a summoning spell and the event "a unit spawns a summoned unit", because "summoning unit" works as a local variable. |
| 07-21-2004, 06:51 PM | #10 |
I use waits in loops all the time nad have yet to suffer any problems with it. Also, the real way would be to do my trigger in Jass using local variables, but I didn't want to explain locals if he didnt already understand them. You could use a local and set the caster to that and then use the loop. |
| 07-21-2004, 08:26 PM | #11 | |
Quote:
That's a misconception, for the most part. Wait is buggy in loops in that if it's below .25 seconds it waits about .25 seconds anyway, but it does not stop the loop prematurely. The problem you are having is that Integer A is a global variable, hence being replaced by any other trigger that uses it when it is behind a wait action. A loop with Integer A wont be replaced if you use it with absolutely no wait time, so if you're going to use a wait time, make a global integer variable and use the action For each integer variable...do. Just make sure you dont use that integer in any other triggers. I've no idea why you were getting crash problems, but I'm relatively sure that a loop with a wait is not the cause of it. I don't know what else was running in your map, so I can't say for sure. As for the topic, a possible solution would be: Code:
Custom Script: local integer i = 1 // has to be in the very top of the trigger Custom Script: loop Custom Script: exitwhen i > 30 Unit - Set mana of (Casting unit) to ((Mana of (Casting unit)) - 1.00) Custom Script: set i = i + 1 Wait 1.00 seconds Custom Script endloop Basically just type the custom script in and inside the loop, put whatever you want. You can change the 30 to whatever endpoint you want the loop to have. |
| 07-22-2004, 07:19 PM | #12 |
I see, didn't realize "Integer A" was a global variable, and don't understand why blizzard didn't make it a local variable, for 99% of the cases you don't need to use the same "Integer A" anywhere else while the loop runs, and for that 1% where you do need it, there is got to be a better solution anyway. And I'm sure the leak in my map was caused by the loop (maybe its combination with something else) because after I removed it and used recursion instead, there was no more leak. |
