- Joined
- Mar 29, 2012
- Messages
- 542
I start a timer but it doesn't expire as i determined... It's supposed to expire every 0.03125 seconds. The debug message inside the periodic function shows every 2 seconds (perhaps)
+Rep for help...
Feel free to give suggestion too...
JASS:
//***************************************************************************
//* Critical Combo
//*
//* Created by: Ofel
//* Version: 1.0
//*
//* =========================================================================
//*
//* Credits :
//* -
//*
//* =========================================================================
//*
//* Changelog :
//* - v1.0: Initial version.
//*
//***************************************************************************
//***************************************************************************
//*
//* Configuration
//*
//***************************************************************************
constant function CC_AbilityID takes nothing returns integer
return 'A000'
endfunction
constant function CC_OrderID takes nothing returns string
return "banish"
endfunction
constant function CC_DummyID takes nothing returns integer
return 'u000'
endfunction
constant function CC_Interval takes nothing returns real
return 0.03125
endfunction
constant function CC_SplatBlood takes nothing returns boolean
return true
endfunction
constant function CC_BloodModel takes nothing returns string
return ""
endfunction
constant function CC_BloodPerSlash takes nothing returns integer
return 2
endfunction
constant function CC_BloodSplatMaxDistance takes nothing returns real
return 400.00
endfunction
constant function CC_BloodSplatMinDistance takes nothing returns real
return 100.00
endfunction
constant function CC_BloodSplatMaxSpeed takes nothing returns real
return 40.00
endfunction
constant function CC_BloodSplatMinSpeed takes nothing returns real
return 20.00
endfunction
constant function CC_SlashAnimation takes nothing returns string
return "attack"
endfunction
constant function CC_SlashAnimationSpeed takes nothing returns real
return 300.00
endfunction
constant function CC_SlashInterval takes nothing returns real
return 0.20
endfunction
constant function CC_SlashDistance takes nothing returns real
return 100.00
endfunction
constant function CC_SlashTargetEffect takes nothing returns string
return ""
endfunction
constant function CC_RunAnimationIndex takes nothing returns integer
return 6
endfunction
constant function CC_RunGroundEffect takes nothing returns string
return ""
endfunction
function CC_SlashNumber takes integer level returns integer
return level * 5 + 15
endfunction
//***************************************************************************
//*
//* End of Configuration
//*
//***************************************************************************
constant function CC_NewSlashDistance takes nothing returns real
return CC_SlashDistance() * CC_SlashDistance()
endfunction
function CC_IsUnitAlive takes unit u returns boolean
return not( GetUnitTypeId(u) == null and IsUnitType(u, UNIT_TYPE_DEAD) and u == null )
endfunction
//***************************************************************************
//*
//* Periodic Function
//*
//***************************************************************************
function CC_Periodic takes nothing returns nothing
local integer index = udg_CC_Next[0]
local real x
local real y
local real x2
local real y2
local real x3
local real y3
local real dist
local real angle
loop
exitwhen index == 0
call DebugInt("index", index)
if (udg_CC_Stage[index] == 1) then
elseif (udg_CC_Stage[index] == 2) then
if (CC_IsUnitAlive(udg_CC_Caster[index]) and CC_IsUnitAlive(udg_CC_Target[index]) and GetUnitCurrentOrder(udg_CC_Caster[index]) == udg_CC_OrderID and udg_CC_Slashed[index] > 0) then
set x = GetUnitX(udg_CC_Caster[index])
set y = GetUnitY(udg_CC_Caster[index])
set x2 = GetUnitX(udg_CC_Target[index])
set y2 = GetUnitY(udg_CC_Target[index])
set x3 = x2 - x
set y3 = y2 - y
set dist = (x3) * (x3) + (y3) * (y3)
if (dist > CC_NewSlashDistance()) then
else
endif
else
endif
elseif (udg_CC_Stage[index] == 3) then
set udg_CC_Recycle[index] = udg_CC_Recycle[0]
set udg_CC_Recycle[0] = index
set udg_CC_Prev[udg_CC_Next[index]] = udg_CC_Prev[index]
set udg_CC_Next[udg_CC_Prev[index]] = udg_CC_Next[index]
set udg_CC_ActiveInstance = udg_CC_ActiveInstance - 1
if (udg_CC_ActiveInstance == 0) then
call PauseTimer(udg_CC_Timer)
endif
endif
set index = udg_CC_Next[index]
endloop
endfunction
//***************************************************************************
//*
//* Starter Function
//*
//***************************************************************************
function CC_Cast takes nothing returns boolean
local integer index
local real x
local real y
if (GetSpellAbilityId() == CC_AbilityID()) then
set index = udg_CC_Recycle[0]
if (index == 0) then
set udg_CC_InstanceCount = udg_CC_InstanceCount + 1
set index = udg_CC_InstanceCount
else
set udg_CC_Recycle[0] = udg_CC_Recycle[index]
endif
set udg_CC_Next[index] = 0
set udg_CC_Prev[index] = udg_CC_Prev[0]
set udg_CC_Next[udg_CC_Prev[0]] = index
set udg_CC_Prev[0] = index
set udg_CC_Caster[index] = GetTriggerUnit()
set udg_CC_Owner[index] = GetTriggerPlayer()
set udg_CC_Target[index] = GetSpellTargetUnit()
set udg_CC_Level[index] = GetUnitAbilityLevel(udg_CC_Caster[index], CC_AbilityID())
set udg_CC_Slashed[index] = CC_SlashNumber(udg_CC_Level[index])
set udg_CC_Stage[index] = 2
set udg_CC_ActiveInstance = udg_CC_ActiveInstance + 1
if (udg_CC_ActiveInstance == 1) then
call TimerStart(udg_CC_Timer, CC_Interval, true, function CC_Periodic)
endif
endif
return false
endfunction
//***************************************************************************
//*
//* Initializer Function
//*
//***************************************************************************
function InitTrig_Critical_Combo takes nothing returns nothing
if (udg_CC_Timer == null) then
set udg_CC_Timer = CreateTimer()
endif
set udg_CC_OrderID = OrderId(CC_OrderID())
set gg_trg_Critical_Combo = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Critical_Combo, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_Critical_Combo, Filter(function CC_Cast))
endfunction
JASS:
function DebugInt takes string msg, integer i returns nothing
call DisplayTimedTextToPlayer(Player(0), 0, 0, 1000000, msg + " = " + I2S(i))
endfunction
+Rep for help...
Feel free to give suggestion too...