- Joined
- Jan 18, 2007
- Messages
- 59
Simple Stun System v1.02b
Pros:
1) Allow to stun for any amount of secs
2) Consists of 49 lines
3) Timer don't expire every 0.01 sec but as u ordered which have to make it fast & furious
3) It is the simpliest system I've ever seen
Cons:
It's not tested a lot )
So if u find any bug post it I'll fix it!
*******************
**How to implant:**
*******************
The system is very easy. The only things you'll have to do to implement the system is to:
1) copy the SimpleStunSystem trigger into ur map
2) copy dammy Unit (if u haven't it yet)
3) copy Ability & Buff "Simple Stun"
4) Change the buff of the ability to the buff "Simple Stun"
5) Change the variables in the system DummyId; AbilId; BuffId
Note: Requires vJass
*******************
**How to use: ******
*******************
To use this system u have to have a trigger with the event unit pick up item and in the actions
just write:
function StunUnit takes unit whichunit,real duration, boolean CheckImmunity returns boolean
Arguments:
unit whichunit - Unit that must be stunned //I think it is clear
real duration - duration of the stun
boolean CheckImmunity - whether to chec kmagic immune units or not
returns boolean - returns whether it stuned the unit or not
Download
Simple Stun System v1.02b
Pros:
1) Allow to stun for any amount of secs
2) Consists of 49 lines
3) Timer don't expire every 0.01 sec but as u ordered which have to make it fast & furious
3) It is the simpliest system I've ever seen
Cons:
It's not tested a lot )
So if u find any bug post it I'll fix it!
*******************
**How to implant:**
*******************
The system is very easy. The only things you'll have to do to implement the system is to:
1) copy the SimpleStunSystem trigger into ur map
2) copy dammy Unit (if u haven't it yet)
3) copy Ability & Buff "Simple Stun"
4) Change the buff of the ability to the buff "Simple Stun"
5) Change the variables in the system DummyId; AbilId; BuffId
Note: Requires vJass
*******************
**How to use: ******
*******************
To use this system u have to have a trigger with the event unit pick up item and in the actions
just write:
function StunUnit takes unit whichunit,real duration, boolean CheckImmunity returns boolean
Arguments:
unit whichunit - Unit that must be stunned //I think it is clear
real duration - duration of the stun
boolean CheckImmunity - whether to chec kmagic immune units or not
returns boolean - returns whether it stuned the unit or not
JASS:
//***************************************************************
//* Simple Stun System v1.02
//* -------------------by Matrix---------------------------------
//* Latest version on [url]http://www.thehelper.net[/url] forums
//* Function Index
//*
//* StunUnit(unit whichunit, real duration, boolean CheckImmunity)
//*
//* unit whichunit - the unit that will be stunned
//* real duration - the duration of the stun
//* boolean CheckImmunity means it checks if the unit is immune, a building or mechanical in which case it does not stun.
//NOTE - The smallest possiable stun duration is 0.01 due to limitations with the system and so it will stun for 0.01 seconds even if u pass duration less than 0.01 but bigger then zero
//NOTE - The system supports stunning the same unit twice with no problems based on the largest stun duration like WC3's stun works normally. In other words if u stun unit for 999 seconds and then for 1 second it will be stunned for 999 secs!
//INTERFACES (inside library)
//integer Total
//The number of units currently stunned by the system.
//***************************************************************
//=============================================================
// How to implant: (Uses Jass NewGen Pack)
//1) copy this trigger into ur map
//2) copy dummy Unit (if u haven't it yet)
//3) copy Ability & Buff "Simple Stun"
//4) Change the buff of the ability to the buff "Simple Stun"
//5) Change the variables in the system DummyId; AbilId; BuffId (See below:)
//=============================================================
//***************************************************************
//**ChangeLog v1.02
//1) Now Double stun on the same unit works properly
//2) Now Calling function with negative amount of sec will do nothing
//3) Now calling function with less amount of sec than 0.01 will set
//it to 0.01
//4) A little bit optimization
//=============================================================
library SimpleStunSystem
globals
//Set this to the raw data value of the dummy unit that must be used by this system.
private constant integer ID_DUMMY = 'h000'
//Set this to the raw data value of the dummy stun ability that must be used by this system.
private constant integer ID_ABILL = 'A000'
//Set this to the raw data value of the stun buff that must be used by this system.
private constant integer ID_BUFF = 'B000'
//Contains the number of units stunned via the system ingame at any point in time.
public integer Total=0
//Variables used by the system to store the timer used for stun duration and the unit who is stunned.
private timer array T
private unit array U
endglobals
private function End takes nothing returns nothing
local integer i = 0
local timer time = GetExpiredTimer()
//Finds which unit the timer went with.
loop
exitwhen time==T[i]
set i = i + 1
endloop
//Gets rid of the timer
call PauseTimer(time)
call DestroyTimer(time)
set time = null
//Unstuns the unit
call UnitRemoveAbility(U[i],ID_BUFF)
//Deallocates the object from the system.
set Total=Total-1
set T[i]=T[Total]
set U[i]=U[Total]
set T[Total]=null
set U[Total]=null
endfunction
function StunUnit takes unit u,real d, boolean CheckImmunity returns boolean
local unit s = null
local integer i = 0
//Checks if the duration is long enough for a stun to be correctly applied and if so then checks if it is to check immunity and if so does so before doing stun actions.
if (not CheckImmunity or (not IsUnitType(u,UNIT_TYPE_MAGIC_IMMUNE) and not IsUnitType(u,UNIT_TYPE_MECHANICAL) and not IsUnitType(u,UNIT_TYPE_STRUCTURE))) and d>0 then
//Loops via a O(n) type loop to check if a unit is already stunned via the system.
//If one is it uses that refference if not it then uses a blank reference.
if d<.01 then
set d =.01
endif
loop
exitwhen U[i]==u or i>Total
set i = i+1
endloop
if i<=Total then
if TimerGetRemaining(T[i])<d then
call PauseTimer(T[i])
call TimerStart(T[i],d,false,function End)
endif
return true
endif
//Creates a dummy and prepairs it so that it can stun.
set s = CreateUnit(GetOwningPlayer(u),ID_DUMMY,GetWidgetX(u),GetWidgetY(u),0)
call UnitAddAbility(s,ID_ABILL)
call UnitApplyTimedLife(s, 'BTLF', 1)
if T[Total]==null then
set T[Total]=CreateTimer()
endif
set U[Total]=u
//Stuns the unit for infinity
call IssueTargetOrderById(s,852095,u)
//Cleans up local objects to null to stop leaks.
set s = null
set u = null
call TimerStart(T[Total],d,false,function End)
set Total=Total+1
return true
endif
set u = null
return false
endfunction
endlibrary
Download
Simple Stun System v1.02b
Last edited: