Warcraft III resources & community, 2003–2006 · archived

How to pick all Heroesfor a player?

2 posts
#1

How to pick all Heroesfor a player?

A friend of mine had asked me to write some JASS codes for him. My problem is how to pick all heroes for a player?
His code requires to add the mana of computer player's heroes every 60 seconds elapsed in game time. Can anyone help me? Thanks!
#2
IsUnitType(u, UNIT_TYPE_HERO) returns true if u is a hero.

function IsUnitHeroFilter takes nothing returns boolean
return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO)
endfunction

function GetHeroGroup takes player p returns group
local filterfunc f = Filter(function IsUnitHeroFilter)
local group g = CreateGroup()
call GroupEnumUnitsOfPlayer(g, p, f)
call DestroyFilter(f)
return g
endfunction