Name | Type | is_array | initial_value |
IsUnitPreplaced | boolean | Yes | |
UDex | integer | No | |
UDexGen | integer | No | |
UDexNext | integer | Yes | |
UDexPrev | integer | Yes | |
UDexRecycle | integer | No | |
UDexUnits | unit | Yes | |
UDexWasted | integer | No | |
UnitIndexerEnabled | boolean | No | |
UnitIndexEvent | real | No |
//TESH.scrollpos=0
//TESH.alwaysfold=0
library DummyCaster /* v2.0.0.1
*************************************************************************************
*
* Dummy caster for casting spells
*
* Spells must have 0 cooldown, 92083 range, and cost 0 mana. Spells must be instant and
* can't share the same order as other spells on the dummy caster.
*
*************************************************************************************
*
* */uses/*
* */ optional UnitIndexer, /* hiveworkshop.com/forums/jass-functions-413/unit-indexer-172090/
*
************************************************************************************
* SETTINGS
*/
globals
constant integer UNITS_DUMMY_CASTER = 'h001'
/*************************************************************************************
*
* PLAYER_OWNER
*
* Owner of dummy caster
*
*************************************************************************************/
private constant player PLAYER_OWNER = Player(15)
endglobals
/*
************************************************************************************
*
* Dummy at position 32256,32256
*
* struct DummyCaster extends array
*
* method cast takes player castingPlayer, integer abilityLevel, integer order, real x, real y returns boolean
* - call DummyCaster[abilityId].cast(...)
* method castTarget takes player castingPlayer, integer abilityLevel, integer order, widget t returns boolean
* - call DummyCaster[abilityId].castTarget(...)
* method castPoint takes player castingPlayer, integer abilityLevel, integer order, real x, real y returns boolean
* - call DummyCaster[abilityId].castPoint(...)
*
************************************************************************************/
globals
private unit u
endglobals
private module N
private static method onInit takes nothing returns nothing
static if LIBRARY_UnitIndexer then
set UnitIndexer.enabled=false
set u=CreateUnit(PLAYER_OWNER,UNITS_DUMMY_CASTER,0,0,0)
set UnitIndexer.enabled=true
else
set u=CreateUnit(PLAYER_OWNER,UNITS_DUMMY_CASTER,0,0,0)
endif
call SetUnitPosition(u,32256,32256)
endmethod
endmodule
struct DummyCaster extends array
implement N
private static method prep takes integer a, player p, integer l returns nothing
call UnitAddAbility(u, a)
if (1 < l) then
call SetUnitAbilityLevel(u, a, l)
endif
if (null != p) then
call SetUnitOwner(u, p, false)
endif
endmethod
private static method finish takes integer a returns nothing
call SetUnitOwner(u, PLAYER_OWNER, false)
call UnitRemoveAbility(u, a)
endmethod
method unit takes nothing returns unit
return u
endmethod
method cast takes player p, integer level, integer order, real x, real y returns boolean
local boolean b
call SetUnitX(u, x)
call SetUnitY(u, y)
call prep(this, p, level)
set b = IssueImmediateOrderById(u,order)
call finish(this)
call SetUnitPosition(u, 32256, 32256)
return b
endmethod
method castTarget takes player p, integer level, integer order, widget t returns boolean
local boolean b
call SetUnitX(u, GetWidgetX(t))
call SetUnitY(u, GetWidgetY(t))
call prep(this, p, level)
set b = IssueTargetOrderById(u,order,t)
call finish(this)
call SetUnitPosition(u, 32256, 32256)
return b
endmethod
method castPoint takes player p, integer level, integer order, real px, real py, real x, real y returns boolean
local boolean b
call SetUnitX(u, px)
call SetUnitY(u, py)
call prep(this, p, level)
set b = IssuePointOrderById(u,order,x,y)
call finish(this)
call SetUnitPosition(u, 32256, 32256)
return b
endmethod
endstruct
endlibrary
//A simple library for killing a unit while still giving kill credit to another unit
//Author: KitsuneTailsPrower
library InstantKill requires optional DamageEngine
native UnitAlive takes unit u returns boolean
globals
integer killertypeid = 'h001' //set this to a dummy unit
unit killer=null
endglobals
function InstantKill takes player p, unit target, real x, real y returns nothing
if not UnitAlive(killer) then
set killer = CreateUnit(p, killertypeid, x, y, 0.0)
else
call SetUnitOwner(killer,p,false)
call SetUnitX(killer,x)
call SetUnitY(killer,y)
endif
static if LIBRARY_DamageEngine then
set udg_NextDamageType = udg_DamageTypePure
endif
call UnitRemoveBuffs(target,true,true)
call SetWidgetLife(target,1.0)
call UnitDamageTarget(killer, target, 100000000., true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null)
endfunction
endlibrary
scope SealingTheKeyHole initializer onInit
globals
//configuration
private constant integer AID = 'A000' //Ability ID of the main spell
private constant integer OID = 852600 //OrderID of the main spell
private constant string VOID_EFFECT_PATH = "Abilities\\Spells\\Undead\\DeathandDecay\\DeathandDecayTarget.mdl" //Model of the initial effect
private constant real VOID_EFFECT_SCALE = 4.0 //Scale of the initial effect
private constant string GATE_EFFECT_PATH = "Doodads\\Icecrown\\Terrain\\IceCrownThroneGate\\IceCrownThroneGate.mdl" //Model of the door effect
private constant real GATE_EFFECT_SCALE = 1.0 //Scale of the initial effect
private constant string EXPLOSION_EFFECT_PATH = "Objects\\Spawnmodels\\Human\\HCancelDeath\\HCancelDeath.mdl" //Model of the explosion effect
private constant real EXPLOSION_EFFECT_SCALE = 3.0 //Scale of the explosion effect
private constant real INITIAL_DAMAGE_BASE = 10.0 //Base damage when the spell is first cast
private constant real INITIAL_DAMAGE_PER_LEVEL = 10.0 //Bonus damage per level when the spell is first cast
private constant real AOE = 200.0 //Area of effect of the spell, set equal to the AoE in the object editor
private constant real KILL_PERCENT_HERO = 33.0 //Heroes at or below this life percent will die instantly when the door apears. KILL_PERCENT values are in % not decimal. Set to a negative value to always kill
private constant real KILL_PERCENT_UNIT = -1.0 //Non hero units at or below this life percent will die instantly when the door apears. KILL_PERCENT values are in % not decimal. Set to a negative value to always kill
private constant real END_DAMAGE_BASE = 50.0 //Base damage when the door appears (Not included in KILL_PERCENT caculations)
private constant real END_DAMAGE_PER_LEVEL = 50.0 //Bonus damage per level when the door appears (Not included in KILL_PERCENT caculations)
private constant integer STUN_AID = 'A001' //Abilty ID of the spell used to perform the stun, feel free to comment out and use an existing stun system
private constant integer STUN_OID = 852095 //Order ID of the spell used to perform the stun, feel free to comment out and use an existing stun system
//don't touch
private group array targets
private real array facingangles
private real array targetx
private real array targety
endglobals
private function FilterTarget takes unit u, unit c returns boolean
return IsUnitEnemy(u, GetOwningPlayer(c)) and not IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE) and not BlzIsUnitInvulnerable(u) and UnitAlive(u) and not IsUnitType(u,UNIT_TYPE_STRUCTURE)
endfunction
private function onCast takes nothing returns nothing
local unit c = GetTriggerUnit()
local unit u = null
local group g = CreateGroup()
local effect fx = null
local real initialdamage = INITIAL_DAMAGE_BASE + (INITIAL_DAMAGE_PER_LEVEL * GetUnitAbilityLevel(c,AID))
local integer userdata = GetUnitUserData(c)
if GetSpellAbilityId() != AID then
call DestroyGroup(g)
set c = null
set g = null
return
endif
if targets[userdata] == null then
set targets[userdata] = CreateGroup()
endif
call GroupClear(targets[userdata])
set facingangles[userdata] = GetUnitFacing(c)
set targetx[userdata] = GetUnitX(GetSpellTargetUnit())
set targety[userdata] = GetUnitY(GetSpellTargetUnit())
set fx=AddSpecialEffect(VOID_EFFECT_PATH,targetx[userdata],targety[userdata])
call BlzSetSpecialEffectScale(fx,VOID_EFFECT_SCALE)
call DestroyEffect(fx)
call GroupEnumUnitsInRange(g, targetx[userdata],targety[userdata], AOE, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if FilterTarget(u,c) then
call UnitDamageTarget(c, u, initialdamage, false, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
call GroupAddUnit(targets[userdata],u)
endif
call GroupRemoveUnit(g, u)
endloop
call DestroyGroup(g)
set g=null
set fx=null
set c=null
endfunction
private function onFinish takes nothing returns nothing
local unit c = GetTriggerUnit()
local unit u=null
local effect fx = null
local real enddamage = END_DAMAGE_BASE + (END_DAMAGE_PER_LEVEL * GetUnitAbilityLevel(c,AID))
local integer userdata = GetUnitUserData(c)
if GetSpellAbilityId() == AID then
set fx=AddSpecialEffect(GATE_EFFECT_PATH,targetx[userdata],targety[userdata])
call BlzSetSpecialEffectScale(fx,GATE_EFFECT_SCALE)
call BlzSetSpecialEffectOrientation(fx,(facingangles[userdata] * 3.14) / 180,0.0,0.0)
call DestroyEffect(fx)
set fx=AddSpecialEffect(EXPLOSION_EFFECT_PATH,targetx[userdata],targety[userdata])
call BlzSetSpecialEffectScale(fx,EXPLOSION_EFFECT_SCALE)
call DestroyEffect(fx)
loop
set u = FirstOfGroup(targets[GetUnitUserData(c)])
exitwhen u == null
if (IsUnitType(u,UNIT_TYPE_HERO) and (KILL_PERCENT_HERO < 0.0 or GetUnitLifePercent(u) <= KILL_PERCENT_HERO)) or /*
*/ (not IsUnitType(u,UNIT_TYPE_HERO) and (KILL_PERCENT_UNIT < 0.0 or GetUnitLifePercent(u) <= KILL_PERCENT_UNIT)) then
call SetUnitX(u,targetx[userdata])
call SetUnitY(u,targety[userdata])
call InstantKill(GetOwningPlayer(c),u,GetUnitX(c),GetUnitY(c))
else
call DummyCaster['A001'].castTarget(GetOwningPlayer(c),GetUnitAbilityLevel(c,AID),STUN_OID,u) //Comment this out and use your own stuns system here if desired
call UnitDamageTarget(c, u, enddamage, false, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
endif
call GroupRemoveUnit(targets[GetUnitUserData(c)], u)
endloop
endif
call GroupClear(targets[GetUnitUserData(c)])
set fx=null
set c = null
endfunction
private function onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition(function onCast) )
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_FINISH )
call TriggerAddCondition( t, Condition(function onFinish) )
set t = null
endfunction
endscope