Jump to content
  • 0

(Question)Check if npc is in map


regal

Question

Hello, everyone! :) 

I hope you have/had a nice day.

So, I want to spawn a NPC via quest.

I've used the pc.setqf so that after it's spawned when another flag is triggered(kill 100 mobs) the action is stopped.

The problem is that as I've seen, pc.setqf is PID specific, so another player can spawn another NPC because he doesn't have that flag set yet.

So, as a another "safety" action, is there any way to check if a specific npc is in a specific map(at least map index)?

Or.. maybe.. set the flag as general for all PIDS? 

I tried to play with npc.is_available0() but I think that this function is for other means...

P.S.: It is for a normal map, not dungeon.. with dungeon functions I think that I would've found a workaround.

Thank you for taking your time! :D 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
struct FCountRaceInMap
{
	size_t count;
	uint32_t dwVnum;

	FCountRaceInMap(uint32_t _dwVnum) : dwVnum(_dwVnum), count(0) {}

	void operator() (LPENTITY ent)
	{
		if (!ent->IsType(ENTITY_CHARACTER))
			return;

		LPCHARACTER ch = static_cast<LPCHARACTER>(ent);
		if (ch->IsPC())
			return;

		if (ch->GetRaceNum() == dwVnum)
			++count;
	}
};

size_t SECTREE_MANAGER::GetRaceCountInMap(long lMapIndex, uint32_t dwVnum) {
	LPSECTREE_MAP sectree = SECTREE_MANAGER::instance().GetMap(lMapIndex);
	if (!sectree)
		return 0;

	FCountRaceInMap f(dwVnum);
	sectree->for_each(f);
	return f.count;
}

 

It should work, but I didn't test.

Edited by Endymion
  • Love 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Activity

    1. 43

      Upgraded Reference (TMP4 Base) By Ulthar

    2. 2

      TXT File To Lower Case [Phaselis Map Works]

    3. 43

      Upgraded Reference (TMP4 Base) By Ulthar

    4. 43

      Upgraded Reference (TMP4 Base) By Ulthar

    5. 5

      Official Environment Effect Options [REVERSED]

    6. 1

      4 Alternatives Open Source to Trello

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.