• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Spell Help::Blur

Status
Not open for further replies.
Level 6
Joined
Jun 30, 2006
Messages
230
This is the code for blur, an ability from DotA:
JASS:
function Trig_blur_Conditions takes nothing returns boolean
    if ( not ( GetLearnedSkillBJ() == 'A03P' ) ) then
        return false
    endif
    return true
endfunction

function Trig_blur_Func001C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('A03P', GetTriggerUnit()) == 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_blur_Func002C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('A03P', GetTriggerUnit()) == 2 ) ) then
        return false
    endif
    return true
endfunction

function Trig_blur_Func003C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('A03P', GetTriggerUnit()) == 3 ) ) then
        return false
    endif
    return true
endfunction

function Trig_blur_Func004C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('A03P', GetTriggerUnit()) == 4 ) ) then
        return false
    endif
    return true
endfunction

function Trig_blur_Actions takes nothing returns nothing
    if ( Trig_blur_Func001C() ) then
        call SetUnitVertexColorBJ( GetTriggerUnit(), 100, 100, 100, 40.00 )
    else
        call DoNothing(  )
    endif
    if ( Trig_blur_Func002C() ) then
        call SetUnitVertexColorBJ( GetTriggerUnit(), 100, 100, 100, 60.00 )
    else
        call DoNothing(  )
    endif
    if ( Trig_blur_Func003C() ) then
        call SetUnitVertexColorBJ( GetTriggerUnit(), 100, 100, 100, 80.00 )
    else
        call DoNothing(  )
    endif
    if ( Trig_blur_Func004C() ) then
        call SetUnitVertexColorBJ( GetTriggerUnit(), 100, 100, 100, 99.00 )
    else
        call DoNothing(  )
    endif
endfunction

//===========================================================================
function InitTrig_blur takes nothing returns nothing
    set gg_trg_blur = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_blur, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddCondition( gg_trg_blur, Condition( function Trig_blur_Conditions ) )
    call TriggerAddAction( gg_trg_blur, function Trig_blur_Actions )
endfunction
I look at that and it looks like to me that he converted a GUI to JASS. It's done horribly inefficient. The essential part of the spell is:
JASS:
SetUnitVertexColorBJ( GetTriggerUnit(), 100, 100, 100, 99.00 )
It follows the RGBA(RedGreenBlueAlpha) standard.

Again, my JASS skills are poor, but what I have so far is this:
JASS:
constant function Blur_AbilityRC takes nothing returns integer
	return 'A001' //The ability's raw code.
endfunction

constant function Blur_Alpha takes integer level returns real
	return 15 + level * 1 
endfunction

function Trig_Blur_Actions takes nothing returns nothing
    local real alpha = Blur_Alpha(GetUnitAbilityLevel(Blur_AbilityRC()))
    call SetUnitVertexColorBJ( GetLearningUnit(), 100, 100, 100, alpha )
endfunction

//===========================================================================
function InitTrig_Blur takes nothing returns nothing
    set gg_trg_Blur = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Blur, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddCondition( gg_trg_Blur, Condition( function Trig_Blur_Conditions ) )
    call TriggerAddAction( gg_trg_Blur, function Trig_Blur_Actions )
endfunction
It's not much, it's practically nothing lol. So how would I go about doing this? Or is the way it was originally done the only way/best way to do it?

And btw, how do you get the code to show up all nice like it does in a JASS editor? I've tried code=jass or code type=jass, but the code is a lot harder to read the way I have it posted.
 
Last edited:
Level 6
Joined
Mar 2, 2006
Messages
306
I look at that and it looks like to me that he converted a GUI to JASS. It's done horribly inefficient.
no, it is pure gui. you can use gui as well.

so, uh, what is your question? do you want the spell pasive like this one (this trigger sets the unit's transparency when the hero learns a skill level) or active (lasting for a few seconds only)?

if you only need the action, you'll find it in the animation section:
  • SpellPassiveBlur
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Blur [color=gray](your spell)[/color]
    • Actions
      • Animation - Change (Learning Hero)'s vertex coloring to (100.00%, 100.00%, 100.00%) with (Real(((Level of Evasion for (Leveling Hero)) + 15)))% transparency
if you want it pasive like in dota, base it on +0 attribute bonus and make a trigger like above (no direct need for jass).

note that if there is a tome of retraining in your map, you'd need a trigger that removes the transparency effect when the tome is used.

and (i dont remember really), you might need to reset alpha on revival...
 
Level 6
Joined
Jun 30, 2006
Messages
230
Will the way I have it set up work for each new level, or only the first time when it learns an ability? Yes, I want it passive, btw. JASS can do things so more efficient than GUI, so I want to do this. Plus, it's a good learning experience.
 
Level 6
Joined
Jun 30, 2006
Messages
230
JASS:
constant function myBlur_AbilityRC takes nothing returns integer
	return 'A001' //The ability's raw code.
endfunction
function myBlur_Alpha takes real level returns real
	return 15 + level
endfunction
function myBlur_Conditions takes nothing returns boolean
	if (not(GetLearnedSkillBJ() == myBlur_AbilityRC())) then
        return false
    endif
    return true
endfunction
function myBlur_Actions takes nothing returns nothing     
    local real level = GetUnitAbilityLevel(GetTriggerUnit(),myBlur_AbilityRC())
    call SetUnitVertexColorBJ(GetLearningUnit(),100,100,100,myBlur_Alpha(level))
endfunction
//===========================================================================
function InitTrig_myBlur takes nothing returns nothing
    set gg_trg_myBlur = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_myBlur, EVENT_PLAYER_HERO_SKILL)
    call TriggerAddCondition(gg_trg_myBlur,Condition(function myBlur_Conditions))
    call TriggerAddAction(gg_trg_myBlur,function myBlur_Actions)
