- Joined
- Feb 4, 2009
- Messages
- 1,313
I'm pratising a little JASS since GUI leaks too much imho
however I'm sure that my script is not perfect yet so I'd like someone to check it for mistakes/point of improvements
NOTE:
-no vJass
-I know it's not the smartest way to time stuff using neg reg or waits but it should work properly anyway
however I'm sure that my script is not perfect yet so I'd like someone to check it for mistakes/point of improvements
NOTE:
-no vJass
-I know it's not the smartest way to time stuff using neg reg or waits but it should work properly anyway
JASS:
function ResetTerrainTimed takes real x, real y, real dur returns nothing
local real size = 448
local real step = 32
local real r = -size
local real r2 = 0
set udg_r = dur-0.8//some delay to make things work (probably it will work smooth with less but this is tested and turned out save)
loop
exitwhen r == size
set r2 = -size
loop
exitwhen r2 == size
set udg_x = x + r
set udg_y = y + r2
set udg_i = GetTerrainType(udg_x, udg_y)
if udg_i != 'Idki' then
call TriggerExecute( gg_trg_Glazed_Frost_Reset_Terrain )
endif
set r2 = r2 + step
endloop
set r = r + step
endloop
call SetTerrainType(x, y, 'Idki', 1, 4, 0 )
endfunction
function HideItem takes nothing returns nothing
call SetItemVisible(GetFilterItem(), false)
endfunction
function ShowItem takes nothing returns nothing
call SetItemVisible(GetFilterItem(), true)
endfunction
function Pathable takes real x, real y returns boolean
local boolean b = false
call MoveRectTo(udg_PathCheckRegion, x, y)
call EnumItemsInRect(udg_PathCheckRegion, null, function HideItem)
call SetItemPosition(udg_pathitem, x, y)
call SetItemPosition(udg_pathitem2, x, y)
if GetWidgetX(udg_pathitem)==x and GetWidgetY(udg_pathitem)==y and GetWidgetX(udg_pathitem2)!=x and GetWidgetY(udg_pathitem2)!=y then
set b = true
else
set b = false
endif
call EnumItemsInRect(udg_PathCheckRegion, null, function ShowItem)
call SetItemVisible(udg_pathitem, false)
call SetItemVisible(udg_pathitem2, false)
return b
endfunction
-
Events
- Map initialization
- Conditions
-
Actions
- Set PathCheckRegion = (Region centered at (Point(0.00, 0.00)) with size (128.00, 128.00))
- Item - Create Cheese at (Center of (Playable map area))
- Set pathitem = (Last created item)
- Item - Create Cheese at (Center of (Playable map area))
- Set pathitem2 = (Last created item)
- -------- Just some dummys to test things --------
-
For each (Integer A) from 1 to 100, do (Actions)
-
Loop - Actions
- Unit - Create 1 Peon for Player 1 (Red) at (Random point in (Playable map area)) facing (Random angle) degrees
-
Loop - Actions
JASS:
function Trig_Glazed_Frost_Cast_Actions takes nothing returns nothing
local real x = GetSpellTargetX()
local real y = GetSpellTargetY()
local unit u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'e000', x, y, 0)
set udg_r = GetUnitAbilityLevel(GetTriggerUnit(), GetSpellAbilityId()) * 5
call SetWidgetLife(u, udg_r)
call ShowUnit(u, false)
call GroupAddUnit(udg_GlazedFrost_Dummys, u)
call ResetTerrainTimed(x, y, udg_r)
set u = null
endfunction
//===========================================================================
function InitTrig_Glazed_Frost_Cast takes nothing returns nothing
set gg_trg_Glazed_Frost_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Glazed_Frost_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( gg_trg_Glazed_Frost_Cast, function Trig_Glazed_Frost_Cast_Actions )
endfunction
JASS:
function GlazedFrost_Filter takes nothing returns boolean
return not (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) or IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING) or GetWidgetLife(GetFilterUnit())<0.405)
endfunction
function GlazedFrost_MoveSliders takes nothing returns nothing
local real r = 17
local real size = 450
local real x = GetUnitX(GetEnumUnit())
local real y = GetUnitY(GetEnumUnit())
local real x2 = 0
local real y2 = 0
local real a = 0
local rect re = Rect(x-size, y-size, x+size, y+size)
local unit u = null
local group g = CreateGroup()
if GetWidgetLife(GetEnumUnit()) > 0.405 then
call GroupEnumUnitsInRect(g, re, Condition(function GlazedFrost_Filter))
loop
set u = FirstOfGroup(g)
exitwhen u == null
set x2 = GetUnitX(u)
set y2 = GetUnitY(u)
if size*size > (x-x2)*(x-x2)+(y-y2)*(y-y2) then
set a = GetUnitFacing(u)*bj_DEGTORAD
set x2 = x2+Cos(a)*r
set y2 = y2+Sin(a)*r
if Pathable(x2, y2) then
call SetUnitX(u, x2)
call SetUnitY(u, y2)
endif
endif
call GroupRemoveUnit(g,u)
endloop
else
call GroupRemoveUnit(udg_GlazedFrost_Dummys,GetEnumUnit())
call RemoveUnit(GetEnumUnit())
set udg_b = true
endif
call DestroyGroup(g)
call RemoveRect(re)
set re = null
set g = null
endfunction
function GlazedFrost_Freeze takes nothing returns nothing
call ResetTerrainTimed(GetUnitX(GetEnumUnit()), GetUnitY(GetEnumUnit()), GetWidgetLife(GetEnumUnit()))
endfunction
function Trig_Glazed_Frost_Loop_Actions takes nothing returns nothing
set udg_b = false
call ForGroup(udg_GlazedFrost_Dummys, function GlazedFrost_MoveSliders)
//replace ice tiles to fill gapes created by overlapping casts
if udg_b and FirstOfGroup(udg_GlazedFrost_Dummys) != null then
call ForGroup(udg_GlazedFrost_Dummys, function GlazedFrost_Freeze)
endif
endfunction
//===========================================================================
function InitTrig_Glazed_Frost_Loop takes nothing returns nothing
set gg_trg_Glazed_Frost_Loop = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Glazed_Frost_Loop, 0.03 )
call TriggerAddAction( gg_trg_Glazed_Frost_Loop, function Trig_Glazed_Frost_Loop_Actions )
endfunction
- Events
- Conditions
-
Actions
- Custom script: local real x = udg_x
- Custom script: local real y = udg_y
- Custom script: local integer i = udg_i
- Wait r game-time seconds
- Custom script: call SetTerrainType(x, y, i, -1, 1, 0 )