• 🏆 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] Setting up an Aura and other Passives

Status
Not open for further replies.
Level 13
Joined
Jul 26, 2008
Messages
1,009
Alright, I've been trying to set up an Aura and some other passives. However, the method I know of places a unit in a global variable once it learns the spell, then creates a new trigger and calls up that unit.

My spells HAVE to be MUI/MPI for the map I'm doing. So that means primarily local variables and other restrictions.

I found an example of an MUI/MPI Aura and am using it to the best of my ability, however it doesn't work.

So how do I set up an aura or a passive using the level of an ability on a stored unit to check the strength of the spell?

I'm trying this method but there's something wrong with it. :\ Any help is appreciated.

JASS:
function Trig_Illum_Conditions takes nothing returns boolean
    if ( not ( GetLearnedSkillBJ() == 'Illu' ) ) then
        return false
    endif
    return true
endfunction

function IllumConditions takes nothing returns boolean
    local unit PotM=GetTriggerUnit()
    if GetBooleanAnd(IsUnitAlly(GetTriggerUnit(), GetOwningPlayer(PotM)), (DistanceBetweenPoints(GetUnitLoc(PotM), GetUnitLoc(GetTriggerUnit())) >= 900.00 ) ) then
        return false
    endif
    return true
endfunction

function IllumActions takes nothing returns nothing
    local integer random = GetRandomInt(1, 100)
    call PolledWait( 0.25 )
    if random <= 10 + (10 * GetUnitAbilityLevelSwapped('Illu', GetTriggerUnit()))  then
        call SetUnitManaBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_MANA, GetTriggerUnit()) + ( 1.50 * I2R(             (random)) ) ) )
        call AddSpecialEffectTargetUnitBJ( "origin", GetAttackedUnitBJ(), "Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl" )
        call DestroyEffect( GetLastCreatedEffectBJ() )
        set random = ( random * R2I(1.50) )
        call CreateTextTagUnitBJ( I2S(random), GetTriggerUnit(), 0, 10.00, 25.00, 50.00, 100.00, 0 )
        call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
        call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 10.00, 90.00 )
        call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 1.50 )
        call SetTextTagFadepointBJ( GetLastCreatedTextTag(), 1.00 )
    endif
endfunction

function Trig_Illum_Actions takes nothing returns nothing
    local unit PotM=GetTriggerUnit()
    local integer lvl=GetUnitAbilityLevel(PotM,'Illu')
    local trigger trg
    if lvl==1 then
    set trg=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trg, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(trg,Condition(function IllumConditions))
    call TriggerAddAction(trg,function IllumActions)
    endif
endfunction

//===========================================================================
function InitTrig_Illum takes nothing returns nothing
    set gg_trg_Illum = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Illum, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddCondition( gg_trg_Illum, Condition( function Trig_Illum_Conditions ) )
    call TriggerAddAction( gg_trg_Illum, function Trig_Illum_Actions )
endfunction
 
Level 17
Joined
Jan 21, 2007
Messages
2,013
Level 12
Joined
Apr 27, 2008
Messages
1,228
GetAttackedUnitBJ()

There is no attacked unit.
Avoid using BJ functions, in most cases they are just wrapper functions - they do nothing except call native functions.
Are you sure those are the conditions for the second trigger?
 
Level 9
Joined
Apr 3, 2008
Messages
700
Spiwn is true.

Some other things:
1. Your trigger special effect won't work.
2. Don't forget to null handle variables. If you don't null them, they cause memory leak.
3. You can optimize
JASS:
 if ( not ( GetLearnedSkillBJ() == 'Illu' ) )
to
JASS:
if ( GetLearnedSkillBJ() != 'Illu' )

P.S. Why won't you make it on GUI with custom scripts?
 
Level 13
Joined
Jul 26, 2008
Messages
1,009
To Hoernchen: lolwut? I can't see any flaw in my description besides one or two unneeded prepositions or adjectives. Your post simply strikes me as trolling and spamming.
If you mean you can't understand the jargon used, then get used to it. You'll see these more and more as you advance from being a complete noob to a skilled Trigger Maker. Until then, don't post stupid posts about not being able to understand the terms used.

terradont: Thanks, unfortunately I don't quiet understand how these auras are level based. Are they even level based? Where does the trigger check what level the passive is on the learning unit?
I already have an aura system that's buff based and MUI. However it bases the spell's power on the buff of the unit instead of the aura-barer's aura level, which to me is innefficient.

