Index: scripts/globals/common.lua =================================================================== --- scripts/globals/common.lua (revision 1571) +++ scripts/globals/common.lua (working copy) @@ -38,4 +38,18 @@ function printf(s,...) print(s:format(...)) +end; + +----------------------------------- +-- inArray +----------------------------------- + +function inArray(a, index) + for k,v in pairs(a) do + if (index == v) then + return true; + end + end + + return false; end; \ No newline at end of file Index: src/map/lua/luautils.cpp =================================================================== --- src/map/lua/luautils.cpp (revision 1571) +++ src/map/lua/luautils.cpp (working copy) @@ -80,6 +80,8 @@ lua_register(LuaHandle,"GetRegionOwner", luautils::GetRegionOwner); lua_register(LuaHandle,"SpawnMob",luautils::SpawnMob); lua_register(LuaHandle,"DespawnMob",luautils::DespawnMob); + lua_register(LuaHandle,"DeterMob",luautils::DeterMob); + lua_register(LuaHandle,"SetMobPos",luautils::SetMobPos); lua_register(LuaHandle,"GetPlayerByName",luautils::GetPlayerByName); lua_register(LuaHandle,"GetMobAction",luautils::GetMobAction); lua_register(LuaHandle,"VanadielTOTD",luautils::VanadielTOTD); @@ -422,6 +424,69 @@ } /************************************************************************ +* * +* Set SpawnType of mob to scripted (128) or normal (0) usind mob id * +* * +************************************************************************/ +int32 DeterMob(lua_State* L) +{ + if ( !lua_isnil(L,1) && lua_isnumber(L,1) ) + { + uint32 mobid = (uint32)lua_tointeger(L,1); + CMobEntity* PMob = (CMobEntity*)zoneutils::GetEntity(mobid, TYPE_MOB); + + if (PMob != NULL) { + bool toDeter = 0; + if ( !lua_isnil(L,2) && lua_isboolean(L,2) ) + toDeter = ( lua_toboolean(L,2) == 0 ? false : true ); + + if (toDeter) { + PMob->m_SpawnType = (SPAWNTYPE)128; + } else { + PMob->m_SpawnType = (SPAWNTYPE)0; + } + return 1; + } else { + ShowDebug(CL_RED"DeterMob: mob <%u> not found\n" CL_RESET, mobid); + } + return 0; + } + lua_pushnil(L); + return 1; +} + +/************************************************************************ +* * +* Set position of mob using mob ID. * +* * +************************************************************************/ +int32 SetMobPos(lua_State* L) +{ + if( !lua_isnil(L,1) && lua_isnumber(L,1) ) { + uint32 mobid = (uint32)lua_tointeger(L,1); + CMobEntity* PMob = (CMobEntity*)zoneutils::GetEntity(mobid, TYPE_MOB); + + if (PMob != NULL) { + if( !lua_isnil(L,2) && lua_isnumber(L,2) ) + PMob->m_SpawnPoint.x = (float) lua_tonumber(L,2); + if( !lua_isnil(L,3) && lua_isnumber(L,3) ) + PMob->m_SpawnPoint.y = (float) lua_tonumber(L,3); + if( !lua_isnil(L,4) && lua_isnumber(L,4) ) + PMob->m_SpawnPoint.z = (float) lua_tonumber(L,4); + if( !lua_isnil(L,5) && lua_isnumber(L,5) ) + PMob->m_SpawnPoint.rotation = (uint8) lua_tointeger(L,5); + + return 1; + } else { + ShowDebug(CL_RED"SetMobPos: mob <%u> not found\n" CL_RESET, mobid); + } + return 0; + } + lua_pushnil(L); + return 1; +} + +/************************************************************************ * * * Gets a player object via the player's name. * * Used for GM commands ONLY. * Index: src/map/lua/luautils.h =================================================================== --- src/map/lua/luautils.h (revision 1571) +++ src/map/lua/luautils.h (working copy) @@ -56,6 +56,8 @@ int32 GetRegionOwner(lua_State*); // узнаем страну, владеющую текущим регионом int32 SpawnMob(lua_State*); // Spawn Mob By Mob Id - NMs, BCNM... int32 DespawnMob(lua_State*); // Despawn (Fade Out) Mob By Id + int32 DeterMob(lua_State*); // Deter Mob By Id + int32 SetMobPos(lua_State*); // Set Mob Position By Id int32 GetPlayerByName(lua_State*); // Gets Player ref from a name supplied int32 GetMobAction(lua_State*); // Get Mobs current action int32 VanadielTOTD(lua_State*); // текущее игровое время суток