Spawn in Zone only.
Displaying 1-6 of 6 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Keast

As my next step towards making this board my personal advice counsel, I announce that:

I do not know how to make them npcs spawn inside one zone only (I really do not want them on the sofa). Is there any idea you guys have?

Thanks.

Posted on 2011-04-04 08:44:03 (last edited on 2011-04-04 08:48:40)

mcgrue

Are you generating NPCs dynamically, or do you just want to plop them on a map and have them wander around inside of a zone?

Posted on 2011-04-04 15:34:19

Keast

I don't understand the "dynamically", but I guess the second one is right: At StartMap, spawn a random number of NPCs within one zone and make them wander around in it.

Posted on 2011-04-04 15:45:06

pthaloearth

this is untested but should (more or less) do what you want

void randomSpawnNPC(int amt,int z)
{
	/*
	amt=total entities you want on the map
	z=zone you want them on
	*/
	
	int i,mapW,mapH,entIndex;
	string npcChr;	

	for(i=0;i<amt;i++)
	{
		//grab a random x,y cord for the entity
		mapW=random(0,curmap.w);
		mapH=random(0,curmap.h);

		//grab a random NPC chr file to throw on the map
		switch(random(0,5))
		{
			CASE 0: npcChr="0.chr"
			CASE 1: npcChr="1.chr"
			CASE 2: npcChr="2.chr"
			CASE 3: npcChr="3.chr"
			CASE 4: npcChr="4.chr"
			CASE 5: npcChr="5.chr"
		}

		//check if the zone is proper		
		if(getZone(mapH,MapW)==z)
		{
			entIndex=EntitySpawn(mapW,mapH,npcChr);
			EntitySetWanderZone(entIndex);
		}
		else i--;//if it's wrong try again (simply...)
	}
}

Posted on 2011-04-04 21:21:05

Keast

Thaaaank you guys. You're seriously awesome.

- and i feel stupid -

Posted on 2011-04-05 14:57:02

mcgrue

The road to smartness is paved with feeling stupid and not letting that deter you.

Posted on 2011-04-05 16:17:23


Displaying 1-6 of 6 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.