bool LdrCell::HandleMessage(const Message& message){ switch(message.Msg){ case Msg_leader_dead: setLeader(false); return true; case Msg_leader_alive: setLeader(true); return true; case Msg_supplier_dead: setSupplied(false); return true; case Msg_supplier_alive: setSupplied(true); return true; case Msg_push_supplies:{ std::cout << "Supplies pushed" << std::endl; int low = 100; int id = 0; int size = subCells.size(); for (int i = 0; i < size; i++){ if (subCells[i]->getSupplies() < low){ low = subCells[i]->getSupplies(); id = subCells[i]->getID(); } }//end for if (low < 100 && id != 0) Commo->Send(SEND_NOW, ID, id, Msg_push_supplies, nullptr); return true; } default: return false; }//end switch }//end HandleMessage
void Party::disband() { getLeader()->sendClosePrivate(CHANNEL_PARTY); getLeader()->setParty(NULL); getLeader()->sendTextMessage(MSG_INFO_DESCR, "Your party has been disbanded."); getLeader()->sendPlayerPartyIcons(getLeader()); for(PlayerVector::iterator it = inviteList.begin(); it != inviteList.end(); ++it) { (*it)->removePartyInvitation(this); (*it)->sendPlayerPartyIcons(getLeader()); (*it)->sendPlayerPartyIcons((*it)); getLeader()->sendPlayerPartyIcons((*it)); } inviteList.clear(); for(PlayerVector::iterator it = memberList.begin(); it != memberList.end(); ++it) { (*it)->sendClosePrivate(CHANNEL_PARTY); (*it)->setParty(NULL); (*it)->sendTextMessage(MSG_INFO_DESCR, "Your party has been disbanded."); (*it)->sendPlayerPartyIcons((*it)); (*it)->sendPlayerPartyIcons(getLeader()); getLeader()->sendPlayerPartyIcons((*it)); } memberList.clear(); setLeader(NULL); delete this; }
bool Party::passLeadership(Player* player) { if(!player || getLeader() == player || !isPlayerMember(player)) return false; //Remove it before to broadcast the message correctly PlayerVector::iterator it = std::find(memberList.begin(), memberList.end(), player); if(it != memberList.end()) memberList.erase(it); Player* oldLeader = getLeader(); setLeader(player); memberList.insert(memberList.begin(), oldLeader); char buffer[125]; sprintf(buffer, "%s is now the leader of the party.", player->getName().c_str()); broadcastMessage(MSG_INFO_DESCR, buffer, true); player->sendTextMessage(MSG_INFO_DESCR, "You are now the leader of the party."); updateSharedExperience(); updateIcons(oldLeader); updateIcons(player); return true; }
void Party::disband() { g_chat.deleteChannel(this); getLeader()->sendTextMessage(MSG_INFO_DESCR, "Your party has been disbanded."); getLeader()->setParty(NULL); getLeader()->sendPlayerPartyIcons(getLeader()); for(uint32_t i = 0; i < inviteList.size(); ++i){ inviteList[i]->removePartyInvitation(this); inviteList[i]->sendPlayerPartyIcons(getLeader()); inviteList[i]->sendPlayerPartyIcons(inviteList[i]); getLeader()->sendPlayerPartyIcons(inviteList[i]); } inviteList.clear(); for(uint32_t i = 0; i < memberList.size(); ++i){ memberList[i]->setParty(NULL); memberList[i]->sendPlayerPartyIcons(getLeader()); memberList[i]->sendPlayerPartyIcons(memberList[i]); memberList[i]->sendTextMessage(MSG_INFO_DESCR, "Your party has been disbanded."); getLeader()->sendPlayerPartyIcons(memberList[i]); } memberList.clear(); setLeader(NULL); delete this; }
bool Party::passPartyLeadership(Player* player) { if(!player || getLeader() == player || !isPlayerMember(player)){ return false; } //Remove it before to broadcast the message correctly PlayerVector::iterator it = std::find(memberList.begin(), memberList.end(), player); if(it != memberList.end()){ memberList.erase(it); } std::stringstream ss; ss << player->getName() << " is now the leader of the party."; broadcastPartyMessage(MSG_INFO_DESCR, ss.str(), true); Player* oldLeader = getLeader(); setLeader(player); memberList.insert(memberList.begin(), oldLeader); updateSharedExperience(); updatePartyIcons(oldLeader); updatePartyIcons(getLeader()); updatePartyIcons(player); player->sendTextMessage(MSG_INFO_DESCR, "You are now the leader of the party."); return true; }
void Party::disband() { leader->setParty(nullptr); leader->sendClosePrivate(CHANNEL_PARTY); g_game.updatePlayerShield(leader); leader->sendCreatureSkull(leader); leader->sendTextMessage(MSG_INFO_DESCR, "Your party has been disbanded."); for (Player* invitee : inviteList) { invitee->removePartyInvitation(this); leader->sendCreatureShield(invitee); } inviteList.clear(); for (Player* member : memberList) { member->setParty(nullptr); member->sendClosePrivate(CHANNEL_PARTY); member->sendTextMessage(MSG_INFO_DESCR, "Your party has been disbanded."); } for (Player* member : memberList) { g_game.updatePlayerShield(member); for (Player* otherMember : memberList) { otherMember->sendCreatureSkull(member); } member->sendCreatureSkull(leader); leader->sendCreatureSkull(member); } memberList.clear(); setLeader(nullptr); delete this; }
/** * \brief 删除组队 * \param leader 队长 */ void TeamManager::deleteTeam() { setLeader(0); setTeamtempId(0); DeleteTeamExec del; team.execEvery(del); team.Clear(); }
Party::Party(Player* _leader) { sharedExpActive = false; sharedExpEnabled = false; if (_leader) { setLeader(_leader); _leader->setParty(this); } }
bool LineCell::HandleMessage(const Message& message){ switch(message.Msg){ case Msg_leader_dead: setLeader(false); return true; case Msg_leader_alive: setLeader(true); return true; case Msg_supplier_dead: setSupplied(false); return true; case Msg_supplier_alive: setSupplied(true); return true; case Msg_push_supplies: supplies += 50; std::cout << "Got a resupply!" << std::endl; return true; default: return false; }//end switch }//end HandleMessage
void Squad::chooseNewLeader() { if (!m_members.empty()) { Ship* newleader = nullptr; float leadermass = 0; // lacking another criteria, choose the heaviest guy for (Ship* member : m_members) { float membermass = member->physics().mass(); if (!newleader || membermass > leadermass) { newleader = member; leadermass = newleader->physics().mass(); } } assert(newleader); setLeader(newleader); } else { m_leader = nullptr; } }
void Party::disband() { if (!g_events->eventPartyOnDisband(this)) { return; } Player* currentLeader = leader; setLeader(nullptr); currentLeader->setParty(nullptr); currentLeader->sendClosePrivate(CHANNEL_PARTY); g_game.updatePlayerShield(currentLeader); g_game.updatePlayerHelpers(*currentLeader); currentLeader->sendCreatureSkull(currentLeader); currentLeader->sendTextMessage(MESSAGE_INFO_DESCR, "Your party has been disbanded."); for (Player* invitee : inviteList) { invitee->removePartyInvitation(this); currentLeader->sendCreatureShield(invitee); } inviteList.clear(); for (Player* member : memberList) { member->setParty(nullptr); member->sendClosePrivate(CHANNEL_PARTY); member->sendTextMessage(MESSAGE_INFO_DESCR, "Your party has been disbanded."); } for (Player* member : memberList) { g_game.updatePlayerShield(member); for (Player* otherMember : memberList) { otherMember->sendCreatureSkull(member); } member->sendCreatureSkull(currentLeader); currentLeader->sendCreatureSkull(member); g_game.updatePlayerHelpers(*member); } memberList.clear(); delete this; }
bool Party::passPartyLeadership(Player* player) { if (!player || leader == player || player->getParty() != this) { return false; } //Remove it before to broadcast the message correctly auto it = std::find(memberList.begin(), memberList.end(), player); if (it != memberList.end()) { memberList.erase(it); } std::ostringstream ss; ss << player->getName() << " is now the leader of the party."; broadcastPartyMessage(MESSAGE_INFO_DESCR, ss.str(), true); Player* oldLeader = leader; setLeader(player); memberList.insert(memberList.begin(), oldLeader); updateSharedExperience(); for (Player* member : memberList) { member->sendCreatureShield(oldLeader); member->sendCreatureShield(leader); } for (Player* invitee : inviteList) { invitee->sendCreatureShield(oldLeader); invitee->sendCreatureShield(leader); } leader->sendCreatureShield(oldLeader); leader->sendCreatureShield(leader); player->sendTextMessage(MESSAGE_INFO_DESCR, "You are now the leader of the party."); return true; }
/** * CAIGroup::updateLeader * @date Modified May 30, 2006 */ void CAIGroup::updateLeader(bool bSpawn) { // if this group has just been created, they need to spawn if (bSpawn) { std::list<CEnemy*>::iterator oEnemyIter = m_loEnemies.begin(); // set all of there states to spawning while (oEnemyIter != m_loEnemies.end()) { // tell them what group they are in ((CEnemy*)(*oEnemyIter))->getAI()->setGroup(this); ((CEnemy*)(*oEnemyIter))->setAIState(CAIStateSpawn::getInstancePtr()); oEnemyIter++; } return; } // as long as there are members of the group still spawning don't update std::list<CEnemy*>::iterator oEnemyIter = m_loEnemies.begin(); while (oEnemyIter != m_loEnemies.end()) { if (((CEnemy*)(*oEnemyIter))->getStateType() == CAIState::AIS_SPAWN) return; oEnemyIter++; } CAIManager* poAIManager = CAIManager::getInstancePtr(); CEnemy* poBestLeader; double dDist = FLT_MAX, dTempDist = FLT_MAX; // make sure the list is not empty if (m_loEnemies.empty()) { m_poLeader = NULL; return; } oEnemyIter = m_loEnemies.begin(); poAIManager->findBestGoal(*oEnemyIter, &dDist); poBestLeader = *oEnemyIter; oEnemyIter++; // find the member of the group closest to a goal while (oEnemyIter != m_loEnemies.end()) { poAIManager->findBestGoal(*oEnemyIter, &dTempDist); if (dTempDist < dDist) { poBestLeader = *oEnemyIter; dDist = dTempDist; } oEnemyIter++; } // if the leader hasn't changed, just leave it and get out of this function if (poBestLeader == m_poLeader) return; setLeader(poBestLeader); oEnemyIter = m_loEnemies.begin(); while (oEnemyIter != m_loEnemies.end()) { if ((*oEnemyIter) != poBestLeader) (*oEnemyIter)->setAIState(CAIStateFollowLeader::getInstancePtr()); (*oEnemyIter)->getAI()->setGroup(this); oEnemyIter++; } // now make that member a Leader poBestLeader->setAIState(CAIStatePathPlan::getInstancePtr()); }