| 06-29-2007, 10:31 AM | #1 |
Hi guys. I made this spell in JASS, called Blood Mana. It doesn't seem to work, as it doesn't restore any mana when the hero kills a unit, which is what the spell was designed to do. Any help would be appreciated and rewarded with rep. This is the code. I am pretty new to JASS, but I am eager to learn more and never have to use GUI again. Thanks in advance. JASS:function Trig_Blood_Mana_Conditions takes nothing returns boolean if ( not ( GetUnitAbilityLevelSwapped('A002', GetKillingUnitBJ()) >= 1 ) ) then return false endif return true endfunction function Trig_Blood_Mana_Actions takes nothing returns nothing local integer a = GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetTriggerUnit()) local integer b = (a*20)-5 local integer c = (a*20)+5 local integer d = GetRandomInt(b,c) call SetUnitManaBJ(GetKillingUnitBJ(),d+GetUnitStateSwap (UNIT_STATE_MANA, GetKillingUnitBJ())) endfunction //=========================================================================== function InitTrig_Blood_Mana takes nothing returns nothing set gg_trg_Blood_Mana = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Blood_Mana, EVENT_PLAYER_UNIT_DEATH ) call TriggerAddCondition( gg_trg_Blood_Mana, Condition( function Trig_Blood_Mana_Conditions ) ) call TriggerAddAction( gg_trg_Blood_Mana, function Trig_Blood_Mana_Actions ) endfunction |
| 06-29-2007, 11:03 AM | #2 |
Here are some tips on optimization:
|
| 06-29-2007, 12:47 PM | #3 |
This is based on what I think you're trying to achieve. You're using GetTriggerUnit() inside of GetUnitAbilityLevelSwapped(). This should be GetKillingUnitBJ(). Also, GetSpellAbilityId() should probably be 'A002'. You're also going a bit extreme with locals b and c. In this case, it would be much clearer to just say "local integer d = a*20 + GetRandomInt(-5, 5)" |
| 06-29-2007, 09:36 PM | #4 |
Thank you so much guys! As I said, I am very new to JASS, and when I make spells in JASS they constantly have problems that I am unable to fix. +rep to both of you :D. I would shower you with rep Pyrogasm but i see that you have enough rep to last a while. Thanks for your responses. Yea, I got rid of all the BJ's, and yea I forgot to use GetKillingUnit() instead of GetTriggerUnit(). @Pyrogasm - With reals in JASS, do you have to put the y's in x.yy? Does JASS require the 2 decimals for reals, or does it automatically put a zero for the decimals when you leave the decimal points blank? |
| 06-30-2007, 06:39 AM | #5 |
You don't have to write the zeroes: "15." is the same as "15.00". The decimal point, however, is important. I forgot to mention; Rising_Dusk has made a spell exactly like this for his hero The Grim Pharoah. You should check it out. |
| 07-01-2007, 10:29 PM | #6 |
Ah k, I thought that you had to do something with maybe a decimal place or a couple zeros to make the world editor accept reals. With the Grim Pharoah though, you get the mana if someone around you dies, not just if you kill them. And also mine heals a somewhat random amount of mana, not just a set amount. And now mine as a floating text that appears above you for 0.9 seconds in blue text that says +(however much mana u healed). Thanks again Pyrogasm! |
