- Joined
- Oct 17, 2017
- Messages
- 9
Hi guys, I'm messing around with a combo system to learn JASS. Yeah, I know, I'm late to the party haha.
So, I currently have a script that makes a combo with Q and W skills. More skills will be added as finishers and things like that but basically when you use Q or W, you get the next skills in the combo chain.
I wish the combos to be level based or even learn-able in a research building but I'm wondering what the most efficient way is to do this. I've programmed a bit in C++ and C# and it feels like I would be tempted to think I could make a class with my hero and fill in the variables for skills as needed and if they are empty, well, there's no skills added so the hero can't do the combo he doesn't have access to. Is there such a thing in JASS? Should I make global variables for every hero? There would technically be around 25 skills or so involved in every character's combos so that would make hundreds of variables. Any thoughts? Here is my code in case.
Please more that I am learning, any tips would be greatly appreciated wetter it has to do with the question or not. There might be some way to make this code half the length that I don't know.
EDIT: Extra question that I've been wondering too. Is there a way to detect if an ability is within a certain range of id? "Is ability ID between A020 and A024", if so then...
I mean, they are considered Ingegers
So, I currently have a script that makes a combo with Q and W skills. More skills will be added as finishers and things like that but basically when you use Q or W, you get the next skills in the combo chain.
I wish the combos to be level based or even learn-able in a research building but I'm wondering what the most efficient way is to do this. I've programmed a bit in C++ and C# and it feels like I would be tempted to think I could make a class with my hero and fill in the variables for skills as needed and if they are empty, well, there's no skills added so the hero can't do the combo he doesn't have access to. Is there such a thing in JASS? Should I make global variables for every hero? There would technically be around 25 skills or so involved in every character's combos so that would make hundreds of variables. Any thoughts? Here is my code in case.
Please more that I am learning, any tips would be greatly appreciated wetter it has to do with the question or not. There might be some way to make this code half the length that I don't know.
EDIT: Extra question that I've been wondering too. Is there a way to detect if an ability is within a certain range of id? "Is ability ID between A020 and A024", if so then...
I mean, they are considered Ingegers
JASS:
scope SWSlashScope initializer Trig_SWSlash
globals
private group grp
private player tempOwner
private unit un
private timer t1=CreateTimer()
private timer t2=CreateTimer()
private integer skill_temp1
private integer skill_temp2
private integer ANIM
private integer SLASH
private integer DSLASH
private integer abilDamage
private real angBetween
private real tempFacing
private real ENUMRANGE
private real SECTORSIZE
private real speed
private constant integer SLASH1='A021'
private constant integer SLASH2='A022'
private constant integer SLASH3='A023'
private constant integer SLASH4='A024'
private constant integer DSLASH1='A025'
private constant integer DSLASH2='A026'
private constant integer DSLASH3='A027'
private constant integer DSLASH4='A028'
private constant integer ANIMATION1=4
private constant integer ANIMATION2=5
private constant real speed1=1.0
private constant real speed2=1.5
private constant real ENUMRANGE1=200
private constant real ENUMRANGE2=250
private constant real SECTORSIZE1=0.5
private constant real SECTORSIZE2=0.9
endglobals
//===========================================================================
private function handler takes nothing returns nothing
call UnitRemoveAbility(un, SLASH)
call UnitRemoveAbility(un, DSLASH)
call UnitAddAbility(un, skill_temp1)
call UnitAddAbility(un, skill_temp2)
call BJDebugMsg("Timer!")
set tempOwner = null
set un = null
endfunction
private function f takes nothing returns boolean
local unit filt = GetFilterUnit()
local real theta
set angBetween=Atan2(GetUnitY(filt)-GetUnitY(un),GetUnitX(filt)-GetUnitX(un))
set theta = Cos(tempFacing-angBetween)
if IsUnitEnemy(filt,tempOwner) and theta>SECTORSIZE then
call UnitDamageTarget(un, filt, abilDamage, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
endif
set filt = null
return false
endfunction
private function handler2 takes nothing returns nothing
call SetUnitAnimationByIndex( un, ANIM)
call BJDebugMsg("Timer2!")
call GroupEnumUnitsInRange(grp,GetUnitX(un),GetUnitY(un),ENUMRANGE,Filter(function f))
call DestroyGroup(grp)
endfunction
private function p takes nothing returns nothing
call BJDebugMsg(I2S(abilDamage))
set tempOwner=GetOwningPlayer(un)
set tempFacing=GetUnitFacing(un)*bj_DEGTORAD
set grp = CreateGroup()
call TimerStart(t2,0.0,false,function handler2)
call TimerStart(t1,speed,false,function handler)
endfunction
//===========================================================================
function SWSlash_Condition takes nothing returns boolean
if GetSpellAbilityId()==SLASH1 then
set un = GetTriggerUnit()
set abilDamage = GetHeroStr(un, true) * 10
set ENUMRANGE=ENUMRANGE1
set SECTORSIZE=SECTORSIZE1
set SLASH = SLASH1
set DSLASH = DSLASH1
set ANIM = ANIMATION1
set skill_temp1=SLASH2
set skill_temp2=DSLASH2
set speed= speed1
call p()
call UnitRemoveAbility(un, DSLASH)
endif
if GetSpellAbilityId()==SLASH2 then
set un = GetTriggerUnit()
set abilDamage = GetHeroStr(un, true) * 11
set ENUMRANGE=ENUMRANGE1
set SECTORSIZE=SECTORSIZE1
set SLASH = SLASH2
set DSLASH = DSLASH2
set ANIM = ANIMATION1
set skill_temp1=SLASH3
set skill_temp2=DSLASH3
set speed= speed1
call p()
call UnitRemoveAbility(un, DSLASH)
endif
if GetSpellAbilityId()==SLASH3 then
set un = GetTriggerUnit()
set abilDamage = GetHeroStr(un, true) * 12
set ENUMRANGE=ENUMRANGE1
set SECTORSIZE=SECTORSIZE1
set SLASH = SLASH3
set DSLASH = DSLASH3
set ANIM = ANIMATION1
set skill_temp1=SLASH4
set skill_temp2=DSLASH4
set speed= speed1
call p()
call UnitRemoveAbility(un, DSLASH)
endif
if GetSpellAbilityId()==SLASH4 then
set un = GetTriggerUnit()
set abilDamage = GetHeroStr(un, true) * 15
set ENUMRANGE=ENUMRANGE1
set SECTORSIZE=SECTORSIZE1
set SLASH = SLASH4
set DSLASH = DSLASH4
set ANIM = ANIMATION1
set skill_temp1=SLASH1
set skill_temp2=DSLASH1
set speed= speed1
call p()
call UnitRemoveAbility(un, DSLASH)
endif
if GetSpellAbilityId()==DSLASH1 then
set un = GetTriggerUnit()
set abilDamage = GetHeroStr(un, true) * 15
set ENUMRANGE=ENUMRANGE2
set SECTORSIZE=SECTORSIZE2
set SLASH = SLASH1
set DSLASH = DSLASH1
set ANIM = ANIMATION2
set skill_temp1=SLASH2
set skill_temp2=DSLASH2
set speed= speed2
call p()
call UnitRemoveAbility(un, SLASH)
endif
if GetSpellAbilityId()==DSLASH2 then
set un = GetTriggerUnit()
set abilDamage = GetHeroStr(un, true) * 17
set ENUMRANGE=ENUMRANGE2
set SECTORSIZE=SECTORSIZE2
set SLASH = SLASH2
set DSLASH = DSLASH2
set ANIM = ANIMATION2
set skill_temp1=SLASH3
set skill_temp2=DSLASH3
set speed= speed2
call p()
call UnitRemoveAbility(un, SLASH)
endif
if GetSpellAbilityId()==DSLASH3 then
set un = GetTriggerUnit()
set abilDamage = GetHeroStr(un, true) * 19
set ENUMRANGE=ENUMRANGE2
set SECTORSIZE=SECTORSIZE2
set SLASH = SLASH3
set DSLASH = DSLASH3
set ANIM = ANIMATION2
set skill_temp1=SLASH4
set skill_temp2=DSLASH4
set speed= speed2
call p()
call UnitRemoveAbility(un, SLASH)
endif
if GetSpellAbilityId()==DSLASH4 then
set un = GetTriggerUnit()
set abilDamage = GetHeroStr(un, true) * 25
set ENUMRANGE=ENUMRANGE2
set SECTORSIZE=SECTORSIZE2
set SLASH = SLASH4
set DSLASH = DSLASH4
set ANIM = ANIMATION2
set skill_temp1=SLASH1
set skill_temp2=DSLASH1
set speed= speed2
call p()
call UnitRemoveAbility(un, SLASH)
endif
return false
endfunction
//===========================================================================
function Trig_SWSlash takes nothing returns nothing
set gg_trg_SWSlash = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(gg_trg_SWSlash, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition( gg_trg_SWSlash, function SWSlash_Condition )
endfunction
endscope
Last edited by a moderator: