Code: Select all
inline int32 CLuaBaseEntity::spawn_Mob(lua_State *L)
{
CCharEntity* PChar = (CCharEntity*)m_PBaseEntity;
CZone* PZone = zoneutils::GetZone(PChar->getZone());
if(m_PBaseEntity == NULL)
{
//ShowNotice(CL_RED"TRACER:COMMAND: addAllKeyItem Error\n" CL_RESET);
return false;
}
if(m_PBaseEntity->objtype != TYPE_PC)
{
//ShowNotice(CL_RED"TRACER:COMMAND: addAllKeyItem Error1\n" CL_RESET);
return false;
}
/*OK THE PLAN LETS SELECT FROM A ID FIRST
OK WE ARE IN GAME AND WE TYPE .spwnmob 16781313 and we should get a return message of the MOBS NAME and will build from there
we select it by id and we get the name then will get all the information needed and then set at our POStion and then once all thatss done will update our view ad see it i think*/
if(lua_isnil(L,-1) || !lua_isnumber(L,-1))
{
PChar->pushPacket(new CChatMessagePacket(PChar, MESSAGE_TELL, "Command Error2"));
PChar->pushPacket(new CChatMessagePacket(PChar, MESSAGE_TELL, "Command Example: .spawnmob 2"));
//ShowNotice(CL_RED"TRACER:COMMAND: addKeyItem Error3\n" CL_RESET);
return false;
}
char buf[110];
uint32 mobid = lua_tointeger(L, -1);
string_t mobname = "";
const int8* Query =
"SELECT mobname, respawntime, spawntype, dropid, mob_groups.HP, mob_groups.MP, minLevel, maxLevel, \
modelid, mJob, sJob, cmbSkill, cmbDelay, behavior, links, mobType, immunity, \
systemid, mobsize, speed, \
STR, DEX, VIT, AGI, `INT`, MND, CHR, EVA, DEF, \
Slash, Pierce, H2H, Impact, \
Fire, Ice, Wind, Earth, Lightning, Water, Light, Dark, Element, \
mob_pools.familyid, name_prefix, unknown, animationsub, \
(mob_family_system.HP / 100), (mob_family_system.MP / 100), hasSpellScript, spellList, ATT, ACC, link_radius \
FROM mob_groups, mob_pools, mob_spawn_points, mob_family_system \
WHERE mob_groups.poolid = mob_pools.poolid \
AND mob_groups.groupid = mob_spawn_points.groupid \
AND mob_family_system.familyid = mob_pools.familyid \
AND mob_spawn_points.mobid = %u;";
int32 ret = Sql_Query(SqlHandle, Query, mobid);
if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0 && Sql_NextRow(SqlHandle) == SQL_SUCCESS)
{
//IF MOB IS IN DATABASE RUN THIS LINE
mobname = Sql_GetData(SqlHandle,0);
CMobEntity* PMob = new CMobEntity;
PMob->name = mobname.c_str();
PMob->name.insert(0,Sql_GetData(SqlHandle,0));
PMob->id = mobid;
PMob->targid = (uint16)PMob->id & 0x0FFF;
PMob->m_SpawnPoint.rotation = PChar->loc.p.rotation;
PMob->m_SpawnPoint.x = PChar->loc.p.x;
PMob->m_SpawnPoint.y = PChar->loc.p.y;
PMob->m_SpawnPoint.z = PChar->loc.p.z;
PMob->m_RespawnTime = Sql_GetUIntData(SqlHandle,1) * 1000;
PMob->m_SpawnType = (SPAWNTYPE)Sql_GetUIntData(SqlHandle,2);
PMob->m_DropID = Sql_GetUIntData(SqlHandle,3);
PMob->HPmodifier = (uint32)Sql_GetIntData(SqlHandle,4);
PMob->MPmodifier = (uint32)Sql_GetIntData(SqlHandle,5);
PMob->m_minLevel = (uint8)Sql_GetIntData(SqlHandle,6);
PMob->m_maxLevel = (uint8)Sql_GetIntData(SqlHandle,7);
memcpy(&PMob->look,Sql_GetData(SqlHandle,8),23);
PMob->SetMJob(Sql_GetIntData(SqlHandle,9));
PMob->SetSJob(Sql_GetIntData(SqlHandle,10));
PMob->m_Weapons[SLOT_MAIN]->setMaxHit(1);
PMob->m_Weapons[SLOT_MAIN]->setSkillType(Sql_GetIntData(SqlHandle,11));
PMob->m_Weapons[SLOT_MAIN]->setDelay((Sql_GetIntData(SqlHandle,12) * 1000)/60);
PMob->m_Weapons[SLOT_MAIN]->setBaseDelay((Sql_GetIntData(SqlHandle,12) * 1000)/60);
PMob->m_Behaviour = (uint16)Sql_GetIntData(SqlHandle,13);
PMob->m_Link = (uint8)Sql_GetIntData(SqlHandle,14);
PMob->m_Type = (uint8)Sql_GetIntData(SqlHandle,15);
PMob->m_Immunity = (IMMUNITY)Sql_GetIntData(SqlHandle,16);
PMob->m_EcoSystem = (ECOSYSTEM)Sql_GetIntData(SqlHandle,17);
PMob->m_ModelSize += (uint8)Sql_GetIntData(SqlHandle,18);
PMob->speed = (uint8)Sql_GetIntData(SqlHandle,19);
PMob->speedsub = (uint8)Sql_GetIntData(SqlHandle,19);
PMob->strRank = (uint8)Sql_GetIntData(SqlHandle,20);
PMob->dexRank = (uint8)Sql_GetIntData(SqlHandle,21);
PMob->vitRank = (uint8)Sql_GetIntData(SqlHandle,22);
PMob->agiRank = (uint8)Sql_GetIntData(SqlHandle,23);
PMob->intRank = (uint8)Sql_GetIntData(SqlHandle,24);
PMob->mndRank = (uint8)Sql_GetIntData(SqlHandle,25);
PMob->chrRank = (uint8)Sql_GetIntData(SqlHandle,26);
PMob->evaRank = (uint8)Sql_GetIntData(SqlHandle,27);
PMob->defRank = (uint8)Sql_GetIntData(SqlHandle,28);
PMob->attRank = (uint8)Sql_GetIntData(SqlHandle,50);
PMob->accRank = (uint8)Sql_GetIntData(SqlHandle,51);
PMob->m_linkRadius = (uint8)Sql_GetIntData(SqlHandle,52);
PMob->setModifier(MOD_SLASHRES, (uint16)(Sql_GetFloatData(SqlHandle,29) * 1000));
PMob->setModifier(MOD_PIERCERES,(uint16)(Sql_GetFloatData(SqlHandle,30) * 1000));
PMob->setModifier(MOD_HTHRES, (uint16)(Sql_GetFloatData(SqlHandle,31) * 1000));
PMob->setModifier(MOD_IMPACTRES,(uint16)(Sql_GetFloatData(SqlHandle,32) * 1000));
PMob->setModifier(MOD_FIREDEF, (int16)((Sql_GetFloatData(SqlHandle, 33) - 1) * -1000)); // These are stored as floating percentages
PMob->setModifier(MOD_ICEDEF, (int16)((Sql_GetFloatData(SqlHandle, 34) - 1) * -1000)); // and need to be adjusted into modifier units.
PMob->setModifier(MOD_WINDDEF, (int16)((Sql_GetFloatData(SqlHandle, 35) - 1) * -1000)); // Higher DEF = lower damage.
PMob->setModifier(MOD_EARTHDEF, (int16)((Sql_GetFloatData(SqlHandle, 36) - 1) * -1000)); // Negatives signify increased damage.
PMob->setModifier(MOD_THUNDERDEF, (int16)((Sql_GetFloatData(SqlHandle, 37) - 1) * -1000)); // Positives signify reduced damage.
PMob->setModifier(MOD_WATERDEF, (int16)((Sql_GetFloatData(SqlHandle, 38) - 1) * -1000)); // Ex: 125% damage would be 1.25, 50% damage would be 0.50
PMob->setModifier(MOD_LIGHTDEF, (int16)((Sql_GetFloatData(SqlHandle, 39) - 1) * -1000)); // (1.25 - 1) * -1000 = -250 DEF
PMob->setModifier(MOD_DARKDEF, (int16)((Sql_GetFloatData(SqlHandle, 40) - 1) * -1000)); // (0.50 - 1) * -1000 = 500 DEF
PMob->setModifier(MOD_FIRERES, (int16)((Sql_GetFloatData(SqlHandle, 33) - 1) * -100)); // These are stored as floating percentages
PMob->setModifier(MOD_ICERES, (int16)((Sql_GetFloatData(SqlHandle, 34) - 1) * -100)); // and need to be adjusted into modifier units.
PMob->setModifier(MOD_WINDRES, (int16)((Sql_GetFloatData(SqlHandle, 35) - 1) * -100)); // Higher RES = lower damage.
PMob->setModifier(MOD_EARTHRES, (int16)((Sql_GetFloatData(SqlHandle, 36) - 1) * -100)); // Negatives signify lower resist chance.
PMob->setModifier(MOD_THUNDERRES, (int16)((Sql_GetFloatData(SqlHandle, 37) - 1) * -100)); // Positives signify increased resist chance.
PMob->setModifier(MOD_WATERRES, (int16)((Sql_GetFloatData(SqlHandle, 38) - 1) * -100));
PMob->setModifier(MOD_LIGHTRES, (int16)((Sql_GetFloatData(SqlHandle, 39) - 1) * -100));
PMob->setModifier(MOD_DARKRES, (int16)((Sql_GetFloatData(SqlHandle, 40) - 1) * -100));
PMob->m_Element = (uint8)Sql_GetIntData(SqlHandle,41);
PMob->m_Family = (uint16)Sql_GetIntData(SqlHandle,42);
PMob->m_name_prefix = (uint8)Sql_GetIntData(SqlHandle,43);
PMob->m_unknown = (uint32)Sql_GetIntData(SqlHandle,44);
//Special sub animation for Mob (yovra, jailer of love, phuabo)
// yovra 1: en hauteur, 2: en bas, 3: en haut
// phuabo 1: sous l'eau, 2: sort de l'eau, 3: rentre dans l'eau
PMob->animationsub = (uint32)Sql_GetIntData(SqlHandle,45);
// Setup HP / MP Stat Percentage Boost
PMob->HPscale = Sql_GetFloatData(SqlHandle,46);
PMob->MPscale = Sql_GetFloatData(SqlHandle,47);
PMob->PBattleAI = new CAIMobDummy(PMob);
if (PMob->m_AllowRespawn = PMob->m_SpawnType == SPAWNTYPE_NORMAL)
{
PMob->PBattleAI->SetCurrentAction(ACTION_SPAWN);
}
// Check if we should be looking up scripts for this mob
PMob->m_HasSpellScript = (uint8)Sql_GetIntData(SqlHandle,48);
PMob->m_SpellListContainer = mobSpellList::GetMobSpellList(Sql_GetIntData(SqlHandle,49));
PZone->InsertMOB(PMob);
sprintf(buf,"Mob ID: %u ",mobid );
PChar->pushPacket(new CChatMessageStringPacket(PChar, MESSAGE_STRING_SAY , ("%s",buf)));
sprintf(buf,"Mob Name: %s ",mobname.c_str() );
PChar->pushPacket(new CChatMessageStringPacket(PChar, MESSAGE_STRING_SAY , ("%s",buf)));
sprintf(buf,"Mob Respawn Time: %u ",PMob->m_RespawnTime );
PChar->pushPacket(new CChatMessageStringPacket(PChar, MESSAGE_STRING_SAY , ("%s",buf)));
sprintf(buf,"Mob Spawn Type: %u ",PMob->m_SpawnType );
PChar->pushPacket(new CChatMessageStringPacket(PChar, MESSAGE_STRING_SAY , ("%s",buf)));
sprintf(buf,"Mob Drop ID: %u ",PMob->m_DropID );
PChar->pushPacket(new CChatMessageStringPacket(PChar, MESSAGE_STRING_SAY , ("%s",buf)));
sprintf(buf,"Mob Is Only Temp:");
PChar->pushPacket(new CChatMessageStringPacket(PChar, MESSAGE_STRING_SAY , ("%s",buf)));
PChar->pushPacket(new CEntityUpdatePacket(PMob,ENTITY_SPAWN));
PChar->loc.zone->PushPacket(PChar, CHAR_INRANGE, new CEntityUpdatePacket(PMob, ENTITY_SPAWN));
return false;
}
else
{
//ELSE THE MOB CAN NOT BE FOUND DO NOTHING BUT SEND MESSAGE TO US IN GAME
char buf[110];
sprintf(buf,"No Mob By The ID: %u Found In Database! ",mobid );
PChar->pushPacket(new CChatMessageStringPacket(PChar, MESSAGE_STRING_SAY , ("%s",buf)));
return false;
}
return false;
}
LUA
Code: Select all
-----------------------------------
-- Action
-----------------------------------
function onTrigger(player,id)
player:spawn_Mob(id);
end;