• 🏆 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!

[JASS] My first vJass spell

Status
Not open for further replies.
Level 24
Joined
Feb 28, 2007
Messages
3,480
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,480
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