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

[JASS] PLzz help, timerstart function not working

Status
Not open for further replies.
Level 2
Joined
Nov 20, 2010
Messages
10
Allright.. so after my first 2 days of learning JASS and experiment with a trigger, I encountered something that I can't even think of wrong. No errors appeared, it's just that the timerstart function doesn't work at all.

can any1 help me?
JASS:
function Trig_edit_charge_of_faith_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A002' ) ) then
        return false
    endif
    return true
endfunction

function condition_group takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_Charge_faith_caster)) == true )
endfunction

function damage2 takes nothing returns nothing

 
loop
    set udg_Charge_group =  GetUnitsInRangeOfLocMatching(512, udg_Charge_faith_target, Condition(function condition_group))
    call UnitDamageTargetBJ( udg_Charge_faith_caster, GetEnumUnit(), ( 5.00 * I2R(GetUnitLevel(udg_Charge_faith_caster))) , ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
    
    set udg_Charge_start_int = udg_Charge_start_int + 1
    set udg_Charge_degree = udg_Charge_degree + 10
    call TriggerSleepAction( 0.01)
    
       
        
    
    exitwhen udg_Charge_start_int > udg_Charge_end_int
    endloop


endfunction

function damage_callback takes nothing returns nothing



    call AddSpecialEffectLocBJ( PolarProjectionBJ(udg_Charge_faith_target, 100, udg_Charge_degree), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
        call DestroyEffectBJ(GetLastCreatedEffectBJ())
    call AddSpecialEffectLocBJ( PolarProjectionBJ(udg_Charge_faith_target, 200, udg_Charge_degree), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
        call DestroyEffectBJ(GetLastCreatedEffectBJ())
    call AddSpecialEffectLocBJ( PolarProjectionBJ(udg_Charge_faith_target, 300, udg_Charge_degree), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
        call DestroyEffectBJ(GetLastCreatedEffectBJ())
    call AddSpecialEffectLocBJ( PolarProjectionBJ(udg_Charge_faith_target, 400, udg_Charge_degree), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
        call DestroyEffectBJ(GetLastCreatedEffectBJ())
 
  

endfunction

function Trig_edit_charge_of_faith_Actions takes nothing returns nothing
    local unit udg_Charge_faith_caster
    local unit centre
    local location udg_Charge_faith_target
    local integer udg_Charge_degree
    local integer udg_Charge_start_int
    local integer udg_Charge_end_int
    local unit unit1
    local unit unit2
    local unit unit3
    local unit unit4
    local unit unit5
    local unit unit6
    local unit unit7
    local unit unit8
    local unit unit9
    local group udg_Charge_group 
    local lightning effect1
    local lightning effect2
    local lightning effect3
    local lightning effect4
    local lightning effect5
    local lightning effect6
    local lightning effect7
    local lightning effect8
    local lightning effect9
    local timer udg_Charge_timer = CreateTimer()
    
    
    
    
    
   
    
    
    
    set udg_Charge_faith_caster =  GetSpellAbilityUnit()
    set udg_Charge_faith_target = GetSpellTargetLoc()
    set udg_Charge_degree = 0
    set udg_Charge_start_int = 0
    set udg_Charge_end_int = 180
    
    set udg_Charge_group =  GetUnitsInRangeOfLocMatching(512, udg_Charge_faith_target, Condition(function condition_group))
    
    
    
    
    call CreateNUnitsAtLoc( 1, 'h004', Player(11),udg_Charge_faith_target, bj_UNIT_FACING )
    set centre = GetLastCreatedUnit()
    
    call TriggerSleepAction(2.00)
    call SetUnitTimeScalePercent(centre, 0.00 )
    
    call TimerStart(udg_Charge_timer, 0.25, true, function damage_callback)
    
    
    call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(udg_Charge_faith_caster),PolarProjectionBJ(udg_Charge_faith_target, 500, 0) , bj_UNIT_FACING )
    set unit1 = GetLastCreatedUnit()
    call AddLightningLoc( "HWPB", GetUnitLoc(unit1), GetUnitLoc(centre) )
    set effect1 = GetLastCreatedLightningBJ()
    
    
    
    call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(udg_Charge_faith_caster),PolarProjectionBJ(udg_Charge_faith_target, 500, 45) , bj_UNIT_FACING )
    set unit2 = GetLastCreatedUnit()
    call AddLightningLoc( "HWPB", GetUnitLoc(unit2), GetUnitLoc(centre) )
    set effect2 = GetLastCreatedLightningBJ()
    
    
    
    call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(udg_Charge_faith_caster),PolarProjectionBJ(udg_Charge_faith_target, 500, 90) , bj_UNIT_FACING )
    set unit3 = GetLastCreatedUnit()
    call AddLightningLoc( "HWPB", GetUnitLoc(unit3), GetUnitLoc(centre) )
    set effect3 = GetLastCreatedLightningBJ()
    
    
    call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(udg_Charge_faith_caster),PolarProjectionBJ(udg_Charge_faith_target, 500, 135) , bj_UNIT_FACING )
    set unit4 = GetLastCreatedUnit()
    
    call AddLightningLoc( "HWPB", GetUnitLoc(unit4), GetUnitLoc(centre) )
    set effect4 = GetLastCreatedLightningBJ()
    
    call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(udg_Charge_faith_caster),PolarProjectionBJ(udg_Charge_faith_target, 500, 180) , bj_UNIT_FACING )
    set unit5 = GetLastCreatedUnit()
    call AddLightningLoc( "HWPB", GetUnitLoc(unit5), GetUnitLoc(centre) )
    set effect5 = GetLastCreatedLightningBJ()
    
    
    call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(udg_Charge_faith_caster),PolarProjectionBJ(udg_Charge_faith_target, 500, 225) , bj_UNIT_FACING )
    set unit6 = GetLastCreatedUnit()
    call AddLightningLoc( "HWPB", GetUnitLoc(unit6), GetUnitLoc(centre) )
    set effect6 = GetLastCreatedLightningBJ()
    
    call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(udg_Charge_faith_caster),PolarProjectionBJ(udg_Charge_faith_target, 500, 270) , bj_UNIT_FACING )
    set unit7 = GetLastCreatedUnit()
    call AddLightningLoc( "HWPB", GetUnitLoc(unit7), GetUnitLoc(centre) )
    set effect7 = GetLastCreatedLightningBJ()
    
    call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(udg_Charge_faith_caster),PolarProjectionBJ(udg_Charge_faith_target, 500, 315) , bj_UNIT_FACING )
    set unit9 = GetLastCreatedUnit()
    call AddLightningLoc( "HWPB", GetUnitLoc(unit9), GetUnitLoc(centre) )
    set effect9 = GetLastCreatedLightningBJ()
    
    call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(udg_Charge_faith_caster),PolarProjectionBJ(udg_Charge_faith_target, 500, 360) , bj_UNIT_FACING )
    set unit8 = GetLastCreatedUnit()
    call AddLightningLoc( "HWPB", GetUnitLoc(unit8), GetUnitLoc(centre) )
    set effect8 = GetLastCreatedLightningBJ()
    
    call ForGroupBJ( udg_Charge_group, function damage2)
    
    
    
    
    
    
    
    set udg_Charge_degree = 0
    set udg_Charge_start_int = 0
    call RemoveLocation( udg_Charge_faith_target)
    
    call RemoveUnit(unit1)
    call RemoveUnit(unit2)
    call RemoveUnit(unit3)
    call RemoveUnit(unit4)
    call RemoveUnit(unit5)
    call RemoveUnit(unit6)
    call RemoveUnit(unit7)
    call RemoveUnit(unit8)
    call RemoveUnit(unit9)
    
    call DestroyLightning( effect1)
    call DestroyLightning( effect2)
    call DestroyLightning( effect3)
    call DestroyLightning( effect4)
    call DestroyLightning( effect5)
    call DestroyLightning( effect6)
    call DestroyLightning( effect7)
    call DestroyLightning( effect8)
    call DestroyLightning( effect9)
    
        
    
    
    set udg_Charge_faith_caster = null
    set unit1 = null
    set unit2 = null
    set unit4 = null
    set unit3 = null
    set unit5 = null
    set unit6 = null
    set unit7 = null
    set unit8 = null
    set unit9 = null
    
    
    
    
    
    
