Failed Attempt in vJASS

SFilip

Gone but not forgotten
Reaction score
634
OK, but my point is that replacing constants does not make it more efficient.
 

cleeezzz

The Undead Ranger.
Reaction score
268
alright, replaced 20 with 0.34906

JASS:
scope Spread

private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00D' or GetSpellAbilityId() == 'A006'
endfunction

private function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location Cast_Point = GetSpellTargetLoc()
    local real x = GetUnitX(Caster)
    local real y = GetUnitY(Caster)
    local real x1 = GetLocationX(Cast_Point)
    local real y1 = GetLocationY(Cast_Point)
    local real Angle = Atan2(y1 - y, x1 - x)
    local real px1 = x + 256 * Cos(Angle + 0.34906)
    local real py1 = y + 256 * Sin(Angle + 0.34906)
    local real px2 = x + 256 * Cos(Angle - 0.34906)
    local real py2 = y + 256 * Sin(Angle - 0.34906)
    local unit Dummy = CreateUnit(GetOwningPlayer(Caster), 'h001', x, y, 0)
    call UnitApplyTimedLife(Dummy, 'BTLF', 4.00 )
    call SetUnitAbilityLevel(Dummy, 'A009', GetUnitAbilityLevel(Caster, GetSpellAbilityId()) )
    call IssuePointOrder(Dummy, "breathoffrost", px1, py1)
    call IssuePointOrder(Dummy, "breathoffrost", px2, py2)
    call RemoveLocation(Cast_Point)
    set Caster = null
    set Cast_Point = null
    set Dummy = null
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger Spread= CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( Spread, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( Spread, Condition( function Conditions ) )
    call TriggerAddAction( Spread, function Actions )
endfunction

endscope

alright, im assuming thats done :p

i have a few questions, why isn't the Shake function Private? (everything else is)
and after i call StartTimer, how do i do actions when the timer expires (without a new trigger perhaps?)
questions for the trigger in my previous post.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
alright, replaced 20 with 0.34906

JASS:
scope Spread

private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00D' or GetSpellAbilityId() == 'A006'
endfunction

private function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location Cast_Point = GetSpellTargetLoc()
    local real x = GetUnitX(Caster)
    local real y = GetUnitY(Caster)
    local real x1 = GetLocationX(Cast_Point)
    local real y1 = GetLocationY(Cast_Point)
    local real Angle = Atan2(y1 - y, x1 - x)
    local real px1 = x + 256 * Cos(Angle + 0.34906)
    local real py1 = y + 256 * Sin(Angle + 0.34906)
    local real px2 = x + 256 * Cos(Angle - 0.34906)
    local real py2 = y + 256 * Sin(Angle - 0.34906)
    local unit Dummy = CreateUnit(GetOwningPlayer(Caster), 'h001', x, y, 0)
    call UnitApplyTimedLife(Dummy, 'BTLF', 4.00 )
    call SetUnitAbilityLevel(Dummy, 'A009', GetUnitAbilityLevel(Caster, GetSpellAbilityId()) )
    call IssuePointOrder(Dummy, "breathoffrost", px1, py1)
    call IssuePointOrder(Dummy, "breathoffrost", px2, py2)
    call RemoveLocation(Cast_Point)
    set Caster = null
    set Cast_Point = null
    set Dummy = null
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger Spread= CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( Spread, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( Spread, Condition( function Conditions ) )
    call TriggerAddAction( Spread, function Actions )
endfunction

endscope

alright, im assuming thats done :p


questions for the trigger in my previous post.

You can make Shake private if you want. It doesn't really matter as long as there isn't another function named "shake". So yeah, it might be wise to make it private.

And when using "TimerStart(...)" the timer will start first, run the amount of time you specified, then the actions in the "callback" will be run. All executions after the "TimerStart(...)" function won't perform after the specified time though.

If you specified "true" for the "periodic" input, then it will keep running, and it will call the "callback" function after each expiration. ;)
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
JASS:
native TimerStart           takes timer whichTimer, real timeout, boolean periodic, code handlerFunc returns nothing


Code Handlerfunc

So you would do something like this for example:
JASS:
globals
    integer i = 0 
endglobals

function Callback takes nothing returns nothing
    local timer t =  GetExpiredTimer()    //retrieves the timer that expired
    set i = i + 1
    if i >= 50 then
        call PauseTimer(t) //will stop the timer
        call DestroyTimer(t) //destroys the timer
    endif
    set t = null
endfunction

function JASS takes nothing returns nothing
    local timer t = CreateTimer()
    call TimerStart(t,0.05,true,function Callback) //starts the timer
//Starts timer "t"
//Runs the function "Callback" every 0.05 seconds
//It is periodic because of the "true"
//It runs to function "Callback" because of the "function Callback" argument
    set t = null
endfunction
 
Reaction score
456
The same would happen if you removed the t nulling and return line from the if. :)
 

