Code: Select all
inline int32 CLuaBaseEntity::GotoMob(lua_State* L)
{
CCharEntity* PChar = (CCharEntity*)m_PBaseEntity;
if(m_PBaseEntity == NULL)
{
ShowNotice(CL_RED"TRACER:COMMAND: spawnmob Error\n" CL_RESET);
return false;
}
if(m_PBaseEntity->objtype != TYPE_PC)
{
ShowNotice(CL_RED"TRACER:COMMAND: spawnmob Error1\n" CL_RESET);
return false;
}
if(lua_isnil(L,-1) || !lua_isnumber(L,-1))
{
PChar->pushPacket(new CChatMessagePacket(PChar, MESSAGE_TELL, "Command Error1"));
PChar->pushPacket(new CChatMessagePacket(PChar, MESSAGE_TELL, "Command Example: .spawnmob 1"));
ShowNotice(CL_RED"TRACER:COMMAND: spawnmob Error2\n" CL_RESET);
return false;
}
uint32 mobid = (uint32)lua_tointeger(L,1);
uint32 groupid =0;
float pos_x =0;
float pos_y =0;
float pos_z =0;
uint32 pos_rot =0;
uint32 zoneid = 0;
CMobEntity* PMob = (CMobEntity*)zoneutils::GetEntity(mobid, TYPE_MOB);
if (PMob != NULL)
{
//BE FUN TO ADD A APPEAR TO MOB AT LOCATION ALSO
const int8* Query = "SELECT groupid,pos_x,pos_y,pos_z,pos_rot FROM mob_spawn_points WHERE mobid = '%u';";
int32 ret = Sql_Query(SqlHandle,Query,mobid);
if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0 && Sql_NextRow(SqlHandle) == SQL_SUCCESS)
{
PMob->PBattleAI->SetCurrentAction(ACTION_SPAWN);
ShowNotice(CL_RED"TRACER:COMMAND: Player %s Is Appearing To Mob ID %u\n" CL_RESET ,PChar->GetName(),mobid);
groupid = Sql_GetUIntData(SqlHandle,0);
ShowNotice(CL_RED"TRACER:COMMAND: GET GROUP ID %u\n" CL_RESET ,groupid);
pos_x = Sql_GetFloatData(SqlHandle,1);
ShowNotice(CL_RED"TRACER:COMMAND: GET POS_X ID %f\n" CL_RESET ,pos_x);
pos_y = Sql_GetFloatData(SqlHandle,2);
ShowNotice(CL_RED"TRACER:COMMAND: GET POS_Y ID %f\n" CL_RESET ,pos_y);
pos_z = Sql_GetFloatData(SqlHandle,3);
ShowNotice(CL_RED"TRACER:COMMAND: GET POS_Z ID %f\n" CL_RESET ,pos_z);
pos_rot = Sql_GetUIntData(SqlHandle,4);
ShowNotice(CL_RED"TRACER:COMMAND: GET POS_ROT ID %u\n" CL_RESET ,pos_rot);
PChar->status = STATUS_DISAPPEAR;
PChar->loc.p.x=pos_x;
PChar->loc.p.y=pos_y;
PChar->loc.p.z=pos_z;
PChar->loc.p.rotation=pos_rot;
PChar->loc.boundary = 0;
const int8* Query = "SELECT zoneid FROM mob_groups WHERE groupid = '%u';";
int32 ret = Sql_Query(SqlHandle,Query,groupid);
if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0 && Sql_NextRow(SqlHandle) == SQL_SUCCESS)
{
zoneid = Sql_GetUIntData(SqlHandle,0);
ShowNotice(CL_RED"TRACER:COMMAND: GET ZONE ID %u\n" CL_RESET ,zoneid);
PChar->loc.destination=zoneid ;
PChar->clearPacketList();
PChar->pushPacket(new CServerIPPacket(PChar,2));
PChar->pushPacket(new CCharUpdatePacket(PChar));
PChar->loc.zone->PushPacket(PChar, CHAR_INRANGE, new CEntityUpdatePacket(PChar, ENTITY_SPAWN));
return false;
}
lua_pushnil(L);
return false;
}
lua_pushnil(L);
return false;
}
lua_pushnil(L);
return false;
}