Moderator
M
Moderator
00:11, 9th Mar 2014
PurgeandFire: Approved. A great stun system.
PurgeandFire: Approved. A great stun system.
(3 ratings)
//Stun Engine v.1.1
//******************************************************************************************************
//*
//* Apply or remove stuns to units. GUI friendly.
//*
//* This systme only works if the Trigger has the excact name: Stun Engine
//* --> Information: The intializer function InitTrig_Stun_Engine doesn't work for a different trigger name.
//*
//******************************************************************************************************
//*
//* API
//*
//* STE_DURATION --> desired stun duration
//* STE_TARGET --> will get stunned.
//* STE_ADD_STUN --> set this to false to remove a stun
//* STE_STACK --> set this to true to stack stun times.
//*
//* Execute the stun with
//*
//* call TriggerEvaluate(udg_STE_TRIGGER)
//*
//******************************************************************************************************
//*
//* SETTINGS
//*
constant function StunEngineDummyId takes nothing returns integer
return 'n000'
endfunction
constant function StunEngineAbility takes nothing returns integer
return 'A000'
endfunction
constant function StunEngineBuff takes nothing returns integer
return 'B000'
endfunction
constant function StunEngineAccuracy takes nothing returns real
return 0.031250000
endfunction
//OrderId used for "stomp"
constant function StunEngineAbilityOrder takes nothing returns integer
return 852127
endfunction
//*
//* END OF SETTINGS
//*
//*******************************************************************************************************
function StunEnginePeriodic takes nothing returns nothing
local integer i = 0
local integer index
loop
exitwhen i == udg_STE_MAX
set index = GetUnitUserData(udg_STE_UNIT[i])
if (0.00 < udg_STE_TRACK[index]) and (0 < GetUnitAbilityLevel(udg_STE_UNIT[i], StunEngineBuff())) then
set udg_STE_TRACK[index] = udg_STE_TRACK[index] - StunEngineAccuracy()
else
call UnitRemoveAbility(udg_STE_UNIT[i], StunEngineBuff())
set udg_STE_TRACK[index] = 0.00
set udg_STE_MAX = udg_STE_MAX - 1
set udg_STE_UNIT[i] = udg_STE_UNIT[udg_STE_MAX]
set udg_STE_UNIT[udg_STE_MAX] = null
set i = i - 1
if (0 == udg_STE_MAX) then
call PauseTimer(udg_STE_TIMER)
endif
endif
set i = i + 1
endloop
endfunction
function EvaluateStunEngine takes nothing returns boolean
local integer index = GetUnitUserData(udg_STE_TARGET)
if (udg_STE_ADD_STUN) then
if (0.00 < udg_STE_DURATION) then
if udg_STE_STACK_TIME then
set udg_STE_TRACK[index] = udg_STE_TRACK[index] + udg_STE_DURATION
elseif (udg_STE_TRACK[index] < udg_STE_DURATION) then
set udg_STE_TRACK[index] = udg_STE_DURATION
endif
if (0 == GetUnitAbilityLevel(udg_STE_TARGET, StunEngineBuff())) then
call SetUnitX(udg_STE_CASTER, GetUnitX(udg_STE_TARGET))
call SetUnitY(udg_STE_CASTER, GetUnitY(udg_STE_TARGET))
call IssueImmediateOrderById(udg_STE_CASTER, StunEngineAbilityOrder())
call SetUnitPosition(udg_STE_CASTER ,2147483647,2147483647)
if (0 == udg_STE_MAX) then
call TimerStart(udg_STE_TIMER, StunEngineAccuracy(), true, function StunEnginePeriodic)
endif
set udg_STE_UNIT[udg_STE_MAX] = udg_STE_TARGET
set udg_STE_MAX = udg_STE_MAX + 1
endif
endif
else
call UnitRemoveAbility(udg_STE_TARGET, StunEngineBuff())
set udg_STE_TRACK[index] = 0.00
endif
set udg_STE_TARGET = null
set udg_STE_DURATION = 0.00
return false
endfunction
function InitTrig_Stun_Engine takes nothing returns nothing
set udg_STE_TRIGGER = CreateTrigger()
call TriggerAddCondition(udg_STE_TRIGGER, Condition(function EvaluateStunEngine))
set udg_STE_CASTER = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), StunEngineDummyId(), 0.,0.,0.)
call UnitAddAbility(udg_STE_CASTER, StunEngineAbility())
call UnitAddAbility(udg_STE_CASTER, 'Aloc')
call SetUnitPosition(udg_STE_CASTER ,2147483647,2147483647)
endfunction
function InitTrig_GUI_Stun_Engine takes nothing returns nothing
set gg_trg_GUI_Stun_Engine = CreateTrigger( )
call TriggerAddAction( gg_trg_GUI_Stun_Engine, function Trig_GUI_Stun_Engine_Actions )
endfunction
function InitTrig_GUI_Stun_Engine takes nothing returns nothing
call TriggerAddAction( CreateTrigger(), function Trig_GUI_Stun_Engine_Actions )
endfunction
Is it bad if someone makes an old idea but in an better way? :s
____________________________
I don't like that nearly whole trigger is custom scripts, would look better in JASS.. but that's only cosmetics.
BPower, I would change one thing: Don't use /* and */ for comments ..so normal WE can not use it
But anyway, why not? Can be useful.
No, but still it's an old idea, so nothing new
If it was not available in GUI then it is a good idea. Even if it is the same thing it is still useful.
You are basically saying that anything that is Jass / vJass should not be remade for GUIers because it has already been made. That is not a good way to look at any type of system. Systems are meant to make it easier for the user.
If you would not want something remade then we should get rid of the GUI unit indexer since there is a jass / vJass equivalent.
Good idea. The Map init trigger just initializes the 4 configurable variables nothing more.Edit:
It would actually be better to use a timer rather than a trigger since you destroy it. You also never add an event so the actions will never fire.
Also have you tried simply running the actions at init ?
I see no reason to make it JASS, in fact there wouldn't even be a real benefit in doing so.No, but still it's an old idea, so nothing new and why this is not JASS ?
Is it bad if someone makes an old idea but in an better way? :s
____________________________
I don't like that nearly whole trigger is custom scripts, would look better in JASS.. but that's only cosmetics.
BPower, I would change one thing: Don't use /* and */ for comments ..so normal WE can not use it
But anyway, why not? Can be useful.
The vanilla editor can't use /* */ ? I really didn't know that.BPower, I would change one thing: Don't use /* and */ for comments ..so normal WE can not use it
Updated the system is no longer written in GUI.
Can now use TriggerEvaluate, aswell.
call SetUnitPosition(udg_STE_CASTER ,2147483647,2147483647)
if (0 < udg_STE_TRACK[index]) and (0 < GetUnitAbilityLevel(udg_STE_UNIT[i], StunEngineBuff())) then
set udg_STE_TRACK[index] = udg_STE_TRACK[index] - StunEngineAccuracy()
else
call UnitRemoveAbility(udg_STE_UNIT[i], StunEngineBuff())
That's not correct.Y U no set the duration of the stun ability to 0.00? it's permanent
Completly optional, it's a stun- not a missle systemand your dummy unit, why you don't use DUMMY.mdl? so you dont need to hide it from map..
Units off screen won't be rendered.use SetUnitX/Y than SetUnitPosition, put the dummy in the middle of the map, if you use dummy.mdl and give it locust. it's safe.
Yeah .... no.isn't that wise to store those fcs into local first? if there are a lot of units in the loop, it will improve the performance..
it won't be noticable, and then you don't need to do SetUnitPosition, isn't that better?but then it might not be off screen.
return 0.031250000
return 0.0312500
mmhANd btw if you're using debug keyword go use vJASS XD !
Indeed, that's important information.you should state at the top that it should be placed in "GUI Trigger" called Stun Engine otherwise it wont work
I'm not sure if I got that one. Do you mean storing the remaining stun duration?evaluating trigger is good, but then you are missing things like StopStunDuration, PauseStunDuration etc etc that could be useful, if you dont want to use many many flag variables
A simple function call is of course much faster than TriggerEvalute, however you are forced to put the code into the map header, which I personally dislike.also currently afaik(prove me wrong if its not true) you only allow it to stun only 1 unit per trigger evaluation, that is kind of costly dont you think?
but isnt 0.00 seconds stun permanent? like, forever, unless you remove the buff or somehow dispel it?
if (0.00 < udg_STE_DURATION) then
--> you can't add duration values of 0 or smaller.Yes I do use a modified version of that one too. Because I'm using UnitIndexer I didn't need the table and used an array instead.I still prefer iAyanami's one.
ANd btw if you're using debug keyword go use vJASS XD !
I don't think debug will work at all on normal world edit
So please ^^
I just want to mention one possible glitch,
have you consider the system to stun invisible unit? I don't know that Passive Player is able to see player's invisible unit (shared vision) or not
Of course it canCan this system be used to stun a group of units, such as in a loop? Because it just uses one dummy, thats why i am asking.
I will move my suggestions here.Yes, and your stun system also needs such buff checking too. It's one easy-to-occur bug. And you should explain to user that your stun engine does not work for magic immune, and I guess you can hit neutral units if you use Player(15) for the dummy caster. Sorry to suggest them here since you never response to my suggestions there.
You should do the whole actions after applying the buff (put that block before the whole actions). Then check whether the target has successfully buffed or not:JASS:call SetUnitX(udg_STE_CASTER, GetUnitX(udg_STE_TARGET)) call SetUnitY(udg_STE_CASTER, GetUnitY(udg_STE_TARGET)) call IssueImmediateOrderById(udg_STE_CASTER, StunEngineAbilityOrder()) call SetUnitPosition(udg_STE_CASTER ,2147483647,2147483647)
if GetUnitAbilityLevel(u, BUFF_ID) > 0 then
To prevent useless actions if the target is invulnerable or somehow un-targetable.
EDIT:
Have found that this checking always returns true no matter what. I think unit type checking is the best solution, basically, war stomp ability does not work only for buildings and magic immune
I will move my suggestions here.Yes, and your stun system also needs such buff checking too. It's one easy-to-occur bug. And you should explain to user that your stun engine does not work for magic immune, and I guess you can hit neutral units if you use Player(15) for the dummy caster. Sorry to suggest them here since you never response to my suggestions there.
You should do the whole actions after applying the buff (put that block before the whole actions). Then check whether the target has successfully buffed or not:JASS:call SetUnitX(udg_STE_CASTER, GetUnitX(udg_STE_TARGET)) call SetUnitY(udg_STE_CASTER, GetUnitY(udg_STE_TARGET)) call IssueImmediateOrderById(udg_STE_CASTER, StunEngineAbilityOrder()) call SetUnitPosition(udg_STE_CASTER ,2147483647,2147483647)
if GetUnitAbilityLevel(u, BUFF_ID) > 0 then
To prevent useless actions if the target is invulnerable or somehow un-targetable.
EDIT:
Have found that this checking always returns true no matter what. I think unit type checking is the best solution, basically, war stomp ability does not work only for buildings and magic immune
This System is Better than all Stun System right guys