BTW Thanks Spiwn. I'll look into what you've pointed out. Yeah, my friend was explaining BJs to me. I convert some code lines to and from GUI still, so I'm not quiet trained with removing BJs and turning them into natives.

To Day-Elven. Thanks, I'll optimize it and clean up the leaks. However, I was gonna wait til it was finished for the leaks. But keeping with Spiwn's suggestions shouldn't it be if GetLearnedSkill() != 'Illu' and I do need to switch around the false and true statements if I do what you suggested.
And I've adjusted it so that the special effect works now :3 TY. I need to get the floating text to work next. Right now I've fixed a few things, but it's still having problems. I'll post the updated spell tomorrow, after I go through it to fix any obvious errors.

And I don't mind making it in GUI with custom script, but doing it that way is A LOT slower than just JASS.
 
Last edited:
Level 10
Joined
Jun 16, 2007
Messages
415
Titanhex, you are quite up yourself. I am quite sure that my coding skills exceed yours, but that is not even topic here. Thing is, I cannot understand your ENGLISH, which you use in a weird way to try and describe what effect you are trying to create.
Also, your coding isn't exactly very good, as Day-Elven pointed out before.
Btw, this would be even better:

JASS:
return GetLearnedSkillBJ() != 'Illu'
 
Level 13
Joined
Jul 26, 2008
Messages
1,009
My coding is a mix of converted GUI and JASS at a need to learn basis. (In other words I don't learn the proper JASS until I need to)

Hoernchen, I've written you a personal message because I don't want this topic to be a flame war, but rather something more productive and educational.

terradont: I'm actually trying to get away from using multiple buffs and instead using only 1 buff. I'm pretty close with this new coding, and will post it tomorrow.
 
Last edited:
Level 12
Joined
Apr 27, 2008
Messages
1,228
Btw, this would be even better:

JASS:
return GetLearnedSkillBJ() != 'Illu'

Uh, no.

This should be working:
JASS:
function Trig_Illum_Conditions takes nothing returns boolean
    if  GetLearnedSkill() == 'Illu'  then
        return true
    endif
    return false
endfunction

function IllumConditions takes nothing returns boolean
    local unit PotM=GetTriggerUnit()
    local real dx
    local real dy
    local unit u
    if GetSpellAbilityId()=='blah' then
        set u=GetSpellAbilityUnit()
        set dx=GetUnitX(PotM)-GetUnitX(u)
        set dy=GetUnitY(PotM)-GetUnitY(u)
        if IsUnitAlly(u, GetOwningPlayer(PotM))==false and dx*dx+dy*dy < 810000.00   then
            set u=null
            set PotM=null
            return true
        endif
    endif
    set PotM=null
    return false
endfunction

function IllumActions takes nothing returns nothing
    local integer random = GetRandomInt(1, 100)
    if random <= 10 + (10 * GetUnitAbilityLevel(GetTriggerUnit(), 'Illu'))  then
        call PolledWait( 0.25 )
        call SetUnitState( GetTriggerUnit(), UNIT_STATE_MANA,  GetUnitState(GetTriggerUnit(), UNIT_STATE_MANA) +  1.50 * random )
        call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl", GetTriggerUnit(),"origin" ))
        set random = ( random * R2I(1.50) )
        set bj_lastCreatedTextTag = CreateTextTag()
        call SetTextTagText(bj_lastCreatedTextTag, I2S(random), 10 * 0.023 / 10)
        call SetTextTagPosUnit(bj_lastCreatedTextTag, GetTriggerUnit(), 0)
        call SetTextTagColor(bj_lastCreatedTextTag, 64, 126, 255, 255)
        call SetTextTagPermanent( bj_lastCreatedTextTag, false )
        call SetTextTagVelocity(bj_lastCreatedTextTag, 0, 0.71 / 128)
        call SetTextTagLifespan( bj_lastCreatedTextTag, 1.50 )
        call SetTextTagFadepoint( bj_lastCreatedTextTag, 1.00 )
    endif
endfunction

function Trig_Illum_Actions takes nothing returns nothing
    local unit PotM=GetTriggerUnit()
    local integer lvl=GetUnitAbilityLevel(PotM,'Illu')
    if lvl==1 then
    call TriggerRegisterUnitEvent(gg_trg_Illum, PotM, EVENT_UNIT_SPELL_EFFECT )
    endif
    set PotM=null
endfunction

//===========================================================================
function InitTrig_Illum takes nothing returns nothing
    local trigger trg = CreateTrigger(  )
    set gg_trg_Illum = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddCondition( trg, Condition( function Trig_Illum_Conditions ) )
    call TriggerAddAction( trg, function Trig_Illum_Actions )
    call TriggerAddCondition(gg_trg_Illum,Condition(function IllumConditions))
    call TriggerAddAction(gg_trg_Illum,function IllumActions)
endfunction
Instead of creating a trigger each time, I just add the event to an already existing trigger. Also the event is unit specific(or should it not be).
I changed the conditions for the second trigger, because checking if a unit is an ally of itself was rather pointless.
Cleaned all the BJs and leaks.
But put simply, I do not know what exactly you want this ability to do ;)
 
