• 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] Help pls

Status
Not open for further replies.
Level 1
Joined
Mar 21, 2013
Messages
3
Hi,

i have a problem with my trigger.. the mainproblem seems to be in shuriken function... the unit is casting a shuriken and throw it in direktion of the target point... at target point there should be a impact of the shuriken and damage the enemy(damage isnt included jet) but for some reason the shuriken doesnt do the impact every time... sometimes its flying and flying and... so on... can anyone help me with the problem pls cause i cant find the problem :/

have to say iam still learning jass since 4 days so dont be that hard. i know it isnt realy clean code.

I also have a question about the hashtable in my trigger... if its declared like in this trigger is the trigger loosing the mui ability? or is it still mui then? if its not mui can you tell me how to get it mui maybe?^^



JASS:
scope GiantShuriken initializer InitTrig_Giant_Shuriken
    globals
        private hashtable table
    endglobals

    private function Trig_Giant_Shuriken_Conditions takes nothing returns boolean
        if ( not ( GetSpellAbilityId() == 'A000' ) ) then
            return false
        endif
        return true
    endfunction

    private function shuriken takes nothing returns nothing
        local timer t = GetExpiredTimer ()                
        local unit caster = LoadUnitHandle(table,GetHandleId(t),1)                
        local unit shuri       
        local integer i = LoadInteger(table,GetHandleId(t),3)        
        local location loc_target = LoadLocationHandle(table,GetHandleId(t),2)
        local location loc_caster = GetUnitLoc(caster)
        local location loc_shuri
        local location move
                
            call SaveInteger(table,GetHandleId(t),3,i+1)       
            
                if (i==1) or (i==3) or (i==5) or (i==7) or (i==9) then
                    call CreateNUnitsAtLoc( 1, 'hkni', GetOwningPlayer(caster), loc_caster, bj_UNIT_FACING )
                    call SetUnitVertexColorBJ( GetLastCreatedUnit(), 100, 100.00, 100.00, 80.00 )
                    call UnitApplyTimedLifeBJ( 0.01, 'BTLF', GetLastCreatedUnit() )            
                    
                elseif (i==10) then        
                
                    call CreateNUnitsAtLoc( 1, 'hmtm', GetOwningPlayer(caster), loc_caster, GetUnitFacing(caster) )
                    set shuri = GetLastCreatedUnit()                                    
                    set loc_shuri = GetUnitLoc(shuri)
                    set move = PolarProjectionBJ(loc_shuri, 50.00, GetUnitFacing(shuri))
                    call SetUnitPositionLoc( shuri, move )
                    call SaveUnitHandle(table,GetHandleId(t),4,shuri)                        
                    
                elseif (i>10) then
            
                    set shuri=LoadUnitHandle(table,GetHandleId(t),4)        
                    set loc_shuri = GetUnitLoc(shuri)            
                    
                        if (DistanceBetweenPoints(loc_shuri,loc_target) <= 50) then
                            
                            call SetUnitTimeScalePercent( shuri, 0.00 )
                            call CreateNUnitsAtLoc( 1, 'h000', GetOwningPlayer(caster), loc_shuri, GetUnitFacing(shuri) )
                            call SetUnitTimeScalePercent( GetLastCreatedUnit(), 0.00 )
                            call UnitApplyTimedLife( GetLastCreatedUnit(), 'BTLF',5.00)
                            call KillUnit( shuri )
                            call DestroyEffect(AddSpecialEffectLoc("NewDirtEXNofire.mdx",loc_shuri)) 
                            
                            call RemoveLocation(loc_target)
                            call RemoveLocation(loc_caster)
                            call RemoveLocation(loc_shuri)
                            call DestroyTimer(GetExpiredTimer())
                            set t=null
                            set loc_target=null
                            set loc_caster=null
                            set loc_shuri=null
                            set move=null
                            set shuri=null
                            set caster=null
                            
                        else
                            set move = PolarProjectionBJ(loc_shuri, 50.00, GetUnitFacing(shuri))
                            call SetUnitPositionLoc( shuri, move)
                            call SaveUnitHandle(table,GetHandleId(t),4,shuri) 

                    endif
                endif    
        
    endfunction

    private function Trig_Giant_Shuriken_Actions takes nothing returns nothing
        local timer t = CreateTimer()
        local unit caster = GetTriggerUnit () 
        local location loc_caster = GetUnitLoc(caster)
        local location loc_target = GetSpellTargetLoc()
        local integer i=0
            call SaveUnitHandle(table,GetHandleId(t),1,caster)
            call SaveLocationHandle(table,GetHandleId(t),2,loc_target)
            call SaveInteger(table,GetHandleId(t),3,i)
            call SetUnitAnimation( caster, "stand" )
            call CreateNUnitsAtLoc( 1, 'hrif', GetOwningPlayer(caster), loc_caster, GetUnitFacing(caster) )                        
            call SetUnitVertexColorBJ( GetLastCreatedUnit(), 17.00, 17.00, 17.00, 0.00 )
            call UnitApplyTimedLifeBJ( 0.5, 'BTLF', GetLastCreatedUnit() )
            call TimerStart(t,0.05,true,function shuriken)
            
            //set t=null
            //set caster=null
            //set loc_caster=null
            //set loc_target=null
            //call RemoveLocation(loc_caster1)
            //call RemoveLocation(loc_target1)
            
    endfunction

