- Joined
- Feb 11, 2011
- Messages
- 1,860
Hello guys,
I am trying to write a script for the first boss (Lich) in my map. Here it is:
Do you have any tips for me on how to improve this? It seems to be working - just wandering how I can improve the script.
Thanks for reading!
P.S. I am still learning JASS/vJASS, so go easy on me!
I am trying to write a script for the first boss (Lich) in my map. Here it is:
JASS:
function Boss_Cast_Abilities_Conditions takes nothing returns boolean
return (IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), Player(11)) == true) and (UnitHasBuffBJ(GetFilterUnit(), 'B003') == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == true)
endfunction
function Boss_Cast_Abilities takes nothing returns nothing
local real life
local unit u
local unit targ
local unit boss = udg_Boss_Unit
local real x = GetUnitX(boss)
local real y = GetUnitY(boss)
local real x2
local real y2
//Picking hero with the lowest hit points:
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, 800, Condition(function Boss_Cast_Abilities_Conditions))
set life = GetUnitState(GroupPickRandomUnit(bj_lastCreatedGroup), UNIT_STATE_LIFE)
loop
set u = FirstOfGroup(bj_lastCreatedGroup)
exitwhen u == null
if (GetUnitState(u, UNIT_STATE_LIFE) < life) then
set life = GetUnitState(u, UNIT_STATE_LIFE)
set targ = u
endif
call GroupRemoveUnit(bj_lastCreatedGroup, u)
endloop
if (targ == null) then
return
endif
//Casting orders - level 5 (Lich):
if (GetUnitTypeId(boss) == 'U007') then //Checks whether the boss is the level 5 boss.
//Breath of Frost:
set x = GetUnitX(targ)
set y = GetUnitY(targ)
call IssuePointOrder(boss, "breathoffrost", x2, y2)
//Frost Pulse (heal):
if (GetUnitLifePercent(boss) < 75) then
call IssueTargetOrder(boss, "holybolt", boss)
endif
endif
set u = null
set targ = null
set boss = null
endfunction
function InitTrig_Boss_Cast_Abilities takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEventPeriodic(t, 0.03)
call TriggerAddAction(t, function Boss_Cast_Abilities)
set t = null
endfunction
ExplanationBasically, it checks periodically how many heroes are within 800 range of the boss that don't have an invisibility buff. The system then picks the hero with the least life (not lowest percentage). It then orders the boss to cast "Breath of Frost" on this hero. Then, when the boss is below 75% health, he casts heal on himself.
Thanks for reading!
P.S. I am still learning JASS/vJASS, so go easy on me!