- Joined
- Mar 1, 2013
- Messages
- 555
Ok I've downloaded it
EDIT: and the file got removed as soon as I turned te virus protector on
EDIT: and the file got removed as soon as I turned te virus protector on
There's no need for a group of "Units that are not in the other group"
U know, you can add a Tornado Aura to the Chronosphere with no effect wich doesn't show up in the Unit's Buff bar. You can then, when the Chrono is created, pick every unit in the map wit the ChronoAuraBuff and pause them. If the unit is pulled outside the Chrono the buff is removed and the unit is unpased. You could test.
Another work around is Pick every Chrono Sphere and Pick every unit around the Chronospheres and check if distance between Chrono and Target is less than or equal to 400, if so, pause, else, unpause.
Did you test the distance method?
1234another work around is pick every chrono sphere and pick every unit around the chronospheres and check if distance between chrono and target is less than or equal to 400, if so, pause, else, unpause.
I know the problem but don't know how to fix it. the trigger sees that the unit is in 400 range with point[1] then it pauses but for the next intiger the unit is further than 400 from point[2] so then it unpauses. :
globals
hashtable ChronosphereHash = InitHashtable()
group ChronosphereGroup = CreateGroup()
group ChronosphereUnits = CreateGroup()
endglobals
// This happens when the Chronosphere Timer expires
function ChronosphereClear takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer i = GetHandleId(t)
local unit u = LoadUnitHandle(ChronosphereHash, i, 0)
local unit fog
call GroupEnumUnitsInRange(bj_lastCreatedGroup, GetUnitX(u), GetUnitY(u), 400, null)
loop
set fog = FirstOfGroup(bj_lastCreatedGroup)
exitwhen fog == null
call PauseUnit(fog, false)
call GroupRemoveUnit(bj_lastCreatedGroup, fog)
call GroupRemoveUnit(ChronosphereUnits, fog)
call SetUnitTimeScale(fog, 1)
endloop
call GroupRemoveUnit(ChronosphereGroup, u)
call FlushChildHashtable(ChronosphereHash, i)
call KillUnit(u)
call RemoveUnit(u)
// Turn off Loop if ChronosphereGroup is empty
set bj_groupCountUnits = 0
call ForGroup(ChronosphereGroup, function CountUnitsInGroupEnum)
if bj_groupCountUnits == 0 then
call DisableTrigger(gg_trg_ChronoLoop)
call BJDebugMsg("ChronosphereGroup empty. ChronoLOOP Disabled")
endif
set t = null
set u = null
set fog = null
endfunction
// ID of Chronosphere ability
function Trig_ChronoCast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
// Chronosphere Cast
function Trig_ChronoCast_Actions takes nothing returns nothing
local real x = GetSpellTargetX()
local real y = GetSpellTargetY()
local unit Chrono = CreateUnit(GetTriggerPlayer(), 'h000', x, y, 0)
local timer t = CreateTimer()
call TimerStart(t, 6, false, function ChronosphereClear)
call SaveUnitHandle(ChronosphereHash, GetHandleId(t), 0, Chrono)
call GroupAddUnit(ChronosphereGroup, Chrono)
call EnableTrigger(gg_trg_ChronoLoop)
set Chrono = null
set t = null
endfunction
//===========================================================================
function InitTrig_ChronoCast takes nothing returns nothing
set gg_trg_ChronoCast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_ChronoCast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_ChronoCast, Condition( function Trig_ChronoCast_Conditions ) )
call TriggerAddAction( gg_trg_ChronoCast, function Trig_ChronoCast_Actions )
endfunction
// Pause Enum units around Chronospheres (Excep Caster type units)
function ChronosphereUnitsPause takes nothing returns nothing
local unit u = GetEnumUnit()
call PauseUnit(u, true)
call SetUnitTimeScale(u, 0)
set u = null
endfunction
// Enum units around Chronospheres, add them to ChronosphereUnits if they're not.
function ChronosphereUnitsEnum takes nothing returns nothing
local unit u = GetEnumUnit()
local unit fog
// Add units in range to ChronosphereUnits (And pause them)
call GroupEnumUnitsInRange(bj_lastCreatedGroup, GetUnitX(u), GetUnitY(u), 400, null)
loop
set fog = FirstOfGroup(bj_lastCreatedGroup)
exitwhen fog == null
if IsUnitInGroup(fog, ChronosphereUnits) == FALSE and GetWidgetLife(fog) > 0 and GetUnitTypeId(fog) != 'Hpal' then
call GroupAddUnit(ChronosphereUnits, fog)
call SaveUnitHandle(ChronosphereHash, GetHandleId(fog), 0, u)
call BJDebugMsg("Unit is alive, not in ChronosphereUnits, and it's not a CasterType. Added to ChronosphereUnits")
endif
call GroupRemoveUnit(bj_lastCreatedGroup, fog)
endloop
call ForGroup(ChronosphereUnits, function ChronosphereUnitsPause)
set u = null
endfunction
// Unpause if Distance between Unit and Chronosphere is greater than 400
function ChronosphereUnitsActions takes nothing returns nothing
local unit u = GetEnumUnit()
local integer i = GetHandleId(u)
local unit Chrono = LoadUnitHandle(ChronosphereHash, i, 0)
local real x = GetUnitX(Chrono) - GetUnitX(u)
local real y = GetUnitY(Chrono) - GetUnitY(u)
if /*This is the Distance -> */ SquareRoot(x*x + y*y) > 400 then
call BJDebugMsg("Distance is greater than 400. Unit unpaused")
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl", GetUnitX(u), GetUnitY(u)))
call PauseUnit(u, false)
call SetUnitTimeScale(u, 1)
call GroupRemoveUnit(ChronosphereUnits, u)
call FlushChildHashtable(ChronosphereHash, i)
endif
set u = null
set Chrono = null
endfunction
// Do the Pause around Chronospheres and Unpause if they're far away.
function ChronosphereGroupActions takes nothing returns nothing
call ForGroup(ChronosphereGroup, function ChronosphereUnitsEnum )
call ForGroup(ChronosphereUnits, function ChronosphereUnitsActions)
endfunction
//===========================================================================
function InitTrig_ChronoLoop takes nothing returns nothing
set gg_trg_ChronoLoop = CreateTrigger( )
call DisableTrigger( gg_trg_ChronoLoop )
call TriggerRegisterTimerEvent(gg_trg_ChronoLoop, 0.03, true)
call TriggerAddAction( gg_trg_ChronoLoop, function ChronosphereGroupActions )
endfunction
Behold
CAST CHRONOSPHERE TRIGGER
JASS:globals hashtable ChronosphereHash = InitHashtable() group ChronosphereGroup = CreateGroup() group ChronosphereUnits = CreateGroup() endglobals // This happens when the Chronosphere Timer expires function ChronosphereClear takes nothing returns nothing local timer t = GetExpiredTimer() local integer i = GetHandleId(t) local unit u = LoadUnitHandle(ChronosphereHash, i, 0) local unit fog call GroupEnumUnitsInRange(bj_lastCreatedGroup, GetUnitX(u), GetUnitY(u), 400, null) loop set fog = FirstOfGroup(bj_lastCreatedGroup) exitwhen fog == null call PauseUnit(fog, false) call GroupRemoveUnit(bj_lastCreatedGroup, fog) call GroupRemoveUnit(ChronosphereUnits, fog) call SetUnitTimeScale(fog, 1) endloop call GroupRemoveUnit(ChronosphereGroup, u) call FlushChildHashtable(ChronosphereHash, i) call KillUnit(u) call RemoveUnit(u) // Turn off Loop if ChronosphereGroup is empty set bj_groupCountUnits = 0 call ForGroup(ChronosphereGroup, function CountUnitsInGroupEnum) if bj_groupCountUnits == 0 then call DisableTrigger(gg_trg_ChronoLoop) call BJDebugMsg("ChronosphereGroup empty. ChronoLOOP Disabled") endif set t = null set u = null set fog = null endfunction // ID of Chronosphere ability function Trig_ChronoCast_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A000' endfunction // Chronosphere Cast function Trig_ChronoCast_Actions takes nothing returns nothing local real x = GetSpellTargetX() local real y = GetSpellTargetY() local unit Chrono = CreateUnit(GetTriggerPlayer(), 'h000', x, y, 0) local timer t = CreateTimer() call TimerStart(t, 6, false, function ChronosphereClear) call SaveUnitHandle(ChronosphereHash, GetHandleId(t), 0, Chrono) call GroupAddUnit(ChronosphereGroup, Chrono) call EnableTrigger(gg_trg_ChronoLoop) set Chrono = null set t = null endfunction //=========================================================================== function InitTrig_ChronoCast takes nothing returns nothing set gg_trg_ChronoCast = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_ChronoCast, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_ChronoCast, Condition( function Trig_ChronoCast_Conditions ) ) call TriggerAddAction( gg_trg_ChronoCast, function Trig_ChronoCast_Actions ) endfunction
CHRONOSPHERE LOOP
JASS:// Pause Enum units around Chronospheres (Excep Caster type units) function ChronosphereUnitsPause takes nothing returns nothing local unit u = GetEnumUnit() call PauseUnit(u, true) call SetUnitTimeScale(u, 0) set u = null endfunction // Enum units around Chronospheres, add them to ChronosphereUnits if they're not. function ChronosphereUnitsEnum takes nothing returns nothing local unit u = GetEnumUnit() local unit fog // Add units in range to ChronosphereUnits (And pause them) call GroupEnumUnitsInRange(bj_lastCreatedGroup, GetUnitX(u), GetUnitY(u), 400, null) loop set fog = FirstOfGroup(bj_lastCreatedGroup) exitwhen fog == null if IsUnitInGroup(fog, ChronosphereUnits) == FALSE and GetWidgetLife(fog) > 0 and GetUnitTypeId(fog) != 'Hpal' then call GroupAddUnit(ChronosphereUnits, fog) call SaveUnitHandle(ChronosphereHash, GetHandleId(fog), 0, u) call BJDebugMsg("Unit is alive, not in ChronosphereUnits, and it's not a CasterType. Added to ChronosphereUnits") endif call GroupRemoveUnit(bj_lastCreatedGroup, fog) endloop call ForGroup(ChronosphereUnits, function ChronosphereUnitsPause) set u = null endfunction // Unpause if Distance between Unit and Chronosphere is greater than 400 function ChronosphereUnitsActions takes nothing returns nothing local unit u = GetEnumUnit() local integer i = GetHandleId(u) local unit Chrono = LoadUnitHandle(ChronosphereHash, i, 0) local real x = GetUnitX(Chrono) - GetUnitX(u) local real y = GetUnitY(Chrono) - GetUnitY(u) if /*This is the Distance -> */ SquareRoot(x*x + y*y) > 400 then call BJDebugMsg("Distance is greater than 400. Unit unpaused") call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl", GetUnitX(u), GetUnitY(u))) call PauseUnit(u, false) call SetUnitTimeScale(u, 1) call GroupRemoveUnit(ChronosphereUnits, u) call FlushChildHashtable(ChronosphereHash, i) endif set u = null set Chrono = null endfunction // Do the Pause around Chronospheres and Unpause if they're far away. function ChronosphereGroupActions takes nothing returns nothing call ForGroup(ChronosphereGroup, function ChronosphereUnitsEnum ) call ForGroup(ChronosphereUnits, function ChronosphereUnitsActions) endfunction //=========================================================================== function InitTrig_ChronoLoop takes nothing returns nothing set gg_trg_ChronoLoop = CreateTrigger( ) call DisableTrigger( gg_trg_ChronoLoop ) call TriggerRegisterTimerEvent(gg_trg_ChronoLoop, 0.03, true) call TriggerAddAction( gg_trg_ChronoLoop, function ChronosphereGroupActions ) endfunction
globals
integer SpartChronoS_UnitId = 'h000' // ID of the Chronosphere Dummy
integer SpartChronoS_AbilityId = 'A000' // ID of the Chronosphere Ability
real SpartChronoS_Radius = 400 // The Chronosphere Radius
real SpartChronoS_ALI = 1 // ALI = Ability Level Influence.
real SpartChronoS_Duration = 3 // Default duration. Formula is: "Duration + (AbiLvl * ALI)"
hashtable SpartChronoS_Hash = InitHashtable() // Don't touch this
group SpartChronoS_Spheres = CreateGroup() // Don't touch this
group SpartChronoS_Targets = CreateGroup() // Don't touch this
endglobals
/************************************************
***** Configurables *****
*************************************************/
globals
integer SpartChronoS_UnitId = 'h000' // ID of the Chronosphere Dummy
integer SpartChronoS_AbilityId = 'A000' // ID of the Chronosphere Ability
real SpartChronoS_Radius = 400 // The Chronosphere Radius
real SpartChronoS_ALI = 1 // ALI = Ability Level Influence.
real SpartChronoS_Duration = 3 // Default duration. Formula is: "Duration + (AbiLvl * ALI)"
hashtable SpartChronoS_Hash = InitHashtable() // Don't touch this
group SpartChronoS_Units = CreateGroup() // Don't touch this
group SpartChronoS_Targets = CreateGroup() // Don't touch this
endglobals
/************************************************
***** Don't touch *****
************************************************/
function SpartChronoS_TargetsActions takes nothing returns nothing
local unit u = GetEnumUnit()
local integer i = GetHandleId(u)
local unit chrono = LoadUnitHandle(SpartChronoS_Hash, i, 0)
local real x = GetUnitX(u) - GetUnitX(chrono)
local real y = GetUnitY(u) - GetUnitY(chrono)
local real distance = SquareRoot(x*x + y*y)
if distance < SpartChronoS_Radius and GetWidgetLife(chrono) > 0 then
call PauseUnit(u, true)
call SetUnitTimeScale(u, 0)
else
call PauseUnit(u, false)
call SetUnitTimeScale(u, 1)
call GroupRemoveUnit(SpartChronoS_Targets, u)
call FlushChildHashtable(SpartChronoS_Hash, i)
endif
set u = null
set chrono = null
endfunction
function SpartChronoS_UnitsActions takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer i = GetHandleId(t)
local unit caster = LoadUnitHandle(SpartChronoS_Hash, i, 0)
local unit chrono = LoadUnitHandle(SpartChronoS_Hash, i, 1)
local real duration = LoadReal(SpartChronoS_Hash, i, 2) - 0.03
local group g = bj_lastCreatedGroup
local unit fog
if duration > 0.031 then
call SaveReal(SpartChronoS_Hash, i, 2, duration)
call GroupEnumUnitsInRange(g, GetUnitX(chrono), GetUnitY(chrono), SpartChronoS_Radius, null)
loop
set fog = FirstOfGroup(g)
exitwhen fog == null
if GetWidgetLife(fog) > 0 and fog != caster and IsUnitInGroup(fog, SpartChronoS_Targets) == false then
call GroupAddUnit(SpartChronoS_Targets, fog)
call SaveUnitHandle(SpartChronoS_Hash, GetHandleId(fog), 0, chrono)
endif
call GroupRemoveUnit(g, fog)
endloop
elseif duration < 0.031 and duration > 0 then
call KillUnit(chrono)
elseif duration <= 0 then
call FlushChildHashtable(SpartChronoS_Hash, i)
call PauseTimer(t)
call DestroyTimer(t)
endif
call ForGroup(SpartChronoS_Targets, function SpartChronoS_TargetsActions)
set t = null
set caster = null
set chrono = null
set g = null
endfunction
// If Ability Being Cast = Chronosphere...
function SpartChronoS_Conditions takes nothing returns boolean
return GetSpellAbilityId() == SpartChronoS_AbilityId
endfunction
// Chronosphere Cast
function SpartChronoS_Actions takes nothing returns nothing
local real x = GetSpellTargetX()
local real y = GetSpellTargetY()
local unit Chrono = CreateUnit(GetTriggerPlayer(), SpartChronoS_UnitId, x, y, 0)
local unit u = GetTriggerUnit()
local real duration = SpartChronoS_Duration + (GetUnitAbilityLevel(u, SpartChronoS_AbilityId) * SpartChronoS_ALI)
local timer t = CreateTimer()
local integer i = GetHandleId(t)
call TimerStart(t, 0.03, true, function SpartChronoS_UnitsActions)
call SaveUnitHandle(SpartChronoS_Hash, i, 0, u)
call SaveUnitHandle(SpartChronoS_Hash, i, 1, Chrono)
call SaveReal(SpartChronoS_Hash, i, 2, duration)
set Chrono = null
set u = null
set t = null
endfunction
//===========================================================================
function InitTrig_SpartChronoS takes nothing returns nothing
set gg_trg_SpartChronoS = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SpartChronoS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_SpartChronoS, Condition( function SpartChronoS_Conditions ) )
call TriggerAddAction( gg_trg_SpartChronoS, function SpartChronoS_Actions )
endfunction
No but it could be.is it even better than the jass version