JASS:
library InvisibilityLibrary initializer Init
//*******************************************************************************************
//* INVISIBILITY LIBRARY *
//* v1.00 *
//* *
//* By Vestras *
//*******************************************************************************************
//*******************************************************************************************
//* Implementation *
//* *
//* Copy this script into your map, save, restart NewGen, open your map and comment the *
//* ObjectMerger. *
//* *
//* Requirements *
//* *
//* JNGP (JASS NewGen Pack) *
//* *
//* Function list *
//* *
//* IsUnitInvisibleEx - checks if the specified units is insivisble. Checks for both the *
//* ability that is added by this script and for the normal IsUnitVisible. *
//* *
//* MakeUnitInvisible - makes the specified unit invisible. *
//* *
//* MakeUnitVisible - makes the specified unit visible. *
//* *
//* MakeUnitInvisibleTimed - makes the specified unit invisible, and after the specified *
//* time, makes it visible. *
//* *
//* Give credit to Vestras when using. *
//* ~Vestras *
//*******************************************************************************************
//! external ObjectMerger w3a Apiv ivs$ anam "Invisibility" aart "" aani "" acat "" aeat "" atat "" alig "" amat "" atar 1 "" adur 1 0.01 amcs 1 0 ahdu 1 0.01 aher 0 aite 1 alev 1 Nfd3 1 0 Nfd1 1 0 Nfd2 1 0.01 arac "other" atp1 1 "" aub1 1 "" ansf ""
//! external ObjectMerger w3a Afod ivs& anam "Invisibility Detector" aart "" aani "" acat "" aeat "" atat "" alig "" amat "" atar 1 "air,ground,structure,vulnerable,ward" acas 1 3600 amcs 1 0 aran 1 99999.0 aher 0 alev 1 Nfd3 1 0 Nfd1 1 0 Nfd2 1 0.01 arac "other" atp1 1 "" aub1 1 "" ansf ""
globals
private constant integer IVS_CODE = 039;ivs$039;
// You don't have to edit that, not as long as the OjbectMerger isn't edited
private constant integer DETECT_CODE = 039;ivs&039;
// You don't have to edit that, not as long as the ObjectMerger isn't edited
private constant integer DUMMY_CODE = 039;nshe039;
// Raw code of the used dummy unit (for checking for invisibility)
private constant real TIMER_INTERVAL = 0.20
// Interval of the timer that runs the InvisibilityHandler function
private constant string DUMMY_ABILITY = "fingerofdeath"
// Order string of the generated dummy ability (for checking for invisibility)
endglobals
// Don't edit below this line if you don't know what you're doing
globals
private unit dummy
endglobals
private struct Data
unit u
real dur
real count
endstruct
globals
private Data array dx
private timer T = CreateTimer()
private integer N = 0
endglobals
function IsUnitInvisibleEx takes unit whichUnit returns boolean
local boolean b = false
if whichUnit != null and GetUnitTypeId(whichUnit) != 0 then
call PauseUnit(dummy, false)
set b = not IssueTargetOrder(dummy, DUMMY_ABILITY, whichUnit)
call PauseUnit(dummy, true)
endif
return b
endfunction
function MakeUnitInvisible takes unit whichUnit returns boolean
if IsUnitInvisibleEx(whichUnit) then
return false
endif
call UnitAddAbility(whichUnit, IVS_CODE)
return true
endfunction
function MakeUnitVisible takes unit whichUnit returns boolean
if not IsUnitInvisibleEx(whichUnit) then
return false
endif
call UnitRemoveAbility(whichUnit, IVS_CODE)
return true
endfunction
private function InvisibilityHandler takes nothing returns nothing
local Data d
local integer j = 1
loop
exitwhen j > N
set d = dx[j]
set d.count = d.count + TIMER_INTERVAL
if d.count >= d.dur then
call MakeUnitVisible(d.u)
set dx[j] = dx[N]
set N = N - 1
call d.destroy()
if N == 0 then
call PauseTimer(T)
endif
endif
set j = j + 1
endloop
endfunction
function MakeUnitInvisibleTimed takes unit whichUnit, real duration returns boolean
local Data d
local boolean b = MakeUnitInvisible(whichUnit)
if not b then
return false
endif
set d = Data.create()
set d.u = whichUnit
set d.dur = duration
set d.count = 0
set N = N + 1
set dx[N] = d
if N == 1 then
call TimerStart(T, TIMER_INTERVAL, true, function InvisibilityHandler)
endif
return b
endfunction
private function Init takes nothing returns nothing
set dummy = CreateUnit(Player(15), DUMMY_CODE, 0, 0, bj_UNIT_FACING)
call UnitAddAbility(dummy, DETECT_CODE)
call ShowUnit(dummy, false)
call PauseUnit(dummy, true)
endfunction
endlibrary
JASS:
library InvisibilityLibrary initializer Init requires TimerUtils
//*******************************************************************************************
//* INVISIBILITY LIBRARY *
//* v1.00 *
//* *
//* By Vestras *
//*******************************************************************************************
//*******************************************************************************************
//* Implementation *
//* *
//* Copy this script into your map, save, restart NewGen, open your map and comment the *
//* ObjectMerger. *
//* *
//* Requirements *
//* *
//* JNGP (JASS NewGen Pack) *
//* *
//* Function list *
//* *
//* IsUnitInvisibleEx - checks if the specified units is insivisble. Checks for both the *
//* ability that is added by this script and for the normal IsUnitVisible. *
//* *
//* MakeUnitInvisible - makes the specified unit invisible. *
//* *
//* MakeUnitVisible - makes the specified unit visible. *
//* *
//* MakeUnitInvisibleTimed - makes the specified unit invisible, and after the specified *
//* time, makes it visible. *
//* *
//* Give credit to Vestras when using. *
//* ~Vestras *
//*******************************************************************************************
//! external ObjectMerger w3a Apiv ivs$ anam "Invisibility" aart "" aani "" acat "" aeat "" atat "" alig "" amat "" atar 1 "" adur 1 0.01 amcs 1 0 ahdu 1 0.01 aher 0 aite 1 alev 1 Nfd3 1 0 Nfd1 1 0 Nfd2 1 0.01 arac "other" atp1 1 "" aub1 1 "" ansf ""
//! external ObjectMerger w3a Afod ivs& anam "Invisibility Detector" aart "" aani "" acat "" aeat "" atat "" alig "" amat "" atar 1 "air,ground,structure,vulnerable,ward" acas 1 3600 amcs 1 0 aran 1 99999.0 aher 0 alev 1 Nfd3 1 0 Nfd1 1 0 Nfd2 1 0.01 arac "other" atp1 1 "" aub1 1 "" ansf ""
globals
private constant integer IVS_CODE = 039;ivs$039;
// You don't have to edit that, not as long as the OjbectMerger isn't edited
private constant integer DETECT_CODE = 039;ivs&039;
// You don't have to edit that, not as long as the ObjectMerger isn't edited
private constant integer DUMMY_CODE = 039;nshe039;
// Raw code of the used dummy unit (for checking for invisibility)
private constant string DUMMY_ABILITY = "fingerofdeath"
// Order string of the generated dummy ability (for checking for invisibility)
endglobals
// Don't edit below this line if you don't know what you're doing
globals
private unit dummy
endglobals
private struct Data
unit u
timer t
method onDestroy takes nothing returns nothing
call ReleaseTimer(.t)
endmethod
endstruct
function IsUnitInvisibleEx takes unit whichUnit returns boolean
local boolean b = false
if whichUnit != null and GetUnitTypeId(whichUnit) != 0 then
call PauseUnit(dummy, false)
set b = not IssueTargetOrder(dummy, DUMMY_ABILITY, whichUnit)
call PauseUnit(dummy, true)
endif
return b
endfunction
function MakeUnitInvisible takes unit whichUnit returns boolean
if IsUnitInvisibleEx(whichUnit) then
return false
endif
call UnitAddAbility(whichUnit, IVS_CODE)
return true
endfunction
function MakeUnitVisible takes unit whichUnit returns boolean
if not IsUnitInvisibleEx(whichUnit) then
return false
endif
call UnitRemoveAbility(whichUnit, IVS_CODE)
return true
endfunction
private function InvisibilityHandler takes nothing returns nothing
local Data d = GetTimerData(GetExpiredTimer())
call MakeUnitVisible(d.u)
call d.destroy()
endfunction
function MakeUnitInvisibleTimed takes unit whichUnit, real duration returns boolean
local Data d
local boolean b = MakeUnitInvisible(whichUnit)
if not b then
return false
endif
set d = Data.create()
set d.u = whichUnit
set d.t = NewTimer()
call TimerStart(d.t, duration, false, function InvisibilityHandler)
return b
endfunction
private function Init takes nothing returns nothing
set dummy = CreateUnit(Player(15), DUMMY_CODE, 0, 0, bj_UNIT_FACING)
call UnitAddAbility(dummy, DETECT_CODE)
call ShowUnit(dummy, false)
call PauseUnit(dummy, true)
endfunction
endlibrary