Premium mackabro2 216 Posted May 6, 2015 Premium Share Posted May 6, 2015 Anyone know of some function that invoke a mob on a map for example in mob.spawn_in_map(MOBVUM, X , Y, MAP_INDEX) Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted May 7, 2015 Premium Share Posted May 7, 2015 File: questlua_global.cpp Find : void RegisterGlobalFunctionTable(lua_State* L) and above this function add: // mob_spawn(vnum, x, y, map_index) int _mob_spawn(lua_State* L) { if (lua_gettop(L) < 4) { sys_err("_mob_spawn: not enough arguments"); lua_pushboolean(L, 0); return 1; } if(false == lua_isnumber(L, 1) || false == lua_isnumber(L, 2) || false == lua_isnumber(L, 3) || false == lua_isnumber(L, 4)) { sys_err("_mob_spawn: invalid arguments"); lua_pushboolean(L, 0); return 1; } const DWORD dwVnum = static_cast<DWORD>(lua_tonumber(L, 1)); const long lX = static_cast<long>(lua_tonumber(L, 2)); const long lY = static_cast<long>(lua_tonumber(L, 3)); const long lMapIndex = static_cast<long>(lua_tonumber(L, 4)); const CMob* pMonster = CMobManager::instance().Get(dwVnum); if (!pMonster) { sys_err("_mob_spawn: wrong vnum"); lua_pushboolean(L, 0); return 1; } LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(lMapIndex); if (!pkSectreeMap) { sys_err("_mob_spawn: wrong mapindex"); lua_pushboolean(L, 0); return 1; } LPCHARACTER mob = CHARACTER_MANAGER::instance().SpawnMob(dwVnum, lMapIndex, lX, lY, 0); if (!mob) { sys_err("_mob_spawn: mob not spawned; coords maybe wrong?"); lua_pushboolean(L, 0); return 1; } lua_pushboolean(L, 1); return 1; } Now search for { "spawn_mob", _spawn_mob }, And add after: { "mob_spawn", _mob_spawn }, And you call it like this: mob_spawn(vnum, x, y, map_index) The function returns true/false if mob was called or not. Also, if the mob is not called then it will display an error in your syserr file: "_mob_spawn: not enough arguments" -- you called the function with fewer arguments "_mob_spawn: invalid arguments" -- you passed an wrong arguments. all must be numbers "_mob_spawn: wrong vnum" -- you provided wrong mob vnum "_mob_spawn: wrong mapindex" -- you provided wrong map index "_mob_spawn: mob not spawned; coords maybe wrong?" -- mob could not be spawned. this may happen if the coords are wrong 1 Link to comment Share on other sites More sharing options...
Premium mackabro2 216 Posted May 7, 2015 Author Premium Share Posted May 7, 2015 mob_spawn(2493, 475, 709, 41) mob x y MAP_INDEX BLUE _mob_spawn: _mob_spawn: wrong mapindex Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted May 7, 2015 Premium Share Posted May 7, 2015 mob_spawn(2493, 475, 709, 41) mob x y MAP_INDEX BLUE _mob_spawn: _mob_spawn: wrong mapindex Oops. My bad. I edited the code from previous post. Check it out. Link to comment Share on other sites More sharing options...
Premium mackabro2 216 Posted May 7, 2015 Author Premium Share Posted May 7, 2015 _mob_spawn: _mob_spawn: wrong mapindex same error Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted May 8, 2015 Premium Share Posted May 8, 2015 _mob_spawn: _mob_spawn: wrong mapindex same error Hmm... that's weird. Are you sure you're not CH99 and you copied new code from above and compiled the source? Check it. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now