cleeezzz

The Undead Ranger.
Reaction score
268
Handlerfunc

ooh thats what thats for..

ok i tried this

JASS:
scope HA

private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00C' or GetSpellAbilityId() == 'A00W'
endfunction

private function Shake takes nothing returns nothing
    call CameraSetEQNoiseForPlayer( GetOwningPlayer(GetEnumUnit()), 50.00 )
endfunction

private function Fire takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local real px = x + Offset * Cos(Angle) 
    local real py = y + Offset * Sin(Angle)
    if Offset <= Offset_Max then
        call IssuePointOrder(Dummy, "flamestrike", px, py)
        set Offset = Offset + 250
    else
        call PauseTimer(t)
        call DestroyTimer(t)
        set t = null
        set Dummy = null        
    endif
endfunction
    
private function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location Caster_Loc = GetUnitLoc(Caster)
    local real x = GetUnitX(Caster)
    local real y = GetUnitY(Caster)
    local location Cast_Point = GetSpellTargetLoc()
    local real x1 = GetLocationX(Cast_Point) 
    local real y1 = GetLocationY(Cast_Point)
    local real Angle = Atan2(y1 - y, x1 - x)          
    local group Shake_Group = GetUnitsInRangeOfLocAll(4000.00, Caster_Loc)
    local unit Dummy = CreateUnit(GetOwningPlayer(Caster),'h000', x, y, 0)
    local unit Dummy2 = CreateUnit(GetOwningPlayer(Caster),'h000', x, y, 0)
    local real Offset = 250.
    local real Offset_Max = (1500 + ( 500 * GetUnitAbilityLevel(Caster, GetSpellAbilityId()))) 
    local timer t = CreateTimer ()

    call ForGroup(Shake_Group, function Shake )
    call DestroyGroup(Shake_Group)
            
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", x, y ))
    call DestroyEffect(AddSpecialEffect( "Abilities\\Spells\\Orc\\AncestralSpirit\\AncestralSpiritCaster.mdl", x , y ))
    call DestroyEffect(AddSpecialEffect( "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl", x, y ))

    call TerrainDeformRipple ( x, y, 2000, 60, 4, 20, 1000.00 , 0.5 , 500.00 , true)
    call SetUnitState(Caster, UNIT_STATE_LIFE, GetUnitState(Caster, UNIT_STATE_MAX_LIFE))
            
    call UnitApplyTimedLife(Dummy,'BTLF',7)
    call SetUnitAbilityLevel(Dummy, 'A00A', GetUnitAbilityLevel(Caster, GetSpellAbilityId()))
            
    call TimerStart( t, 0.27, true, function Fire )
    
    call UnitApplyTimedLife(Dummy2,'BTLF',5)
    call SetUnitAbilityLevel(Dummy2, 'A001', GetUnitAbilityLevel(Caster, GetSpellAbilityId()))
    call IssuePointOrder(Dummy2, "shockwave", x1 , y1 )
    call RemoveLocation(Cast_Point)
    call RemoveLocation(Caster_Loc)
    call DestroyTimer(Holy_Arrow_Timer)
    set Caster = null
    set Dummy2 = null
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger HA = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( HA, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( HA, Condition( function Conditions ) )
    call TriggerAddAction( HA, function Actions )
endfunction

endscope

few issues though, since the variables are local, they dont carry over to the Fire function, should i make them global? (if not, how should i?)
 

cleeezzz

The Undead Ranger.
Reaction score
268
well i guess i tested myself.

JASS:
scope HA

globals
    real x
    real y
    real x1
    real y1
    real px
    real py
    real Angle
    unit Dummy
    real Offset
    real Offset_Max
endglobals


private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00C' or GetSpellAbilityId() == 'A00W'
endfunction

private function Shake takes nothing returns nothing
    call CameraSetEQNoiseForPlayer( GetOwningPlayer(GetEnumUnit()), 50.00 )
endfunction

private function Fire takes nothing returns nothing
    local timer t = GetExpiredTimer()
    set px = x + Offset * Cos(Angle) 
    set py = y + Offset * Sin(Angle)
    if Offset <= Offset_Max then
        call IssuePointOrder(Dummy, "flamestrike", px, py)
        set Offset = Offset + 250
    else
        call PauseTimer(t)
        call DestroyTimer(t)
        set t = null
        set Dummy = null        
    endif
endfunction
    
private function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location Caster_Loc = GetUnitLoc(Caster)   
    local location Cast_Point = GetSpellTargetLoc()  
    local group Shake_Group = GetUnitsInRangeOfLocAll(4000.00, Caster_Loc)
    local unit Dummy2 = CreateUnit(GetOwningPlayer(Caster),'h000', x, y, 0)
    local timer t = CreateTimer ()

    set x = GetUnitX(Caster)
    set y = GetUnitY(Caster)
    set x1 = GetLocationX(Cast_Point) 
    set y1 = GetLocationY(Cast_Point)
    set Angle = Atan2(y1 - y, x1 - x)  
    set Offset = 250.
    set Offset_Max = (1500 + ( 500 * GetUnitAbilityLevel(Caster, GetSpellAbilityId())))
    set Dummy = CreateUnit(GetOwningPlayer(Caster),'h000', x, y, 0) 
    
    call ForGroup(Shake_Group, function Shake )
    call DestroyGroup(Shake_Group)
            
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", x, y ))
    call DestroyEffect(AddSpecialEffect( "Abilities\\Spells\\Orc\\AncestralSpirit\\AncestralSpiritCaster.mdl", x , y ))
    call DestroyEffect(AddSpecialEffect( "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl", x, y ))

    call TerrainDeformRipple ( x, y, 2000, 60, 4, 20, 1000.00 , 0.5 , 500.00 , true)
    call SetUnitState(Caster, UNIT_STATE_LIFE, GetUnitState(Caster, UNIT_STATE_MAX_LIFE))
            
    call UnitApplyTimedLife(Dummy,'BTLF',7)
    call SetUnitAbilityLevel(Dummy, 'A00A', GetUnitAbilityLevel(Caster, GetSpellAbilityId()))
            
    call TimerStart( t, 0.27, true, function Fire )
    
    call UnitApplyTimedLife(Dummy2,'BTLF',5)
    call SetUnitAbilityLevel(Dummy2, 'A001', GetUnitAbilityLevel(Caster, GetSpellAbilityId()))
    call IssuePointOrder(Dummy2, "shockwave", x1 , y1 )
    call RemoveLocation(Cast_Point)
    call RemoveLocation(Caster_Loc)
    set Caster = null
    set Dummy2 = null
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger HA = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( HA, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( HA, Condition( function Conditions ) )
    call TriggerAddAction( HA, function Actions )
endfunction

endscope

and it works, not sure if its MUI though.

EDIT: does it clash with spreadshot? cuz suddenly both dont work.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top