//===========================================================================
function InitTrig_Giant_Shuriken takes nothing returns nothing
    call InitHashtableBJ(  )
    set table = GetLastCreatedHashtableBJ()
    set gg_trg_Giant_Shuriken = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Giant_Shuriken, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Giant_Shuriken, Condition( function Trig_Giant_Shuriken_Conditions ) )
    call TriggerAddAction( gg_trg_Giant_Shuriken, function Trig_Giant_Shuriken_Actions )
    //set gg_trg_Giant_Shuriken = null
endfunction

endscope
 
since u just learned jass learn how to inline. that means get rid of all the functions in red and replace w the purple ones also use x and y values instead of locations as locations leak and x and y values do not. this way u could get rid of all those removelocations.

this is also vjass not jass so next time put the vjass tags on it.

also make ur function names shorter u dont need those long names. and change ur initTrig trigger into a private function

heres what ur init trig should look like
JASS:
private function init takes nothing returns nothing
    local trigger t = CreateTrigger()
    set table = InitHashtable()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerAddAction( t, function Actions )
    set t = null
endfunction

heres what conditions should be
JASS:
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A000' 
    endfunction
 
Last edited:

Wrda

Spell Reviewer
Level 28
Joined
Nov 18, 2012
Messages
1,993
heres what conditions should be
JASS:
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A000' 
    endfunction
Uh? This returns a boolean? So what's its value? Shouldn't it be like this:
JASS:
    private function Trig_Giant_Shuriken_Conditions takes nothing returns boolean
        if ( GetSpellAbilityId() == 'A000' ) then
        return true
    endfunction
Remove the
JASS:
call TriggerAddCondition( gg_trg_Giant_Shuriken, Condition( function Trig_Giant_Shuriken_Conditions ) )

JASS:
private function shuriken takes nothing returns nothing
        local timer t = GetExpiredTimer ()                
        local unit caster = LoadUnitHandle(table,GetHandleId(t),1)                
        local unit shuri       
        local integer i = LoadInteger(table,GetHandleId(t),3)        
        local location loc_target = LoadLocationHandle(table,GetHandleId(t),2)
        local location loc_caster = GetUnitLoc(caster)
        local location loc_shuri
        local location move
            if (Trig_Giant_shuriken_Conditions) then    
              call SaveInteger(table,GetHandleId(t),3,i+1)
...................................blabla................................
            else
              set t=null
              set loc_target=null
              set loc_caster=null
              set loc_shuri=null
              set move=null
              set shuri=null
              set caster=null
            endif
Don't laugh at me( I don't have jngp, and unfortunately can't get it), I only know some vjass.
 
Uh? This returns a boolean? So what's its value? Shouldn't it be like this:
JASS:
    private function Trig_Giant_Shuriken_Conditions takes nothing returns boolean
        if ( GetSpellAbilityId() == 'A000' ) then
        return true
    endfunction

all u need is the way i put it it will return the value. if spell ability id is the same as 'A000' then it will return true. if it is not the same it will return false

you should also never null variables in the else function it will cause leaks since they wont be removed.

and i told him to inline his functions so tht will change things if he needs help w tht i can help him or someone else will
 
Status
Not open for further replies.
Top