Originally Posted by
Stenberg
I'm currently running the TrinityCore 3.3.5a repack created by Bretti1993.
Everything seems to work somewhat fine, but when I create new (custom) npcs using the command .npc add #id, they don't seem to be added properly to the 'creature' table. I need them in this table to change some of their data individually, and doing .npc info for each NPC and plot them manually seems... unfun.
Is this expected behaviour, or is the GM command bugged, and is there a way for me to modify the GM command if this is the case?
TrinityCore/cs_npc.cpp#L276
Code:
{ "add", rbac::RBAC_PERM_COMMAND_NPC_ADD, false, nullptr, "", npcAddCommandTable },
Code:
//add spawn of creature
static bool HandleNpcAddCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
char* charID = handler->extractKeyFromLink((char*)args, "Hcreature_entry");
if (!charID)
return false;
uint32 id = atoul(charID);
if (!sObjectMgr->GetCreatureTemplate(id))
return false;
Player* chr = handler->GetSession()->GetPlayer();
Map* map = chr->GetMap();
if (Transport* trans = chr->GetTransport())
{
ObjectGuid::LowType guid = map->GenerateLowGuid<HighGuid::Creature>();
CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid);
data.id = id;
data.posX = chr->GetTransOffsetX();
data.posY = chr->GetTransOffsetY();
data.posZ = chr->GetTransOffsetZ();
data.orientation = chr->GetTransOffsetO();
/// @todo: add phases
Creature* creature = trans->CreateNPCPassenger(guid, &data);
creature->SaveToDB(trans->GetGOInfo()->moTransport.SpawnMap, { map->GetDifficultyID() });
sObjectMgr->AddCreatureToGrid(guid, &data);
return true;
}
Creature* creature = Creature::CreateCreature(id, map, chr->GetPosition());
if (!creature)
return false;
PhasingHandler::InheritPhaseShift(creature, chr);
creature->SaveToDB(map->GetId(), { map->GetDifficultyID() });
ObjectGuid::LowType db_guid = creature->GetSpawnId();
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells()
// current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
creature->CleanupsBeforeDelete();
delete creature;
creature = Creature::CreateCreatureFromDB(db_guid, map);
if (!creature)
return false;
sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid));
return true;
}
It looks like '.npc add <creature_template_id>' should work and persist it to the database.
TC documents it as TrinityCore GM commands
Code:
Syntax: .npc add #creatureid Spawn a creature by the given template id of #creatureid
It might be a consequence of using a repack. Bugs can exist and if they do it is almost impossible for you to fix them because the code is pre-compiled.
Have a look at compiling it yourself; the process is quite well documented and we can help if you get stuck. TrinityCore How to compile