• 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.

[JASS] Charge spell

Status
Not open for further replies.
Level 14
Joined
Oct 27, 2007
Messages
1,395
I know.. it would be.. but as he said he was beginning jass as well.. why not start off with something easy?
it's rare that you actually find someone that wants to learn.. just let him try it.
 
Level 3
Joined
May 6, 2008
Messages
28
I made my spell, i copied and pasted it and edited it heres what i got

JASS:
function Trig_Charge_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A02K' 
endfunction

function Trig_Charge_Actions takes nothing returns nothing
    local integer i=GetUnitAbilityLevel(GetTriggerUnit(), 'A02K' )
    call TriggerSleepAction(0.1)
    set udg_chargec=GetTriggerUnit() 
    set udg_chargetarget=GetSpellTargetUnit()   
    if (i==1) then
        call UnitAddAbility(udg_chargec,'A02S')
        call UnitAddAbility(udg_chargec,'A02W')
        set udg_Charge1='A02S'
        set udg_Charge2='A02W'
    elseif (i==2) then
        call UnitAddAbility(udg_chargec,'A02T')
        call UnitAddAbility(udg_chargec,'A02Z')
        set udg_Charge1='A02T'
        set udg_Charge2='A02Z'
    elseif (i==3) then
        call UnitAddAbility(udg_chargec,'A02U')
        call UnitAddAbility(udg_chargec,'A02Y')
        set udg_Charge1='A02U'
        set udg_Charge2='A02Y'
    elseif (i==4) then
        call UnitAddAbility(udg_chargec,'A02V')
        call UnitAddAbility(udg_chargec,'A02X')
        set udg_Charge1='A02V'
        set udg_Charge2='A02X'
    elseif (i==5) then
        call UnitAddAbility(udg_chargec,'A02L')
        call UnitAddAbility(udg_chargec,'A030')
        set udg_Charge1='A02L'
        set udg_Charge2='A030'
    endif
    call IssueTargetOrderById(GetTriggerUnit(),851983,GetSpellTargetUnit())
    call TriggerSleepAction(0.01)
    call SetUnitPathing(GetTriggerUnit(),false)
    call EnableTrigger(gg_trg_Charge_Attack)
    call EnableTrigger(gg_trg_Charge_Order)
    call EnableTrigger(gg_trg_Charge_Death)
    call EnableTrigger(gg_trg_Charge_Remove)
    call TriggerSleepAction(7.00)
    call DisableTrigger(gg_trg_Charge_Remove)
endfunction

function InitTrig_Charge takes nothing returns nothing
    set gg_trg_Charge = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Charge, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Charge, Condition( function Trig_Charge_Conditions ) )
    call TriggerAddAction( gg_trg_Charge, function Trig_Charge_Actions )
endfunction

JASS:
function Trig_Charge_Attack_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetAttacker()) == 'U00Y' 
endfunction

function Trig_Charge_Attack_Actions takes nothing returns nothing
    local unit u=GetAttacker()
    call DisableTrigger(GetTriggeringTrigger())
    call AddSpecialEffectTargetUnitBJ("origin",u,"Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl")
    call TriggerSleepAction(0.5+0.5*GetUnitAbilityLevelSwapped('A02K',u))
    call IssueTargetOrderById(bj_lastCreatedUnit,852095,GetTriggerUnit())    
    call DestroyEffect(bj_lastCreatedEffect)
    call SetUnitPathing(u,true)
    set u = null
endfunction


function InitTrig_Charge_Attack takes nothing returns nothing
    set gg_trg_Charge_Attack = CreateTrigger(  )
    call DisableTrigger( gg_trg_Charge_Attack )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Charge_Attack, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Charge_Attack, Condition( function Trig_Charge_Attack_Conditions ) )
    call TriggerAddAction( gg_trg_Charge_Attack, function Trig_Charge_Attack_Actions )
endfunction

JASS:
function Trig_Charge_Order_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'O001' 
endfunction

function Trig_Charge_Order_Actions takes nothing returns nothing
    call DisableTrigger(GetTriggeringTrigger())
    call DisableTrigger(gg_trg_Charge_Attack)
    call DisableTrigger(gg_trg_Charge_Death)
    call SetUnitPathing(GetTriggerUnit(),true)
    set udg_chargetarget = null
endfunction


function InitTrig_Charge_Order takes nothing returns nothing
    set gg_trg_Charge_Order = CreateTrigger(  )
    call DisableTrigger( gg_trg_Charge_Order )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Charge_Order, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Charge_Order, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Charge_Order, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerAddCondition( gg_trg_Charge_Order, Condition( function Trig_Charge_Order_Conditions ) )
    call TriggerAddAction( gg_trg_Charge_Order, function Trig_Charge_Order_Actions )
endfunction

JASS:
function Trig_Charge_Death_Func001C takes nothing returns boolean
    if ( ( GetTriggerUnit() == udg_chargec ) ) then
        return true
    endif
    return GetTriggerUnit() == udg_chargetarget
endfunction

function Trig_Charge_Death_Conditions takes nothing returns boolean
    return Trig_Charge_Death_Func001C() 
endfunction

function Trig_Charge_Death_Actions takes nothing returns nothing
    call DisableTrigger(GetTriggeringTrigger())
    call DisableTrigger(gg_trg_Charge_Attack)
    call DisableTrigger(gg_trg_Charge_Order)
    call SetUnitPathing(udg_chargec,true)
    set udg_chargetarget = null
endfunction


function InitTrig_Charge_Death takes nothing returns nothing
    set gg_trg_Charge_Death = CreateTrigger(  )
    call DisableTrigger( gg_trg_Charge_Death )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Charge_Death, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Charge_Death, Condition( function Trig_Charge_Death_Conditions ) )
    call TriggerAddAction( gg_trg_Charge_Death, function Trig_Charge_Death_Actions )
endfunction

JASS:
function Trig_Charge_Remove_Actions takes nothing returns nothing
    call UnitRemoveAbilityBJ( udg_Charge1, udg_chargec )
    call UnitRemoveAbilityBJ( udg_Charge2, udg_chargec )
endfunction


function InitTrig_Charge_Remove takes nothing returns nothing
    set gg_trg_Charge_Remove = CreateTrigger(  )
    call DisableTrigger( gg_trg_Charge_Remove )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Charge_Remove, 7.00 )
    call TriggerAddAction( gg_trg_Charge_Remove, function Trig_Charge_Remove_Actions )
endfunction

Edit: woah thats huge!
 
Last edited by a moderator:
Level 2
Joined
Apr 15, 2007
Messages
18
Uhh, why is it so huge for such a simple spell. I still am voting for GUI for this spell.

There is no voting here, hes learning JASS and he wanted to make it in JASS, so just leave GUI outside of this...
 
Status
Not open for further replies.
Top