Jump to content

pc.in_dungeon function for quest


Recommended Posts

  • Active Member

Description:

Quote

Get rid of any other functions and put it directly in the source

if you want to don't use anymore this nasty piece of code :

if pc.get_map_index() >= (206 * 10000) and pc.get_map_index() < ((206 + 1) * 10000) then

 

Usage:

Quote
when 2493.kill with pc.in_dungeon(208) begin
when kill with pc.in_dungeon() begin -- any dungeon

 

Function:

Quote
// dungeon.h

// Find
	long	GetMapIndex() { return m_lMapIndex; }

// Add after
	int		GetOriginalMapIndex() { return m_lOrigMapIndex; }

// questlua_pc.cpp
// Find & replace the whole function
	int pc_in_dungeon(lua_State * L)
	{
		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
		if (!ch)
		{
			lua_pushboolean(L, false);
			return 1;
		}

		LPDUNGEON dungeon = ch->GetDungeon();
		bool ret = (dungeon != NULL);

		if (ret && lua_gettop(L) >= 1 && lua_isnumber(L, 1))
		{
			int mapIndex = (int)lua_tonumber(L, 1);
			if (mapIndex > 0)
				ret = (mapIndex == dungeon->GetOriginalMapIndex());
		}

		lua_pushboolean(L, ret);
		return 1;
	}

 

 

  • Confused 1
  • Good 1
Link to comment
Share on other sites

  • Premium

Why would you add a new source function for such a thing?

 

  • Angry 1

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • 1 year later...


questlua_pc.cpp: In function 'int quest::pc_in_dungeon(lua_State*)':
questlua_pc.cpp:277:31: error: invalid use of incomplete type 'class CDungeon'
  277 |     ret = (mapIndex == dungeon->GetOriginalMapIndex());
      |                               ^~
In file included from stdafx.h:57,
                 from questlua_pc.cpp:1:
typedef.h:78:7: note: forward declaration of 'class CDungeon'
   78 | class CDungeon;
      |       ^~~~~~~~
gmake: *** [Makefile:171: .obj/questlua_pc.o] Error 1

 

 

 

This is the solution

#include "dungeon.h" 

 

in questlua_pc.cpp

Edited by shenhui1986
Link to comment
Share on other sites

  • Premium

 

13 hours ago, shenhui1986 said:


questlua_pc.cpp: In function 'int quest::pc_in_dungeon(lua_State*)':
questlua_pc.cpp:277:31: error: invalid use of incomplete type 'class CDungeon'
  277 |     ret = (mapIndex == dungeon->GetOriginalMapIndex());
      |                               ^~
In file included from stdafx.h:57,
                 from questlua_pc.cpp:1:
typedef.h:78:7: note: forward declaration of 'class CDungeon'
   78 | class CDungeon;
      |       ^~~~~~~~
gmake: *** [Makefile:171: .obj/questlua_pc.o] Error 1

 

 

 

This is the solution

#include "dungeon.h" 

 

in questlua_pc.cpp

Bro.

You don't need a C++ function for such a thing.

InDungeon = function(map_index)
    local pc_index = pc.get_map_index();
    return
        pc.in_dungeon() and
        pc_index >= ToDungeonIndex(map_index) and
        pc_index < ToDungeonIndex(map_index+1);
end -- function
when MOB_VNUM.kill with InDungeon(DUNGEON_MAP_INDEX) begin

 

  • Love 1

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

Announcements



×
×
  • 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.