• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Spell] Customized Banish Spell

Status
Not open for further replies.
Level 7
Joined
Feb 26, 2005
Messages
210
I am working on a customized version of Banish which has a different effect depending on what the spell is cast on. For some reason nothing happens except the first time, and only the first time, there is a brief moment of lag. Otherwise nothing. Please help.

JASS:
function Trig_Banish_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A009' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Banish_Actions takes nothing returns nothing
    local location l
    local unit u1 = GetSpellAbilityUnit()
    local unit u2 = GetSpellTargetUnit()
    if GetOwningPlayer(u1) == GetOwningPlayer(u2) and IsUnitType(u2, UNIT_TYPE_HERO) != true then
        call UnitAddAbility( u2, 'A00A' )
    else
        set l = GetUnitLoc(u1)
        call CreateNUnitsAtLoc( 1, 'n000', GetOwningPlayer(u1), l, GetUnitFacing(u1) )
        call UnitAddAbility( GetLastCreatedUnit(), 'A00C' )
        if IsUnitType(GetSpellTargetUnit(), UNIT_TYPE_HERO) == true then
            call SetUnitAbilityLevelSwapped( 'A00C', GetLastCreatedUnit(), GetHeroLevel(u2) )
        else
            call SetUnitAbilityLevelSwapped( 'A00C', GetLastCreatedUnit(), GetHeroLevel(u1) )
        endif
        call IssueTargetOrderBJ( GetLastCreatedUnit(), "banish", u2 )
    endif
    call RemoveLocation(l)
endfunction

//===========================================================================
function InitTrig_Banish takes nothing returns nothing
    set gg_trg_Banish = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Banish, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Banish, Condition( function Trig_Banish_Conditions ) )
    call TriggerAddAction( gg_trg_Banish, function Trig_Banish_Actions )
endfunction
 
Last edited:
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

Well we don't need to talk about it, but your coding is shitty ^^

JASS:
function Banish_Actions takes nothing returns nothing
    local unit u1 = GetTriggerUnit()
    local unit u2 = GetSpellTargetUnit()
    local unit u3
    
    if GetSpellAbilityId() == 'A009' then
        
        if IsUnitAlly(u2,GetOwningPlayer(u1)) and IsUnitType(u2,UNIT_TYPE_HERO) != true then
            call UnitAddAbility(u2,'A00A')
        else
            set u3 = CreateUnit(GetOwningPlayer(u1),'n000',GetUnitX(u1),GetUnitY(u1),0.)
            call UnitAddAbility(u3,'A00C')
            if IsUnitType(u2,UNIT_TYPE_HERO) then
                call SetUnitAbilityLevel(u3,'A00C',GetHeroLevel(u2))
            else
                call SetUnitAbilityLevel(u3,'A00C',GetHeroLevel(u1)) 
            endif
            call IssueTargetOrder(u3,"banish",u2)
        endif
        set u1 = null
        set u2 = null
        set u3 = null
    endif
endfunction
    
function InitTrig_Banish takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
        
    loop
        exitwhen i == 11
        call TriggerRegisterPlayerUnitEvent(t,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
        set i = i + 1
    endloop
    call TriggerAddAction(t,function Banish_Actions)
        
    set t = null
endfunction


Notes:
In your first if you check if the target is an ally of the caster and a unit (so you can target allies with your spell). Then you use else, which means you also can target enemies with it but only heroes then!!

But this point makes the if - else inside this else no needed, because the target (u2) must be a hero, so it hasn't any sense, that you filter, if the target is a unit or a hero you understand?

Also are you sure, that you want use "GetHeroLevel"?. Mean when your hero is level 20 or something, but your banish ability has only 4 levels, it will not work like this.

Also what's the ability 'A00A' because you add this to the ally unit in the first part, but you don't remove it. So if you target this unit more then one time, you permanently add the ability to this unit. So when you target 20 times the same unit, the unit has 20 abilities at least.

Edit: Seems to be solved now!
Edit2: Now it's not solved again .. dude get it!

Greetings and Peace
Dr. Boom
 
Last edited:
Level 7
Joined
Feb 26, 2005
Messages
210
I already solved the problem but thanks for the response - your code is a lot neater.

I should have been more clear on the exact nature of the spell, however.

The spell has three different effects depending on the the target. There is a permanent effect which is only suppose to work on your own non-hero units; if the permanent effect also worked on allied units it could cause abuse. And if it worked on heros that would ruin their attacks for the rest of the game.

The other two are the same as Banish but the duration depends on whether the target is a hero or a unit. A unit will be banished for as many seconds as the caster's level plus 5. A hero is reverse; as many seconds as the targets level plus 5. The max level of the dummy Banish ability is equal to the maximum hero level.
 
Status
Not open for further replies.
Top