• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[JASS] Hero wont finish actions

Status
Not open for further replies.
Level 14
Joined
Jul 26, 2008
Messages
1,009
Hi, I'm making a skill called Assassin's leap. Basically the hero throws knives, dissappears, and reappears with more knife throwing. It's like blink but with knives being thrown on take off and land and a minor pause betwee dissappearing and reappearing.

The problem is the spell isn't even starting. It won't even process it's conditions. I imagine this might be because of my poor vJASS skills. Any help or insight is appreciated.

JASS:
scope AssassinLeap

globals
    private constant integer    SpellID = 'asle'    //Spell Rawcode
    private constant real       til     = 0.1       //Periodic of timer
    private constant damagetype dmg     = DAMAGE_TYPE_POISON
    private constant weapontype wpn     = WEAPON_TYPE_WHOKNOWS
    private constant attacktype atk     = ATTACK_TYPE_MAGIC
endglobals

private struct Data
    unit c
    real cX
    real cY
    real X
    real Y
    
    static method create takes unit caster, real casterX, real casterY, real targX, real targY returns Data
     local Data D = Data.allocate()
        set D.c = caster
        set D.cX = casterX
        set D.cY = casterY
        set D.X = targX
        set D.Y = targY
     return D
    endmethod
     
     
endstruct

private function AssassinLeap_Timer takes nothing returns nothing
 local timer tim = GetExpiredTimer()
    local Data D = Data(GetTimerData(tim))
    local group g = CreateGroup()
    local unit t    
    call SetUnitPosition(D.c, D.X, D.Y)
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\shadowstrike\\shadowstrike.mdl", GetUnitX(D.c), GetUnitY(D.c)))
    call ShowUnit(D.c, true)
    
    if GetUnitAbilityLevel(D.c, 'afok') > 0 then
    
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\FanOfKnives\\FanOfKnivesCaster.mdl", GetUnitX(D.c), GetUnitY(D.c)))
    call GroupEnumUnitsInRange(g, D.X, D.Y, 250., null)
    loop
        set t = FirstOfGroup(g)
    exitwhen t == null
        if IsUnitEnemy(t, GetOwningPlayer(D.c)) == true then
            call UnitDamageTarget(D.c, t, 25*GetUnitAbilityLevel(D.c, 'afok'), true, false, atk, dmg, wpn)
        endif
        set t = null
    endloop
    
    endif
    call ReleaseTimer(tim)
    call D.destroy()
endfunction

private function AssassinLeap_Actions takes nothing returns nothing
 local Data D = Data.create(GetTriggerUnit(), GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), GetSpellTargetX(), GetSpellTargetY())
 local group g = CreateGroup()
 local unit t
 local real til
 local timer tim = NewTimer()
 set til = SquareRoot(Pow(D.X - D.cX, 2) + Pow(D.Y - D.cY, 2)) / GetUnitMoveSpeed(D.c)
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\shadowstrike\\shadowstrike.mdl", GetUnitX(D.c), GetUnitY(D.c)))
    
    if GetUnitAbilityLevel(D.c, 'afok') > 0 then
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\FanOfKnives\\FanOfKnivesCaster.mdl", GetUnitX(D.c), GetUnitY(D.c)))
        call GroupEnumUnitsInRange(g, GetUnitX(D.c), GetUnitY(D.c), 250., null)
        loop
            set t = FirstOfGroup(g)
        exitwhen t == null
            if IsUnitEnemy(t, GetOwningPlayer(D.c)) == true then
                call UnitDamageTarget(D.c, t, 25*GetUnitAbilityLevel(D.c, 'afok'), true, false, atk, dmg, wpn)
            endif
            set t = null
        endloop
    endif
    call ShowUnit(D.c, false)
    call SetTimerData(tim, D)
    call TimerStart(tim, til, false, function AssassinLeap_Timer)
    call DestroyGroup(g)
 set g = null
 set t = null
 set tim = null
endfunction

private function AssassinLeap_Conditions takes nothing returns boolean
        return GetSpellAbilityId() == SpellID
endfunction

//===========================================================================
function InitTrig_AssassinLeap takes nothing returns nothing
    local trigger AssassinLeap = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( AssassinLeap, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( AssassinLeap, function AssassinLeap_Conditions )
    call TriggerAddAction( AssassinLeap, function AssassinLeap_Actions )
endfunction

endscope
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
JASS:
call TriggerAddCondition( AssassinLeap, function AssassinLeap_Conditions )

This should be:

JASS:
call TriggerAddCondition( AssassinLeap, Filter( function AssassinLeap_Conditions ))

This should have given you a syntax error though. That's really weird. After further testing it seems that it doesn't respond with a syntax error.

JASS:
native Condition takes code func returns conditionfunc
native Filter takes code func returns filterfunc
native TriggerAddCondition takes trigger t, boolexpr cond returns triggercondition

Actually, this is not the cause of the problem. Prior to patch 1.24 this would have returned a syntax error, however now it seems to work perfectly fine even without the boolexpr conversion.
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
The rawcode is 'asle' So that's not the problem. The trigger isn't running. Sometimes I think my JNGP is broken, that or the map. I'll try it in another map.

EDIT: Yourname got me to thinking, and I changed the name of the trigger in the lefthand panel from AssassinsLeap to AssassinLeap. I also added initializer InitTrig_AssassinLeap to the scope. It seems to work now.
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
Yea so it was probably an issue with your initializer. This is what I tend to do:

JASS:
scope ScopeName initializer init
...
    public function init takes nothing returns nothing
    ...
    endfunction
endscope
 
Level 11
Joined
Apr 29, 2007
Messages
826
JASS:
call TriggerAddCondition( AssassinLeap, function AssassinLeap_Conditions )
This should be:

JASS:
call TriggerAddCondition( AssassinLeap, Filter( function AssassinLeap_Conditions ))
This should have given you a syntax error though. That's really weird. After further testing it seems that it doesn't respond with a syntax error.
It does not give you an syntax error with the newest version of JassHelper, it automatically adds Condition()
 
Last edited:
Status
Not open for further replies.
Top