- Joined
- Apr 24, 2012
- Messages
- 9,802
Hi. You might have forgotten my invite to LoL.
Because your burning hehehe... wait, this isn't the jokes thread, sorry.It's so hotttttt
Sakura Trick (my fave!)
function LastOfGroup takes group g returns unit
local unit u
local unit v
loop
if FirstOfGroup(g) == null then
set u = v
endif
set v = FirstOfGroup(g)
exitwhen v == null
call GroupRemoveUnit(g, v)
endloop
return u
endfunction
function LastOfGroup takes group g, unit u returns unit
local integer unitcount
// [1] Terminate the troll function if the group is
// initially empty
if FirstOfGroup(g)==null then
return null
endif
// [2] Copy the group
// make a copy group function; preferably one that uses
// ForGroup, because there is a bug with null (removed
// units from the game) unit references within the group
// not being released
call CopyGroup(g, g_temp) // let's assume g_temp is a global variable
// [3] Count the number of units in the group
// counting the units within the group, I think, is better
// again this could be a custom function or the BJ function
// that is already provided by Blizzard
set unitcount = CountUnitsInGroup(g_temp)
// Find the last unit
loop
// check if this iteration is the last
// if it is, store the unit on the variable
if unitcount==1 then
set u=FirstOfGroup(g_temp)
endif
call GroupRemoveUnit(g_temp, FirstOfGroup(g_temp))
set unitcount = unitcount - 1
// terminate loop when the group is empty
exitwhen FirstOfGroup(g)==null
endloop
set g_temp = null // Prevent leaks in global variables by clearing
// their contents after use, jass weirdness. The
// leak in this case is found by troll_brain. The
// memory leak is garbage collecto(r/ion) related.
return u // this will leak if it is created within this function block
// that's another jass weirdness for you; won't leak though
// if the variable was declared as a parameter
endfunction
function ClosestOfGroup takes group g, real x, real y returns unit
local real r
local real record
local real tx
local real ty
local unit u
local unit v
loop
set v = FirstOfGroup(g)
exitwhen v == null
set tx = GetUnitX(v)
set ty = GetUnitY(v)
set r = SquareRoot((tx-x)*(tx-x)+(ty-y)*(ty-y))
if r < record then
set record = r
set u = v
endif
call GroupRemoveUnit(g, v)
endloop
return u
endfunction
library troll initializer init
private function init takes nothing returns nothing
//Do victory here
endfunction
endlibrary
Orcnet;2521855 said:Half of the week I've been doing meet ups on my little business sideline, pretty successful and time consuming.
Went on a Fully Booked comic event yesterday and met comic artist Whilce Portacio, really nice guy and such a bad-ass.
Expecting to only get 3 free comics from that day, end up getting 30 pieces haha.