Converted MQ2 TLO - NearestSpawn (Untested)

Moderator: MacroQuest Developers

theduck
orc pawn
orc pawn
Posts: 26
Joined: Mon Dec 15, 2003 4:24 am

Converted MQ2 TLO - NearestSpawn (Untested)

Post by theduck » Thu Sep 22, 2005 2:58 pm

Ditto: Needed a place to stick this so if you want to test it and tell me if it formats your hard drive or anything... <evil grin>

Spawn.NearestSpawn[blah blah] works currently unless the spawn is you (e.g. ${Me.NearestSpawn[npc]} doesn't work because it specifically uses the TLO.

So this is mostly just a code copy and paste, should work, may not, but here goes. Will test once I'm able and we have offsets and other goodness.

MQ2Data.cpp

Code: Select all

TLO(dataNearestSpawn)
{
#ifndef ISXEQ
	if (ISINDEX())
	{
		PCHAR pSearch;
		unsigned long nth;
		SEARCHSPAWN ssSpawn;
		ClearSearchSpawn(&ssSpawn);
		ssSpawn.FRadius=999999.0f;
		if (pSearch=strchr(szIndex,','))
		{
			*pSearch=0;
			++pSearch;
			ParseSearchSpawn(pSearch,&ssSpawn);
			nth=GETNUMBER();
		}
		else
		{
			if (IsNumberToComma(szIndex))
			{
				nth=GETNUMBER();
			}
			else
			{
				nth=1;
				ParseSearchSpawn(szIndex,&ssSpawn);
			}
		}

		for (unsigned long N = 0 ; N < gSpawnCount ; N++)
		{
			if (EQP_DistArray[N].Value.Float>ssSpawn.FRadius)
				return false;
			if (SpawnMatchesSearch(&ssSpawn,(PSPAWNINFO)pCharSpawn,(PSPAWNINFO)EQP_DistArray[N].VarPtr.Ptr))
			{
				if (--nth==0)
				{
					Ret.Ptr=EQP_DistArray[N].VarPtr.Ptr;
					Ret.Type=pSpawnType;
					return true;
				}
			}
		}
	}
#else
   if (argc)
	{
		unsigned long nth;
		SEARCHSPAWN ssSpawn;
		ClearSearchSpawn(&ssSpawn);
		ssSpawn.FRadius=999999.0f;
		if (argc>=2 || !IsNumber(argv[0]))
		{
			ParseSearchSpawn(1,argc,argv,ssSpawn);
			nth=atoi(argv[0]);
		}
		else
		{
			nth=atoi(argv[0]);
		}
		
		for (unsigned long N = 0 ; N < gSpawnCount ; N++)
		{
			if (EQP_DistArray[N].Value.Float>ssSpawn.FRadius)
				return false;
			if (SpawnMatchesSearch(&ssSpawn,(PSPAWNINFO)pCharSpawn,(PSPAWNINFO)EQP_DistArray[N].VarPtr.Ptr))
			{
				if (--nth==0)
				{
					Ret.Ptr=EQP_DistArray[N].VarPtr.Ptr;
					Ret.Type=pSpawnType;
					return true;
				}
			}
		}
	}
#endif
	return false;
}
*QUACK*

echoism
a ghoul
a ghoul
Posts: 131
Joined: Tue Oct 19, 2004 9:59 am

Post by echoism » Sat Dec 17, 2005 10:03 pm

I was not able to use this with much success.

The only way I got any mildly useful info from it, was with:
${Spawn[npc].NearestSpawn[1,partial name]}

I wasn't able to use Spawn[pc], (including Spawn[pc,name]), range, radius, etc.

It did work with [npc,name], but thats was it.