Level 13
Joined
Jul 26, 2008
Messages
1,009
Okay, here's my adapted version of my old spell with the suggestions given.

JASS:
function Trig_Illum_Conditions takes nothing returns boolean
    if GetLearnedSkill() == 'Illu' then
        return true
    endif
    return false
endfunction

function IllumConditions takes nothing returns boolean
    local unit PotM=GetTriggerUnit()
    if GetBooleanAnd(IsUnitAlly(GetTriggerUnit(), GetOwningPlayer(PotM)), (DistanceBetweenPoints(GetUnitLoc(PotM), GetUnitLoc(GetTriggerUnit())) >= 900.00 ) ) then
        return false
    endif
    return true
endfunction

function IllumActions takes nothing returns nothing
    local unit PotM=GetTriggerUnit()
    local integer random = GetRandomInt(1, 100)
    call PolledWait( 0.25 )
    if random <= 10 + (30 * GetUnitAbilityLevelSwapped('Illu', PotM))  then
        call SetUnitManaBJ( GetTriggerUnit(), GetUnitStateSwap(UNIT_STATE_MANA, GetTriggerUnit()) + GetUnitAbilityLevelSwapped('TotM', PotM) * I2R(random) )
        call AddSpecialEffectTargetUnitBJ( "origin", GetTriggerUnit(), "Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl" )
        call DestroyEffect( GetLastCreatedEffectBJ() )
        set random = random * ( GetUnitAbilityLevelSwapped('TotM', PotM) )
        call CreateTextTagUnitBJ( I2S(random), GetTriggerUnit(), 0, 10.00, 25.00, 50.00, 100.00, 0 )
        call SetTextTagPermanent( GetLastCreatedTextTag(), false )
        call SetTextTagVelocity( GetLastCreatedTextTag(), 10.00, 90.00 )
        call SetTextTagLifespan( GetLastCreatedTextTag(), 1.50 )
        call SetTextTagFadepoint( GetLastCreatedTextTag(), 1.00 )
    endif
endfunction

function Trig_Illum_Actions takes nothing returns nothing
    local unit PotM=GetTriggerUnit()
    local integer lvl=GetUnitAbilityLevel(PotM,'Illu')
    local trigger trg
    if lvl==1 then
    set trg=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trg, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(trg,Condition(function IllumConditions))
    call TriggerAddAction(trg,function IllumActions)
    endif
endfunction

//===========================================================================
function InitTrig_Illum_Copy takes nothing returns nothing
    set gg_trg_Illum_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Illum_Copy, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddCondition( gg_trg_Illum_Copy, Condition( function Trig_Illum_Conditions ) )
    call TriggerAddAction( gg_trg_Illum_Copy, function Trig_Illum_Actions )
endfunction

I have the formula at 10 + (30 * etc.) so that at level 3 the aura has a 100% success rate for the sake of testing it. This spell works on the one who learned the skill, but the ones in range only get a +random to their mana because the spell isn't set up correctly to use the learner's skill level. Instead, it's pointing to the aura level on the unit, which doesn't even have the aura. I need to find the fix for that.

I tried fixing up the spell suggestion you provided, Spiwn, and it obviously doesn't work.

JASS:
function Trig_Illum_Conditions takes nothing returns boolean
    if GetLearnedSkill() == 'Illu' then
        return true
    endif
    return false
endfunction

