Jump to content

Help new function for spawn a mob in a map


Go to solution Solved by Ken,

Recommended Posts

  • Solution
	int _spawn_mob_in_map(lua_State * L)
	{
		if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3) || !lua_isnumber(L,4) || !lua_isnumber(L,5) || !lua_isboolean(L,6))
		{
			sys_err("Missing argument!");
			return 1;
		}

		long lMapIndex = static_cast<long>(lua_tonumber(L, 1));
		DWORD dwMobVnum = static_cast<DWORD>(lua_tonumber(L, 2));
		long x = static_cast<long>(lua_tonumber(L, 3));
		long y = static_cast<long>(lua_tonumber(L, 4));
		BYTE bSpawnCount = static_cast<BYTE>(lua_tonumber(L, 5));
		bool isAggressive = lua_toboolean(L, 6);

		const CMob * pMonster = CMobManager::instance().Get(dwMobVnum);

		if (pMonster)
		{
			for (BYTE i = 0; i < bSpawnCount; ++i)
			{
				LPCHARACTER pSpawnMonster = CHARACTER_MANAGER::instance().SpawnMobRange(
					lMapIndex,
					x - number(200, 750),
					y - number(200, 750),
					x + number(200, 750),
					y + number(200, 750),
					true,
					pMonster->m_table.bType == CHAR_TYPE_STONE,
					isAggressive);

				if (pSpawnMonster)
					++bSpawnCount;
			}
			
			sys_log(0, "QUEST Spawn Monster: VNUM(%u) COUNT(%d) isAggressive(%d)", dwMobVnum, bSpawnCount, isAggressive);
		}

		lua_pushnumber(L, 0);
		return 1;
	}

How to use it ;

spawn_mob_in_map(mapIndex,mobVnum,coordinateX,coordinateY,spawnCount,isAggressive);

Kind Regards

Ken ~ TA

  • Love 3

Do not be sorry, be better.

Link to comment
Share on other sites

on is agressive what i need to put?

 

If you want to this mob as aggressive (when it's spawn, mob is attack to player)

 

if you want to this mob as aggressive ; true

if you don't want to this mob as aggressive ; false

 

Kind Regards

Ken ~ TA

Edited by Ken

Do not be sorry, be better.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

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.