• 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] My first vJass spell

Status
Not open for further replies.
Level 24
Joined
Feb 28, 2007
Messages
3,479
O hai, I just finished my first vJass spell, and I just wanna know if iamdoinitrite.
Yah, it's a simple spell, but it's just for training, obviously.
JASS:
scope Fire initializer Init
    globals
        private constant integer SPELL_ID = 'A000'
        private constant real DAMAGE = 50
        private constant damagetype D_TYPE = DAMAGE_TYPE_NORMAL
        private constant attacktype A_TYPE = ATTACK_TYPE_MAGIC
    endglobals

    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == SPELL_ID
    endfunction

    private function Actions takes nothing returns nothing
        local unit caster = GetTriggerUnit()
        local unit target = GetSpellTargetUnit()
        call UnitDamageTarget(caster,target,DAMAGE,true,false,A_TYPE,D_TYPE,null)
        set caster = null
        set target = null
    endfunction
 
    private function Init takes nothing returns nothing
        local trigger Trg = CreateTrigger()
        call TriggerAddAction(Trg, function Actions)
        call TriggerAddCondition(Trg, Condition(function Conditions))
        call TriggerRegisterAnyUnitEventBJ(Trg,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    endfunction
endscope
Thanks.
 
Last edited:
Level 24
Joined
Feb 28, 2007
Messages
3,479
JASS:
private function Init takes nothing returns nothing
        local trigger Trg = CreateTrigger()
        call TriggerAddAction(Trg, function Actions)
        call TriggerAddCondition(Trg, Condition(function Conditions))
        call TriggerRegisterAnyUnitEventBJ(Trg,EVENT_PLAYER_UNIT_SPELL_EFFECT)
endfunction
Like so?
 
Level 11
Joined
Apr 6, 2008
Messages
760
JASS:
private function Init takes nothing returns nothing
        local trigger Trg = CreateTrigger()
        call TriggerAddAction(Trg, function Actions)
        call TriggerAddCondition(Trg, Condition(function Conditions))
        call TriggerRegisterAnyUnitEventBJ(Trg,EVENT_PLAYER_UNIT_SPELL_EFFECT)
        set Trg = null
endfunction

like this
 
Status
Not open for further replies.
Top