endfunction

//===========================================================================
function InitTrig_edit_charge_of_faith takes nothing returns nothing
    set gg_trg_edit_charge_of_faith = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_edit_charge_of_faith, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_edit_charge_of_faith, Condition( function Trig_edit_charge_of_faith_Conditions ) )
    call TriggerAddAction( gg_trg_edit_charge_of_faith, function Trig_edit_charge_of_faith_Actions )
endfunction
PLZZ help..
pls help...
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
In the initialization block:

udg_Charge_timer = CreateTimer()

Remove that call CreateTimer you have there.

Try to get rid of all those BJ's, marked in red.

For example: UnitDamageTargetBJ - > UnitDamageTarget.

You can also do this: call DestroyEffect(AddSpecialEffect(xxx)).

Try not to use locations, use coordinates instead.
 
Level 2
Joined
Nov 20, 2010
Messages
10
Thanks for the help, but unfortunately, removing BJs makes things worse in my comp...




Or maybe I can just make a custom dummy unit to cast a certain AOE/second invisible damage spell to replace the DPS? just some random thoughts.. but if that's possible, than I don't have problems with local variables and their limitations.
 
You have to know BJs a bit before changing them into natives. Just removing "BJ" doesn't work all the time.

I guess your problem is a variable issue. What the hell are all those "udg" in the name of your local variables? udg means User Defined Globals so you shouldn't name a local with udg.

