//TESH.scrollpos=84
//TESH.alwaysfold=0
function wall_condition takes nothing returns boolean
return GetUnitUserData(GetFilterUnit()) != GetUnitUserData(GetTriggerUnit()) and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == true
endfunction
function wall_condition2 takes nothing returns boolean
return IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == true
endfunction
function recting_unit takes unit u returns group
local real ux = GetUnitX(u)
local real uy = GetUnitY(u)
local location loc1
local location loc2
local group gr = CreateGroup()
local real radius = 0
if GetUnitTypeId(u) == 'h002' or GetUnitTypeId(u) == 'h003' then
set radius = 128
else
set radius = 160
endif
set loc1 = Location(ux+radius, uy+radius)
set loc2 = Location(ux-radius, uy-radius)
call GroupAddGroup( GetUnitsInRectMatching(RectFromLoc(loc1, loc2), function wall_condition), gr )
call RemoveLocation(loc1)
call RemoveLocation(loc2)
set loc1 = null
set loc2 = null
set u = null
return gr
endfunction
function dest_condition1 takes nothing returns boolean
return GetDestructableTypeId(GetFilterDestructable()) == 'B000'
endfunction
function dest_condition2 takes nothing returns boolean
return GetDestructableTypeId(GetFilterDestructable()) == 'B003'
endfunction
function recting_dest takes unit u returns integer
local real ux = GetUnitX(u)
local real uy = GetUnitY(u)
local location loc1
local location loc2
local destructable dest1
local destructable dest2
local integer bL = 0
local integer bR = 0
local real radius = 0
if GetUnitTypeId(u) == 'h002' or GetUnitTypeId(u) == 'h003' then
set radius = 128
else
set radius = 160
endif
set loc1 = Location(ux+radius, uy+radius)
set loc2 = Location(ux-radius, uy-radius)
set dest1 = RandomDestructableInRectBJ(RectFromLoc(loc1, loc2),function dest_condition1)
set dest2 = RandomDestructableInRectBJ(RectFromLoc(loc1, loc2),function dest_condition2)
if dest1 != null then
set bL = 1
endif
if dest2 != null then
set bR = 2
endif
if bL + bR == 3 then
call RemoveUnit(u)
endif
call RemoveLocation(loc1)
call RemoveLocation(loc2)
set loc1 = null
set loc2 = null
set dest1 = null
set dest2 = null
return bL + bR
endfunction
function yd2 takes integer i returns nothing
local texttag t1
local texttag t2
local texttag t3
local location array loc
local unit u
set loc[0] = GetUnitLoc(gg_unit_owtw_0045)
set loc[1] = OffsetLocation(loc[0], -300.00, 600.00)
set loc[2] = OffsetLocation(loc[0], -300.00, 400.00)
set loc[3] = OffsetLocation(loc[0], -300.00, 200.00)
set t1 = CreateTextTagLocBJ( ( "|cff75b4f5Maze Type|r : " + udg_modetext ),loc[1], 0, 10, 100, 100, 100, 0 )
set udg_text[1] = GetLastCreatedTextTag()
set t2 = CreateTextTagLocBJ( ( "|cff75ccf5Round|r : " + I2S(udg_Round) ),loc[2], 0, 10, 100, 100, 100, 0)
set udg_text[2] = GetLastCreatedTextTag()
set t3 = CreateTextTagLocBJ( ( "|cff75ddf5Time Limit|r : " + ( I2S(R2I(udg_time)) + " second" ) ),loc[3], 0, 10, 100, 100, 100, 0 )
set udg_text[3] = GetLastCreatedTextTag()
if i != 0 then
set u = CreateUnitAtLoc(Player(11),'hfoo',loc[i],0)
call SetUnitAnimation(u,"birth")
endif
call RemoveLocation(loc[1])
set loc[1] = null
call RemoveLocation(loc[2])
set loc[2] = null
call RemoveLocation(loc[3])
set loc[3] = null
call RemoveLocation(loc[0])
set loc[0] = null
set u = null
set t1 = null
set t2 = null
set t3 = null
endfunction
Name | Type | is_array | initial_value |
Alive | integer | No | 1 |
bool_Random | boolean | No | |
cam_distance | real | Yes | 2500.00 |
col | integer | No | |
default_group | group | No | |
del_group | group | No | |
ent | integer | No | |
exit | integer | No | |
Field | rect | Yes | |
gen | unit | No | |
gold | integer | No | |
group_inRoundTech | group | No | |
iceG | player | No | |
loc_end | location | Yes | |
loc_start | location | Yes | |
LR | integer | Yes | |
maze_x | integer | No | 11 |
maze_y | integer | No | 11 |
Mode | integer | No | |
modetext | string | No | |
mul | multiboard | No | |
name | string | Yes | |
no1 | real | No | |
no1player | integer | No | |
nR | integer | No | |
point | integer | Yes | |
r | real | No | |
rank | integer | No | |
red | unit | No | |
Round | integer | No | |
runnerGroup | group | No | |
runTimer | timer | No | |
scoreTime | real | Yes | |
soundTimer | timer | No | |
starter | destructable | Yes | |
TARGET | unit | No | |
tech_inRound | unit | Yes | |
temp_round | integer | No | 1 |
test_i | integer | No | |
text | texttag | Yes | |
time | real | No | |
Timer | timer | No | |
tt | texttag | Yes | |
wallcount | integer | No | |
wood | integer | No | |
worker | unit | Yes |
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_remote_destroy_wall_Func001Func001Func001001003 takes nothing returns boolean
return GetOwningPlayer(GetFilterUnit()) == GetTriggerPlayer() and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == true
endfunction
function Trig_remote_destroy_wall_Func001Func001Func001A takes nothing returns nothing
call IssueImmediateOrder( GetEnumUnit(), "channel" )
endfunction
function Trig_remote_destroy_wall_Actions takes nothing returns nothing
local location loc = GetSpellTargetLoc()
if GetSpellAbilityId() == 'A005' and GetTriggerPlayer() == GetOwningPlayer(GetSpellTargetUnit()) then
call IssueImmediateOrder( GetSpellTargetUnit(), "channel" )
endif
if GetSpellAbilityId() == 'A009' then
call ForGroupBJ( GetUnitsInRangeOfLocMatching(230.00, loc, Condition(function Trig_remote_destroy_wall_Func001Func001Func001001003)), function Trig_remote_destroy_wall_Func001Func001Func001A )
endif
call RemoveLocation(loc)
set loc = null
endfunction
//===========================================================================
function InitTrig_remote_destroy_wall takes nothing returns nothing
set gg_trg_remote_destroy_wall = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_remote_destroy_wall, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( gg_trg_remote_destroy_wall, function Trig_remote_destroy_wall_Actions )
endfunction
//TESH.scrollpos=225
//TESH.alwaysfold=0
struct stack
integer array data[100]
integer index
static method create takes integer MAX returns thistype
local thistype this = thistype.allocate()
local integer i = 0
loop
exitwhen i >= MAX
set .data[i] = i
set i = i + 1
endloop
set .index = MAX - 1
return this
endmethod
method pop takes nothing returns integer
local integer temp = .data[.index]
set .index = .index - 1
if .index < 0 then
call BJDebugMsg( "error : overflow" )
return 0
else
return temp
endif
endmethod
method push takes integer data1 returns nothing
set .index = .index + 1
set .data[.index] = data1
endmethod
endstruct
globals
stack groupNumStack
stack thunderIndexStack
group array thunderGroup[80]
integer thunderMax = 80
endglobals
function thunderClear takes nothing returns nothing
local integer i = 0
loop
exitwhen i == thunderMax
set groupNumStack.data[i] = i
call GroupClear( thunderGroup[i] )
endloop
set groupNumStack.index = thunderMax - 1
endfunction
function stackInit takes nothing returns nothing
local integer i = 0
loop
exitwhen i >= 80
set thunderGroup[i] = CreateGroup()
set i = i + 1
endloop
set groupNumStack = stack.create( 80 )
set thunderIndexStack = stack.create( 80 )
endfunction
function toggleOn takes nothing returns nothing
local tick t = tick.getExpired()
local thunder th = t.data
if th.enable then
set th.toggle = true
call UnitRemoveAbility( th.tower, 'A00P' )
endif
call t.destroy()
endfunction
globals
hashtable wallTypeHT = InitHashtable()
unit tempThunderWall
endglobals
function thunderCheck takes nothing returns nothing
local tick t = tick.getExpired()
local integer id = t.data
call THUNDER[id].check()
endfunction
function initWallTypeHT takes nothing returns nothing
call SaveInteger( wallTypeHT, 0, 'h000', 'h009' )
call SaveInteger( wallTypeHT, 0, 'h009', 'h000' )
call SaveInteger( wallTypeHT, 0, 'h001', 'h00B' )
call SaveInteger( wallTypeHT, 0, 'h00B', 'h001' )
call SaveInteger( wallTypeHT, 0, 'h002', 'h00A' )
call SaveInteger( wallTypeHT, 0, 'h00A', 'h002' )
call SaveInteger( wallTypeHT, 0, 'h003', 'h00C' )
call SaveInteger( wallTypeHT, 0, 'h00C', 'h003' )
endfunction
function toggleThunderModel takes unit u returns unit
local integer changeTyp
local integer tempUserData
set tempThunderWall = u
set u = null
set changeTyp = LoadInteger( wallTypeHT, 0, GetUnitTypeId( tempThunderWall ) )
set tempUserData = GetUnitUserData( tempThunderWall )
set tempThunderWall = ReplaceUnitBJ( tempThunderWall, changeTyp, bj_UNIT_STATE_METHOD_RELATIVE )
call SetUnitUserData( tempThunderWall, tempUserData )
return tempThunderWall
endfunction
struct thunder
unit tower
real x
real y
boolean toggle
boolean enable
integer groupNum
integer owner
tick checkTick
static method create takes nothing returns thistype
local thistype this = thistype.allocate()
set .checkTick = tick.create(this)
return this
endmethod
method Allocate takes unit u, integer tid returns nothing
set .tower = u
set .x = GetUnitX( u )
set .y = GetUnitY( u )
set .owner = GetPlayerId( GetOwningPlayer( .tower ) )
set .toggle = true
set .enable = true
set .groupNum = tid
set .checkTick.data = tid
call SetUnitState( .tower, UNIT_STATE_MANA, tid )
call toggleThunderModel(.tower)
set .tower = tempThunderWall
call AddSpecialEffectTargetTimed( "war3mapImported\\BoltImpact.mdx", .tower, "head", 1 )
set tempThunderWall = null
call PingMinimap( GetUnitX(.tower), GetUnitY(.tower), 3)
set u = null
endmethod
method Deallocate takes nothing returns nothing
call groupNumStack.push( .groupNum )
call .checkTick.pause()
if not IsUnitDeadBJ(.tower) then
call toggleThunderModel(.tower)
set .tower = tempThunderWall
set tempThunderWall = null
endif
call SetPlayerState( Player(owner), PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState( Player(.owner), PLAYER_STATE_RESOURCE_LUMBER ) +1 )
call AddSpecialEffectTargetTimed( "Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl", .tower, "head", 1 )
set .x = 0
set .y = 0
set .toggle = false
set .enable = false
set .tower = null
set .owner = -1
call GroupClear( thunderGroup[groupNum] )
endmethod
method check takes nothing returns nothing
local location loc = Location( .x, .y )
local unit u
local tick t
if IsUnitDeadBJ(.tower) then
call this.Deallocate()
return
endif
call GroupClear( thunderGroup[.groupNum] )
call GroupEnumUnitsInRangeOfLoc( thunderGroup[.groupNum], loc, 256, null )
if .toggle then
loop
exitwhen CountUnitsInGroup( thunderGroup[.groupNum] ) == 0
set u = FirstOfGroup( thunderGroup[.groupNum] )
if GetUnitTypeId( u ) == 'hmpr' then
set .toggle = false
set t = tick.create( this )
call UnitAddAbility( .tower, 'A00P' )
call IssueImmediateOrder( .tower, "thunderclap" )
call t.start( 5, false, function toggleOn )
endif
call GroupRemoveUnit( thunderGroup[.groupNum], u )
endloop
endif
set u = null
call RemoveLocation( loc )
set loc = null
endmethod
endstruct
globals
thunder array THUNDER[80]
integer array thunderGroupNum
group array thunderGroup
trigger addThunder
trigger addThunderSelf
trigger removeThunder
trigger removeThunderSelf
endglobals
function thunderInit takes nothing returns nothing
local integer i = 0
loop
exitwhen i == 80
set THUNDER[i] = thunder.create()
set i = i + 1
endloop
endfunction
function thunderAllocate takes unit u returns nothing
local integer tid = groupNumStack.pop()
call THUNDER[tid].Allocate( u, tid )
call THUNDER[tid].checkTick.start( 0.05, true, function thunderCheck )
set u = null
endfunction
function thunderQualifying takes unit u, integer id returns boolean
if GetUnitAbilityLevel( u, 'A00I' ) > 0 then
call DisplayTimedTextToPlayer(Player(id),0,0,2,"The wall has already been upgraded!")
else
if GetPlayerState( Player(id), PLAYER_STATE_RESOURCE_LUMBER ) < 1 then
call DisplayTimedTextToPlayer(Player(id),0,0,2,"not enogugh Wood!")
else
if GetPlayerId( GetOwningPlayer( u ) ) != id then
call DisplayTimedTextToPlayer(Player(id),0,0,2,"Only your own wall can be upgraded!")
else
return true
endif
endif
endif
set u = null
return false
endfunction
function addThunder_Actions takes nothing returns nothing
local unit u = GetSpellTargetUnit()
local integer id = GetPlayerId( GetOwningPlayer( GetTriggerUnit() ) )
if thunderQualifying( u, id ) then
call SetPlayerState( Player(id), PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState( Player(id), PLAYER_STATE_RESOURCE_LUMBER ) -1 )
call thunderAllocate( u )
endif
set u = null
endfunction
function addThunderSelf_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer id = GetPlayerId(GetOwningPlayer(u))
if thunderQualifying( u, id ) then
call SetPlayerState( Player(id), PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState( Player(id), PLAYER_STATE_RESOURCE_LUMBER ) -1 )
call thunderAllocate( u )
endif
set u = null
endfunction
function removeThunder_Actions takes nothing returns nothing
local unit u = GetSpellTargetUnit()
local integer id = GetPlayerId( GetOwningPlayer( GetTriggerUnit() ) )
local integer tid = R2I(GetUnitState( u, UNIT_STATE_MANA ))
if GetOwningPlayer( u ) == Player( id ) then
if GetUnitAbilityLevel( u, 'A00I' ) > 0 then
call THUNDER[tid].Deallocate()
endif
endif
set u = null
endfunction
function removeThunderSelf_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer id = GetPlayerId(GetOwningPlayer(u))
local integer tid = R2I(GetUnitState( u, UNIT_STATE_MANA ))
if GetUnitAbilityLevel( u, 'A00I' ) > 0 then
call THUNDER[tid].Deallocate()
endif
set u = null
endfunction
function AddThunder_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00K'
endfunction
function AddThunderSelf_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00Z'
endfunction
function RemoveThunder_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00L'
endfunction
function RemoveThunderSelf_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A010'
endfunction
function InitTrig_sdf takes nothing returns nothing
set addThunder = CreateTrigger()
set addThunderSelf = CreateTrigger()
set removeThunder = CreateTrigger()
set removeThunderSelf = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( addThunder, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerRegisterAnyUnitEventBJ( addThunderSelf, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerRegisterAnyUnitEventBJ( removeThunder, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerRegisterAnyUnitEventBJ( removeThunderSelf, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( addThunder, Condition( function AddThunder_Conditions ) )
call TriggerAddCondition( addThunderSelf, Condition( function AddThunderSelf_Conditions ) )
call TriggerAddCondition( removeThunder, Condition( function RemoveThunder_Conditions ) )
call TriggerAddCondition( removeThunderSelf, Condition( function RemoveThunderSelf_Conditions ) )
call TriggerAddAction( addThunder, function addThunder_Actions )
call TriggerAddAction( addThunderSelf, function addThunderSelf_Actions )
call TriggerAddAction( removeThunder, function removeThunder_Actions )
call TriggerAddAction( removeThunderSelf, function removeThunderSelf_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_ChangeType_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00Q'
endfunction
function Trig_ChangeType_Func003C takes nothing returns boolean
return GetUnitAbilityLevelSwapped('A003', GetTriggerUnit()) == 1
endfunction
function Trig_ChangeType_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
if GetUnitAbilityLevelSwapped('A003', GetTriggerUnit()) == 1 then
call UnitRemoveAbility(u, 'A003')
call UnitAddAbility(u, 'A006')
else
call UnitRemoveAbility(u, 'A006' )
call UnitAddAbility(u, 'A003')
endif
set u = null
endfunction
//===========================================================================
function InitTrig_ChangeType takes nothing returns nothing
set gg_trg_ChangeType = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_ChangeType, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_ChangeType, Condition( function Trig_ChangeType_Conditions ) )
call TriggerAddAction( gg_trg_ChangeType, function Trig_ChangeType_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_LR_Actions takes nothing returns nothing
call BJDebugMsg("LR["+I2S(GetUnitUserData(GetTriggerUnit()))+"] = " + I2S(udg_LR[GetUnitUserData(GetTriggerUnit())]))
endfunction
//===========================================================================
function InitTrig_check_LR takes nothing returns nothing
set gg_trg_check_LR = CreateTrigger( )
call TriggerRegisterPlayerSelectionEventBJ( gg_trg_check_LR, Player(0), true )
call TriggerAddAction( gg_trg_check_LR, function Trig_LR_Actions )
endfunction
//TESH.scrollpos=204
//TESH.alwaysfold=0
globals
integer p_i = 1
integer Type = 1
real x
real y
integer w_i = 1
integer sequence = 0
integer ii = 1
endglobals
function red_thunder takes nothing returns nothing
local unit u = GroupPickRandomUnit(GetUnitsInRectAll(udg_Field[udg_Alive]))
local real x1 = GetUnitX(u) - GetLocationX(GetRectCenter(udg_Field[udg_Alive]))
local real y1 = GetUnitY(u) - GetLocationY(GetRectCenter(udg_Field[udg_Alive]))
local location loc
local integer i = 1
loop
exitwhen i > 8
if GetPlayerController(ConvertedPlayer(i)) == MAP_CONTROL_USER and GetPlayerSlotState(ConvertedPlayer(i)) == PLAYER_SLOT_STATE_PLAYING then
set loc = Location(GetLocationX(GetRectCenter(udg_Field[i]))+x1,GetLocationY(GetRectCenter(udg_Field[i]))+y1)
set u = GroupPickRandomUnit(GetUnitsInRectAll(RectFromCenterSizeBJ(loc, 128, 128)))
call thunderAllocate( u )
call RemoveLocation(loc)
set loc = null
set u = null
endif
set i = i + 1
endloop
endfunction
function red_wall_gen takes nothing returns nothing
local integer r = 0
local location loc
local unit u
local timer t = CreateTimer()
local integer intA = 1
if sequence == 0 then
set w_i = GetRandomInt(3,28)
set sequence = 1
endif
//!세팅부
if sequence == 1 then
set x = GetRandomReal(-576,576)
set y = GetRandomReal(-576,576)
if GetRandomInt(1,100)>20 then
set Type = 1
else
set Type = 2
endif
set sequence = 2
//!이 함수가 마지막으로 발동될때 실행할 액션들
if ii > w_i then
set sequence = 0
set ii = 0
loop
exitwhen intA >8
call ShowUnitShow( udg_worker[intA] )
call SelectUnitForPlayerSingle( udg_worker[intA], ConvertedPlayer(intA) )
set intA = intA + 1
endloop
if GetRandomInt(1,100) > 83 then
call TimerStart(t,0.3,false,function red_thunder)
endif
else
set ii = ii + 1
endif
endif
//!유닛생성부
if sequence == 2 then
if GetPlayerController(ConvertedPlayer(p_i)) == MAP_CONTROL_USER and GetPlayerSlotState(ConvertedPlayer(p_i)) == PLAYER_SLOT_STATE_PLAYING then
set loc = Location(GetLocationX(GetRectCenter(udg_Field[p_i]))+x,GetLocationY(GetRectCenter(udg_Field[p_i]))+y)
call UnitUseItemPointLoc( gg_unit_hhou_0000, UnitItemInSlotBJ(gg_unit_hhou_0000, Type), loc )
call RemoveLocation(loc)
set loc = null
endif
if p_i < 8 then
set p_i = p_i + 1
else
set sequence = 1
set p_i = 1
endif
endif
if sequence != 0 then
call TimerStart(t,0.0001,false,function red_wall_gen)
endif
set t = null
endfunction
function Trig_wall_build_Actions takes nothing returns nothing
local integer id = GetConvertedPlayerId(GetTriggerPlayer())
local unit u = GetTriggerUnit()
local group gr = CreateGroup()
local group checkgr = CreateGroup()
local unit checkunit
local integer checkint = 0
local integer bL = 0
local integer bR = 0
local real ux = GetUnitX(u)
local real uy = GetUnitY(u)
local real radius = 0
local location loc1
local location loc2
local destructable dest1
local destructable dest2
if RectContainsUnit(udg_Field[id], u) == true or GetConvertedPlayerId(GetTriggerPlayer()) == 12 then
if GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) > 0 then
//!작은벽이면 주변유닛그룹 잡는범위를 128로 해줌
if GetUnitTypeId(u) == 'h002' or GetUnitTypeId(u) == 'h003' then
set radius = 128
else
set radius = 160
endif
set loc1 = Location(ux+radius, uy+radius)
set loc2 = Location(ux-radius, uy-radius)
set dest1 = RandomDestructableInRectBJ(RectFromLoc(loc1, loc2),function dest_condition1)
set dest2 = RandomDestructableInRectBJ(RectFromLoc(loc1, loc2),function dest_condition2)
//!주변에 오른벽이 있다면 1을 추가
if GetDestructableTypeId(dest1) == 'B000' then
set bR = 1
endif
//!주변에 왼벽이 있다면 2를 추가
if GetDestructableTypeId(dest2) == 'B003' then
set bL = 2
endif
//!총합 3이라면 트작유를 제거
if bR+bL == 3 then
call RemoveUnit(u)
call DisplayTimedTextToPlayer(ConvertedPlayer(id),0,0,2,"It is impossible to build!")
else
//!총합이 3미만일때 이하액션이 실행
//!트작유와 밀접한 벽들을 유닛그룹에 넣는다. gr은 액션을 실행할 그룹이고 checkgr은 길막검사용그룹
call GroupAddGroup( GetUnitsInRectMatching(RectFromLoc(loc1, loc2), function wall_condition), gr )
call GroupAddGroup( GetUnitsInRectMatching(RectFromLoc(loc1, loc2), function wall_condition), checkgr )
if CountUnitsInGroup(gr) != 0 then
//!gr의 유닛수가 0 이 아니라면 주변에 벽이 있는것이므로 이하액션을 실행
//!checkgr의 모든유닛들의 LR값을 불러온다.
loop
exitwhen CountUnitsInGroup(checkgr) == 0
set checkunit = FirstOfGroup(checkgr)
set checkint = GetUnitUserData(checkunit)
call GroupRemoveUnit(checkgr, checkunit)
if udg_LR[checkint] == 1 then
set bR = 1
endif
if udg_LR[checkint] == 2 then
set bL = 2
endif
set checkunit = null
endloop
//!checkgr루프를 통해 bR+bL의 값이 3 이상이라면 주변에 밀접한 벽들과 자신이 합쳐질경우 길막이 된다는것을 의미하므로 트작유제거
if bR+bL >= 3 then
call RemoveUnit(u)
call DisplayTimedTextToPlayer(ConvertedPlayer(id),0,0,2,"It is impossible to build.")
else
call SetPlayerStateBJ( GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD, ( GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) - 1 ) )
//!주변의 모든벽들과 연결해도 좋다는 것이니 월카운트를 1 올려주고 트작유와 연결되어있는 모든벽들의 커스텀값을 월카운트로 바꾸는 액션실행
set udg_wallcount = udg_wallcount + 1
set udg_LR[udg_wallcount] = bR+bL
call SetUnitUserData(u,udg_wallcount)
call AddSpecialEffectTargetTimed( "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl", u, "origin", 0.1 )
loop
exitwhen CountUnitsInGroup(gr) == 0
set checkunit = FirstOfGroup(gr)
call GroupRemoveUnit( gr, checkunit )
call SetUnitUserData(checkunit,udg_wallcount)
if GetUnitTypeId(checkunit) == 'h002' or GetUnitTypeId(checkunit) == 'h003' then
set radius = 128
else
set radius = 160
endif
set ux = GetUnitX(checkunit)
set uy= GetUnitY(checkunit)
set loc1 = Location(ux+radius, uy+radius)
set loc2 = Location(ux-radius, uy-radius)
call GroupAddGroup( GetUnitsInRectMatching(RectFromLoc(loc1, loc2), function wall_condition), gr )
call RemoveLocation(loc1)
call RemoveLocation(loc2)
set loc1 = null
set loc2 = null
set checkunit = null
endloop
endif
//!주변에 연결될 벽이 하나도 없을때 실행된다.
else
call SetPlayerStateBJ( GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD, ( GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) - 1 ) )
set udg_wallcount = udg_wallcount + 1
call SetUnitUserData(u,udg_wallcount)
call AddSpecialEffectTargetTimed( "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl", u, "origin", 0.1 )
set udg_LR[udg_wallcount] = bR+bL
endif
endif
else
call RemoveUnit( GetConstructingStructure() )
call DisplayTimedTextToPlayer(ConvertedPlayer(id),0,0,2,"not enough |cfff5e451Gold|r!")
endif
else
call RemoveUnit( GetConstructingStructure() )
call DisplayTimedTextToPlayer(ConvertedPlayer(id),0,0,2,"It is impossible to build.")
endif
call RemoveLocation(loc1)
call RemoveLocation(loc2)
set loc1 = null
set loc2 = null
set u = null
endfunction
function InitTrig_wall_build takes nothing returns nothing
set gg_trg_wall_build = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_wall_build, EVENT_PLAYER_UNIT_CONSTRUCT_START )
call TriggerAddAction( gg_trg_wall_build, function Trig_wall_build_Actions )
endfunction
//TESH.scrollpos=84
//TESH.alwaysfold=0
function Trig_destroy_condition takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function destroy_wall_condition takes nothing returns boolean
return IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == true
endfunction
function Trig_destroy_wall_Actions takes nothing returns nothing
local integer id = GetConvertedPlayerId(GetTriggerPlayer())
local unit u = GetTriggerUnit()
local group gr1 = CreateGroup()
local group gr2 = CreateGroup()
local real ux = GetUnitX(u)
local real uy = GetUnitY(u)
local real radius = 0
local location loc1
local location loc2
local destructable dest1
local destructable dest2
local integer bL = 0
local integer bR = 0
local unit u2
call AddSpecialEffectTimed("Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl",GetUnitX(u),GetUnitY(u),0.3)
call SetPlayerStateBJ( GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD, ( GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) + 1 ) )
if GetUnitTypeId(u) == 'h002' or GetUnitTypeId(u) == 'h003' then
set radius = 128
else
set radius = 160
endif
set loc1 = Location(ux+radius, uy+radius)
set loc2 = Location(ux-radius, uy-radius)
set dest1 = RandomDestructableInRectBJ(RectFromLoc(loc1, loc2),function dest_condition1)
set dest2 = RandomDestructableInRectBJ(RectFromLoc(loc1, loc2),function dest_condition2)
//!트작유와 밀접한 벽들을 gr1에 넣는다.
call GroupAddGroup( GetUnitsInRectMatching(RectFromLoc(loc1, loc2), function wall_condition2), gr1 )
call GroupRemoveUnit(gr1,u)
//!gr1의 유닛이 전부 사라지면 곁가지 처리가 끝난것
loop
exitwhen CountUnitsInGroup(gr1) == 0
//!트작유와 붙어있는 벽중 하나를 잡은뒤 두번째 루프문을 위한 준비를한다.
set udg_wallcount = udg_wallcount + 1
set u2 = GroupPickRandomUnit(gr1)
call SetUnitUserData(u,udg_wallcount)
call SetUnitUserData(u2,udg_wallcount)
call GroupRemoveUnit(gr1,u2)
call GroupAddGroup(recting_unit(u2), gr2)
call GroupAddUnit(gr2,u2)
set u2 = null
//!GR1에 있는 유닛을 시작으로 연결된 모든 유닛을 찾는 루프문
loop
exitwhen CountUnitsInGroup(gr2) == 0
set u2 = GroupPickRandomUnit(gr2)
call SetUnitUserData(u2, udg_wallcount)
set udg_LR[GetUnitUserData(u2)] = recting_dest(u2)
call GroupRemoveUnit(gr2,u2)
if GetUnitTypeId(u2) == 'h002' or GetUnitTypeId(u2) == 'h003' then
set radius = 128
else
set radius = 160
endif
set ux = GetUnitX(u2)
set uy = GetUnitY(u2)
set loc1 = Location(ux+radius, uy+radius)
set loc2 = Location(ux-radius, uy-radius)
//!첫번쨰 루프문에서 트작유의 커스텀값이 계속해서 바뀐다. 트작유와 붙어잇던 서로 다른 곁가지마다 다른 커스텀값을 줘야하는데
//!function wall condition 트작유의 커스텀값을 기준으로 비교
call GroupAddGroup( GetUnitsInRectMatching(RectFromLoc(loc1, loc2), function wall_condition), gr2 )
set dest1 = RandomDestructableInRectBJ(RectFromLoc(loc1, loc2),function dest_condition1)
set dest2 = RandomDestructableInRectBJ(RectFromLoc(loc1, loc2),function dest_condition2)
if GetDestructableTypeId(dest1) == 'B000' then
set bR = 1
endif
if GetDestructableTypeId(dest2) == 'B003' then
set bL = 2
endif
call RemoveLocation(loc1)
call RemoveLocation(loc2)
set loc1 = null
set loc2 = null
set u2 = null
set dest1 = null
set dest2 = null
endloop
set udg_LR[udg_wallcount] = bR + bL
set bR = 0
set bL = 0
endloop
call RemoveUnit(u)
set u = null
set u2 = null
call RemoveLocation(loc1)
call RemoveLocation(loc2)
set loc1 = null
set loc2 = null
call DestroyGroup(gr1)
call DestroyGroup(gr2)
set gr1 = null
set gr2 = null
endfunction
//===========================================================================
function InitTrig_destroy_wall takes nothing returns nothing
set gg_trg_destroy_wall = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_destroy_wall, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_destroy_wall, Condition( function Trig_destroy_condition ) )
call TriggerAddAction( gg_trg_destroy_wall, function Trig_destroy_wall_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_handle_Actions takes nothing returns nothing
local location a = Location(4,7)
call BJDebugMsg(I2S(GetHandleId(a)))
call RemoveLocation(a)
set a = null
endfunction
//===========================================================================
function InitTrig_handle takes nothing returns nothing
set gg_trg_handle = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_handle, 0.01 )
call TriggerAddAction( gg_trg_handle, function Trig_handle_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_initial2_Actions takes nothing returns nothing
local integer i = 0
set udg_name[1] = ( "|cffff0202" + GetPlayerName(ConvertedPlayer(1)) + "|r" )
set udg_name[2] = ( "|cff0041ff" + GetPlayerName(ConvertedPlayer(2)) + "|r" )
set udg_name[3] = ( "|cff1be6B8" + GetPlayerName(ConvertedPlayer(3)) + "|r" )
set udg_name[4] = ( "|cff530080" + GetPlayerName(ConvertedPlayer(4)) + "|r" )
set udg_name[5] = ( "|cfffffc00" + GetPlayerName(ConvertedPlayer(5)) + "|r" )
set udg_name[6] = ( "|cfffe890d" + GetPlayerName(ConvertedPlayer(6)) + "|r" )
set udg_name[7] = ( "|cff1fbf00" + GetPlayerName(ConvertedPlayer(7)) + "|r" )
set udg_name[8] = ( "|cffe55aaf" + GetPlayerName(ConvertedPlayer(8)) + "|r" )
set udg_name[9] = ( "|cff949596" + GetPlayerName(ConvertedPlayer(9)) + "|r" )
set udg_name[10] = ( "|cff7dbef1" + GetPlayerName(ConvertedPlayer(10)) + "|r" )
loop
exitwhen i == 4
call GroupAddUnit( udg_group_inRoundTech, CreateUnit( Player(i), 'H008', -8600, 2500, 0 ) )
set i = i + 1
endloop
call stackInit()
call thunderInit()
call InitTrig_sdf()
call initWallTypeHT()
endfunction
//===========================================================================
function InitTrig_initial2 takes nothing returns nothing
set gg_trg_initial2 = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_initial2, 0.10 )
call TriggerAddAction( gg_trg_initial2, function Trig_initial2_Actions )
endfunction
//TESH.scrollpos=61
//TESH.alwaysfold=0
function Trig_cine1_Func002Func001Func002C takes nothing returns boolean
if ( ( GetUnitTypeId(GetEnumUnit()) == 'h002' ) ) then
return true
endif
if ( ( GetUnitTypeId(GetEnumUnit()) == 'h000' ) ) then
return true
endif
return false
endfunction
function Trig_cine1_Func002Func001C takes nothing returns boolean
if ( not Trig_cine1_Func002Func001Func002C() ) then
return false
endif
return true
endfunction
function Trig_cine1_Func002A takes nothing returns nothing
if ( Trig_cine1_Func002Func001C() ) then
call ShowUnitHide( GetEnumUnit() )
else
endif
endfunction
function Trig_cine1_Actions takes nothing returns nothing
call ShowUnitHide( gg_unit_hmpr_0043 )
call ForGroupBJ( GetUnitsInRectAll(gg_rct_Setting_zone), function Trig_cine1_Func002A )
call SelectUnitForPlayerSingle( gg_unit_owtw_0045, Player(0) )
call TriggerSleepAction( 3.00 )
call ShowUnitShow( gg_unit_h000_0003 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0003),GetUnitY(gg_unit_h000_0003),0.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h002_0029 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h002_0029),GetUnitY(gg_unit_h002_0029),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0005 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0005),GetUnitY(gg_unit_h000_0005),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0004 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0004),GetUnitY(gg_unit_h000_0004),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0006 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0006),GetUnitY(gg_unit_h000_0006),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0007 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0007),GetUnitY(gg_unit_h000_0007),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0008 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0008),GetUnitY(gg_unit_h000_0008),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0009 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0009),GetUnitY(gg_unit_h000_0009),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0010 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0010),GetUnitY(gg_unit_h000_0010),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0011 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0011),GetUnitY(gg_unit_h000_0011),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0012 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0012),GetUnitY(gg_unit_h000_0012),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0023 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0023),GetUnitY(gg_unit_h000_0023),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0022 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0022),GetUnitY(gg_unit_h000_0022),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0024 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0024),GetUnitY(gg_unit_h000_0024),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0025 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0025),GetUnitY(gg_unit_h000_0025),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h002_0028 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h002_0028 ),GetUnitY(gg_unit_h002_0028 ),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0026 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0026 ),GetUnitY(gg_unit_h000_0026 ),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0014 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0014 ),GetUnitY(gg_unit_h000_0014 ),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h002_0030 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h002_0030 ),GetUnitY(gg_unit_h002_0030 ),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_h000_0013 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_h000_0013 ),GetUnitY(gg_unit_h000_0013 ),.3)
call TriggerSleepAction( 0.13 )
call ShowUnitShow( gg_unit_hmpr_0043 )
call AddSpecialEffectTimed("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",GetUnitX(gg_unit_hmpr_0043),GetUnitY(gg_unit_hmpr_0043),.3)
call IssuePointOrderLoc( gg_unit_hmpr_0043, "move", GetUnitLoc(gg_unit_hkni_0044) )
endfunction
//===========================================================================
function InitTrig_cine1 takes nothing returns nothing
set gg_trg_cine1 = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_cine1, 0.50 )
call TriggerAddAction( gg_trg_cine1, function Trig_cine1_Actions )
endfunction
//TESH.scrollpos=173
//TESH.alwaysfold=0
globals
integer pii = 1
endglobals
function CreateWall takes nothing returns nothing
local destructable starter
local integer i = 1
local integer dest_id = 'B003'
local location start_loc
local location dest_loc
local real loc_x = 0
local real loc_y = 0
local integer wallnum = (udg_maze_x * 2) + (udg_maze_y * 2) - 4
local timer t = CreateTimer()
if GetPlayerController(ConvertedPlayer(pii)) == MAP_CONTROL_USER and GetPlayerSlotState(ConvertedPlayer(pii)) == PLAYER_SLOT_STATE_PLAYING then
set dest_id = 'B003'
set dest_loc = GetDestructableLoc(udg_starter[pii])
set loc_x = GetLocationX(dest_loc)
set loc_y = GetLocationY(dest_loc)
loop
exitwhen i > udg_maze_x -1
set loc_x = loc_x + 128
set start_loc = Location(loc_x,loc_y)
if i == udg_ent then
if dest_id == 'B003' then
set dest_id = 'B000'
else
set dest_id = 'B003'
endif
set udg_loc_start[pii] = Location(loc_x,loc_y)
endif
if i == udg_exit then
call CreateUnit(Player(11),'hkni',loc_x,loc_y,0)
call GroupAddUnit(udg_del_group,GetLastCreatedUnit())
set udg_loc_end[pii] = Location(loc_x,loc_y)
if dest_id == 'B003' then
set dest_id = 'B000'
else
set dest_id = 'B003'
endif
endif
if i != udg_ent and i != udg_exit then
call CreateDestructableLoc(dest_id,start_loc,0,.44,0)
endif
set i = i + 1
call RemoveLocation(start_loc)
set start_loc = null
endloop
loop
exitwhen i > udg_maze_x*2-2
set loc_y = loc_y - 128
set start_loc = Location(loc_x,loc_y)
if i == udg_ent then
if dest_id == 'B003' then
set dest_id = 'B000'
else
set dest_id = 'B003'
endif
set udg_loc_start[pii] = Location(loc_x,loc_y)
endif
if i == udg_exit then
call CreateUnit(Player(11),'hkni',loc_x,loc_y,0)
call GroupAddUnit(udg_del_group,GetLastCreatedUnit())
set udg_loc_end[pii] = Location(loc_x,loc_y)
if dest_id == 'B003' then
set dest_id = 'B000'
else
set dest_id = 'B003'
endif
endif
if i != udg_ent and i != udg_exit then
call CreateDestructableLoc(dest_id,start_loc,0,.44,0)
endif
set i = i + 1
call RemoveLocation(start_loc)
set start_loc = null
endloop
loop
exitwhen i > udg_maze_x*3-3
set loc_x = loc_x - 128
set start_loc = Location(loc_x,loc_y)
if i == udg_ent then
if dest_id == 'B003' then
set dest_id = 'B000'
else
set dest_id = 'B003'
endif
set udg_loc_start[pii] = Location(loc_x,loc_y)
endif
if i == udg_exit then
call CreateUnit(Player(11),'hkni',loc_x,loc_y,0)
call GroupAddUnit(udg_del_group,GetLastCreatedUnit())
set udg_loc_end[pii] = Location(loc_x,loc_y)
if dest_id == 'B003' then
set dest_id = 'B000'
else
set dest_id = 'B003'
endif
endif
if i != udg_ent and i != udg_exit then
call CreateDestructableLoc(dest_id,start_loc,0,.44,0)
endif
set i = i + 1
call RemoveLocation(start_loc)
set start_loc = null
endloop
loop
exitwhen i > udg_maze_x*4-5
set loc_y = loc_y + 128
set start_loc = Location(loc_x,loc_y)
if i == udg_ent then
if dest_id == 'B003' then
set dest_id = 'B000'
else
set dest_id = 'B003'
endif
set udg_loc_start[pii] = Location(loc_x,loc_y)
endif
if i == udg_exit then
call CreateUnit(Player(11),'hkni',loc_x,loc_y,0)
call GroupAddUnit(udg_del_group,GetLastCreatedUnit())
set udg_loc_end[pii] = Location(loc_x,loc_y)
if dest_id == 'B003' then
set dest_id = 'B000'
else
set dest_id = 'B003'
endif
endif
if i != udg_ent and i != udg_exit then
call CreateDestructableLoc(dest_id,start_loc,0,.44,0)
endif
set i = i + 1
call RemoveLocation(start_loc)
set start_loc = null
endloop
call CreateNUnitsAtLocFacingLocBJ( 1, 'hgyr', Player(11), udg_loc_start[pii], udg_loc_end[pii] )
call GroupAddUnit(udg_del_group,GetLastCreatedUnit())
endif
set pii = pii +1
if pii < 9 then
call TimerStart(t,0.1,false,function CreateWall)
else
set pii = 1
call red_wall_gen()
endif
call RemoveLocation(dest_loc)
call RemoveLocation(start_loc)
set start_loc = null
set dest_loc = null
set t =null
endfunction
function randomstart takes nothing returns nothing
local integer wallnum = (udg_maze_x * 2) + (udg_maze_y * 2) - 4
local integer ent = GetRandomInt(2, wallnum-1)
local integer exit = GetRandomInt(2, wallnum-1)
local timer t = CreateTimer()
loop
exitwhen ent != 10 and ent != 20 and ent != 30
set ent = GetRandomInt(2, wallnum-1)
endloop
loop
exitwhen IAbsBJ(ent-exit) > 2 and exit != 10 and exit !=20 and exit !=30
set exit = GetRandomInt(2, wallnum-1)
endloop
set udg_ent = ent
set udg_exit = exit
call TimerStart(t,0.03,false,function CreateWall)
set t = null
endfunction
//TESH.scrollpos=135
//TESH.alwaysfold=0
function reviveinRoundTech takes nothing returns nothing
call ReviveHero( GetEnumUnit(), -8600, 2500, false )
endfunction
//!금,나무를 배분하고, 카메라를 이동,카메라범위설정,벽제거능력on,워커보이기
function step1 takes nothing returns nothing
local integer intA = 1
local integer i = GetRandomInt(1,100)
set udg_gold = GetRandomInt(6, 33)
call ForGroup( udg_group_inRoundTech, function reviveinRoundTech )
if i <= 100 and i >70 then
set udg_wood = 2
elseif i <= 70 and i >25 then
set udg_wood = 1
else
set udg_wood = 0
endif
loop
exitwhen intA > 8
if GetPlayerController(ConvertedPlayer(intA)) == MAP_CONTROL_USER and GetPlayerSlotState(ConvertedPlayer(intA)) == PLAYER_SLOT_STATE_PLAYING then
call SmartCameraPanBJ( ConvertedPlayer(intA), GetRectCenter(udg_Field[intA]), 0.00 )
call SetPlayerStateBJ( ConvertedPlayer(intA), PLAYER_STATE_RESOURCE_GOLD, udg_gold )
call SetPlayerStateBJ( ConvertedPlayer(intA), PLAYER_STATE_RESOURCE_LUMBER, udg_wood )
call SetPlayerAbilityAvailableBJ( true, 'A000', ConvertedPlayer(intA) )
endif
set intA = intA+1
endloop
endfunction
//!변수 깔끄미
function ClearLR takes nothing returns nothing
local integer i = 0
set udg_wallcount = 0
loop
exitwhen i > 2000
set udg_LR[i] = 0
set i = i + 1
endloop
set i = 1
loop
exitwhen i > 8
if GetPlayerController(ConvertedPlayer(i)) == MAP_CONTROL_USER and GetPlayerSlotState(ConvertedPlayer(i)) == PLAYER_SLOT_STATE_PLAYING then
set udg_Alive = i
endif
set i = i + 1
endloop
endfunction
//!건물건설제한시간, 이 타이머가 끝났을떄 러너가 생성되고, 워커를 숨기고,
function BuildTimer takes nothing returns nothing
call StartTimerBJ(udg_soundTimer,false,udg_time-5)
call StartTimerBJ(udg_Timer, false, udg_time )
call CreateTimerDialogBJ( GetLastCreatedTimerBJ(), "Time Remaning" )
endfunction
//!갈색유닛들을 전부 제거한다. 벽,나이트 포함
function removeUnitAction takes nothing returns nothing
call RemoveUnit( GetEnumUnit() )
endfunction
function removePlayer11Unit takes nothing returns nothing
call ForGroupBJ( GetUnitsInRectOfPlayer(gg_rct_BIG, Player(11)), function removeUnitAction )
endfunction
//!기본모드에서 사용, 나이트는 그대로두고 벽들만 지움.
function removeUnitAction2 takes nothing returns nothing
if GetUnitTypeId(GetEnumUnit()) == 'h001' or GetUnitTypeId(GetEnumUnit()) == 'h003' then
call RemoveUnit( GetEnumUnit() )
endif
endfunction
function removePlayer11Unit2 takes nothing returns nothing
call ForGroupBJ( GetUnitsInRectOfPlayer(gg_rct_BIG, Player(11)), function removeUnitAction2 )
endfunction
//!모든 길막감지벽들을 제거한다. 랜덤모드에서만 사용
function removeWallAction takes nothing returns nothing
if GetDestructableTypeId(GetFilterDestructable()) == 'B000' or GetDestructableTypeId(GetFilterDestructable()) == 'B003' then
call RemoveDestructable( GetEnumDestructable() )
endif
endfunction
function removeWall takes nothing returns nothing
call EnumDestructablesInRectAll( gg_rct_BIG, function removeWallAction )
endfunction
//!플레이어들의 모든 벽들을 제거한다.
function removePlayerWallAction takes nothing returns nothing
local integer typ = GetUnitTypeId(GetEnumUnit())
if typ == 'h000' or typ == 'h002' or typ == 'h009' or typ == 'h00A' then
call RemoveUnit(GetEnumUnit())
endif
endfunction
function removePlayerWall takes nothing returns nothing
local integer i = 1
loop
exitwhen i > 8
call ForGroupBJ(GetUnitsInRectOfPlayer(udg_Field[i],Player(i-1)),function removePlayerWallAction)
set i = i + 1
endloop
endfunction
function newRound takes nothing returns nothing
local timer t = CreateTimer()
local integer a = 1
if udg_nR == 1 then
call ClearLR()
elseif udg_nR == 2 then
call removePlayer11Unit2()
elseif udg_nR == 3 then
if udg_Mode == 1 then
call removePlayer11Unit()
endif
elseif udg_nR == 4 then
if udg_Mode == 1 then
call removeWall()
else
call red_wall_gen()
endif
elseif udg_nR == 5 then
if udg_Mode == 1 then
call randomstart()
endif
elseif udg_nR == 6 then
call removePlayerWall()
elseif udg_nR == 7 then
call step1()
elseif udg_nR == 8 then
elseif udg_nR == 9 then
call BuildTimer()
endif
if udg_nR < 9 then
call TimerStart(t,0.05,false,function newRound)
set udg_nR = udg_nR + 1
else
set udg_nR = 1
set udg_temp_round = udg_temp_round + 1
endif
set t = null
endfunction
function runnerGen takes nothing returns nothing
local integer i = 1
loop
exitwhen i > 8
if GetPlayerController(ConvertedPlayer(i)) == MAP_CONTROL_USER and GetPlayerSlotState(ConvertedPlayer(i)) == PLAYER_SLOT_STATE_PLAYING then
call CreateNUnitsAtLoc( 1, 'hmpr', Player(10), Location(GetLocationX(udg_loc_start[i])+20,GetLocationY(udg_loc_start[i])), 90.00 )
call GroupAddUnitSimple( GetLastCreatedUnit(), udg_runnerGroup )
call SetUnitUserData( GetLastCreatedUnit(), i )
call TriggerRegisterUnitEvent( gg_trg_dmgRun, GetLastCreatedUnit(), EVENT_UNIT_DAMAGED )
call IssuePointOrderLoc( GetLastCreatedUnit(), "move", udg_loc_end[GetUnitUserData(GetLastCreatedUnit())] )
endif
set i = i + 1
endloop
call StartTimerBJ(udg_runTimer,false,40)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function killinRoundTech takes nothing returns nothing
call KillUnit( GetEnumUnit() )
endfunction
function Trig_Build_timer_end_Actions takes nothing returns nothing
call DestroyTimerDialogBJ( GetLastCreatedTimerDialogBJ() )
call DisableTrigger( gg_trg_tick_sound )
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 8
call ForGroup( udg_group_inRoundTech, function killinRoundTech )
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
call ShowUnitHide( udg_worker[GetForLoopIndexA()] )
call SetPlayerAbilityAvailableBJ( false, 'A000', ConvertedPlayer(GetForLoopIndexA()) )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
call runnerGen()
endfunction
//===========================================================================
function InitTrig_Build_timer_end takes nothing returns nothing
set gg_trg_Build_timer_end = CreateTrigger( )
call TriggerRegisterTimerExpireEventBJ( gg_trg_Build_timer_end, udg_Timer )
call TriggerAddAction( gg_trg_Build_timer_end, function Trig_Build_timer_end_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_ending_Actions takes nothing returns nothing
local integer i = 0
local real tempMax = -1
local integer tempVictory
loop
exitwhen i == 8
if udg_scoreTime[i] > tempMax then
set tempMax = udg_scoreTime[i]
set tempVictory = i
endif
set i = i + 1
endloop
call DisplayTextToForce( GetPlayersAll(), ( "game is end! " + ( "Winner is " + ( udg_name[tempVictory+1] + "!!" ) ) ) )
call CreateTextTagUnitBJ( udg_name[tempVictory+1], gg_unit_hspt_0055, 0, 10, 100, 100, 100, 0 )
set i = 0
loop
exitwhen i == 8
set udg_cam_distance[i] = 3500.00
call CameraSetupApplyForPlayer( true, gg_cam_ending_cam, Player(i), 1.00 )
set i = i + 1
endloop
endfunction
//===========================================================================
function InitTrig_ending takes nothing returns nothing
set gg_trg_ending = CreateTrigger( )
call TriggerAddAction( gg_trg_ending, function Trig_ending_Actions )
endfunction
//TESH.scrollpos=30
//TESH.alwaysfold=0
/*******************************************************************************
* Dialog Utils *
* 만든이 : 크로와상 *
* 버전 : 1.00 (2016-12-30) *
* 설명 : 다이얼로그에 편리한 함수를 제공합니다. *
* *
* 사용법 : *
* - integer GetDialogLength(whichDialog) *
* whichDialog에 등록된 버튼의 개수를 반환 *
* (DialogAddButtonEx 함수로 추가한 버튼만 해당됩니다.) *
* *
* - integer GetButtonIndex(whichDialog, whichButton) *
* whichDialog에서의 whichButton의 번호를 반환 *
* (DialogAddButtonEx 함수로 추가한 버튼만 해당됩니다.) *
* *
* - button DialogAddButtonEx(whichDialog, buttonText, hotkey) *
* whichDialog에 buttonText으로 표기된 단축키 hotkey의 버튼 추가 *
* *
* - integer DialogDisplayModal(whichPlayer, whichDialog, timeout) *
* whichPlayer에게 whichDialog를 timeout초 동안 보여주고 대기합니다. *
* 선택한 버튼의 번호가 반환되며, 아무 버튼도 선택하지 않은 경우 -1이 *
* 반환됩니다. *
* (DialogAddButtonEx 함수로 추가한 버튼만 해당됩니다.) *
* *
* - integer DialogDisplayModalWithTimerDialog(whichPlayer, whichDialog, *
* timeout, tdTitle) *
* whichPlayer에게 whichDialog를 timeout초 동안 보여주고 대기합니다. *
* 선택한 버튼의 번호가 반환되며, 아무 버튼도 선택하지 않은 경우 -1이 *
* 반환됩니다. *
* tdTitle 이름의 타이머 다이얼로그도 함께 보여줍니다. tdTitle이 null이라면 *
* 타이머 다이얼로그를 보여주지 않습니다. *
* (DialogAddButtonEx 함수로 추가한 버튼만 해당됩니다.) *
* *
* *
******************************************************************************/
library DialogUtils requires optional TimerUtils
globals
private hashtable hash = InitHashtable()
endglobals
private function SetDialogLength takes dialog whichDialog, integer length returns nothing
call SaveInteger(hash, GetHandleId(whichDialog), -1, length)
endfunction
function GetDialogLength takes dialog whichDialog returns integer
return LoadInteger(hash, GetHandleId(whichDialog), -1)
endfunction
private function RegisterDialogButton takes dialog whichDialog, button whichButton returns nothing
local integer length = GetDialogLength(whichDialog)
call SaveButtonHandle(hash, GetHandleId(whichDialog), length, whichButton)
call SaveInteger(hash, GetHandleId(whichDialog), GetHandleId(whichButton), length)
call SetDialogLength(whichDialog, length + 1)
endfunction
private function FlushDialogButtons takes dialog whichDialog returns nothing
call FlushChildHashtable(hash, GetHandleId(whichDialog))
endfunction
function GetButtonIndex takes dialog whichDialog, button whichButton returns integer
if (HaveSavedInteger(hash, GetHandleId(whichDialog), GetHandleId(whichButton))) then
return LoadInteger(hash, GetHandleId(whichDialog), GetHandleId(whichButton))
endif
return -1
endfunction
function DialogAddButtonEx takes dialog whichDialog, string buttonText, integer hotkey returns button
set bj_lastCreatedButton = DialogAddButton(whichDialog, buttonText, hotkey)
call RegisterDialogButton(whichDialog, bj_lastCreatedButton)
return bj_lastCreatedButton
endfunction
hook DialogClear FlushDialogButtons
hook DialogDestroy FlushDialogButtons
hook DialogClearBJ FlushDialogButtons
private function DialogOnClick takes nothing returns boolean
local trigger trig = GetTriggeringTrigger()
call SaveButtonHandle(hash, GetHandleId(trig), 0, GetClickedButton())
if (HaveSavedHandle(hash, GetHandleId(trig), 1)) then
call TimerStart(LoadTimerHandle(hash, GetHandleId(trig), 1) , 0, false, null)
endif
set trig = null
return false
endfunction
private function PolledWaitDialogWithTimerDialog takes dialog whichDialog, real timeout, string tdTitle returns nothing
local timer t
local real timeRemaining
local trigger trig = LoadTriggerHandle(hash, GetHandleId(whichDialog), -2)
local timerdialog td
if (timeout > 0) then
static if LIBRARY_TimerUtils then
set t = NewTimer()
else
set t = CreateTimer()
endif
call TimerStart(t, timeout, false, null)
call SaveTimerHandle(hash, GetHandleId(trig), 1, t)
set td = CreateTimerDialog(t)
call TimerDialogSetTitle(td, tdTitle)
if (tdTitle != null) then
call TimerDialogDisplay(td, true)
else
call TimerDialogDisplay(td, false)
endif
loop
set timeRemaining = TimerGetRemaining(t)
exitwhen (timeRemaining <= 0)
call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
endloop
static if LIBRARY_TimerUtils then
call ReleaseTimer(t)
else
call DestroyTimer(t)
endif
if (td != null) then
call DestroyTimerDialog(td)
endif
endif
set t = null
set trig = null
endfunction
private function PolledWaitDialog takes dialog whichDialog, real timeout returns nothing
call PolledWaitDialogWithTimerDialog(whichDialog, timeout, null)
endfunction
function DialogDisplayModalWithTimerDialog takes player whichPlayer, dialog whichDialog, real timeout, string tdTitle returns integer
local integer index
local trigger trig
local button clickedButton
set trig = CreateTrigger()
call TriggerRegisterDialogEvent(trig, whichDialog)
call TriggerAddCondition(trig, function DialogOnClick)
call SaveTriggerHandle(hash, GetHandleId(whichDialog), -2, trig)
call RemoveSavedHandle(hash, GetHandleId(trig), 0)
call DialogDisplay(whichPlayer, whichDialog, true)
set clickedButton = LoadButtonHandle(hash, GetHandleId(trig), 0)
if (clickedButton == null) then
if (timeout > 0) then
call PolledWaitDialogWithTimerDialog(whichDialog, timeout, tdTitle)
else
call PolledWaitDialogWithTimerDialog(whichDialog, 604800, tdTitle)
endif
set clickedButton = LoadButtonHandle(hash, GetHandleId(trig), 0)
endif
call RemoveSavedHandle(hash, GetHandleId(whichDialog), -2)
call FlushChildHashtable(hash, GetHandleId(trig))
call DestroyTrigger(trig)
//! 반환 값 : 클릭된 버튼 인덱스
if (clickedButton == null) then
call DialogDisplay(whichPlayer, whichDialog, false)
set index = -1
else
set index = GetButtonIndex(whichDialog, clickedButton)
endif
set trig = null
set clickedButton = null
return index
endfunction
function DialogDisplayModal takes player whichPlayer, dialog whichDialog, real timeout returns integer
return DialogDisplayModalWithTimerDialog(whichPlayer, whichDialog, timeout, null)
endfunction
endlibrary
//TESH.scrollpos=19
//TESH.alwaysfold=0
library TimerUtil
private struct N
endstruct
globals
private constant string ERROR_GETDATA = "값을 가져올 수 없는 타이머로부터 값을 가져오려고 했습니다!"
private constant string ERROR_RELEASE = "NewTimer1, NewTimerEx1 외의 방법으로 생성된 타이머를 Release하려 했습니다!"
private hashtable H = InitHashtable( )
private timer array T
private integer array D
endglobals
function GetTimerData1 takes timer t returns integer
local N n = LoadInteger( H, 0, GetHandleId( t ) )
if n == 0 then
debug call BJDebugMsg( ERROR_GETDATA )
return 0
endif
return D[n]
endfunction
function SetTimerData1 takes timer t, integer i returns nothing
local N n = LoadInteger( H, 0, GetHandleId( t ) )
if n == 0 then
return
endif
set D[n] = i
endfunction
function NewTimerEx1 takes integer d returns timer
local N n = N.create( )
if T[n] == null then
set T[n] = CreateTimer( )
endif
call SaveInteger( H, 0, GetHandleId( T[n] ), n )
set D[n] = d
return T[n]
endfunction
function NewTimer1 takes nothing returns timer
return NewTimerEx1( 0 )
endfunction
function ReleaseTimer1 takes timer t returns nothing
local N n = LoadInteger( H, 0, GetHandleId( t ) )
if n == 0 then
debug call BJDebugMsg( ERROR_RELEASE )
return
endif
call PauseTimer( t )
call n.destroy( )
endfunction
endlibrary
//TESH.scrollpos=221
//TESH.alwaysfold=0
library TimerUtils initializer init
//*********************************************************************
//* TimerUtils (red+blue+orange flavors for 1.24b+) 2.0
//* ----------
//*
//* To implement it , create a custom text trigger called TimerUtils
//* and paste the contents of this script there.
//*
//* To copy from a map to another, copy the trigger holding this
//* library to your map.
//*
//* (requires vJass) More scripts: htt://www.wc3c.net
//*
//* For your timer needs:
//* * Attaching
//* * Recycling (with double-free protection)
//*
//* set t=NewTimer() : Get a timer (alternative to CreateTimer)
//* set t=NewTimerEx(x) : Get a timer (alternative to CreateTimer), call
//* Initialize timer data as x, instead of 0.
//*
//* ReleaseTimer(t) : Relese a timer (alt to DestroyTimer)
//* SetTimerData(t,2) : Attach value 2 to timer
//* GetTimerData(t) : Get the timer's value.
//* You can assume a timer's value is 0
//* after NewTimer.
//*
//* Multi-flavor:
//* Set USE_HASH_TABLE to true if you don't want to complicate your life.
//*
//* If you like speed and giberish try learning about the other flavors.
//*
//********************************************************************
//================================================================
globals
//How to tweak timer utils:
// USE_HASH_TABLE = true (new blue)
// * SAFEST
// * SLOWEST (though hash tables are kind of fast)
//
// USE_HASH_TABLE = false, USE_FLEXIBLE_OFFSET = true (orange)
// * kinda safe (except there is a limit in the number of timers)
// * ALMOST FAST
//
// USE_HASH_TABLE = false, USE_FLEXIBLE_OFFSET = false (red)
// * THE FASTEST (though is only faster than the previous method
// after using the optimizer on the map)
// * THE LEAST SAFE ( you may have to tweak OFSSET manually for it to
// work)
//
private constant boolean USE_HASH_TABLE = true
private constant boolean USE_FLEXIBLE_OFFSET = false
private constant integer OFFSET = 0x100000
private integer VOFFSET = OFFSET
//Timers to preload at map init:
private constant integer QUANTITY = 1024
//Changing this to something big will allow you to keep recycling
// timers even when there are already AN INCREDIBLE AMOUNT of timers in
// the stack. But it will make things far slower so that's probably a bad idea...
private constant integer ARRAY_SIZE = 8190
endglobals
//==================================================================================================
globals
private integer array data[ARRAY_SIZE]
private hashtable ht
endglobals
//It is dependent on jasshelper's recent inlining optimization in order to perform correctly.
function SetTimerData takes timer t, integer value returns nothing
static if(USE_HASH_TABLE) then
// new blue
call SaveInteger(ht,0,GetHandleId(t), value)
elseif (USE_FLEXIBLE_OFFSET) then
// orange
static if (DEBUG_MODE) then
if(GetHandleId(t)-VOFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
set data[GetHandleId(t)-VOFFSET]=value
else
// new red
static if (DEBUG_MODE) then
if(GetHandleId(t)-OFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
set data[GetHandleId(t)-OFFSET]=value
endif
endfunction
function GetTimerData takes timer t returns integer
static if(USE_HASH_TABLE) then
// new blue
return LoadInteger(ht,0,GetHandleId(t) )
elseif (USE_FLEXIBLE_OFFSET) then
// orange
static if (DEBUG_MODE) then
if(GetHandleId(t)-VOFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
return data[GetHandleId(t)-VOFFSET]
else
// new red
static if (DEBUG_MODE) then
if(GetHandleId(t)-OFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
return data[GetHandleId(t)-OFFSET]
endif
endfunction
//==========================================================================================
globals
private timer array tT[ARRAY_SIZE]
private integer tN = 0
private constant integer HELD=0x28829022
//use a totally random number here, the more improbable someone uses it, the better.
private boolean didinit = false
endglobals
private keyword init
//==========================================================================================
// I needed to decide between duplicating code ignoring the "Once and only once" rule
// and using the ugly textmacros. I guess textmacros won.
//
//! textmacro TIMERUTIS_PRIVATE_NewTimerCommon takes VALUE
// On second thought, no.
//! endtextmacro
function NewTimerEx takes integer value returns timer
if (tN==0) then
if (not didinit) then
//This extra if shouldn't represent a major performance drawback
//because QUANTITY rule is not supposed to be broken every day.
call init.evaluate()
set tN = tN - 1
else
//If this happens then the QUANTITY rule has already been broken, try to fix the
// issue, else fail.
debug call BJDebugMsg("NewTimer: Warning, Exceeding TimerUtils_QUANTITY, make sure all timers are getting recycled correctly")
set tT[0]=CreateTimer()
static if( not USE_HASH_TABLE) then
debug call BJDebugMsg("In case of errors, please increase it accordingly, or set TimerUtils_USE_HASH_TABLE to true")
static if( USE_FLEXIBLE_OFFSET) then
if (GetHandleId(tT[0])-VOFFSET<0) or (GetHandleId(tT[0])-VOFFSET>=ARRAY_SIZE) then
//all right, couldn't fix it
call BJDebugMsg("NewTimer: Unable to allocate a timer, you should probably set TimerUtils_USE_HASH_TABLE to true or fix timer leaks.")
return null
endif
else
if (GetHandleId(tT[0])-OFFSET<0) or (GetHandleId(tT[0])-OFFSET>=ARRAY_SIZE) then
//all right, couldn't fix it
call BJDebugMsg("NewTimer: Unable to allocate a timer, you should probably set TimerUtils_USE_HASH_TABLE to true or fix timer leaks.")
return null
endif
endif
endif
endif
else
set tN=tN-1
endif
call SetTimerData(tT[tN],value)
return tT[tN]
endfunction
function NewTimer takes nothing returns timer
return NewTimerEx(0)
endfunction
//==========================================================================================
function ReleaseTimer takes timer t returns nothing
if(t==null) then
debug call BJDebugMsg("Warning: attempt to release a null timer")
return
endif
if (tN==ARRAY_SIZE) then
debug call BJDebugMsg("Warning: Timer stack is full, destroying timer!!")
//stack is full, the map already has much more troubles than the chance of bug
call DestroyTimer(t)
else
call PauseTimer(t)
if(GetTimerData(t)==HELD) then
debug call BJDebugMsg("Warning: ReleaseTimer: Double free!")
return
endif
call SetTimerData(t,HELD)
set tT[tN]=t
set tN=tN+1
endif
endfunction
private function init takes nothing returns nothing
local integer i=0
local integer o=-1
local boolean oops = false
if ( didinit ) then
return
else
set didinit = true
endif
static if( USE_HASH_TABLE ) then
set ht = InitHashtable()
loop
exitwhen(i==QUANTITY)
set tT[i]=CreateTimer()
call SetTimerData(tT[i], HELD)
set i=i+1
endloop
set tN = QUANTITY
else
loop
set i=0
loop
exitwhen (i==QUANTITY)
set tT[i] = CreateTimer()
if(i==0) then
set VOFFSET = GetHandleId(tT[i])
static if(USE_FLEXIBLE_OFFSET) then
set o=VOFFSET
else
set o=OFFSET
endif
endif
if (GetHandleId(tT[i])-o>=ARRAY_SIZE) then
exitwhen true
endif
if (GetHandleId(tT[i])-o>=0) then
set i=i+1
endif
endloop
set tN = i
exitwhen(tN == QUANTITY)
set oops = true
exitwhen not USE_FLEXIBLE_OFFSET
debug call BJDebugMsg("TimerUtils_init: Failed a initialization attempt, will try again")
endloop
if(oops) then
static if ( USE_FLEXIBLE_OFFSET) then
debug call BJDebugMsg("The problem has been fixed.")
//If this message doesn't appear then there is so much
//handle id fragmentation that it was impossible to preload
//so many timers and the thread crashed! Therefore this
//debug message is useful.
elseif(DEBUG_MODE) then
call BJDebugMsg("There were problems and the new timer limit is "+I2S(i))
call BJDebugMsg("This is a rare ocurrence, if the timer limit is too low:")
call BJDebugMsg("a) Change USE_FLEXIBLE_OFFSET to true (reduces performance a little)")
call BJDebugMsg("b) or try changing OFFSET to "+I2S(VOFFSET) )
endif
endif
endif
endfunction
endlibrary
//TESH.scrollpos=3
//TESH.alwaysfold=0
library AOK requires EZEffect
endlibrary
library EZEffect requires TimerUtil
private struct fx
endstruct
globals
private effect array E
endglobals
private function KillSpecialEffectTimed takes nothing returns nothing
local fx e = GetTimerData( GetExpiredTimer() )
call DestroyEffect( E[e] )
call e.destroy()
call ReleaseTimer( GetExpiredTimer() )
set E[e] = null
endfunction
function AddSpecialEffectTimed takes string modelName, real x, real y, real t returns effect
local fx e = fx.create()
set E[e] = AddSpecialEffect( modelName, x, y )
call TimerStart( NewTimerEx(e), t, false, function KillSpecialEffectTimed )
return E[e]
endfunction
function AddSpecialEffectLocTimed takes string modelName, location loc, real t returns effect
local fx e = fx.create()
set E[e] = AddSpecialEffectLoc( modelName, loc )
call TimerStart( NewTimerEx(e), t, false, function KillSpecialEffectTimed )
return E[e]
endfunction
function AddSpecialEffectTargetTimed takes string modelName, widget targetWidget, string attachPointName, real t returns effect
local fx e = fx.create()
set E[e] = AddSpecialEffectTarget( modelName, targetWidget, attachPointName )
call TimerStart( NewTimerEx(e), t, false, function KillSpecialEffectTimed )
return E[e]
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Tick
struct tick
private static integer MAX = 0
private static hashtable H = InitHashtable( )
private timer T
integer data
static method operator count takes nothing returns integer
return MAX
endmethod
static method getExpired takes nothing returns thistype
return LoadInteger( H, 0, GetHandleId(GetExpiredTimer()) )
endmethod
static method create takes integer userData returns thistype
local thistype this = thistype.allocate( )
set MAX = MAX + 1
if .T == null then
set .T = CreateTimer( )
call SaveInteger( H, 0, GetHandleId(T), this )
endif
set .data = userData
return this
endmethod
method operator super takes nothing returns timer
return .T
endmethod
method operator elapsed takes nothing returns real
return TimerGetElapsed( .T )
endmethod
method operator remaining takes nothing returns real
return TimerGetRemaining( .T )
endmethod
method operator timeout takes nothing returns real
return TimerGetTimeout( .T )
endmethod
method pause takes nothing returns nothing
call PauseTimer( .T )
endmethod
method resume takes nothing returns nothing
call ResumeTimer( .T )
endmethod
method start takes real r, boolean flag, code c returns nothing
call TimerStart( .T, r, flag, c )
endmethod
method destroy takes nothing returns nothing
set MAX = MAX - 1
call PauseTimer( .T )
call thistype.deallocate( this )
endmethod
endstruct
struct tickUI
private static integer MAX = 0
private timerdialog T
static method operator count takes nothing returns integer
return MAX
endmethod
static method create takes tick t returns thistype
local thistype this = thistype.allocate( )
set MAX = MAX + 1
set .T = CreateTimerDialog( t.super )
return this
endmethod
method operator super takes nothing returns timerdialog
return .T
endmethod
method operator title= takes string s returns nothing
call TimerDialogSetTitle( .T, s )
endmethod
method operator speed= takes real r returns nothing
call TimerDialogSetSpeed( .T, r )
endmethod
method operator remaining= takes real r returns nothing
call TimerDialogSetRealTimeRemaining( .T, r )
endmethod
method operator visible= takes boolean f returns nothing
call TimerDialogDisplay( .T, f )
endmethod
method operator visible takes nothing returns boolean
return IsTimerDialogDisplayed( .T )
endmethod
method setTimeColor takes integer r, integer g, integer b returns nothing
call TimerDialogSetTimeColor( .T, r, g, b, 255 )
endmethod
method setTitleColor takes integer r, integer g, integer b returns nothing
call TimerDialogSetTitleColor( .T, r, g, b, 255 )
endmethod
method destroy takes nothing returns nothing
set MAX = MAX - 1
call DestroyTimerDialog( .T )
set .T = null
call thistype.deallocate( this )
endmethod
endstruct
endlibrary
//TESH.scrollpos=166
//TESH.alwaysfold=0
library Splash
globals
private player PSRC = null
private unit SRC = null
endglobals
private struct filter extends array
static method E takes nothing returns boolean
if not IsUnitEnemy( GetFilterUnit(), PSRC ) then
return false
endif
if IsUnitType( GetFilterUnit(), UNIT_TYPE_DEAD ) then
return false
endif
return true
endmethod
static method O takes nothing returns boolean
if GetOwningPlayer(GetFilterUnit()) != PSRC then
return false
endif
if IsUnitType( GetFilterUnit(), UNIT_TYPE_DEAD ) then
return false
endif
return true
endmethod
static method A takes nothing returns boolean
if not IsUnitAlly( GetFilterUnit(), PSRC ) then
return false
endif
if IsUnitType( GetFilterUnit(), UNIT_TYPE_DEAD ) then
return false
endif
return true
endmethod
static method W takes nothing returns boolean
return not IsUnitType( GetFilterUnit(), UNIT_TYPE_DEAD )
endmethod
static method ANOT takes nothing returns boolean
if not IsUnitAlly( GetFilterUnit(), PSRC ) then
return false
endif
if GetFilterUnit() == SRC then
return false
endif
if IsUnitType( GetFilterUnit(), UNIT_TYPE_DEAD ) then
return false
endif
return true
endmethod
endstruct
struct splash extends array
static boolexpr ENEMY = null
static boolexpr PLAYER = null
static boolexpr ALLY = null
static boolexpr ANY = null
static boolexpr ALLYNOTME = null
private static method onInit takes nothing returns nothing
set ENEMY = Filter( function filter.E )
set PLAYER = Filter( function filter.O )
set ALLY = Filter( function filter.A )
set ANY = Filter( function filter.W )
set ALLYNOTME = Filter( function filter.ANOT )
endmethod
static method operator source takes nothing returns unit
return SRC
endmethod
static method operator owner takes nothing returns player
return PSRC
endmethod
static method range takes boolexpr f, unit src, real x, real y, real rng, code c returns nothing
local party ul = party.create()
local player ppsrc = PSRC
local unit psrc = SRC
set SRC = src
set PSRC = GetOwningPlayer( src )
call GroupEnumUnitsInRange( ul.super, x, y, rng, f )
call ForGroup( ul.super, c )
call ul.destroy()
set SRC = psrc
set PSRC = ppsrc
set psrc = null
set ppsrc = null
endmethod
static method zone takes boolexpr f, unit src, real x, real y, real w, real h, code c returns nothing
local party ul = party.create()
local player ppsrc = PSRC
local rect r = Rect( x-w/2,y-h/2,x+w/2,y+h/2)
set PSRC = GetOwningPlayer( src )
call GroupEnumUnitsInRect( ul.super, r, f )
call ForGroup( ul.super, c )
call RemoveRect( r )
call ul.destroy()
set r = null
set PSRC = ppsrc
set ppsrc = null
endmethod
static method rect takes boolexpr f, unit src, rect r, code c returns nothing
local party ul = party.create()
local player ppsrc = PSRC
set PSRC = GetOwningPlayer( src )
call GroupEnumUnitsInRect( ul.super, r, f )
call ForGroup( ul.super, c )
call ul.destroy()
set PSRC = ppsrc
set ppsrc = null
endmethod
endstruct
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Party
struct party
private group G
static method create takes nothing returns thistype
local thistype this = thistype.allocate()
if .G == null then
set .G = CreateGroup()
endif
call GroupClear( .G )
return this
endmethod
method operator super takes nothing returns group
return .G
endmethod
method destroy takes nothing returns nothing
call thistype.deallocate( this )
endmethod
endstruct
endlibrary
//TESH.scrollpos=33
//TESH.alwaysfold=0
globals
integer redP = 0
endglobals
function set_round takes nothing returns nothing
local dialog dlg = DialogCreate()
local integer index
call DialogSetMessage(dlg,"set Max rounds")
call DialogAddButtonEx(dlg,"5",0)
call DialogAddButtonEx(dlg,"7",0)
call DialogAddButtonEx(dlg,"10",0)
call DialogAddButtonEx(dlg,"13",0)
call DialogAddButtonEx(dlg,"15",0)
set index = DialogDisplayModalWithTimerDialog(Player(redP), dlg, 10.00, "Rounds")
if(index == 0) then
set udg_Round = 5
elseif(index == 1) then
set udg_Round = 7
elseif(index == 2) then
set udg_Round = 10
elseif(index == 3) then
set udg_Round = 13
elseif(index == 4) then
set udg_Round = 15
endif
call DestroyTextTag( udg_text[1] )
call DestroyTextTag( udg_text[2] )
call DestroyTextTag( udg_text[3] )
call yd2(2)
call DialogDestroy(dlg)
set dlg = null
endfunction
function set_time takes nothing returns nothing
local dialog dlg = DialogCreate()
local integer index
call DialogSetMessage(dlg,"set Time Limit")
call DialogAddButtonEx(dlg,"35 sec",0)
call DialogAddButtonEx(dlg,"40 sec",0)
call DialogAddButtonEx(dlg,"45 sec",0)
call DialogAddButtonEx(dlg,"50 sec",0)
call DialogAddButtonEx(dlg,"55 sec",0)
call DialogAddButtonEx(dlg,"60 sec",0)
call DialogAddButtonEx(dlg,"70 sec",0)
call DialogAddButtonEx(dlg,"80 sec",0)
set index = DialogDisplayModalWithTimerDialog(Player(redP), dlg, 10.00, "set Time Limit")
if(index == 0) then
set udg_time = 35
elseif(index == 1) then
set udg_time = 40
elseif(index == 2) then
set udg_time = 45
elseif(index == 3) then
set udg_time = 50
elseif(index == 4) then
set udg_time = 55
elseif(index == 5) then
set udg_time = 60
elseif(index == 6) then
set udg_time = 70
elseif(index == 7) then
set udg_time = 80
endif
call DestroyTextTag( udg_text[1] )
call DestroyTextTag( udg_text[2] )
call DestroyTextTag( udg_text[3] )
call yd2(3)
call DialogDestroy(dlg)
set dlg = null
endfunction
function set_mode takes nothing returns nothing
local dialog dlg = DialogCreate()
local integer index
call DialogSetMessage(dlg,"set Mode")
call DialogAddButtonEx(dlg,"Default Mode",0)
call DialogAddButtonEx(dlg,"Random Mode(Random Exit)",0)
set index = DialogDisplayModalWithTimerDialog(Player(redP), dlg, 5.00, "set Mode")
if(index == 0) then
set udg_Mode = 0
set udg_modetext = "Default Mode"
elseif(index == 1) then
set udg_Mode = 1
set udg_modetext = "Random Exit/Entrance"
endif
call DestroyTextTag( udg_text[1] )
call DestroyTextTag( udg_text[2] )
call DestroyTextTag( udg_text[3] )
call yd2(1)
call DialogDestroy(dlg)
set dlg = null
endfunction