Пример #1
0
  void Map::RemoveNPC (const yap::ID& worldID)
  {
    NPC& npc = GetNPC (worldID);

    npcs_.Remove (npc.GetWorldID ());

    RemoveDrawableDynamicObject (npc.GetWorldID ());
  }
Пример #2
0
void MapData::CreateNPCS() {
    mNumberOfNPCS = 0;

    for (int a = 0; a < mTileAmount; ++a) {
        int npc = mLayer1[a].GetNPC();

        if (npc > 0) {
            ++mNumberOfNPCS;

            NPCData* temp;
            temp = GetNPC(npc);
            temp->SetPosition(mLayer1[a].GetPosition());
            mNPCS.push_back(temp);
        }
    }
}
Пример #3
0
// check if the actor is in npclevel.2da and replace accordingly
bool Game::CheckForReplacementActor(int i)
{
	if (core->InCutSceneMode() || npclevels.empty()) {
		return false;
	}

	Actor* act = NPCs[i];
	ieDword level = GetPartyLevel(false) / GetPartySize(false);
	if (!(act->Modified[IE_MC_FLAGS]&MC_BEENINPARTY) && !(act->Modified[IE_STATE_ID]&STATE_DEAD) && act->GetXPLevel(false) < level) {
		ieResRef newcre = "****"; // default table value
		std::vector<std::vector<char *> >::iterator it;
		for (it = npclevels.begin(); it != npclevels.end(); it++) {
			if (!stricmp((*it)[0], act->GetScriptName()) && (level > 2)) {
				// the tables have entries only up to level 24
				ieDword safeLevel = npclevels[0].size() - 1;
				if (level < safeLevel) {
					safeLevel = level;
				}
				CopyResRef(newcre, (*it)[safeLevel-2]);
				break;
			}
		}

		if (stricmp(newcre, "****")) {
			int pos = gamedata->LoadCreature(newcre, 0, false, act->version);
			if (pos < 0) {
				error("Game::CheckForReplacementActor", "LoadCreature failed: pos is negative!\n");
			} else {
				Actor *newact = GetNPC(pos);
				if (!newact) {
					error("Game::CheckForReplacementActor", "GetNPC failed: cannot find act!\n");
				} else {
					newact->Pos = act->Pos; // the map is not loaded yet, so no SetPosition
					newact->TalkCount = act->TalkCount;
					newact->InteractCount = act->InteractCount;
					CopyResRef(newact->Area, act->Area);
					DelNPC(InStore(act), true);
					return true;
				}
			}
		}
	}
	return false;
}