| 279 | } |
| 280 | |
| 281 | Handle::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 | |
| 307 | void ScriptEngine::onLogEntryAdded(const std::string& topic, const std::string& entry) |
| 308 | { |