//*************************************************************//TEST THE SPELL FIRST TO CONFIGURE ANYTHING BELOW THIS//*************************************************************function MA_HeroAbility takesnothingreturnsintegerreturn'A001'//Rawcode of the hero spellendfunctionfunction MA_DMGBonusAbilityInfo takesnothingreturnsintegerreturn'A002'//Rawcode of the damage bonus ability for the heroendfunctionfunction MA_SPDBonusAbilityInfo takesnothingreturnsintegerreturn'A003'//Rawcode of the speed bonus ability for the heroendfunctionfunction MA_DamageAbility takesnothingreturnsintegerreturn'A005'//Rawcode of the ability that gives the damage bonus to the heroendfunctionfunction MA_SpeedAbility takesnothingreturnsintegerreturn'A004'//Rawcode of the ability that gives the speed bonus to the heroendfunctionfunction MA_Dummy takesnothingreturnsintegerreturn'u000'//Rawcode of the dummy that cast the bonus spellsendfunctionfunction MA_DamageOrder takesnothingreturnsstringreturn"innerfire"//The order to cast the damage bonus spellendfunctionfunction MA_SpeedOrder takesnothingreturnsstringreturn"bloodlust"//The order to cast the speed bonus spellendfunctionfunction MA_ChargesPerLevel takesinteger level returnsintegerreturn5+15* level
//Max charges per level, you can change this relationated with the bonus spells on the object editorendfunction//*************************************************************//TOUCH ANYTHING BELOW THIS ONLY IF YOU KNOW JASS//*************************************************************function MA1_Actions takesnothingreturnsbooleanlocalunit u =GetTriggerUnit()ifGetLearnedSkill()== MA_HeroAbility()andGetLearnedSkillLevel()==1thencallUnitAddAbility(u, MA_DMGBonusAbilityInfo())callUnitAddAbility(u, MA_SPDBonusAbilityInfo())endifset u =nullreturnfalseendfunctionfunction MA2_Actions takesnothingreturnsbooleanlocalunit a = udg_DamageEventSource
localunit t = udg_DamageEventTarget
localtexttag tt
localinteger i
localinteger level
localstring st
ifIsUnitEnemy(a,GetOwningPlayer(t))andGetUnitAbilityLevel(a, MA_HeroAbility())>0andnotIsUnitType(t,UNIT_TYPE_DEAD)andnotIsUnitType(t,UNIT_TYPE_STRUCTURE)andnotIsUnitType(t,UNIT_TYPE_MAGIC_IMMUNE)thenset i =GetUnitUserData(a)set level =GetUnitAbilityLevel(a, MA_HeroAbility())if udg_MA_MagicCount[i]< MA_ChargesPerLevel(level)thenset udg_MA_MagicCount[i]= udg_MA_MagicCount[i]+1ifGetLocalPlayer()==GetOwningPlayer(a)thenset st =I2S(udg_MA_MagicCount[i])endifset tt =CreateTextTag()callSetTextTagText(tt, st,0.028)callSetTextTagPos(tt,GetUnitX(a),GetUnitY(a)+75,160)callSetTextTagColor(tt,100,180,255,255)callSetTextTagVisibility(tt,true)callSetTextTagVelocity(tt,0,0.03)callSetTextTagFadepoint(tt,0.25)callSetTextTagLifespan(tt,0.4)callSetTextTagPermanent(tt,false)endifendifset a =nullset t =nullreturnfalseendfunctionfunction MA3_Actions takesnothingreturnsbooleanlocalunit caster =GetTriggerUnit()localinteger unitId =GetUnitUserData(caster)localinteger abilityId
localunit dummy
if udg_MA_MagicCount[unitId]>0thenset abilityId =GetSpellAbilityId()if abilityId == MA_DMGBonusAbilityInfo()thenset dummy =CreateUnit(GetOwningPlayer(caster), MA_Dummy(),GetUnitX(caster),GetUnitY(caster),0)callUnitAddAbility(dummy, MA_DamageAbility())callSetUnitAbilityLevel(dummy, MA_DamageAbility(), udg_MA_MagicCount[unitId])callIssueTargetOrder(dummy, MA_DamageOrder(), caster)callUnitApplyTimedLife(dummy,'BTLF',0.5)set udg_MA_MagicCount[unitId]=0set dummy =nullelseif abilityId == MA_SPDBonusAbilityInfo()thenset dummy =CreateUnit(GetOwningPlayer(caster), MA_Dummy(),GetUnitX(caster),GetUnitY(caster),0)callUnitAddAbility(dummy, MA_SpeedAbility())callSetUnitAbilityLevel(dummy, MA_SpeedAbility(), udg_MA_MagicCount[unitId])callIssueTargetOrder(dummy, MA_SpeedOrder(), caster)callUnitApplyTimedLife(dummy,'BTLF',0.5)set udg_MA_MagicCount[unitId]=0set dummy =nullendifendifset caster =nullreturnfalseendfunctionfunction InitTrig_MA takesnothingreturnsnothinglocaltrigger t =CreateTrigger()localunit u =CreateUnit(Player(0), MA_Dummy(),0,0,0)callUnitAddAbility(u, MA_DMGBonusAbilityInfo())callUnitAddAbility(u, MA_SPDBonusAbilityInfo())callUnitAddAbility(u, MA_SpeedAbility())callUnitAddAbility(u, MA_DamageAbility())callRemoveUnit(u)set u =nullcallTriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_HERO_SKILL)callTriggerAddCondition(t,Condition(function MA1_Actions))set t =CreateTrigger()callTriggerRegisterVariableEvent(t,"udg_DamageEvent",EQUAL,1.00)callTriggerAddCondition(t,Condition(function MA2_Actions))set t =CreateTrigger()callTriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)callTriggerAddCondition(t,Condition(function MA3_Actions))set t =nullendfunction
This will attract quite a bit of attention from mods ;p
Many bjs, you could have used global variables for the ability IDs and it isn't indented, but unindented is the way I roll too. +rep!
You should really indent your code :/
If it isn't indented, it's much harder to read. (Don't listen to maddeem and his wacky anti-indentation movement =P)
Or, instead of wasting time, clicking that link, downloading the application and inputting the code, then pasting it, here, I did it for you manually:
Jass:
//************************************************************* //TEST THE SPELL FIRST TO CONFIGURE ANYTHING BELOW THIS //*************************************************************
function MA_HeroAbility takesnothingreturnsinteger return'A001' //Rawcode of the hero spell endfunction
function MA_DMGBonusAbilityInfo takesnothingreturnsinteger return'A002' //Rawcode of the damage bonus ability for the hero endfunction
function MA_SPDBonusAbilityInfo takesnothingreturnsinteger return'A003' //Rawcode of the speed bonus ability for the hero endfunction
function MA_DamageAbility takesnothingreturnsinteger return'A005' //Rawcode of the ability that gives the damage bonus to the hero endfunction
function MA_SpeedAbility takesnothingreturnsinteger return'A004' //Rawcode of the ability that gives the speed bonus to the hero endfunction
function MA_Dummy takesnothingreturnsinteger return'u000' //Rawcode of the dummy that cast the bonus spells endfunction
function MA_DamageOrder takesnothingreturnsstring return"innerfire" //The order to cast the damage bonus spell endfunction
function MA_SpeedOrder takesnothingreturnsstring return"bloodlust" //The order to cast the speed bonus spell endfunction
function MA_ChargesPerLevel takesinteger level returnsinteger return5+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 takesnothingreturnsboolean localunit u=GetTriggerUnit()
ifGetLearnedSkill()== MA_HeroAbility()andGetLearnedSkillLevel()==1then callUnitAddAbility(u,MA_DMGBonusAbilityInfo()) callUnitAddAbility(u,MA_SPDBonusAbilityInfo()) set udg_MA_CustomValue=udg_MA_CustomValue+1
@callSetUnitUserData(u,udg_MA_CustomValue)@ // You shouldn't be doing this >:| endif
set u=null returnfalse endfunction
function MA2_Actions takesnothingreturnsboolean localunit a=udg_DamageEventSource localunit t=udg_DamageEventTarget localtexttag tt localinteger i localinteger level localstring st
if udg_DamageTypeDOT >0andIsUnitEnemy(a,GetOwningPlayer(t))andGetUnitAbilityLevel(a,MA_HeroAbility())>0andnotIsUnitType(t,UNIT_TYPE_DEAD)andnotIsUnitType(t,UNIT_TYPE_STRUCTURE)andnotIsUnitType(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
ifGetLocalPlayer()==GetOwningPlayer(a)then set st=I2S(udg_MA_MagicCount[i]) endif
function MA3_Actions takesnothingreturnsboolean localunit c=GetTriggerUnit() localunit d localinteger i localinteger ud=GetUnitUserData(c)
ifGetSpellAbilityId()== MA_DMGBonusAbilityInfo()and udg_MA_MagicCount[ud]>0then set i=udg_MA_MagicCount[ud] set d=CreateUnit(GetOwningPlayer(c),MA_Dummy(),GetUnitX(c),GetUnitY(c),0) callUnitAddAbility(d,MA_DamageAbility()) callSetUnitAbilityLevel(d,MA_DamageAbility(),i) callIssueTargetOrder(d,MA_DamageOrder(),c) callUnitApplyTimedLife(d,'BTLF',0.5) set udg_MA_MagicCount[ud]=0 elseifGetSpellAbilityId()== MA_SPDBonusAbilityInfo()and udg_MA_MagicCount[ud]>0then set i=udg_MA_MagicCount[ud] set d=CreateUnit(GetOwningPlayer(c),MA_Dummy(),GetUnitX(c),GetUnitY(c),0) callUnitAddAbility(d,MA_SpeedAbility()) callSetUnitAbilityLevel(d,MA_SpeedAbility(),i) callIssueTargetOrder(d,MA_SpeedOrder(),c) callUnitApplyTimedLife(d,'BTLF',0.5) set udg_MA_MagicCount[ud]=0 endif
set c=null set d=null returnfalse endfunction
function InitTrig_MA takesnothingreturnsnothing localtrigger t=CreateTrigger() localunit u=CreateUnit(Player(0),MA_Dummy(),0,0,0) callUnitAddAbility(u,MA_DMGBonusAbilityInfo()) callUnitAddAbility(u,MA_SPDBonusAbilityInfo()) callUnitAddAbility(u,MA_SpeedAbility()) callUnitAddAbility(u,MA_DamageAbility()) callUnitApplyTimedLife(u,'BTLF',0.5) set u=null callTriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_HERO_SKILL) callTriggerAddCondition(t,Condition(function MA1_Actions)) set t=CreateTrigger() callTriggerRegisterVariableEvent(t,"udg_DamageEvent",EQUAL,1.00) callTriggerAddCondition(t,Condition(function MA2_Actions)) set t=CreateTrigger() callTriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT) callTriggerAddCondition(t,Condition(function MA3_Actions)) set t=null endfunction
Also, here's a tip:
Your MA3_Actions function could be optimized and cleaned to look like this:
- Use GUI SpellEvent v2.1.0.0 by Magtheridon, its for GUI and jass...
- You need to reset the MagicCount if it's getting debuffed, not only when it's used...
- Put the "set t = null" in the set tt = CreateTextTag() line...
EDIT:
Quote:
the people use IndexUnit (bad choise by the way) and this can result in a bug
UnitIndexer is faster than hashtables, but if you're talking about people making manual indexing of a unit then my bad :)...