Name | Type | is_array | initial_value |
library DummyCaster initializer OnInit
//---------------------------------------------------
// Make sure that CASTER_TYPE correctly points to the DummyCaster's Id
// press ctrl + d to show the id in the object editor
//---------------------------------------------------
globals
private integer CASTER_TYPE = 'h000'
// do not touch
private unit dummyCaster
endglobals
private function LoadCaster takes nothing returns nothing
set dummyCaster = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), CASTER_TYPE, 0, 0, 0)
endfunction
function OrderCaster takes unit u, integer level, integer a, integer o returns nothing
call SetUnitX(dummyCaster, GetUnitX(u))
call SetUnitY(dummyCaster, GetUnitY(u))
call UnitAddAbility(dummyCaster, a)
call SetUnitAbilityLevel(dummyCaster, a, level)
call IssueTargetOrderById(dummyCaster,o,u)
call UnitRemoveAbility(dummyCaster, a)
endfunction
private function OnInit takes nothing returns nothing
call LoadCaster()
endfunction
endlibrary
library Preload
//---------------------------------------------------
// Make sure that PRELOAD_TYPE correctly points to the DummyCaster's Id
// press ctrl + d to show the id in the object editor
//
// Also change the (x, y) to point at the unused point in your map (usually the corner)
// You can find it by using the terrain editor and hovering over the point that you want
// the point is listed on the lower left portion of the editor labeled as point followed
// by the x and y values
//---------------------------------------------------
globals
private integer PRELOAD_TYPE = 'h000'
private real x = -1231.7
private real y = 988.4
private real cleanUpDelay = 0
endglobals
private module Init
private static unit preloadDummy
private static method onInit takes nothing returns nothing
set preloadDummy = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), PRELOAD_TYPE, x, y, 0)
endmethod
static method preloadEffect takes string s returns nothing
call DestroyEffect(AddSpecialEffectTarget(s, thistype.preloadDummy, "origin"))
endmethod
static method preloadAbility takes integer i returns nothing
call UnitAddAbility(thistype.preloadDummy, i)
call UnitRemoveAbility(thistype.preloadDummy, i)
endmethod
static method cleanPreload takes nothing returns nothing
call RemoveUnit(thistype.preloadDummy)
set preloadDummy = null
endmethod
endmodule
struct Initialize
implement Init
private static method clean takes nothing returns nothing
call cleanPreload()
endmethod
static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEventSingle(t, cleanUpDelay)
call TriggerAddAction(t, function thistype.clean)
set t = null
endmethod
endstruct
endlibrary
library Auramancer
//-----------------------------------------------------------------------
// Auramancer v1.3
// Author: Blightsower
//
// DESCRIPTION:
// A system that assigns bonuses (in the form of spell books) to any specific de/buff.
// Works with de/buffs obtained from anywhere including auras.
//
// HOW TO USE:
// Call the function below at map initialization.
//
// API:
// call Auramancer.register(BUFF_ID, ABILITY_ID, AURA_LEVEL)
//
// Expectation from the system:
// The system accepts a pair of BUFF_ID and ABILITY_ID.
// Whenever a unit gains the BUFF_ID you registered, the system applies the
// appropriate ABILITY_ID and AURA_LEVEL to the unit. Should a moment arise
// where the unit obtains two BUFF_ID's that shares the same ABILITY_ID, the
// ABILITY_ID with the higher AURA_LEVEL gets applied to the unit.
//
// Expectation from the users:
// The user is expected to call Auramancer.register(BUFF_ID, ABILITY_ID, AURA_LEVEL)
// at map initialization either through GUI or vJass initialization.
//
// If the user's BUFF_ID supports multiple levels, the user must declare each BUFF_ID for each
// level.BUFF_ID with multiple levels can share the same spell book. The user must specify
// the AURA_LEVEL. ABILITY_ID must support the levels defined by AURA_LEVEL.
//
//---------------------------------------------------------------
// Requirements:
// - Enable JassHelper
//
// How to enable JassHelper
// - In the Trigger Editor window, look for the menu labeled JassHelper
// and click Enable JassHelper
//-------------------------------------------------------------------------
// HOW TO IMPORT:
// - Copy and paste Auramancer to your map
//-----------------------------------------------------------------------
// SPECIAL THANKS
// Antares
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// CONFIGURATION
//-----------------------------------------------------------------------
globals
private real timerInterval = .03
private real auramancerStartDelay = 0.
endglobals
//-----------------------------------------------------------------------
// END OF CONFIGURATION
//-----------------------------------------------------------------------
private module CircularLinkedList
readonly thistype next
readonly thistype prev
method init takes nothing returns thistype
set next = this
set prev = this
return this
endmethod
method pushBack takes thistype node returns thistype
set node.prev = prev
set node.next = this
set prev.next = node
set prev = node
return node
endmethod
method pushFront takes thistype node returns thistype
set node.prev = this
set node.next = next
set next.prev = node
set next = node
return node
endmethod
method pop takes nothing returns nothing
set prev.next = next
set next.prev = prev
endmethod
endmodule
module Auramancer
implement CircularLinkedList
private integer buffId
private integer bonusId
private integer auraLevel
private group buffGroup = CreateGroup()
private static timer auraTimer = CreateTimer()
private static group g = CreateGroup()
private static rect r
private static thistype curr = 0
private static method Check takes nothing returns boolean
local unit u = GetFilterUnit()
local thistype this = curr
local integer bonusLevel
if GetUnitAbilityLevel(u, .buffId) > 0 then
if not(IsUnitInGroup(u, .buffGroup)) then
// when unit is first added to the group, its ability level will match the
// aura level
if GetUnitAbilityLevel(u, .bonusId) == 0 then
call UnitAddAbility(u, .bonusId)
endif
call SetUnitAbilityLevel(u, .bonusId, .auraLevel)
call GroupAddUnit(.buffGroup , u)
else
// only happens when the unit is already in the group but the system
// is unsure if the unit has the correct level of bonuses applied
set bonusLevel = GetUnitAbilityLevel(u, .bonusId)
if bonusLevel == 0 then
call UnitAddAbility(u, .bonusId)
call SetUnitAbilityLevel(u, .bonusId, .auraLevel)
else
if bonusLevel < .auraLevel then
call SetUnitAbilityLevel(u, .bonusId, .auraLevel)
else
call SetUnitAbilityLevel(u, .bonusId, bonusLevel)
endif
endif
endif
// unit is expelled from the group and bonuses revoked when it no longer bears the buff
elseif IsUnitInGroup(u, .buffGroup) then
call UnitRemoveAbility(u, .bonusId)
call GroupRemoveUnit(.buffGroup , u)
endif
call GroupRemoveUnit(g,u)
return false
endmethod
private static method auraLoop takes nothing returns nothing
call GroupEnumUnitsInRect(g, r, Filter(function Auramancer.Check))
set curr = curr.next
endmethod
private static method disableAbility takes integer a returns nothing
local integer i = 1
loop
exitwhen i > 24
call SetPlayerAbilityAvailableBJ( false, a, ConvertedPlayer(i))
set i = i + 1
endloop
endmethod
static method register takes integer boof, integer bonus, integer level returns nothing
local thistype this = thistype.allocate()
set .buffId = boof
set .bonusId = bonus
set .auraLevel = level
call disableAbility(.bonusId)
if curr == 0 then
call this.init()
set curr = this
else
call curr.pushBack(this)
endif
endmethod
static method auramancerTimerStart takes nothing returns nothing
set .r = GetPlayableMapRect()
call TimerStart(auraTimer, timerInterval, true, function thistype.auraLoop)
endmethod
endmodule
struct Auramancer
implement Auramancer
private static method auramancerDelayedStart takes nothing returns nothing
call auramancerTimerStart()
endmethod
static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEventSingle(t, auramancerStartDelay)
call TriggerAddAction(t, function thistype.auramancerDelayedStart)
set t = null
endmethod
endstruct
endlibrary
library AuraOfSilence initializer OnInit requires Auramancer, DummyCaster, Preload
//---------------------------------------------------------------
// Aura of Silence v1.0
// Author: Blightsower
//
// Description - Reduces the maximum mana of nearby enemy units. Additionally, grants
// a chance to silence afflicted enemy units whenever they attempt to cast a spell.
//
//---------------------------------------------------------------
// Requirements:
// * Enable JassHelper
//
// How to enable JassHelper
// * In the Trigger Editor window, look for the menu labeled JassHelper
// and click Enable JassHelper
//-------------------------------------------------------------------------
// How to Import:
// 1. Copy and paste the objects from this map to your map
// * There are a ton of objects within this map due to the nature of the spell
// which affects both allies and enemies.
// * The important objects that you need to import to have it work successfully
// in your map are the following:
// - Aura of Silence - (Hero Ability)
// - Aura of Silence - (Silence)
// - Aura of Silence - (Penalty)
// - Buffs
// - Mana Penalties
// - Dummy Caster
// 2. Copy and paste the Aura of Silence Category into your map
// 3. Configure the spell so that everything points to the correct
// variables. Additional information about the variables are
// provided for clarity
//-------------------------------------------------------------------------
// Note:
// This spell includes some optional libraries to handle dummy casting and preloading.
// You might want to get rid of those libraries if you already have a system
// that handles those functionalities or you just feel like writing your own. Should you choose to keep
// the libraries, there are a few things that you need to configure to fit your needs. Check the libraries
// individually to have the variables point to the correct objects.
//
// How to remove optional libraries:
// To remove DummyCaster:
// Remove DummyCaster from the requires and delete whats inside the OnDummyCast function found
// at the bottom of configurables. Delete DummyCaster script
// To remove Preload:
// Remove Preload from the requires and delete whats inside the OnPreload function found
// at the bottom of configurables. Delete Preload script
//
// It also includes one required library which is Auramancer. You also need a DummyCaster
// to keep this spell working. The DummyCaster included in this map does not account
// for the owner of the dummy spell so refrain from adding damage to the dummy spell.
//-------------------------------------------------------------------------
//---------------------------------------------------------------
// CONFIGURABLES
//---------------------------------------------------------------
globals
// must point to Aura of Silence - (Penalty)
private constant integer BONUS_ABILITY = 'A001'
// must point to Aura of Silence - (Silence)
private constant integer DUMMY_ABILITY_ID = 'A002'
// this is the ID of Soul Burn
private constant integer DUMMY_ABILITY_ORDER = 852668
// Effects that will appear when an afflicted enemy unit casts a spell
private constant string SILENCE_EFFECT = "Abilities\\Spells\\Items\\AIil\\AIilTarget.mdl"
private constant string SILENCE_EFFECT_ATTACHMENT = "origin"
endglobals
// Chance of unit getting silenced
private function GetChance takes integer level returns real
return 40. + (10*level)
endfunction
// Dummy caster function
private function OnDummyCast takes unit u, integer l returns nothing
call OrderCaster(u, l, DUMMY_ABILITY_ID, DUMMY_ABILITY_ORDER)
endfunction
// Preload
private function OnPreload takes nothing returns nothing
// Temporary preload
call Initialize.preloadAbility(BONUS_ABILITY)
call Initialize.preloadAbility(DUMMY_ABILITY_ID)
call Initialize.preloadEffect(SILENCE_EFFECT)
// Auramancer set up
// 'B000', 'B001', 'B002' must point to the buffs
// also assign the correct levels for each buff
call Auramancer.register('B000', BONUS_ABILITY, 1)
call Auramancer.register('B001', BONUS_ABILITY, 2)
call Auramancer.register('B002', BONUS_ABILITY, 3)
endfunction
//---------------------------------------------------------------
// END OF CONFIGURABLES
//---------------------------------------------------------------
private function OnCast takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer l = GetUnitAbilityLevel(u, BONUS_ABILITY)
if l > 0 then
if GetChance(l) >= GetRandomReal(0, 100.) then
call DestroyEffect(AddSpecialEffectTarget(SILENCE_EFFECT, u, SILENCE_EFFECT_ATTACHMENT))
call OnDummyCast(u, l)
endif
endif
set u = null
endfunction
private function OnInit takes nothing returns nothing
local trigger t = CreateTrigger()
call OnPreload()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function OnCast))
set t = null
endfunction
endlibrary