//TESH.scrollpos=0
//TESH.alwaysfold=0
//*************************************************************************************************
// Caster System Free Attach Variables / Sets and Tables (from 12.7)
//
// Requirement: gamecache global variable udg_cscache
//
//*************************************************************************************************
//##Begin of CS Gamecache engine##
//=================================================================================================
// GameCache - Return bug module : Without gamecache or return bug, JASS would be a
// retarded-limited scripting language.
//
//=================================================================================================
// a.k.a H2I, changed name to CS_H2I to prevent conflicts with other systems (I intended this
// system to be easy to copy
//
function CS_H2I takes handle h returns integer
return h
return 0
endfunction
//=================================================================================================
// Main Gamecache handler
//
function CSCache takes nothing returns gamecache
if udg_cscache==null then
call FlushGameCache(InitGameCache("CasterSystem.vx"))
set udg_cscache=InitGameCache("CasterSystem.vx")
call StoreInteger(udg_cscache,"misc","TableMaxReleasedIndex",100)
endif
return udg_cscache
endfunction
//==================================================================================================
// Attachable vars : Attacheable variables are what most other people call Handle Variables, they
// allow to relate data with any handle, using a label, and its value, the stuff auto flushes if
// the value is 0, false, "", or null .
//
// Differences between Attacheable variables and "Local Handle Variables" :
// - The names of the functions
// - The name of the function group does not cause confusion, it is difficult to say:
// "you should set local handle variables to null at the end of a function" since
// it sounds as if you were talking about the "Local Handle Variables"
// - Also Have Attacheable Sets.
// - And can work together with Tables.
//
// Notes: don't "attach" variables on texttags nor those handle types used mostly for parameters
// (for example damagetype) , Although there is no reason to do so anyways
//
// Gamecache stuff are NOT Case Sensitive, don't ever use "" for label (Crashes game!)
//
//============================================================================================================
// For integers
//
function AttachInt takes handle h, string label, integer x returns nothing
local string k=I2S(CS_H2I(h))
if x==0 then
call FlushStoredInteger(CSCache(),k,label)
else
call StoreInteger(CSCache(),k,label,x)
endif
endfunction
function GetAttachedInt_FromSet takes handle h, gamecache g returns integer
return GetStoredInteger(g,I2S(CS_H2I(h))+";"+GetStoredString(g,"argpass","set"),GetStoredString(g,"argpass","seti"))
endfunction
function GetAttachedInt takes handle h, string label returns integer
if (label=="") then
return GetAttachedInt_FromSet(h,CSCache())
endif
return GetStoredInteger(CSCache(), I2S(CS_H2I(h)), label)
endfunction
//=============================================================================================================
function AttachReal takes handle h, string label, real x returns nothing
local string k=I2S(CS_H2I(h))
if x==0 then
call FlushStoredReal(CSCache(),k,label)
else
call StoreReal(CSCache(),k,label,x)
endif
endfunction
function GetAttachedReal takes handle h, string label returns real
return GetStoredReal(CSCache(),I2S(CS_H2I(h)),label)
endfunction
//=============================================================================================================
function AttachBoolean takes handle h, string label, boolean x returns nothing
local string k=I2S(CS_H2I(h))
if not x then
call FlushStoredBoolean(CSCache(),k,label)
else
call StoreBoolean(CSCache(),k,label,x)
endif
endfunction
function GetAttachedBoolean takes handle h, string label returns boolean
return GetStoredBoolean(CSCache(),I2S(CS_H2I(h)),label)
endfunction
//=============================================================================================================
function AttachString takes handle h, string label, string x returns nothing
local string k=I2S(CS_H2I(h))
if x=="" then
call FlushStoredString(CSCache(),k,label)
else
call StoreString(CSCache(),k,label,x)
endif
endfunction
function GetAttachedString takes handle h, string label returns string
return GetStoredString(CSCache(),I2S(CS_H2I(h)),label)
endfunction
//=============================================================================================================
function AttachObject takes handle h, string label, handle x returns nothing
local string k=I2S(CS_H2I(h))
if (x==null) then
call FlushStoredInteger(CSCache(),k,label)
else
call StoreInteger(CSCache(),k,label,CS_H2I(x))
endif
endfunction
function GetAttachedObject takes handle h, string label returns handle
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedWidget takes handle h, string label returns widget
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedRect takes handle h, string label returns rect
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedRegion takes handle h, string label returns region
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedTimerDialog takes handle h, string label returns timerdialog
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedUnit takes handle h, string label returns unit
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedItem takes handle h, string label returns item
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedEffect takes handle h, string label returns effect
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedDestructable takes handle h, string label returns destructable
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedTrigger takes handle h, string label returns trigger
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedTimer takes handle h, string label returns timer
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedGroup takes handle h, string label returns group
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedTriggerAction takes handle h, string label returns triggeraction
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedLightning takes handle h, string label returns lightning
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedImage takes handle h, string label returns image
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedUbersplat takes handle h, string label returns ubersplat
return GetAttachedInt(h,label)
return null
endfunction
//============================================================================================================
// Attached Sets: Attachable Sets are handy in some situations and are a part of attachable variables,
// you can add integers or objects to a set, order doesn't matter and adding the same object twice is
// meaningless. CleanAttachedVars is always ready to clean every set owned by the handle.
//
//============================================================================================================
function AttachedSetAddInt takes handle h, string setn, integer int returns nothing
local gamecache g=CSCache()
local string k=I2S(CS_H2I(h))
local integer n
local integer x=GetStoredInteger(g,k,"#setnumberof;"+setn)
local integer y
if x==0 then
set y=GetStoredInteger(g,k,"#totalsets")+1
call StoreInteger(g,k,"#totalsets",y)
call StoreInteger(g,k,"#setnumberof;"+setn,y)
call StoreString(g,k,"#setName;"+I2S(y),setn)
endif
set k=k+";"+setn
if not HaveStoredInteger(g,k,"Pos"+I2S(int)) then
set n=GetStoredInteger(g,k,"n")+1
call StoreInteger(g,k,"n",n)
call StoreInteger(g,k,I2S(n),int)
call StoreInteger(g,k,"Pos"+I2S(int),n)
endif
set g=null
endfunction
function AttachedSetAddObject takes handle h, string setn, handle val returns nothing
call AttachedSetAddInt(h,setn,CS_H2I(val))
endfunction
//============================================================================================================
function AttachedSetHasInt takes handle h, string setn, integer int returns boolean
return HaveStoredInteger(CSCache(),I2S(CS_H2I(h))+";"+setn,"Pos"+I2S(int))
endfunction
function AttachedSetHasObject takes handle h, string setn, handle val returns boolean
return AttachedSetHasInt(h,setn,CS_H2I(val))
endfunction
//============================================================================================================
function GetAttachedSetSize takes handle h, string setn returns integer
return GetStoredInteger(CSCache(),I2S(CS_H2I(h))+";"+setn,"n")
endfunction
//============================================================================================================
function AttachedSetRemInt takes handle h, string setn, integer int returns nothing
local gamecache g=CSCache()
local string k=I2S(CS_H2I(h))+";"+setn
local integer n
local integer x
local integer y
if HaveStoredInteger(g,k,"Pos"+I2S(int)) then
set x=GetStoredInteger(g,k,"Pos"+I2S(int))
set n=GetStoredInteger(g,k,"n")
if x!=n then
set y=GetStoredInteger(g,k,I2S(n))
call StoreInteger(g,k,I2S(x),y)
call StoreInteger(g,k,"Pos"+I2S(y),x)
endif
call FlushStoredInteger(g,k,"Pos"+I2S(int))
call FlushStoredInteger(g,k,I2S(n))
call StoreInteger(g,k,"n",n-1)
endif
set g=null
endfunction
function AttachedSetRemObject takes handle h, string setn, handle val returns nothing
call AttachedSetRemInt(h,setn,CS_H2I(val))
endfunction
//============================================================================================================
function FromSetElement takes string setn, integer index returns string
local gamecache g=CSCache()
call StoreString(g,"argpass","set",setn)
call StoreString(g,"argpass","seti",I2S(index))
set g=null
return ""
endfunction
//============================================================================================================
function ClearAttachedSet takes handle h, string setn returns nothing
call FlushStoredMission(CSCache(),I2S(CS_H2I(h))+";"+setn)
endfunction
function CleanAttachedVars takes handle h returns nothing
local gamecache g=CSCache()
local string k=I2S(CS_H2I(h))
local integer n=GetStoredInteger(g,k,"#totalsets")
local integer i=1
loop
exitwhen i>n
call FlushStoredMission(g,k+";"+GetStoredString(g,k,"#setName;"+I2S(i)))
set i=i+1
endloop
call FlushStoredMission(g, k )
set g=null
endfunction
function CleanAttachedVars_NoSets takes handle h returns nothing
call FlushStoredMission(CSCache(), I2S(CS_H2I(h)) )
endfunction
//=============================================================================================
// Tables
//
// Tables are lame, the real name would be hash tables, they are just abbreviated usage
// of gamecache natives with the addition that you can also Copy the values of a table to
// another one, but don't expect it to be automatic, it must use a FieldData object to know
// which fields and of wich types to copy, Copying a table to another, with a lot of Fields,
// should surelly be lag friendly.
//
// The other thing about tables is that I can say that the Attached variables of a handle work
// inside a table and GetAttachmentTable which is just return bug and I2S , works to allow you
// to manipulate a handle's attached variables through a table.
//
// NewTable and DestroyTable were created to allow to create tables in the fly, but you can
// simply use strings for tables, but place the table names should be between "("")" for example
// "(mytable)" to avoid conflicts with other caster system stuff.
//
function NewTableIndex takes nothing returns integer
local gamecache g=CSCache()
local integer n=GetStoredInteger(g,"misc","FreeTableTotal")
local integer i
if (n>0) then
set i=GetStoredInteger(g,"misc","FreeTable1")
if (n>1) then
call StoreInteger(g,"misc","FreeTable1", GetStoredInteger(g,"misc","FreeTable"+I2S(n)) )
call FlushStoredInteger(g,"misc","FreeTable"+I2S(n))
endif
call StoreInteger(g,"misc","FreeTableTotal", n-1)
else
set i=GetStoredInteger(g,"misc","TableMaxReleasedIndex")+1
call StoreInteger(g,"misc","TableMaxReleasedIndex",i)
endif
call StoreBoolean(g,"misc","Created"+I2S(i),true)
set g=null
return i
endfunction
function NewTable takes nothing returns string
return I2S(NewTableIndex())
endfunction
function GetAttachmentTable takes handle h returns string
return I2S(CS_H2I(h))
endfunction
//============================================================================================================
function DestroyTable takes string table returns nothing
local gamecache g=CSCache()
local integer i=S2I(table)
local integer n
if (i!=0) and (GetStoredBoolean(g,"misc","Created"+table)) then
call FlushStoredBoolean(g,"misc","Created"+table)
set n=GetStoredInteger(g,"misc","FreeTableTotal")+1
call StoreInteger(g,"misc","FreeTableTotal",n)
call StoreInteger(g,"misc","FreeTable"+I2S(n),i)
endif
call FlushStoredMission(g,table)
set g=null
endfunction
//============================================================================================================
function ClearTable takes string table returns nothing
call FlushStoredMission(CSCache(),table)
endfunction
//============================================================================================================
function SetTableInt takes string table, string field, integer val returns nothing
local gamecache g=CSCache()
if (val==0) then
call FlushStoredInteger(g,table,field)
else
call StoreInteger(g,table,field,val)
endif
set g=null
endfunction
function GetTableInt takes string table, string field returns integer
return GetStoredInteger(CSCache(),table,field)
endfunction
//============================================================================================================
function SetTableReal takes string table, string field, real val returns nothing
local gamecache g=CSCache()
if (val==0) then
call FlushStoredReal(g,table,field)
else
call StoreReal(g,table,field,val)
endif
set g=null
endfunction
function GetTableReal takes string table, string field returns real
return GetStoredReal(CSCache(),table,field)
endfunction
//============================================================================================================
function SetTableBoolean takes string table, string field, boolean val returns nothing
local gamecache g=CSCache()
if (not(val)) then
call FlushStoredBoolean(g,table,field)
else
call StoreBoolean(g,table,field,val)
endif
set g=null
endfunction
function GetTableBoolean takes string table, string field returns boolean
return GetStoredBoolean(CSCache(),table,field)
endfunction
//============================================================================================================
function SetTableString takes string table, string field, string val returns nothing
local gamecache g=CSCache()
if (val=="") or (val==null) then
call FlushStoredString(g,table,field)
else
call StoreString(g,table,field,val)
endif
set g=null
endfunction
function GetTableString takes string table, string field returns string
return GetStoredString(CSCache(),table,field)
endfunction
//============================================================================================================
// You may ask why am I using thousands of functions instead of multi-use return bug exploiters? Well,
// these make the thing much easier to read (in my opinion) and it is also better in performance since we
// have less function calls (H2U(GetTableObject("table","unit"))) would be worse than GetTableUnit that is
// quite direct.
//
function SetTableObject takes string table, string field, handle val returns nothing
local gamecache g=CSCache()
if (val==null) then
call FlushStoredInteger(g,table,field)
else
call StoreInteger(g,table,field,CS_H2I(val))
endif
set g=null
endfunction
function GetTableObject takes string table, string field returns handle
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableWidget takes string table, string field returns widget
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableRect takes string table, string field returns rect
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableRegion takes string table, string field returns region
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableTimerDialog takes string table, string field returns timerdialog
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableUnit takes string table, string field returns unit
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableItem takes string table, string field returns item
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableEffect takes string table, string field returns effect
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableDestructable takes string table, string field returns destructable
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableTrigger takes string table, string field returns trigger
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableTimer takes string table, string field returns timer
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableGroup takes string table, string field returns group
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableTriggerAction takes string table, string field returns triggeraction
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableLightning takes string table, string field returns lightning
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableImage takes string table, string field returns image
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableUbersplat takes string table, string field returns ubersplat
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
//============================================================================================================
// Returns true if the fiel contains a value different from 0, false, null, or "" (depending on the type)
// it is worthless to use this with boolean, since it would be the same as reading the boolean value
//
function HaveSetField takes string table, string field, integer fieldType returns boolean
if (fieldType == bj_GAMECACHE_BOOLEAN) then
return HaveStoredBoolean(CSCache(),table,field)
elseif (fieldType == bj_GAMECACHE_INTEGER) then
return HaveStoredInteger(CSCache(),table,field)
elseif (fieldType == bj_GAMECACHE_REAL) then
return HaveStoredReal(CSCache(),table,field)
elseif (fieldType == bj_GAMECACHE_STRING) then
return HaveStoredString(CSCache(),table,field)
endif
return false
endfunction
//============================================================================================================
// Allows to copy a table to another one, but it needs a FieldData object to know which fields of which type
// it is supposed to copy.
//
function CopyTable takes integer FieldData, string sourceTable, string destTable returns nothing
local gamecache g=CSCache()
local integer i=1
local string k=I2S(FieldData)
local string k2
local string k3
local integer n=GetStoredInteger(g,k,"N")
local integer t
loop
exitwhen (i>n)
set k2=I2S(i)
set t=GetStoredInteger(g,k,k2)
set k3=GetStoredString(g,k,k2)
if (t==bj_GAMECACHE_BOOLEAN) then
if (HaveStoredBoolean(g,sourceTable,k3)) then
call StoreBoolean(g,destTable,k3,GetStoredBoolean(g,sourceTable,k3))
else
call FlushStoredBoolean(g,destTable,k3)
endif
elseif (t==bj_GAMECACHE_INTEGER) then
if (HaveStoredInteger(g,sourceTable,k3)) then
call StoreInteger(g,destTable,k3,GetStoredInteger(g,sourceTable,k3))
else
call FlushStoredInteger(g,destTable,k3)
endif
elseif (t==bj_GAMECACHE_REAL) then
if (HaveStoredReal(g,sourceTable,k3)) then
call StoreReal(g,destTable,k3,GetStoredReal(g,sourceTable,k3))
else
call FlushStoredReal(g,destTable,k3)
endif
elseif (t==bj_GAMECACHE_STRING) then
if (HaveStoredString(g,sourceTable,k3)) then
call StoreString(g,destTable,k3,GetStoredString(g,sourceTable,k3))
else
call FlushStoredString(g,destTable,k3)
endif
endif
set i=i+1
endloop
set g=null
endfunction
//=============================================================================================
// FieldData inherits from Table, was just designed to be used by CopyTable.
//
function FieldData_Create takes nothing returns integer
return NewTableIndex()
endfunction
//============================================================================================================
// valueType uses the same integer variables from blizzard.j :
// bj_GAMECACHE_BOOLEAN, bj_GAMECACHE_INTEGER, bj_GAMECACHE_REAL and bj_GAMECACHE_STRING
//
function FieldData_AddField takes integer fielddata, string field, integer valueType returns nothing
local gamecache g=CSCache()
local string k=I2S(fielddata)
local integer n=GetStoredInteger(g,k,"N")+1
local string k2=I2S(n)
call StoreString(g,k,k2,field)
call StoreInteger(g,k,k2,valueType)
call StoreInteger(g,k,"N",n)
set g=null
endfunction
//=============================================================================================
// Destroys Field Data
function FieldData_Destroy takes integer fielddata returns nothing
call DestroyTable(I2S(fielddata))
endfunction
//##End of CS Gamecache engine##
Name | Type | is_array | initial_value |
AIInteger | integer | Yes | |
AIPoint | location | Yes | |
cscache | gamecache | No | |
DeathNote | string | Yes | |
East_Death | integer | No | |
East_Kill | integer | No | |
HeroAgi | real | Yes | 3.00 |
Multiboard | multiboard | No | |
Player_Color | string | Yes | |
Player_Death | integer | Yes | |
Player_Kill | integer | Yes | |
Player_Name | string | Yes | |
StringColorEnd | string | No | |
West_Death | integer | No | |
West_Kill | integer | No | |
zInteger | integer | No |
//TESH.scrollpos=25
//TESH.alwaysfold=0
function InitMultiboard_Filter takes nothing returns boolean
return GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING
endfunction
function InitMultiboard_Actions takes nothing returns nothing
local integer i = CountPlayersInForceBJ(GetPlayersMatching(Condition(function InitMultiboard_Filter)))
local integer cnt = 0
set udg_Multiboard = CreateMultiboard()
call MultiboardDisplay(udg_Multiboard,true)
call MultiboardSetRowCount(udg_Multiboard,i + 3)
call MultiboardSetColumnCount(udg_Multiboard,3)
call MultiboardSetTitleText(udg_Multiboard,"|c007ebff1Archers Again v1.2 +AI|r")
loop
exitwhen cnt == i + 3
call MultiboardSetItemStyleBJ(udg_Multiboard,1,cnt,true,false)
call MultiboardSetItemStyleBJ(udg_Multiboard,2,cnt,true,false)
call MultiboardSetItemStyleBJ(udg_Multiboard,3,cnt,true,false)
call MultiboardSetItemValueBJ(udg_Multiboard,1,cnt,udg_Player_Name[cnt - 1])
call MultiboardSetItemValueBJ(udg_Multiboard,2,cnt,I2S(udg_Player_Kill[cnt - 1]))
call MultiboardSetItemValueBJ(udg_Multiboard,3,cnt,I2S(udg_Player_Death[cnt - 1]))
call MultiboardSetItemWidthBJ(udg_Multiboard,1,cnt,10)
call MultiboardSetItemWidthBJ(udg_Multiboard,2,cnt,4)
call MultiboardSetItemWidthBJ(udg_Multiboard,3,cnt,4)
set cnt = cnt + 1
endloop
call MultiboardSetItemValueBJ(udg_Multiboard,1,1,"|c00106246Player")
call MultiboardSetItemValueBJ(udg_Multiboard,2,1,"|c00106246Kills")
call MultiboardSetItemValueBJ(udg_Multiboard,3,1,"|c00106246Deaths")
call MultiboardSetItemValueBJ(udg_Multiboard,1,10,"|c004e2a04West Team")
call MultiboardSetItemValueBJ(udg_Multiboard,2,10,I2S(udg_West_Kill))
call MultiboardSetItemValueBJ(udg_Multiboard,3,10,I2S(udg_West_Death))
call MultiboardSetItemValueBJ(udg_Multiboard,1,11,"|c004e2a04East Team")
call MultiboardSetItemValueBJ(udg_Multiboard,2,11,I2S(udg_East_Kill))
call MultiboardSetItemValueBJ(udg_Multiboard,3,11,I2S(udg_East_Death))
endfunction
function InitTrig_InitMultiboard takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEventSingle(t,1)
call TriggerAddAction(t,function InitMultiboard_Actions)
set t = null
endfunction
//TESH.scrollpos=5
//TESH.alwaysfold=0
function Revive_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'H000'
endfunction
function Revive_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit k = GetKillingUnit()
local location p
local player pla = GetOwningPlayer(u)
local player kill = GetOwningPlayer(k)
local integer ui = GetPlayerId(pla) + 1
local integer ki = GetPlayerId(kill) + 1
call DisplayTimedTextToForce(GetPlayersAll(),4.0,udg_Player_Name[ki] + udg_DeathNote[GetRandomInt(1,9)] + udg_Player_Name[ui] + "!!")
call DisplayTimedTextToForce(GetPlayersAll(),4.0,"============================")
if IsUnitAlly(u,Player(0)) then
set udg_Player_Kill[ki] = udg_Player_Kill[ki] + 1
call MultiboardSetItemValueBJ(udg_Multiboard,2,ki + 1,I2S(udg_Player_Kill[ki]))
set udg_Player_Death[ui] = udg_Player_Death[ui] + 1
call MultiboardSetItemValueBJ(udg_Multiboard,3,ui + 1,I2S(udg_Player_Death[ui]))
set udg_East_Kill = udg_East_Kill + 1
call MultiboardSetItemValueBJ(udg_Multiboard,2,11,I2S(udg_East_Kill))
set udg_West_Death = udg_West_Death + 1
call MultiboardSetItemValueBJ(udg_Multiboard,3,10,I2S(udg_West_Death))
set p = GetRandomLocInRect(gg_rct_west)
call PolledWait(5)
call ReviveHeroLoc(u,p,true)
call SelectUnitAddForPlayer(u,pla)
call PanCameraToLocForPlayer(pla,p)
call RemoveLocation(p)
set p = null
set u = null
set k = null
set pla = null
set kill = null
else
set udg_Player_Kill[ki] = udg_Player_Kill[ki] + 1
call MultiboardSetItemValueBJ(udg_Multiboard,2,ki + 1,I2S(udg_Player_Kill[ki]))
set udg_Player_Death[ui] = udg_Player_Death[ui] + 1
call MultiboardSetItemValueBJ(udg_Multiboard,3,ui + 1,I2S(udg_Player_Death[ui]))
set udg_West_Kill = udg_West_Kill + 1
call MultiboardSetItemValueBJ(udg_Multiboard,2,10,I2S(udg_West_Kill))
set udg_East_Death = udg_East_Death + 1
call MultiboardSetItemValueBJ(udg_Multiboard,3,11,I2S(udg_East_Death))
set p = GetRandomLocInRect(gg_rct_east)
call PolledWait(5)
call ReviveHeroLoc(u,p,true)
call SelectUnitAddForPlayer(u,pla)
call PanCameraToLocForPlayer(pla,p)
call RemoveLocation(p)
set p = null
set u = null
set k = null
set pla = null
set kill = null
endif
endfunction
//===========================================================================
function InitTrig_Revive takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(t,Condition(function Revive_Conditions))
call TriggerAddAction(t,function Revive_Actions)
set t = null
endfunction
//TESH.scrollpos=3
//TESH.alwaysfold=0
function MA_Filter2 takes nothing returns boolean
return GetUnitTypeId(GetFilterUnit()) != 'h001'
endfunction
function MA_Filter1 takes nothing returns boolean
return IsUnitAliveBJ(GetFilterUnit()) == true
endfunction
function MA_Filter takes nothing returns boolean
return MA_Filter1() and MA_Filter2()
endfunction
function MA_Effect takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit c = GetAttachedUnit(t,"caster")
local unit d = GetAttachedUnit(t,"dummy")
local unit u
local real x1 = GetAttachedReal(t,"x1")
local real y1 = GetAttachedReal(t,"y1")
local real x2 = GetAttachedReal(t,"x2")
local real y2 = GetAttachedReal(t,"y2")
local real dis = GetAttachedReal(t,"distance")
local real dam = GetAttachedReal(t,"damage")
local real ang = GetAttachedReal(t,"angle")
local location p
local boolean tar = GetAttachedBoolean(t,"target")
if dis > 0 then
if IsUnitAliveBJ(d) == false then
set dis = 0
call AttachReal(t,"distance",dis)
endif
set dis = dis - 1
call AttachReal(t,"distance",dis)
call SetUnitPosition(d,GetUnitX(d) + 34 * Cos(ang * bj_DEGTORAD),GetUnitY(d) + 34 * Sin(ang * bj_DEGTORAD))
set u = GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(80,GetUnitLoc(d),Condition(function MA_Filter)))
if IsUnit(u,null) == false and IsUnit(u,c) == false and IsUnit(u,d) == false and IsUnitEnemy(u,GetOwningPlayer(c)) == true then
set dis = 0
call AttachReal(t,"distance",dis)
set tar = true
call AttachBoolean(t,"target",tar)
call UnitDamageTarget(c,u,dam,true,false,ATTACK_TYPE_PIERCE,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_METAL_LIGHT_SLICE)
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Orc\\Orcblood\\BattrollBlood.mdl",u,"chest"))
set u = null
endif
else
call KillUnit(d)
set p = GetUnitLoc(d)
call PauseTimer(t)
if tar == false then
call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl",GetUnitLoc(c)))
call SetUnitPositionLoc(c,p)
call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl",GetUnitLoc(c)))
if IsUnitAliveBJ(c) == true then
call SetUnitAnimation(c,"Stand Ready")
endif
call PanCameraToTimedLocForPlayer(GetOwningPlayer(c),p,0.5)
call RemoveLocation(p)
set p = null
endif
call CleanAttachedVars(t)
call DestroyTimer(t)
set t = null
set c = null
set d = null
endif
call RemoveLocation(p)
set p = null
set t = null
set c = null
set u = null
set d = null
endfunction
function MA_Actions takes nothing returns nothing
local timer t = CreateTimer()
local unit c = GetTriggerUnit()
local unit d
local integer i = GetPlayerId(GetOwningPlayer(c)) + 1
local location p = GetSpellTargetLoc()
local real x1 = GetUnitX(c)
local real y1 = GetUnitY(c)
local real x2 = GetLocationX(p)
local real y2 = GetLocationY(p)
local real dis = 50
local real dam = 20 * 10 + udg_HeroAgi[i]
local real ang = bj_RADTODEG * Atan2(y2 - y1, x2 - x1)
set d = CreateUnit(GetOwningPlayer(c),'h001',GetUnitX(c) + 40 * Cos(ang * bj_DEGTORAD),GetUnitY(c) + 40 * Sin(ang * bj_DEGTORAD),ang)
call AttachObject(t,"caster",c)
call AttachObject(t,"dummy",d)
call AttachReal(t,"x1",x1)
call AttachReal(t,"y1",y1)
call AttachReal(t,"x2",x2)
call AttachReal(t,"y2",y2)
call AttachReal(t,"angle",ang)
call AttachReal(t,"distance",dis)
call AttachReal(t,"damage",dam)
call TimerStart(t,0.03,true,function MA_Effect)
call RemoveLocation(p)
set t = null
set c = null
set d = null
set p = null
endfunction
function MA_Condition takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function InitTrig_MA takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i == 16
call TriggerRegisterPlayerUnitEvent(t,Player(i),ConvertPlayerUnitEvent(274),null)
set i = i + 1
endloop
call TriggerAddCondition(t,Condition(function MA_Condition))
call TriggerAddAction(t,function MA_Actions)
set t = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Remove_Arrows_Condition takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'h001'
endfunction
function Remove_Arrows_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
call PolledWait(1)
call RemoveUnit(u)
set u = null
endfunction
function InitTrig_Remove_Arrows takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(t,Condition(function Remove_Arrows_Condition))
call TriggerAddAction(t,function Remove_Arrows_Actions)
set t = null
endfunction
//TESH.scrollpos=10
//TESH.alwaysfold=0
function Border_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
call KillUnit(u)
set u = null
endfunction
function Border_Condition takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'h001'
endfunction
function InitTrig_Border takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterEnterRectSimple(t, gg_rct_bottomborder )
call TriggerRegisterEnterRectSimple(t, gg_rct_bottomleftborder )
call TriggerRegisterEnterRectSimple(t, gg_rct_bottomleftborder2 )
call TriggerRegisterEnterRectSimple(t, gg_rct_bottomrightborder )
call TriggerRegisterEnterRectSimple(t, gg_rct_bottomrightborder2 )
call TriggerRegisterEnterRectSimple(t, gg_rct_leftborder )
call TriggerRegisterEnterRectSimple(t, gg_rct_rightborder )
call TriggerRegisterEnterRectSimple(t, gg_rct_topborder )
call TriggerRegisterEnterRectSimple(t, gg_rct_topleftborder )
call TriggerRegisterEnterRectSimple(t, gg_rct_topleftborder2 )
call TriggerRegisterEnterRectSimple(t, gg_rct_toprightborder )
call TriggerRegisterEnterRectSimple(t, gg_rct_toprightborder2 )
call TriggerAddCondition(t,Condition(function Border_Condition))
call TriggerAddAction(t, function Border_Actions )
set t = null
endfunction