Joker(Div)
Always Here..
- Reaction score
- 86
CustomStun System
By: Joker(Div)
By: Joker(Div)
An extremely short and simple CustomStun System. All the info is written on the code.
Screenshot:
Code:
Changelog:
Requirements:
Screenshot:
Code:
JASS:
//==============================================================================
// CUSTOMSTUN SYSTEM BY JOKER(DIV) -- v1.3
//==============================================================================
//
// PURPOSE:
// * Easy stunning
// * Customizable stun duration without 99 lvls of storm bolt
// * (Instead uses 1 lvl storm bolt)
//
// HOW TO USE:
// * function CustomStun_Unit takes unit attacker, unit target, string sfx, string attach, real duration returns nothing
//
// Yep, 1 function.
//
// PROS:
// * Extremelly easy to use
// * Short simple script
// * Customizable sfx
//
// CONS:
// * You still need a 1 level storm bolt
// * Has a delta value, although its configureable
// * Cannot go through magic immunity
// * Buff icon cannot change regardless of what sfx used
//
// DETAILS:
// * It...
// - Casts a permanent storm bolt to the target
// - Creates a timer for the instance
// - Removes the stun buff after duration
//
// REQUIREMENTS:
// * vJASS (Vexorian)
// * TimerUtils (Vexorian)
// * PUI v5.0 or higher (Cohadar)
//
// HOW TO IMPORT:
// * Just create a trigger named CustomStun
// * convert it to text and replace the whole trigger text with this one
//
//==============================================================================
library CustomStun uses TimerUtils, PUI
//! runtextmacro PUI_PROPERTY("private", "real", "Stunned", "0.")
globals
private constant real Delta = 0.25 //Interval of the timer, thus, delta value
private constant integer Dummy_Id = 039;n000039; //Dummy ID
private constant real Dummy_Dur = 1. //Dummy duration
private constant integer Bolt_Id = 039;A000039; //Storm bolt ID
private constant integer Buff_Id = 039;B000039; //Stun buff Id
endglobals
private struct Stun
unit targ
timer t
effect ef
static method start takes unit targ, effect ef returns nothing
local Stun dat = Stun.create()
set dat.targ = targ
set dat.t = NewTimer()
set dat.ef = ef
call SetTimerData( dat.t, dat )
call TimerStart( dat.t, Delta, true, function Stun.callback )
endmethod
private static method callback takes nothing returns nothing
local timer t = GetExpiredTimer()
local Stun dat = GetTimerData( t )
if GetWidgetLife( dat.targ ) < 0.405 or Stunned[ dat.targ ] < Delta then //If dead or met duration
call dat.destroy()
return
endif
set Stunned[ dat.targ ] = Stunned[ dat.targ ] - Delta
endmethod
private method onDestroy takes nothing returns nothing
call UnitRemoveAbility( .targ, Buff_Id ) //Remove buff, stopping stun
call DestroyEffect( .ef )
call ReleaseTimer( .t )
endmethod
endstruct
public function Unit takes unit attacker, unit target, string sfx, string attach, real duration returns nothing
local unit dummy
if Stunned[target] <= 0. and IsUnitType( target, UNIT_TYPE_MAGIC_IMMUNE ) == false then //Storm bolt cannot ever go through Magic Immune
set Stunned[ target ] = 0. //Safety
set dummy = CreateUnit( GetOwningPlayer(attacker), Dummy_Id, GetUnitX( target ), GetUnitY( target ), bj_UNIT_FACING )
call UnitAddAbility( dummy, Bolt_Id ) //The dummy stuff
call IssueTargetOrder( dummy, "thunderbolt", target )
call UnitApplyTimedLife( dummy, 039;BTLF039;, Dummy_Dur )
call Stun.start( target, AddSpecialEffectTarget( sfx, target, attach ) )
endif
set Stunned[target] = (Stunned[target] + duration)
set dummy = null
endfunction
endlibrary
Changelog:
< 1.3 >
*A bug fix
*Miniscule improvement
< 1.2 >
*Small improvements
*Allows custom stunned effects
< 1.1 >
*Minor bug fix
*A bug fix
*Miniscule improvement
< 1.2 >
*Small improvements
*Allows custom stunned effects
< 1.1 >
*Minor bug fix
Requirements:
- vJASS
- TimerUtils
- PUI