function IllumConditions takes nothing returns boolean
    local unit PotM=GetTriggerUnit()    
    local real dx    
    local real dy    
    local unit u    
    if GetSpellAbilityId()=='Illu' then
        set u=GetSpellAbilityUnit()
        set dx=GetUnitX(PotM)-GetUnitX(u)
        set dy=GetUnitY(PotM)-GetUnitY(u)
            if IsUnitAlly(u, GetOwningPlayer(PotM))==false and dx*dx+dy*dy < 810000.00   then
            set u=null
            set PotM=null
            return true
        endif
    endif
    set PotM=null
    return false
endfunction

function IllumActions takes nothing returns nothing
    local integer random = GetRandomInt(1, 100)
        if random <= 10 + (30 * GetUnitAbilityLevel(GetTriggerUnit(), 'Illu'))  then
        call PolledWait( 0.25 )
        call SetUnitState( GetTriggerUnit(), UNIT_STATE_MANA,  GetUnitState(GetTriggerUnit(), UNIT_STATE_MANA) +  GetUnitAbilityLevelSwapped('TotM', GetTriggerUnit()) * random )
        call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl", GetTriggerUnit(),"origin" ))
        set random = random * GetUnitAbilityLevelSwapped('TotM', GetTriggerUnit())
        set bj_lastCreatedTextTag = CreateTextTag()
        call SetTextTagText(bj_lastCreatedTextTag, I2S(random), 10 * 0.023 / 10)
        call SetTextTagPosUnit(bj_lastCreatedTextTag, GetTriggerUnit(), 0)
        call SetTextTagColor(bj_lastCreatedTextTag, 64, 126, 255, 255)
        call SetTextTagPermanent( bj_lastCreatedTextTag, false )
        call SetTextTagVelocity(bj_lastCreatedTextTag, 0, 0.71 / 128)
        call SetTextTagLifespan( bj_lastCreatedTextTag, 1.50 )
        call SetTextTagFadepoint( bj_lastCreatedTextTag, 1.00 )
    endif
endfunction

function Trig_Illum_Actions takes nothing returns nothing
    local unit PotM=GetTriggerUnit()    
    local integer lvl=GetUnitAbilityLevel(PotM,'Illu')    
    if lvl==1 then
        call TriggerRegisterUnitEvent(gg_trg_Illum, PotM, EVENT_UNIT_SPELL_EFFECT )
    endif
    set PotM=null
endfunction

//===========================================================================
function InitTrig_Illum takes nothing returns nothing
    set gg_trg_Illum = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Illum, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddCondition( gg_trg_Illum, Condition( function Trig_Illum_Conditions ) )
    call TriggerAddAction( gg_trg_Illum, function Trig_Illum_Actions )
endfunction

Okay, obviously the reason is because PotM isn't properly pointed to as the aura-barer. Likely there's a few more issues, but I haven't gone over the spell adaptation.

The reason for the changes is because the formula needs to take into account the level of the aura for the Aura-Barer. I'll probably add the max mana amount of the aura barer into the formula instead of basing it on random.

However, I'm still faced with the dilemma of how to point the spell's power at the one who is learning Illuminaura.

+Rep for providing a solid solution =3 I'll try going over it too myself, to find an answer, but at present I don't think I know what coding I need to fix this.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
JASS:
function IllumConditions takes nothing returns boolean
    local unit PotM=GetTriggerUnit()
    //Just edit in the next line the last 4 codes so that they match the raw codes of the buffs.
    if GetUnitAbilityLevel(PotM,'Illu')>0 or GetUnitAbilityLevel(PotM,'Illu')>0 or GetUnitAbilityLevel(PotM,'Illu')>0 or GetUnitAbilityLevel(PotM,'Illu')>0 or GetUnitAbilityLevel(PotM,'Illu')>0then
        set PotM=null
        return true
    endif
    set PotM=null
    return false
endfunction

