int Game::LeaveParty (Actor* actor) { core->SetEventFlag(EF_PORTRAIT); actor->CreateStats(); //create or update stats for leaving actor->SetBase(IE_EXPLORE, 0); SelectActor(actor, false, SELECT_NORMAL); int slot = InParty( actor ); if (slot < 0) { return slot; } std::vector< Actor*>::iterator m = PCs.begin() + slot; PCs.erase( m ); ieDword id = actor->GetGlobalID(); for ( m = PCs.begin(); m != PCs.end(); ++m) { (*m)->PCStats->LastLeft = id; if ( (*m)->InParty>actor->InParty) { (*m)->InParty--; } } //removing from party, but actor remains in 'game' actor->SetPersistent(0); NPCs.push_back( actor ); if (core->HasFeature( GF_HAS_DPLAYER )) { actor->SetScript( "", SCR_DEFAULT ); if (actor->GetBase(IE_MC_FLAGS) & MC_EXPORTABLE) { actor->SetDialog("MULTIJ"); } } actor->SetBase( IE_EA, EA_NEUTRAL ); return ( int ) NPCs.size() - 1; }
int Game::JoinParty(Actor* actor, int join) { core->SetEventFlag(EF_PORTRAIT); actor->CreateStats(); //create stats if they didn't exist yet actor->InitButtons(actor->GetStat(IE_CLASS), false); //init actor's buttons actor->SetBase(IE_EXPLORE, 1); if (join&JP_INITPOS) { InitActorPos(actor); } int slot = InParty( actor ); if (slot != -1) { return slot; } size_t size = PCs.size(); //set the lastjoined trigger if (join&JP_JOIN) { //update kit abilities of actor actor->ApplyKit(false); //update the quickslots actor->ReinitQuickSlots(); //set the joining date actor->PCStats->JoinDate = GameTime; if (size) { ieDword id = actor->GetGlobalID(); for (size_t i=0;i<size; i++) { Actor *a = GetPC(i, false); a->PCStats->LastJoined = id; } } else { Reputation = actor->GetStat(IE_REPUTATION); } } slot = InStore( actor ); if (slot >= 0) { std::vector< Actor*>::iterator m = NPCs.begin() + slot; NPCs.erase( m ); } PCs.push_back( actor ); if (!actor->InParty) { actor->InParty = (ieByte) (size+1); } if (join&(JP_INITPOS|JP_SELECT)) { actor->Selected = 0; // don't confuse SelectActor! SelectActor(actor,true, SELECT_NORMAL); } return ( int ) size; }
int Game::AddNPC(Actor* npc) { int slot = InStore( npc ); //already an npc if (slot != -1) { return slot; } slot = InParty( npc ); if (slot != -1) { return -1; } //can't add as npc already in party npc->SetPersistent(0); NPCs.push_back( npc ); return (int) NPCs.size() - 1; }
bool Party::Withdraw(Poke* mon) { if (!mon) { return false; } if (InParty(mon)) { return false; } if (Team.size() < 6) { Team.emplace_back(mon); return true; } else { return false; } //cout << "Team size is now " << Team.size() << '\n'; }