That means that the variable "udg_Charge_faith_target" (which you can replace with coordinates, as Maker said) is both a local and a global and that's epic fail. You have several choices :
- Use globals to store your coordinates but it won't be MUI,
- Use an hashtable to attach coordinates to your timer's Id,
- Use a TimerUtils library to attach your coordinates to your timer's custom value (faster).

GetExpiredTimer() works with callback called functions, of course.
 
Level 2
Joined
Nov 20, 2010
Messages
10
function Trig_Earth_divide_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A00H' ) ) then
return false
endif
return true
endfunction

function Trig_Earth_divide_Actions takes nothing returns nothing
local unit udg_Earth_divide_caster
local unit udg_Earth_divide_unit
local timer udg_Earth_divide_timer
set udg_Key_hashtable = ( udg_Key_hashtable + 1 )
set udg_Earth_divide_caster = GetSpellAbilityUnit()
call PauseUnitBJ( true, udg_Earth_divide_caster )
call AddSpecialEffectLocBJ( GetUnitLoc(udg_Earth_divide_caster), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
call AddSpecialEffectLocBJ( PolarProjectionBJ(GetUnitLoc(udg_Earth_divide_caster), 256, 0), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call AddSpecialEffectLocBJ( PolarProjectionBJ(GetUnitLoc(udg_Earth_divide_caster), 256, 45.00), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call AddSpecialEffectLocBJ( PolarProjectionBJ(GetUnitLoc(udg_Earth_divide_caster), 256, 90.00), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call AddSpecialEffectLocBJ( PolarProjectionBJ(GetUnitLoc(udg_Earth_divide_caster), 256, 135.00), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call AddSpecialEffectLocBJ( PolarProjectionBJ(GetUnitLoc(udg_Earth_divide_caster), 256, 180.00), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call AddSpecialEffectLocBJ( PolarProjectionBJ(GetUnitLoc(udg_Earth_divide_caster), 256, 225.00), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call AddSpecialEffectLocBJ( PolarProjectionBJ(GetUnitLoc(udg_Earth_divide_caster), 256, 270.00), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call AddSpecialEffectLocBJ( PolarProjectionBJ(GetUnitLoc(udg_Earth_divide_caster), 256, 315.00), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call AddSpecialEffectLocBJ( PolarProjectionBJ(GetUnitLoc(udg_Earth_divide_caster), 256, 360.00), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call TerrainDeformationRippleBJ( 2.00, false, GetUnitLoc(udg_Earth_divide_caster), 1024, 1024, 64, 1, 512 )
call CreateNUnitsAtLoc( 1, 'h001', Player(0), GetUnitLoc(udg_Earth_divide_caster), bj_UNIT_FACING )
call SaveUnitHandleBJ( udg_Earth_divide_unit, 0, GetHandleIdBJ(GetLastCreatedUnit()), udg_Earth_divide_hashtable )
call GroupAddUnitSimple( GetLastCreatedUnit(), udg_Earth_divide_group )
call TriggerSleepAction( 2 )
call TerrainDeformationRippleBJ( 5.00, false, GetUnitLoc(udg_Earth_divide_caster), 1024, 1024, 64, 1, 512 )
call PauseUnitBJ( false, udg_Earth_divide_caster )
call TriggerExecute( gg_trg_Earth_divide_contd )
endfunction

//===========================================================================
function InitTrig_Earth_divide takes nothing returns nothing
set gg_trg_Earth_divide = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Earth_divide, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Earth_divide, Condition( function Trig_Earth_divide_Conditions ) )
call TriggerAddAction( gg_trg_Earth_divide, function Trig_Earth_divide_Actions )
endfunction

Then what about this one... the trigger stops working when I tried to save a unit handle.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • call SaveUnitHandle( udg_Earth_divide_hashtable , GetHandleId(bj_lastCreatedUnit) , 0 , udg_Earth_divide_unit )
Use [code=jass][/code] tags.

And do this: DestroyEffect(AddSpecialEffect(...))

You have lots of leaks. Try to get rid of using BJ's and locations. Use coordinates instead.

The condition can be like this:
JASS:
function Trig_Earth_divide_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00H'
endfunction
 
Status
Not open for further replies.
Top