- Reaction score
- 889
JASS - Yes - vJASS Required
MUI - Yes
Works - Yes
Leaks - I find your lack of leaklessness disturbing.
Ice Wall
This spell summons a wall of ice behind the caster, blocking advancing enemy units.
Code:
I created this spell on a request, so now I'm submitting it for review.
Enjoy!
MUI - Yes
Works - Yes
Leaks - I find your lack of leaklessness disturbing.
Ice Wall
This spell summons a wall of ice behind the caster, blocking advancing enemy units.
Code:
JASS:
//**************************ICE WALL by GHAN_04***********************
//******************************DESCRIPTION*****************************
//**Creates a wall of ice behind the caster that blocks enemy advance.**
//**********************************************************************
//**********************************************************************
scope IceWall initializer Init
globals
private trigger t = CreateTrigger()
private integer ICE_WALL_CODE = 039;A000039; //The raw code of the Ice Wall ability.
private integer ICE_WALL_SECTION_CODE = 039;h000039; //The raw code of the Ice Wall unit.
private integer ICE_WALL_DURATION = 15 //The duration of the ice wall.
private integer ICE_WALL_DURATION_FACTOR = 5 //The amount that the duration increases each level.
private real ICE_WALL_DISTANCE = 500 //The initial distance back from the caster that the wall appears.
private real ICE_WALL_DISTANCE_FACTOR = 25 //The amount that the distance decreases with each level.
private real ICE_WALL_WIDTH = 600 //The distance sideways that the wall will expand.
private real ICE_WALL_WIDTH_FACTOR = 25 //The amount that the width increases with each level.
private real ICE_WALL_SIZE = 80 //This is the distance between each wall section. CHANGE WITH CAUTION
private real PLAYABLE_MAX_X
private real PLAYABLE_MIN_X
private real PLAYABLE_MAX_Y
private real PLAYABLE_MIN_Y
endglobals
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == ICE_WALL_CODE
endfunction
private function checkPoint takes real X1, real Y1, real X2, real Y2 returns boolean
local real height1 = GetLocationZ(Location(X1, Y1))
local real height2 = GetLocationZ(Location(X2, Y2))
local real offset = height1 - height2
if (offset < 0) then
set offset = -offset
endif
return (PLAYABLE_MIN_X <= X2) and (X2 <= PLAYABLE_MAX_X) and (PLAYABLE_MIN_Y <= Y2) and (Y2 <= PLAYABLE_MAX_Y) and offset < 10
endfunction
private function Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local real abilitylevel = GetUnitAbilityLevel(caster, ICE_WALL_CODE)
local real X = GetUnitX(caster)
local real Y = GetUnitY(caster)
local real facing = GetUnitFacing(caster)
local real left = facing - 90
local real right = facing + 90
local real wallstartX = X + (ICE_WALL_DISTANCE - ICE_WALL_DISTANCE_FACTOR * GetUnitAbilityLevel(caster, ICE_WALL_CODE)) * Cos((facing + 180) * bj_DEGTORAD)
local real wallstartY = Y + (ICE_WALL_DISTANCE - ICE_WALL_DISTANCE_FACTOR * abilitylevel) * Sin((facing + 180) * bj_DEGTORAD)
local unit start = CreateUnit(Player(15), ICE_WALL_SECTION_CODE, wallstartX, wallstartY, 0.00)
local real count = 0
local real currentwallX
local real currentwallY
local real oldX = wallstartX
local real oldY = wallstartY
call UnitApplyTimedLife(start, 039;BTLF039;, ICE_WALL_DURATION + ICE_WALL_DURATION_FACTOR * abilitylevel)
loop
exitwhen count >= (ICE_WALL_WIDTH + ICE_WALL_WIDTH_FACTOR * abilitylevel)/2
set count = count + ICE_WALL_SIZE
if(not checkPoint(oldX, oldY, wallstartX + count * Cos((left) * bj_DEGTORAD), wallstartY + count * Sin((left) * bj_DEGTORAD))) then
exitwhen true
endif
set currentwallX = wallstartX + count * Cos(left * bj_DEGTORAD)
set currentwallY = wallstartY + count * Sin(left * bj_DEGTORAD)
set oldX = currentwallX
set oldY = currentwallY
call UnitApplyTimedLife(CreateUnit(Player(15), ICE_WALL_SECTION_CODE, currentwallX, currentwallY, 0.00), 039;BTLF039;, ICE_WALL_DURATION + ICE_WALL_DURATION_FACTOR * abilitylevel)
endloop
set count = 0
loop
exitwhen count >= (ICE_WALL_WIDTH + ICE_WALL_WIDTH_FACTOR * abilitylevel)/2
set count = count + ICE_WALL_SIZE
if(not checkPoint(oldX, oldY, wallstartX + count * Cos(right * bj_DEGTORAD), wallstartY + count * Sin((right) * bj_DEGTORAD))) then
exitwhen true
endif
set currentwallX = wallstartX + count * Cos(right * bj_DEGTORAD)
set currentwallY = wallstartY + count * Sin(right * bj_DEGTORAD)
set oldX = currentwallX
set oldY = currentwallY
call UnitApplyTimedLife(CreateUnit(Player(15), ICE_WALL_SECTION_CODE, currentwallX, currentwallY, 0.00), 039;BTLF039;, ICE_WALL_DURATION + ICE_WALL_DURATION_FACTOR * abilitylevel)
endloop
set caster = null
set start = null
endfunction
private function Init takes nothing returns nothing
local integer index = 0
set PLAYABLE_MAX_X = GetRectMaxX(bj_mapInitialPlayableArea)
set PLAYABLE_MIN_X = GetRectMinX(bj_mapInitialPlayableArea)
set PLAYABLE_MAX_Y = GetRectMaxY(bj_mapInitialPlayableArea)
set PLAYABLE_MIN_Y = GetRectMinY(bj_mapInitialPlayableArea)
loop
call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(t, Condition(function Conditions))
call TriggerAddAction(t, function Actions)
endfunction
endscope
I created this spell on a request, so now I'm submitting it for review.
Enjoy!