MCPcopy Create free account
hub / github.com/REGoth-project/REGoth / findWorldNPC

Method findWorldNPC

src/logic/ScriptEngine.cpp:281–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279}
280
281Handle::EntityHandle ScriptEngine::findWorldNPC(const std::string& name)
282{
283 auto& datFile = getVM().getDATFile();
284
285 for (const Handle::EntityHandle& npc : getWorldNPCs())
286 {
287 VobTypes::NpcVobInformation npcVobInfo = VobTypes::asNpcVob(m_World, npc);
288 if (!npcVobInfo.isValid())
289 continue;
290
291 Daedalus::GEngineClasses::C_Npc& npcScriptObject = npcVobInfo.playerController->getScriptInstance();
292 std::string npcDisplayName = npcScriptObject.name[0];
293 std::string npcDatFileName = datFile.getSymbolByIndex(npcScriptObject.instanceSymbol).name;
294
295 for (auto npcName : {npcDisplayName, npcDatFileName})
296 {
297 std::replace(npcName.begin(), npcName.end(), ' ', '_');
298 if (Utils::stringEqualIngoreCase(name, npcName))
299 {
300 return npc;
301 }
302 }
303 }
304 return Handle::EntityHandle();
305}
306
307void ScriptEngine::onLogEntryAdded(const std::string& topic, const std::string& entry)
308{

Callers

nothing calls this directly

Calls 3

isValidMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected