D.V.D
Make a wish
- Reaction score
- 73
Stun Library
Thanks to uberfoop for helping me fix my struct problem which allowed me to test my functions after.
Have fun with stuning your enemies.
Thanks to uberfoop for helping me fix my struct problem which allowed me to test my functions after.
Have fun with stuning your enemies.
JASS:
library Stun initializer Init requires TimerUtils
//==========================================================================\\
// Stun Library By D.V.D \\
//==========================================================================\\
// Description: \\
// The Stun Library allows you to stun units without the use of spells or \\
// units. This allows you to stop the stun at a certian period and even \\
// pausing and resuming your stun. With this code, you are able to fully \\
// customize your stun so it fits the spells that will use this in your map.\\
//==========================================================================\\
// Pros: \\
// - Does not use dummy units \\
// - Does not use custom abilities \\
// - Does not use custom buffs but they can be added. \\
// - Allows you to fully customize your stun like pausing and resuming \\
//==========================================================================\\
// Functions: \\
// static method StunUnit takes unit target, real time, real damage, \\
// attacktype type1, damagetype type2, string effect, string attachment \\
// returns stun \\
// method PauseStun takes nothing returns nothing \\
// method ResumeStun takes nothing returns nothing \\
// method ChangeEffect takes string effect returns nothing \\
// method ChangeAttachment takes string attachment returns nothing \\
//==========================================================================\\
// How to Implement: \\
// 1. Copy the code in this trigger \\
// 2. Create A New Trigger In Your Map \\
// 3. Convert the trigger to Jass and Paste this code over the trigger code \\
// 4. Click the check mark for the Run on Map Initialization button \\
// 5. Have fun! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" /> \\
//==========================================================================\\
struct stun
attacktype type1
damagetype type2
effect e1
integer count
real damage
real time
string attachment
string e
timer p
unit caster
unit target
//===========================================================================
method onDestroy takes nothing returns nothing
set .type1 = null
set .type2 = null
call DestroyEffect(.e1)
call ReleaseTimer(.p)
endmethod
//===========================================================================
static method Stunned takes nothing returns nothing
local timer t = GetExpiredTimer()
local stun d = GetTimerData(t)
call IssueImmediateOrder( d.target, "stop" )
set d.count = d.count + 1
if ( d.count / 100 == R2I( d.time ) ) then
call ReleaseTimer(t)
call d.destroy()
elseif ( IsUnitAliveBJ( d.target ) == false ) then
call ReleaseTimer(t)
call d.destroy()
endif
endmethod
//===========================================================================
static method StunUnit takes unit caster, unit target, real time, real damage, attacktype type1, damagetype type2, string e, string attachment returns stun
local stun d = stun.create()
local timer t = NewTimer()
set d.attachment = attachment
set d.caster = caster
set d.count = 0
set d.damage = damage
set d.e = e
set d.p = NewTimer()
set d.target = target
set d.time = time
set d.type1 = type1
set d.type2 = type2
set d.e1 = AddSpecialEffectTarget( d.e, d.target, d.attachment )
call UnitDamageTarget( d.caster, d.target, d.damage, true, false, d.type1, d.type2, null )
call SetTimerData( d.p, d )
call TimerStart( d.p, 0.01, true, function stun.Stunned )
return d
endmethod
//===========================================================================
method PauseStun takes nothing returns nothing
call PauseTimer( .p )
call DestroyEffect(.e1)
endmethod
//===========================================================================
method ResumeStun takes nothing returns nothing
call ResumeTimer( .p )
call AddSpecialEffectTarget( .e, .target, .attachment )
endmethod
//===========================================================================
method ChangeEffect takes string e returns nothing
call DestroyEffect(.e1)
set .e1 = AddSpecialEffectTarget( e, .target, "origin" )
endmethod
//===========================================================================
method ChangeAttachment takes string attachment returns nothing
call DestroyEffect(.e1)
set .e1 = AddSpecialEffectTarget( .e, .target, attachment )
endmethod
endstruct
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
endfunction
endlibrary