| 05-15-2010, 11:12 AM | #1 |
I'm trying to create an ability that increases a target hero's strength by 10*(LVL of ability) for 5 seconds. Originally, I was using the GUI to program this, but I moved over to JASS in an attempt to learn some of it, especially timers. Presently, my code works perfectly fine except that the hero's stat does not shrink by 10*(LVL of ability) after the 5 seconds, causing the strength growth to be permanent. I have no clue as to what I'm doing wrong. Would anyone care to help? JASS:function Trig_Signet_of_Might_3_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A002' ) ) then return false endif return true endfunction function derp takes nothing returns nothing // end local timer ti2 = GetExpiredTimer() call UnitRemoveAbilityBJ( 'A003', udg_u_signofmight ) call ModifyHeroStat( bj_HEROSTAT_STR, udg_u_signofmight, bj_MODIFYMETHOD_SUB, ( 10 * GetUnitAbilityLevelSwapped('A002', GetTriggerUnit()) ) ) set udg_u_signofmight = null call DestroyEffectBJ( udg_vfx_signofmight ) call DestroyEffectBJ( udg_vfx_signofmight2 ) call DestroyTimer(ti2) set ti2 = null endfunction function Trig_Signet_of_Might_3_Actions takes nothing returns nothing // init local timer ti = CreateTimer() set udg_u_signofmight = GetSpellTargetUnit() call UnitAddAbilityBJ( 'A003', udg_u_signofmight ) call ModifyHeroStat( bj_HEROSTAT_STR, udg_u_signofmight, bj_MODIFYMETHOD_ADD, ( 10 * GetUnitAbilityLevelSwapped('A002', GetTriggerUnit()) ) ) call AddSpecialEffectTargetUnitBJ( "lefthand", udg_u_signofmight, "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl" ) set udg_vfx_signofmight = GetLastCreatedEffectBJ() call AddSpecialEffectTargetUnitBJ( "righthand", udg_u_signofmight, "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl" ) set udg_vfx_signofmight2 = GetLastCreatedEffectBJ() call TimerStart(ti, 5, false, function derp) set ti = null endfunction //=========================================================================== function InitTrig_Signet_of_Might_3 takes nothing returns nothing set gg_trg_Signet_of_Might_3 = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Signet_of_Might_3, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Signet_of_Might_3, Condition( function Trig_Signet_of_Might_3_Conditions ) ) call TriggerAddAction( gg_trg_Signet_of_Might_3, function Trig_Signet_of_Might_3_Actions ) endfunction |
| 05-15-2010, 01:17 PM | #2 | |
Quote:
first of all get you jngp and replace all those BJ's with normal calls and uses proper function names! then the coude should be atleast a bit better readable/understandable |
| 05-15-2010, 02:02 PM | #3 |
I am now thoroughly confused. I feel that I only need help with one or two lines of code. I don't think the problem calls for installing JNPG, which I have installed now. :/ |
| 05-15-2010, 02:39 PM | #4 | |
Quote:
you're useing BJ-funcs; these are functons used for GUI code, and they are slower then non-BJ functions. Some of these BJs are also bugged. --> replace your BJ sith the code you can find when looking them up with tesh. --> try idf it works now --> if not, poste the readable non-BJ code here |
| 05-15-2010, 02:44 PM | #5 |
its non MUI... |
| 05-15-2010, 03:01 PM | #6 | |
Quote:
JASS:call ModifyHeroStat( bj_HEROSTAT_STR, udg_u_signofmight, bj_MODIFYMETHOD_SUB, ( 10 * GetUnitAbilityLevelSwapped('A002', GetTriggerUnit()) ) ) This is wrong, instead make a global variable to store casting unit in it (set udg_yourunit = GetTriggerUnit() should be in function in which you add the attribute), then replace "GetTriggerUnit()" with "udg_yourunit" |
| 05-15-2010, 03:42 PM | #7 |
Derp. I've got that already now. And, yes, I was aware that it was not MUI, but it isn't much of a concern for me ATM. I've gotten the ability to work now. However, I fear that the code might trip up in some occasions, such as when a Hero levels up while the buff is active, or when another temporary stat attribute is modified and the buff wears off, etc. Code efficiency, errors, etc.? JASS:function Trig_Signet_of_Might_3_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A002' ) ) then return false endif return true endfunction function Signet_of_Might_derp takes nothing returns nothing // end local timer ti2 = GetExpiredTimer() local integer lvl = GetUnitAbilityLevel( udg_u_signofmight2, 'A002' ) call UnitRemoveAbility( udg_u_signofmight, 'A003' ) call UnitRemoveAbility( udg_u_signofmight, 'B003' ) set udg_int_signofmight = GetHeroStr( udg_u_signofmight, true ) call SetHeroStr( udg_u_signofmight, ( udg_int_signofmight - ( 10 * lvl ) ), true ) set udg_u_signofmight = null call DestroyEffect( udg_vfx_signofmight ) call DestroyEffect( udg_vfx_signofmight2 ) call DestroyTimer(ti2) set ti2 = null endfunction function Trig_Signet_of_Might_3_Actions takes nothing returns nothing // init local timer ti = CreateTimer() local integer lvl = GetUnitAbilityLevel( GetTriggerUnit(), 'A002' ) set udg_u_signofmight2 = GetTriggerUnit() set udg_u_signofmight = GetSpellTargetUnit() call UnitAddAbility( udg_u_signofmight, 'A003' ) set udg_int_signofmight = GetHeroStr( udg_u_signofmight, true ) call SetHeroStr( udg_u_signofmight, ( udg_int_signofmight + ( 10 * lvl ) ), true ) set udg_vfx_signofmight = AddSpecialEffectTarget( "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl", udg_u_signofmight, "lefthand" ) set udg_vfx_signofmight2 = AddSpecialEffectTarget( "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl", udg_u_signofmight, "righthand" ) call TimerStart( ti, 5.00, false, function Signet_of_Might_derp ) set ti = null endfunction //=========================================================================== function InitTrig_Signet_of_Might_3 takes nothing returns nothing local integer i set i = 0 set gg_trg_Signet_of_Might_3 = CreateTrigger( ) loop call TriggerRegisterPlayerUnitEvent( gg_trg_Signet_of_Might_3, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null ) set i = i + 1 exitwhen i == 16 endloop call TriggerAddCondition( gg_trg_Signet_of_Might_3, Condition( function Trig_Signet_of_Might_3_Conditions ) ) call TriggerAddAction( gg_trg_Signet_of_Might_3, function Trig_Signet_of_Might_3_Actions ) endfunction EDIT: This is pretty fun. Programming is fun. +) Especially with JNPG. |
