• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] Spell Unknown problem

Status
Not open for further replies.
Hi again. I have a problem with my spell which i will post now:

JASS:
function SpeedThurst_Conds takes nothing returns boolean
    return GetSpellAbilityId () == 'AHbh'
endfunction
//=======================================================
function SpeedThurst_Acts takes nothing returns nothing
    local unit attacker = GetAttacker()
    local effect e = AddSpecialEffectTarget("origin", attacker, "Abilities\\Spells\\Items\\AIsm\\AIsmTarget.mdl")
    local integer stats
    local integer Time = 5*GetUnitAbilityLevel( attacker, 'AHbh' )
    local texttag Bonus = CreateTextTag()
    if GetUnitAbilityLevel( GetAttacker(), 'AHbh' ) == 1 and 5 >= GetRandomInt(1, 100) then
        set stats = 3
    elseif GetUnitAbilityLevel( GetAttacker(), 'AHbh' ) == 2 and 7 >= GetRandomInt(1, 100) then
        set stats = 6
    elseif GetUnitAbilityLevel( GetAttacker(), 'AHbh' ) == 3 and 10 >= GetRandomInt(1, 100) then
        set stats = 9
    endif
        call SetTextTagText(Bonus, "+" + "stats", .023 )   
        call SetTextTagPosUnit( Bonus, attacker, 0 )
        call SetTextTagColor( Bonus, 10, 100, 100, 255 )   
        call ModifyHeroStat( bj_HEROSTAT_AGI, attacker, bj_MODIFYMETHOD_ADD, stats )
        call SetTextTagPermanent(Bonus, false)
        call SetTextTagVelocity( Bonus, 0, .0277 )
        call TriggerSleepAction(2.00)
        call DestroyTextTag(Bonus)
        call DestroyEffect(e) 
        call TriggerSleepAction( Time )
        call ModifyHeroStat( bj_HEROSTAT_AGI, attacker, bj_MODIFYMETHOD_SUB, stats )
        set attacker = null
        set e = null
        set Bonus = null
        set e = null
endfunction

//===========================================================================
function InitTrig_Speed_Thurst takes nothing returns nothing
    local trigger SpeedThurst = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( SpeedThurst, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( SpeedThurst, Condition( function SpeedThurst_Conds ) )
    call TriggerAddAction( SpeedThurst, function SpeedThurst_Acts )
endfunction

The objective of the spell is:
- level 1: Every time the hero attacks, he has 5% chance to gain 3 additional ability stats. Lasts for 5 seconds.
- level 2: Every time the hero attacks, he has 7% chance to gain 6 additional ability stats. Lasts for 10 seconds.
- level 3: Every time the hero attacks, he has 10% chance to gain 9 additional ability stats. Lasts for 15 seconds.

I used as much formulas as i could and used the texttag properly ( i think, i tried to do the same thing PurplePoot told in my last post about tags)

I also tried to removed all BJ's, but in this case i couldn't do so, i have at least 2 BJ's that change the hero stats and i don't understand how to change them.

Anyway, the problem is that my spell DOES NOT work ... and i don't know why .... can some1 please tell me what is wrong ?

The JassCrasft program i use points no errors ...
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
First: AddSpecialEffectTarget takes path,unit,attachpoint not attachpoint,unit,path :p

Second: you don't need that if-statement, I subbed in formulas

Third: you nulled e twice

Fourth: you would've had a thread crash (or somesuch) if the chance didn't fire

Fifth: for On-Attack spells, you can't use GetSpellAbilityId; you need to use GetUnitAbilityLevel

Sixth: I inlined your % chance into your condition, for greater efficiency

Seventh: "+" + "stats" would show "+stats", not "+(stat bonus)" - you need to use I2S

Eighth: I got rid of a ton of your extra variables

Try this:

JASS:
function SpeedThurst_Conds takes nothing returns boolean
    local integer lv = GetUnitAbilityLevel(GetAttacker(),'AHbh')
    local integer pc
    if lv == 1 then
        set pc = 5
    elseif lv == 2 then
        set pc = 7
    elseif lv == 3 then
        set pc = 10
    endif
    return lv > 0 and GetRandomInt(0,100) < pc
endfunction

function SpeedThurst_Acts takes nothing returns nothing
    local unit att = GetAttacker()
    local effect e = AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIsm\\AIsmTarget.mdl", att, "origin")
    local integer lv = GetUnitAbilityLevel(att,'AHbh')
    local texttag Bonus = CreateTextTag()
    call SetTextTagText(Bonus, "+" + I2S(3*lv), .023 )   
    call SetTextTagPosUnit( Bonus, att, 0 )
    call SetTextTagColor( Bonus, 10, 100, 100, 255 )
    call SetHeroAgi(att,GetHeroAgi(att,false)+3*lv,true)
    call SetTextTagPermanent(Bonus, false)
    call SetTextTagVelocity( Bonus, 0, .0277 )
    call TriggerSleepAction(2)
    call DestroyTextTag(Bonus)
    call DestroyEffect(e) 
    call TriggerSleepAction(5*lv)
    call SetHeroAgi(att,GetHeroAgi(att,false)-3*lv,true)
    set Bonus = null
    set att = null
    set e = null
endfunction

//===========================================================================
function InitTrig_Speed_Thurst takes nothing returns nothing
    local trigger SpeedThurst = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( SpeedThurst, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( SpeedThurst, Condition( function SpeedThurst_Conds ) )
    call TriggerAddAction( SpeedThurst, function SpeedThurst_Acts )
endfunction
 
Status
Not open for further replies.
Top