//TESH.scrollpos=18
//TESH.alwaysfold=0
scope RESET initializer init
globals
private constant timer Tim = CreateTimer()
private constant group unitGroup = CreateGroup()
private boolean Power = false
private constant real interval = 0.03125
endglobals
private function unitDies takes nothing returns nothing
local unit u = GetTriggerUnit()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
call SetUnitExploded(u, true)
call KillUnit(u)
call TriggerSleepAction(1)
set u = CreateUnit(GetTriggerPlayer(), GetUnitTypeId(u), x, y, 0)
call UnitRemoveAbility(u, 'Aatk')
endfunction
private function Timer takes nothing returns nothing
local unit j
call GroupEnumUnitsInRect(unitGroup, bj_mapInitialPlayableArea, null)
loop
set j = FirstOfGroup(unitGroup)
exitwhen j == null
call GroupRemoveUnit(unitGroup, j)
if GetOwningPlayer(j) == Player(0) then
call UnitResetCooldown(j)
//call SetUnitState(j, UNIT_STATE_LIFE, GetUnitState(j, UNIT_STATE_MAX_LIFE))
call SetUnitState(j, UNIT_STATE_MANA, GetUnitState(j, UNIT_STATE_MAX_MANA))
endif
endloop
endfunction
private function run takes nothing returns nothing
if not Power then
call TimerStart(Tim, interval, true, function Timer)
call DisplayTimedTextToPlayer(Player(0), 0, 0, 10, "WTF mode now is on!")
set Power = true
else
call PauseTimer(Tim)
call DisplayTimedTextToPlayer(Player(0), 0, 0, 10, "WTF mode now is off!")
set Power = false
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local unit j
local integer index = 0
call TriggerRegisterPlayerChatEvent(t, Player(0), "-wtf", true )
call TriggerAddAction(t, function run)
set t = CreateTrigger()
loop
call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_DEATH, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddAction(t, function unitDies)
call GroupEnumUnitsInRect(unitGroup, bj_mapInitialPlayableArea, null)
loop
set j = FirstOfGroup(unitGroup)
exitwhen j == null
call GroupRemoveUnit(unitGroup, j)
if GetOwningPlayer(j) == Player(0) then
else
call UnitRemoveAbility(j, 'Aatk')
endif
endloop
call FogModifierStart(CreateFogModifierRect(Player(0), FOG_OF_WAR_VISIBLE, bj_mapInitialPlayableArea, true, false))
call DisplayTimedTextToPlayer(Player(0), 0, 0, 10, "Fan of Toxic Knives made by KhaosMachine
If you want to enable/disable WTF mode type '-wtf' without the quotes!")
set t = null
endfunction
endscope
Name | Type | is_array | initial_value |
D | integer | No |
//TESH.scrollpos=42
//TESH.alwaysfold=0
/*
Guerded Attack v 1.0 made by 'KhaosMachine'
Original idea by 'En_Tropy'
IF YOU WANT TO IMPORT THIS SPELL INTO YOUR MAP YOU HAVE TO COPY THE NEXT THINGS:
*********************************************************************************
TRIGGER EDITOR:
FOLDERS: NONE
TRIGGERS: Guarded Attack
OBJECT EDITOR:
UNITS: Dummy ('u000')
ABILITIES: Guarded Attack ('A000')
Guarded Attack ('A001')
Invisibility ('A002')
BUFFS: Guarded Attack ('B001')
*********************************************************************************
THEN YOU HAVE TO CONFIGURE THE SPELL:
OBVIOUSLY THINGS:
ABILITY_ID = RAWCODE OF THE SPELL
REDUCE_ABILITY_ID = RAWCODE OF THE SLOW SPELL
BUFF_ID = RAWCODE OF THE REDUCE ABILITY ABILITY BUFF
REDUCE_ABILITY_ORDER = STRING ORDER OF THE REDUCE ABILITY
ABILITY_INVISIBLE_ID = RAWCODE OF THE INVISIBILITY ABILITY
DUMMY_ID = RAWCODE OF THE DUMMY
*/
scope guardedAttack initializer init
/*************************************************************
|*** ***|
|** **|
|* *|
|====> ¡¡¡START OF THE CONFIGURATION!!! <====|
|* *|
|** **|
|*** ***|
|************************************************************/
globals
private constant integer ABILITY_ID = 'A000' //HERO ABILITY ID
private constant integer REDUCE_ABILITY_ID = 'A001' //REDUCE DAMAGE ABILITY ID
private constant integer BUFF_ID = 'B001' //REDUCE DAMAGE BUFF ID
private constant string REDUCE_ABILITY_ORDER = "innerfire" //REDUCE DAMAGE ABILITY ORDER
private constant integer ABILITY_INVISIBLE_ID = 'A002' //PERMANENT INVISIBILITY ID
private constant integer DUMMY_ID = 'u000' //DUMMY UNIT ID
private real FPS = 32 //FRAMES PER SECOND
endglobals
private constant function DURATION takes integer level returns real
return 6. + 2. * level//SPELL DURATION
endfunction
/*************************************************************
|*** ***|
|** **|
|* *|
|====> ¡¡¡END OF THE CONFIGURATION!!! <====|
|* *|
|** **|
|*** ***|
|************************************************************/
private struct DATA
unit target
real duration
endstruct
globals
private constant timer TIMER = CreateTimer()
private DATA array ARRAY
private integer TOTAL = 0
endglobals
private function action takes nothing returns nothing
local DATA D
local boolean DESTROY_DATA
local integer i = 0
loop
exitwhen i >= TOTAL
set D = ARRAY[i]
set D.duration = D.duration - FPS
set DESTROY_DATA = D.duration <= 0
if DESTROY_DATA then
call IssueImmediateOrder(D.target, "stop")
call UnitRemoveAbility(D.target, ABILITY_INVISIBLE_ID)
call UnitRemoveAbility(D.target, BUFF_ID)
set ARRAY[i] = ARRAY[TOTAL - 1]
set TOTAL = TOTAL - 1
call D.destroy()
endif
set i = i + 1
endloop
if TOTAL == 0 then
call PauseTimer(TIMER)
endif
endfunction
private function run takes nothing returns boolean
local DATA D
local unit caster
local unit dummy
local integer level
if GetSpellAbilityId() == ABILITY_ID then
set D = DATA.create()
set caster = GetTriggerUnit()
set level = GetUnitAbilityLevel(caster, ABILITY_ID)
call UnitAddAbility(caster, ABILITY_INVISIBLE_ID)
set D.target = caster
set D.duration = DURATION(level)
set dummy = CreateUnit(GetOwningPlayer(caster), DUMMY_ID, GetUnitX(caster), GetUnitY(caster), 0)
call UnitAddAbility(dummy, REDUCE_ABILITY_ID)
call SetUnitAbilityLevel(dummy, REDUCE_ABILITY_ID, level)
call IssueTargetOrder(dummy, REDUCE_ABILITY_ORDER, caster)
call UnitApplyTimedLife(dummy, 'BTLF', 0.5)
if TOTAL == 0 then
call TimerStart(TIMER, FPS, true, function action)
endif
set TOTAL = TOTAL + 1
set ARRAY[TOTAL - 1] = D
set caster = null
set dummy = null
endif
return false
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
local unit d
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(t, Condition(function run))
set FPS = 1 / FPS
set d = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), DUMMY_ID, 0, 0, 0)
call UnitAddAbility(d, ABILITY_ID)
call UnitAddAbility(d, BUFF_ID)
call UnitAddAbility(d, REDUCE_ABILITY_ID)
call UnitAddAbility(d, ABILITY_INVISIBLE_ID)
call RemoveUnit(d)
set d = null
set t = null
endfunction
endscope