Hello,
Having 2 issues with spellbooks,
1) The spellbook icon is showing up, even though it's disabled
2) The spellbook (DkNs) has 2 passive abilities inside, one for HP regen (DkHP), one for MP regen (DkMP), and they're supposed to scale with the level of the spellbook.
The HP skill is fine, but the MP skill stays at level 1 even when the spell book is level 2 or 3
The second trigger is because the ability is only active during the night
Having 2 issues with spellbooks,
1) The spellbook icon is showing up, even though it's disabled
2) The spellbook (DkNs) has 2 passive abilities inside, one for HP regen (DkHP), one for MP regen (DkMP), and they're supposed to scale with the level of the spellbook.
The HP skill is fine, but the MP skill stays at level 1 even when the spell book is level 2 or 3
The second trigger is because the ability is only active during the night
JASS:
function Trig_Darkness_Conditions takes nothing returns boolean
return GetLearnedSkill()=='DydW' or GetLearnedSkill()=='DydE' or GetLearnedSkill()=='DydR'
endfunction
function Trig_Darkness_Actions takes nothing returns nothing
set udg_unit_darkness=GetTriggerUnit()
set udg_integer_darkness=GetLearnedSkillLevel()
if udg_integer_darkness==1 then
call UnitAddAbility(udg_unit_darkness,'Ashm')
call UnitAddAbility(udg_unit_darkness,'DkNs')
call SetPlayerAbilityAvailable(GetOwningPlayer(udg_unit_darkness),'DkNs',true)
call SetPlayerAbilityAvailable(GetOwningPlayer(udg_unit_darkness),'DkNs',false)
call UnitMakeAbilityPermanent(udg_unit_darkness,true,'Ashm')
call EnableTrigger(gg_trg_Darkness_Time)
endif
endfunction
//===========================================================================
function InitTrig_Darkness takes nothing returns nothing
local integer i=0
set gg_trg_Darkness=CreateTrigger()
loop
exitwhen i==bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(gg_trg_Darkness,Player(i),EVENT_PLAYER_HERO_SKILL,null)
set i=i+1
endloop
call TriggerAddCondition(gg_trg_Darkness,Condition(function Trig_Darkness_Conditions))
call TriggerAddAction(gg_trg_Darkness,function Trig_Darkness_Actions)
endfunction
JASS:
function Trig_Darkness_Time_Actions takes nothing returns nothing
local real r=GetFloatGameState(GAME_STATE_TIME_OF_DAY)
if r==0.00 or r<6.00 or r>=18.00 then
call UnitAddAbility(udg_unit_darkness,'DkNs')
call SetUnitAbilityLevel(udg_unit_darkness,'DkMP',udg_integer_darkness)
call SetUnitAbilityLevel(udg_unit_darkness,'DkHP',udg_integer_darkness)
call SetPlayerAbilityAvailable(GetOwningPlayer(udg_unit_darkness),'DkNs',true)
call SetPlayerAbilityAvailable(GetOwningPlayer(udg_unit_darkness),'DkNs',false)
else
if r>=6.00 and r<18.00 then
call UnitRemoveAbility(udg_unit_darkness,'DkNs')
endif
endif
endfunction
//===========================================================================
function InitTrig_Darkness_Time takes nothing returns nothing
set gg_trg_Darkness_Time=CreateTrigger()
call DisableTrigger(gg_trg_Darkness_Time)
call TriggerRegisterTimerEvent(gg_trg_Darkness_Time,1.00,true)
call TriggerAddAction(gg_trg_Darkness_Time,function Trig_Darkness_Time_Actions)
endfunction