My spellbook does not go on cd after I issue my unit immediate order "immolation". How can I fix this or go around this? If I don't issue this order, everything works fine.
EDIT: Another question I have to how to make shared cooldown with the spells I add to the spellbook by triggers or maybe any other way to set the order of the spells? I currently add a new spellbook with the same ID that contains the required spell.
Edit2: I solved both problems. I still don't understand why the first one happened. I just issued the order at the timer start, and it started to work fine. On the second problem, it is possible to add all three spells in the spellbook and just set the min and max spells equal to the number of spells in the book. Then, the order will be the same as in OE. I am surprised no one said anything about it in guides.
EDIT: Another question I have to how to make shared cooldown with the spells I add to the spellbook by triggers or maybe any other way to set the order of the spells? I currently add a new spellbook with the same ID that contains the required spell.
Edit2: I solved both problems. I still don't understand why the first one happened. I just issued the order at the timer start, and it started to work fine. On the second problem, it is possible to add all three spells in the spellbook and just set the min and max spells equal to the number of spells in the book. Then, the order will be the same as in OE. I am surprised no one said anything about it in guides.
JASS:
library Room /*
[I]/uses /[/I]
[I]/SpellFramework /[/I]
[I]/UnitIndexer /[/I]
*/GetUnitCollision
/*****************************************************************
* SPELL CONFIGURATION *
*****************************************************************/
private module SpellConfiguration
static constant integer SPELL_ABILITY_ID = 'A01T'
static constant integer ROOM_SPELL_BOOK_ID = 'A01Q'
static constant integer ROOM_MED_SPELL_BOOK_ID = 'A01R'
static constant integer ROOM_BIG_SPELL_BOOK_ID = 'A01S'
static constant integer SPELL_ROOM_MED_ID = 'A01U'
static constant integer SPELL_CLOSE_ROOM_ID = 'A01X'
static constant integer SPELL_ROOM_BIG_ID = 'A01V'
static constant integer SPELL_ROOM_STOP_ID = 'A01W'
static constant integer BUFF_ROOM_ACTIVE_ID = 'B002'
static constant integer SPELL_ROOM_STOP_ORDER_ID = ORDER_immolation
static constant string ROOM_MODEL_ID = "effect_law_room.mdl"
static constant integer SPELL_EVENT_TYPE = EVENT_SPELL_EFFECT
static constant real SPELL_PERIOD = 1.00/32.00
static constant real SFX_DEATH_TIME = 1.50
//Small Room
static constant real SMALL_ROOM_AOE = 400
static constant real SMALL_ROOM_MPS = 5 * SPELL_PERIOD
static constant real SMALL_ROOM_SCALE = 0.66
//0.82
//Medium Room
static constant real MED_ROOM_AOE = 1000
static constant real MED_ROOM_MPS = 10 * SPELL_PERIOD
static constant real MED_ROOM_SCALE = 1.0
static constant integer MED_ROOM_HERO_LEVEL = 2
//Big Room
static constant real BIG_ROOM_AOE = 1500
static constant real BIG_ROOM_MPS = 15 * SPELL_PERIOD
static constant real BIG_ROOM_MAX_HEALTH = 100
static constant real BIG_ROOM_SCALE = 1.5
static constant integer BIG_ROOM_HERO_LEVEL = 3
endmodule
/*****************************************************************
* END OF SPELL CONFIGURATION *
*****************************************************************/
/[I]========================= SPELL CODE =========================[/I]/
globals
private group tempG
private group copyG
endglobals
private struct Room extends array
implement SpellConfiguration
private effect roomSfx
private real aoe
private real mps
private unit caster
private real spellX
private real spellY
private real roomDist
private boolean IsRoomStopped
static Table lawInRoom
static Table roomG
private method onSpellStart takes nothing returns thistype
local integer spellid = GetSpellAbilityId()
local real dist
local real cX
local real cY
local real roomScale
set this = GetUnitId(Spell.triggerUnit)
if spellid == SPELL_ABILITY_ID then
set this.aoe = SMALL_ROOM_AOE
set this.mps = SMALL_ROOM_MPS
set roomScale = SMALL_ROOM_SCALE
elseif spellid == SPELL_ROOM_MED_ID then
set this.aoe = MED_ROOM_AOE
set this.mps = MED_ROOM_MPS
set roomScale = MED_ROOM_SCALE
elseif spellid == SPELL_ROOM_BIG_ID then
set this.aoe = BIG_ROOM_AOE
set this.mps = BIG_ROOM_MPS
set roomScale = BIG_ROOM_SCALE
call SetUnitState(Spell.triggerUnit, UNIT_STATE_MAX_LIFE, -BIG_ROOM_MAX_HEALTH)
endif
set this.caster = Spell.triggerUnit
set this.spellX = Spell.targetX
set this.spellY = Spell.targetY
set this.roomDist = this.aoe
set this.IsRoomStopped = false
set this.roomSfx = AddSpecialEffect(ROOM_MODEL_ID, Spell.targetX, Spell.targetY)
call SetEffectScale(this.roomSfx, roomScale)
call UnitAddAbility(Spell.triggerUnit, SPELL_CLOSE_ROOM_ID )
call UnitRemoveAbility(Spell.triggerUnit, SPELL_CLOSE_ROOM_ID )
call ShowUnitAbility(Spell.triggerUnit, ROOM_SPELL_BOOK_ID, false )
//call SetPlayerAbilityAvailable( Spell.triggerPlayer, ROOM_SPELL_BOOK_ID, false )
call UnitAddAbility(Spell.triggerUnit, SPELL_ROOM_STOP_ID)
call IssueImmediateOrderById(Spell.triggerUnit, SPELL_ROOM_STOP_ORDER_ID)
set cX = GetUnitX(Spell.triggerUnit)
set cY = GetUnitY(Spell.triggerUnit)
set dist = GetDist3d(cX, cY, Spell.targetX, Spell.targetY)
//debug call BJDebugMsg("[Law] Start Pereodic")
if dist <= this.roomDist then
set lawInRoom.boolean[this] = true
debug call BJDebugMsg("[Room] Law Is Inside the Roomn")
endif
//debug call BJDebugMsg("[Law] Unit Id: " + I2S(GetUnitId(Spell.triggerUnit)))
//debug call BJDebugMsg("[Law] This: " + I2S(this))
// set roomG.group[this] = CreateGroup()
//debug call BJDebugMsg("[Law] Start Pereodic")
return this
endmethod
private method onSpellPeriodic takes nothing returns boolean
local real cCurMana = GetUnitState(this.caster, UNIT_STATE_MANA)
local unit u
local real dist
local real uX
local real uY
local boolean IsRoomStopped = GetUnitAbilityLevel(this.caster, BUFF_ROOM_ACTIVE_ID) < 1
local boolean IsManaFinished = cCurMana < this.mps
//debug call BJDebugMsg("[Law] Pereodic Is Going")
if IsRoomStopped or IsManaFinished then
return true
endif
call SetUnitState(this.caster, UNIT_STATE_MANA, cCurMana - this.mps)
call GroupEnumUnitsInRange(tempG, this.spellX, this.spellY, this.aoe, null)
loop
set u = FirstOfGroup(tempG)
exitwhen u == null
if (BaseBool(u) and not IsUnitInGroup(u, roomG.group[this])) then
call GroupAddUnit(roomG.group[this], u)
debug call BJDebugMsg("[Room] " + GetUnitName(u) + " Got Added to The Group")
endif
call GroupRemoveUnit(tempG, u)
endloop
//debug call BJDebugMsg("[Law] Room Group Count: " + I2S(GetGroupUnitCount(roomG.group[this])))
set copyG = CopyGroup(roomG.group[this])
loop
set u = FirstOfGroup(copyG)
exitwhen u == null
set uX = GetUnitX(u)
set uY = GetUnitY(u)
set dist = GetDist3d(this.spellX, this.spellY, uX, uY)
// debug call BJDebugMsg("[Law] Distance Between " + GetUnitName(u) + " and Room Center is " + R2S(dist))
if dist > (this.roomDist + GetUnitCollisionSize(u)) then
call GroupRemoveUnit(roomG.group[this], u)
debug call BJDebugMsg("[Room] " + GetUnitName(u) + " Got Deleted From The Room Group Because Its Dist(" + R2S(dist) + ") more than " + R2S(this.roomDist + GetUnitCollisionSize(u)))
endif
call GroupRemoveUnit(copyG, u)
endloop
if (IsUnitInGroup(this.caster, roomG.group[this]) and not lawInRoom.boolean[this]) then
set lawInRoom.boolean[this] = true
debug call BJDebugMsg("[Room] Law Is Inside the Room")
elseif (not IsUnitInGroup(this.caster, roomG.group[this]) and lawInRoom.boolean[this]) then
set lawInRoom.boolean[this] = false
debug call BJDebugMsg("[Room] Law Is Outside of the Room")
endif
set u = null
return false
endmethod
private method onSpellEnd takes nothing returns nothing
//local real curCd = GetUnitAbilityCurrentCooldown(this.caster, SPELL_ROOM_STOP_ID)
debug call BJDebugMsg("[Room] Spell Finished")
if lawInRoom.boolean[this] then
set lawInRoom.boolean[this] = false
endif
call GroupClear(roomG.group[this])
//debug call BJDebugMsg("[Room] Cd left: " + R2S(curCd))
call UnitRemoveAbility(this.caster, SPELL_ROOM_STOP_ID)
call ShowUnitAbility(this.caster, ROOM_SPELL_BOOK_ID, true)
//call StartUnitAbilityCooldown(this.caster, ROOM_SPELL_BOOK_ID, curCd)
call DestroyEffect(this.roomSfx)
//
set this.roomSfx = null
set this.caster = null
endmethod
private static method run takes nothing returns nothing
local unit caster = GetTriggerUnit()
local integer abilityLevel = GetUnitAbilityLevel(caster, ROOM_SPELL_BOOK_ID)
local thistype this = GetUnitId(caster)
//debug call BJDebugMsg("[Law] Prep Finished")
//
if (GetLearnedSkill() == ROOM_SPELL_BOOK_ID and abilityLevel == 1) then
set lawInRoom.boolean[this] = false
set roomG.group[this] = CreateGroup()
//debug call BJDebugMsg("[Law] This: " + I2S(this))
debug call BJDebugMsg("[Law] Prep Finished")
endif
set caster = null
endmethod
private static method levelUp takes nothing returns nothing
local unit caster = GetTriggerUnit()
local integer abilityLevel = GetUnitAbilityLevel(caster, ROOM_SPELL_BOOK_ID)
if (GetUnitLevel(caster) == MED_ROOM_HERO_LEVEL and abilityLevel > 0) then
call UnitAddAbility(caster, ROOM_MED_SPELL_BOOK_ID)
call ShowUnitAbility(caster, ROOM_MED_SPELL_BOOK_ID, false )
elseif (GetUnitLevel(caster) == BIG_ROOM_HERO_LEVEL and abilityLevel > 0) then
call UnitAddAbility(caster, ROOM_BIG_SPELL_BOOK_ID)
call ShowUnitAbility(caster, ROOM_BIG_SPELL_BOOK_ID, false )
endif
set caster = null
endmethod
private static method onInit takes nothing returns nothing
call registerSpellEvent(SPELL_ROOM_MED_ID ,EVENT_SPELL_EFFECT)
call registerSpellEvent(SPELL_ROOM_BIG_ID ,EVENT_SPELL_EFFECT)
call RegisterAnyPlayerUnitEvent(EVENT_PLAYER_HERO_SKILL, function thistype.run)
call RegisterAnyPlayerUnitEvent(EVENT_PLAYER_HERO_LEVEL , function thistype.levelUp)
set lawInRoom = Table.create()
set roomG = Table.create()
set tempG = CreateGroup()
set copyG = CreateGroup()
endmethod
implement SpellEvent
endstruct
endlibrary
Last edited: