Moderator
M
Moderator
21st May 2012
Bribe: Looks good. Approved!
Bribe: Looks good. Approved!
//*************************************************************
//TEST THE SPELL FIRST TO CONFIGURE ANYTHING BELOW THIS
//*************************************************************
function MA_HeroAbility takes nothing returns integer
return 'A001'
//Rawcode of the hero spell
endfunction
function MA_DMGBonusAbilityInfo takes nothing returns integer
return 'A002'
//Rawcode of the damage bonus ability for the hero
endfunction
function MA_SPDBonusAbilityInfo takes nothing returns integer
return 'A003'
//Rawcode of the speed bonus ability for the hero
endfunction
function MA_DamageAbility takes nothing returns integer
return 'A005'
//Rawcode of the ability that gives the damage bonus to the hero
endfunction
function MA_SpeedAbility takes nothing returns integer
return 'A004'
//Rawcode of the ability that gives the speed bonus to the hero
endfunction
function MA_Dummy takes nothing returns integer
return 'u000'
//Rawcode of the dummy that cast the bonus spells
endfunction
function MA_DamageOrder takes nothing returns string
return "innerfire"
//The order to cast the damage bonus spell
endfunction
function MA_SpeedOrder takes nothing returns string
return "bloodlust"
//The order to cast the speed bonus spell
endfunction
function MA_ChargesPerLevel takes integer level returns integer
return 5 + 15 * level
//Max charges per level, you can change this relationated with the bonus spells on the object editor
endfunction
//*************************************************************
//TOUCH ANYTHING BELOW THIS ONLY IF YOU KNOW JASS
//*************************************************************
function MA1_Actions takes nothing returns boolean
local unit u = GetTriggerUnit()
if GetLearnedSkill() == MA_HeroAbility() and GetLearnedSkillLevel() == 1 then
call UnitAddAbility(u, MA_DMGBonusAbilityInfo())
call UnitAddAbility(u, MA_SPDBonusAbilityInfo())
endif
set u = null
return false
endfunction
function MA2_Actions takes nothing returns boolean
local unit a = udg_DamageEventSource
local unit t = udg_DamageEventTarget
local texttag tt
local integer i
local integer level
local string st
if IsUnitEnemy(a, GetOwningPlayer(t)) and GetUnitAbilityLevel(a, MA_HeroAbility()) > 0 and not IsUnitType(t, UNIT_TYPE_DEAD) and not IsUnitType(t, UNIT_TYPE_STRUCTURE) and not IsUnitType(t, UNIT_TYPE_MAGIC_IMMUNE) then
set i = GetUnitUserData(a)
set level = GetUnitAbilityLevel(a, MA_HeroAbility())
if udg_MA_MagicCount[i] < MA_ChargesPerLevel(level) then
set udg_MA_MagicCount[i] = udg_MA_MagicCount[i] + 1
if GetLocalPlayer() == GetOwningPlayer(a) then
set st = I2S(udg_MA_MagicCount[i])
endif
set tt = CreateTextTag()
call SetTextTagText(tt, st, 0.028)
call SetTextTagPos(tt, GetUnitX(a), GetUnitY(a) + 75, 160)
call SetTextTagColor(tt, 100, 180, 255, 255)
call SetTextTagVisibility(tt, true)
call SetTextTagVelocity(tt, 0, 0.03)
call SetTextTagFadepoint(tt, 0.25)
call SetTextTagLifespan(tt, 0.4)
call SetTextTagPermanent(tt, false)
endif
endif
set a = null
set t = null
return false
endfunction
function MA3_Actions takes nothing returns boolean
local unit caster = GetTriggerUnit()
local integer unitId = GetUnitUserData(caster)
local integer abilityId
local unit dummy
if udg_MA_MagicCount[unitId] > 0 then
set abilityId = GetSpellAbilityId()
if abilityId == MA_DMGBonusAbilityInfo() then
set dummy = CreateUnit(GetOwningPlayer(caster), MA_Dummy(), GetUnitX(caster), GetUnitY(caster), 0)
call UnitAddAbility(dummy, MA_DamageAbility())
call SetUnitAbilityLevel(dummy, MA_DamageAbility(), udg_MA_MagicCount[unitId])
call IssueTargetOrder(dummy, MA_DamageOrder(), caster)
call UnitApplyTimedLife(dummy, 'BTLF', 0.5)
set udg_MA_MagicCount[unitId] = 0
set dummy = null
elseif abilityId == MA_SPDBonusAbilityInfo() then
set dummy = CreateUnit(GetOwningPlayer(caster), MA_Dummy(), GetUnitX(caster), GetUnitY(caster), 0)
call UnitAddAbility(dummy, MA_SpeedAbility())
call SetUnitAbilityLevel(dummy, MA_SpeedAbility(), udg_MA_MagicCount[unitId])
call IssueTargetOrder(dummy, MA_SpeedOrder(), caster)
call UnitApplyTimedLife(dummy, 'BTLF', 0.5)
set udg_MA_MagicCount[unitId] = 0
set dummy = null
endif
endif
set caster = null
return false
endfunction
function InitTrig_MA takes nothing returns nothing
local trigger t = CreateTrigger()
local unit u = CreateUnit(Player(0), MA_Dummy(), 0, 0, 0)
call UnitAddAbility(u, MA_DMGBonusAbilityInfo())
call UnitAddAbility(u, MA_SPDBonusAbilityInfo())
call UnitAddAbility(u, MA_SpeedAbility())
call UnitAddAbility(u, MA_DamageAbility())
call RemoveUnit(u)
set u = null
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_HERO_SKILL)
call TriggerAddCondition(t, Condition(function MA1_Actions))
set t = CreateTrigger()
call TriggerRegisterVariableEvent(t, "udg_DamageEvent", EQUAL, 1.00)
call TriggerAddCondition(t, Condition(function MA2_Actions))
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function MA3_Actions))
set t = null
endfunction