endfunction
Finally, I get no errors. The downside is that it doesn't appear to do anything. Help?
Edit: It does do something. But only when you learn the spell. So it can only one level. Help?
 
Last edited:
Level 9
Joined
Jul 18, 2005
Messages
319
Here i'll just clean up a few things for ya

JASS:
constant function myBlur_AbilityRC takes nothing returns integer
	return 'A001' //The ability's raw code.
endfunction
function myBlur_Alpha takes integer level returns integer
	return 15 + level
endfunction
function myBlur_Conditions takes nothing returns boolean
	return (GetLearnedSkill() == myBlur_AbilityRC())
endfunction
function myBlur_Actions takes nothing returns nothing
    local unit b = GetLearningUnit()
    local integer level = GetUnitAbilityLevel(b,myBlur_AbilityRC())
    call SetUnitVertexColor(b,100,100,100,myBlur_Alpha(level))
    call SetUnitVertexColor(b,100,100,100,myBlur_Alpha(level))
    set b = null
endfunction
//===========================================================================
function InitTrig_myBlur takes nothing returns nothing
    set gg_trg_myBlur = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_myBlur, EVENT_PLAYER_HERO_SKILL)
    call TriggerAddCondition(gg_trg_myBlur,Condition(function myBlur_Conditions))
    call TriggerAddAction(gg_trg_myBlur,function myBlur_Actions)
endfunction
You'll need to find an work around soon... Maybe I should help but hey, i don't toy with passives... Ok You might want to check each the hero is leveled and check his level for your ability i suppose running a timer for awhile or when he has no skill points then destroy the timer

-Av3n
 
Level 11
Joined
Jul 12, 2005
Messages
764
You all messed up sthg around math part..
'15 + level' will be 16/17/18, so it means, it only changes transparency to 84/83/82%... :S
This one works as you originally wanted (40/60/80/99% transparency):
JASS:
constant function myBlur_AbilityRC takes nothing returns integer
return 'A001'
endfunction
constant function myBlur_Alpha takes integer level returns integer
return 20 + level*20
endfunction
function myBlur_Conditions takes nothing returns boolean
return GetLearnedSkill() == myBlur_AbilityRC()
endfunction
function myBlur_Actions takes nothing returns nothing
    local unit b = GetTriggerUnit()
    if GetUnitAbilityLevel(b,myBlur_AbilityRC()) == 4 then
    call SetUnitVertexColor(b,100,100,100,99)
    else
    call SetUnitVertexColor(b,100,100,100,myBlur_Alpha(level))
    endif
    set b = null
endfunction
//===========================================================================
function InitTrig_myBlur takes nothing returns nothing
    set gg_trg_myBlur = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_myBlur, EVENT_PLAYER_HERO_SKILL)
    call TriggerAddCondition(gg_trg_myBlur,Condition(function myBlur_Conditions))
    call TriggerAddAction(gg_trg_myBlur,function myBlur_Actions)
endfunction
 
Level 6
Joined
Jun 30, 2006
Messages
230
Thanks for all your help! I actually caught the math part and fixed it on my comp, but forgot to fix it here. I'm also curious why setting alpha to 100 isn't done? Everyone sets it to 99.0 instead.

Also, at
JASS:
        call SetUnitVertexColor(b,100,100,100,myBlur_Alpha(level))
I get that integer level is undefined. So I did this instead
JASS:
function myBlur_Actions takes nothing returns nothing
    local unit b = GetTriggerUnit()
    local integer level = GetUnitAbilityLevel(b,myBlur_AbilityRC())
    if level > 3 then
        call SetUnitVertexColor(b,100,100,100,99)
    else
        call SetUnitVertexColor(b,100,100,100,myBlur_Alpha(level))
    endif
    set b = null
    set level = 0
endfunction
I changed if it was equal to four to greater than three because what if there are more than four levels for some reason? It would catch a bug.
Now I have the problem that you get really transparent at level 1, and then lightly get more visible with each level. Help?
 
Status
Not open for further replies.
Top