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

Method onNPCInserted

src/logic/ScriptEngine.cpp:175–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175void ScriptEngine::onNPCInserted(Daedalus::GameState::NpcHandle npc, const std::string& spawnpoint)
176{
177 // LogInfo() << "Created npc " << npc.index <<" on: " << spawnpoint;
178
179 // Create the NPC-vob
180 Handle::EntityHandle e = VobTypes::initNPCFromScript(m_World, npc);
181 registerNpc(e);
182
183 VobTypes::NpcVobInformation vob = VobTypes::asNpcVob(m_World, e);
184
185 if (vob.isValid() && !spawnpoint.empty())
186 {
187 if (World::Waynet::waypointExists(m_World.getWaynet(), spawnpoint))
188 vob.playerController->teleportToWaypoint(World::Waynet::getWaypointIndex(m_World.getWaynet(), spawnpoint));
189 else if(m_World.doesFreepointExist(spawnpoint))
190 {
191 vob.playerController->teleportToPosition(m_World.getFreepointPosition(spawnpoint));
192 } else
193 {
194 LogError() << "spawnpoint does not exist: " << spawnpoint;
195 assert(false);
196 }
197 }
198}
199
200Daedalus::GameState::DaedalusGameState& ScriptEngine::getGameState()
201{

Callers

nothing calls this directly

Calls 8

waypointExistsFunction · 0.85
getWaypointIndexFunction · 0.85
teleportToWaypointMethod · 0.80
doesFreepointExistMethod · 0.80
teleportToPositionMethod · 0.80
getFreepointPositionMethod · 0.80
isValidMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected