- Joined
- Oct 11, 2012
- Messages
- 711
Is it possible to use Polledwait or TriggerSleepAction in a loop? I tried but failed, so I suppose the answer is no? If not, are there any other alternative ways to achieve the same effect? Thanks a lot.
Thank you for the advice.You can, but neither of those actions are efficient. If you wait 1 second, it will wait a bit more or less than 1 second.
Also, all the actions after the loop with be stuck there until the loop finishes.
Loop is meant for instant processing, not periodic. For periodic processing you have timers and periodic triggers.
What effect do you want to achieve?
If u want a times effect use a counter in a loop. Every instance increase it by one. Then when it reaches the number do actions
Then use a timer or a periodic 0.7 sec trigger to create the dummies.
Describe to me exactly every detail of what you want and i'll show you how.
u can describe it here so many ppl can help. i would show u how but best i can do is tell u how to do it.
globals
// Start Configurations //
// Note: Press CTRL+D on the Object Editor to see objects Id's
integer StompRush_Id = 'xxxx' // ID of your StompRush ability (The one that triggers everything)
integer StompRush_Dummy = 'zzzz' // ID of your Dummy Stomper
string StompRush_Order = "stomp" // Order of the Dummy Stomp Ability
real StompRush_Interval = 0.5 // Every *this interval* a dummy will stun
real StompRush_Duration = 3 // The duration of the effect
real StompRush_AoE = 500 // AoE of the ability
// End Configurations //
hashtable StompRush_Hash = InitHashtable()
endglobals
function StompRush_TimerFunc takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local integer duration = LoadInteger(StompRush_Hash, id, 1)
local unit dummy
local unit caster
local real x
local real y
if duration >= StompRush_Interval then
call SaveReal(StompRush_Hash, id, 1, duration-StompRush_Interval)
set dummy = LoadUnitHandle(StompRush_Hash, id, 0)
set caster = LoadUnitHandle(StompRush_Hash, id, 2)
set x = GetUnitX(caster) + GetRandomReal(0, StompRush_AoE)
set y = GetUnitY(caster) + GetRandomReal(0, StompRush_AoE)
call SetUnitX(dummy, x)
call SetUnitY(dummy, y)
call IssueImmediateOrder(dummy, StompRush_Order)
set dummy = null
set caster = null
else
call PauseTimer(t)
call DestroyTimer(t)
call KillUnit(dummy)
call RemoveUnit(dummy)
call FlushChildHashtable(StompRush_Hash, id)
endif
set t = null
endfunction
function Trig_Stomp_Rush_Conditions takes nothing returns boolean
local unit caster
local unit dummy
local timer t
local real ux
local real uy
local integer id
if GetSpellAbilityId() == StompRush_Id then
set caster = GetTriggerUnit()
set ux = GetUnitX(caster)
set uy = GetUnitY(caster)
set dummy = CreateUnit(GetTriggerPlayer(), StompRush_Dummy, ux, uy, 0)
set t = CreateTimer()
set id = GetHandleId(t)
call SaveUnitHandle(StompRush_Hash, id, 0, dummy)
call SaveReal(StompRush_Hash, id, 1, StompRush_Duration)
call SaveUnitHandle(StompRush_Hash, id, 2, caster)
// Null Locals - Clear leaks
set t = null
set dummy = null
set caster = null
endif
return false
endfunction
//===========================================================================
function InitTrig_Stomp_Rush takes nothing returns nothing
set gg_trg_Stomp_Rush = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Stomp_Rush, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Stomp_Rush, Condition( function Trig_Stomp_Rush_Conditions ) )
endfunction
1- Create a trigger
2- Conver it to Custom Text (Edit -> Convert to custom text)
3- Replace everything inside with the script below
4- Rename your trigger to whatever you want (I called this Stomp Rush)
5- Check the Globals Configurables and adjust the values as you desire
6- Save, test, and ejoy.
This doesn't create a dummy unit for every stomp, it just moves the same dummy from one position to the next one. Dummy castpoint and backswing must be lower than the interval (0 is better for instant cast). There are some tutorials an guides around that explains how to properly configure a Dummy Unit.
JASS:globals // Start Configurations // // Note: Press CTRL+D on the Object Editor to see objects Id's integer StompRush_Id = 'xxxx' // ID of your StompRush ability (The one that triggers everything) integer StompRush_Dummy = 'zzzz' // ID of your Dummy Stomper string StompRush_Order = "stomp" // Order of the Dummy Stomp Ability real StompRush_Interval = 0.5 // Every *this interval* a dummy will stun real StompRush_Duration = 3 // The duration of the effect real StompRush_AoE = 500 // AoE of the ability // End Configurations // hashtable StompRush_Hash = InitHashtable() endglobals function StompRush_TimerFunc takes nothing returns nothing local timer t = GetExpiredTimer() local integer id = GetHandleId(t) local integer duration = LoadInteger(StompRush_Hash, id, 1) local unit dummy local unit caster local real x local real y if duration >= StompRush_Interval then call SaveReal(StompRush_Hash, id, 1, duration-StompRush_Interval) set dummy = LoadUnitHandle(StompRush_Hash, id, 0) set caster = LoadUnitHandle(StompRush_Hash, id, 2) set x = GetUnitX(caster) + GetRandomReal(0, StompRush_AoE) set y = GetUnitY(caster) + GetRandomReal(0, StompRush_AoE) call SetUnitX(dummy, x) call SetUnitY(dummy, y) call IssueImmediateOrder(dummy, StompRush_Order) set dummy = null set caster = null else call PauseTimer(t) call DestroyTimer(t) call KillUnit(dummy) call RemoveUnit(dummy) call FlushChildHashtable(StompRush_Hash, id) endif set t = null endfunction function Trig_Stomp_Rush_Conditions takes nothing returns boolean local unit caster local unit dummy local timer t local real ux local real uy local integer id if GetSpellAbilityId() == StompRush_Id then set caster = GetTriggerUnit() set ux = GetUnitX(caster) set uy = GetUnitY(caster) set dummy = CreateUnit(GetTriggerPlayer(), StompRush_Dummy, ux, uy, 0) set t = CreateTimer() set id = GetHandleId(t) call SaveUnitHandle(StompRush_Hash, id, 0, dummy) call SaveReal(StompRush_Hash, id, 1, StompRush_Duration) call SaveUnitHandle(StompRush_Hash, id, 2, caster) // Null Locals - Clear leaks set t = null set dummy = null set caster = null endif return false endfunction //=========================================================================== function InitTrig_Stomp_Rush takes nothing returns nothing set gg_trg_Stomp_Rush = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Stomp_Rush, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Stomp_Rush, Condition( function Trig_Stomp_Rush_Conditions ) ) endfunction
I didn't test it, but it should work.
First of all.. did it work? xD
Let me know if you wanna modify something or add some new feature like special effects
The action part is included in the Condition.
What isn't working? Did you adjust the ID of the Dummy and the Ability that triggers everything? Does it compile when you save?
" if GetSpellAbilityId() == StompRush_Id then"
Jasshelper detected the error of this line, is it?
Rename the trigger to whatever you want, the system will adjust the trigger script part automatically. I named the trigger "Stomp Rush"
What error?
Remember the ID's are 4 letters inside single quotes
'sadf'
That does not make any sense...Not actually dimf. As far a I know locals with no data reference doesn't need to be nulled; they just have to be nulled when they hold some kind of information; else, you would null already "null" variables wasting like 0.0000000001 memory in the process xD
Not actually dimf. As far a I know locals with no data reference doesn't need to be nulled; they just have to be nulled when they hold some kind of information; else, you would null already "null" variables wasting like 0.0000000001 memory in the process xD
Sorry Dr. Super Good, I don't know that much about computing words (my native language is spanish) I just wanted to say that there's no need to null "null" locals (locals with no assigned/allocated value)
@ deathismyfriend
Also thank you for your advice.