• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Enumerate units with rawcode 'XXXX' in map

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,337
Hi,

What native enumerates all the units whose rawcode == 'XXXX' in the entire map?

I found these, but I am confused why they require a group as an argument.

Which one would I use, the rect (and make the rect the entire map), or the second one?

JASS:
GroupEnumUnitsInRect
//or this one?
GroupEnumUnitsOfType
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
Aye I did figure it out eventually.

JASS:
library NPCLoc requires Print
//returns the location of a unique NPC in the map
globals
	location npcLoc
endglobals

private function main takes nothing returns nothing
	//call KillUnit(GetEnumUnit())
	//call print("killed a unit")
	set npcLoc = GetUnitLoc(GetEnumUnit())
endfunction

function getNPCLoc takes integer npcId returns location
	local group g = CreateGroup()
	set g = GetUnitsOfTypeIdAll(npcId)
	//call GroupEnumUnitsOfType(g, npcStr, null) //enumerate the group
	call ForGroup(g, function main)
	call DestroyGroup(g)
	return npcLoc
endfunction

endlibrary
 
Status
Not open for further replies.
Top