function IllumActions takes nothing returns nothing
    local integer random = GetRandomInt(1, 100)
    local integer a=GetUnitAbilityLevel(GetTriggerUnit(), 'Illu')
    //So if the triggering unit has the actual  ability he is the "aura-bearer"
    //Else he has one of the 4 buffs
    //So now lets determine which one it is
    if a>0 then
        set a=4+a
    //Edit the next 3 lines so that the raw codes match those of the buffs for level 1,2 and 3
    elseif GetUnitAbilityLevel(GetTriggerUnit(), 'Illu')>0 then
        set a=1
    elseif GetUnitAbilityLevel(GetTriggerUnit(), 'Illu')>0 then
        set a=2
    elseif GetUnitAbilityLevel(GetTriggerUnit(), 'Illu')>0 then
        set a=3
    else
        set a=4
    endif
    //And then do stuff
    if random <= 10 + (10 * a) then
        call PolledWait( 0.25 )
        //
        call SetUnitState( GetTriggerUnit(), UNIT_STATE_MANA, GetUnitState(GetTriggerUnit(), UNIT_STATE_MANA) + 1.50 * random * a )
        call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl", GetTriggerUnit(),"origin" ))
        set random = ( random * R2I(1.50) )
        set bj_lastCreatedTextTag = CreateTextTag()
        call SetTextTagText(bj_lastCreatedTextTag, I2S(random), 10 * 0.023 / 10)
        call SetTextTagPosUnit(bj_lastCreatedTextTag, GetTriggerUnit(), 0)
        call SetTextTagColor(bj_lastCreatedTextTag, 64, 126, 255, 255)
        call SetTextTagPermanent( bj_lastCreatedTextTag, false )
        call SetTextTagVelocity(bj_lastCreatedTextTag, 0, 0.71 / 128)
        call SetTextTagLifespan( bj_lastCreatedTextTag, 1.50 )
        call SetTextTagFadepoint( bj_lastCreatedTextTag, 1.00 )
    endif
endfunction

//===========================================================================
function InitTrig_Illum takes nothing returns nothing
    set gg_trg_Illum = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Illum, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(gg_trg_Illum,Condition(function IllumConditions))
    call TriggerAddAction(gg_trg_Illum,function IllumActions)
endfunction

Remember to always describe what you want your spell to do.
There is no need for local triggers or event adding.
 
Level 13
Joined
Jul 26, 2008
Messages
1,009
I apologize for not being clear, and thank you for the work you've done here.

I'll remember to place //Description tags in my posted spells from now on to get the full benefit of assistance that can be provided.

This aura you've given me, while not what I am looking for, does give me an idea for a future aura set up.

What I'm actually in need of is how to set an aura that doesn't use buff determination at all.

Hypothetically lets say I'm making this aura with 300 levels. Instead of wasting hours of time copying and pasting code, how can I set up the aura so it just runs off the level of the one who has the aura?

Kind of like Essence Aura on Oblivion Statue. Or just any other normal aura which uses only one buff, not one buff per level?

--

Side note, lets say I have a hero with a skill, like evasion. It's a passive, and not an aura. Every time the hero attacks, it has a 2/4/6% chance to be bloodlusted. What would be a proper condition to use for this trigger without using a buff or effect?
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
You still have not said what you want this aura to do.

Anyway, there are a couple of ways to do that:
Essence Aura (A0OG)
Based on Item Devotion Aura.

When the skill is first learnt, create a new trigger which is called every time that a unit's spell goes into effect, while saving "Destroyer" to the cache. Also Destroyer is given an item mana bonus ability (A0OL A0OM A0ON A0OH) depending on its level that gives the Max Mana increase.

When a unit's spell goes into effect, check if the unit has the Essence Aura buff (B06X) and the skill is one of the allowed skills, then make a random int between 1 and 100, and if it is lower or equal than EssenceAura*10 and the distance between the casting hero and "Destroyer" is lower than 1400 then make the unit's mana become CurrentMana+0.25*MaxMana and show the effect on top of the unit.

This means creating a trigger for each unit that learns the aura and then attaching that unit to the trigger.


The condition for your last question should be:
random integer between 1 and 100 is less than or equal to 2*Level of your ability for the attacking unit
 
Level 13
Joined
Jul 26, 2008
Messages
1,009
Wow, didn't even think about that for the condition. Guess I thought it would have errors, and didn't even consider it.

Okay, here's what I want the spell to do. Every time a hero within 900 of the PotM casts a spell, there's a chance it's mana will be restored by an amount based off of the max mana of the PotM. The amount restored and the chance goes up per level of the aura.

Anyways, how do I save the hero to the cache without resorting to globals, or other things that cause the spell to no longer work MUI. There's another dilemma, how do I save the hero to the cache if the hero doesn't learn it, but rather acquires it?

Perhaps I should use a different method or something? Maybe a pick every unit in range set up?
 
Status
Not open for further replies.
Top