// --------------------------------------------------------- void CPartyDef::StatsUpdateAll( CChar *pCharSrc, PacketSend *pPacket ) { ADDTOCALLSTACK("CPartyDef::StatsUpdateAll"); size_t iQty = m_Chars.GetCharCount(); if ( iQty <= 0 ) return; CChar *pChar = NULL; for ( size_t i = 0; i < iQty; i++ ) { pChar = m_Chars.GetChar(i).CharFind(); if ( !pChar || !pChar->m_pClient || (pChar == pCharSrc) || !pChar->CanSee(pCharSrc) ) continue; pPacket->send(pChar->m_pClient); } }
// --------------------------------------------------------- void CPartyDef::AddStatsUpdate( CChar * pChar, PacketSend * pPacket ) { ADDTOCALLSTACK("CPartyDef::AddStatsUpdate"); size_t iQty = m_Chars.GetCharCount(); if ( iQty <= 0 ) return; for ( size_t i = 0; i < iQty; i++ ) { CChar * pCharNow = m_Chars.GetChar(i).CharFind(); if ( pCharNow && pCharNow != pChar ) { if ( pCharNow->CanSee( pChar ) && pCharNow->IsClient() ) pPacket->send(pCharNow->GetClient()); } } }
void CChar::NPC_PetDesert() { ADDTOCALLSTACK("CChar::NPC_PetDesert"); CChar * pCharOwn = NPC_PetGetOwner(); if ( !pCharOwn ) return; if ( IsTrigUsed(TRIGGER_PETDESERT) ) { if ( OnTrigger( CTRIG_PetDesert, pCharOwn, NULL ) == TRIGRET_RET_TRUE ) return; } NPC_PetClearOwners(); if ( ! pCharOwn->CanSee(this)) pCharOwn->SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_DESERTED), GetName()); TCHAR *pszMsg = Str_GetTemp(); sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_DECIDE_MASTER), GetName()); Speak(pszMsg); // free to do as i wish ! Skill_Start( SKILL_NONE ); }
bool CPartyDef::AcceptEvent( CChar *pCharAccept, CGrayUID uidInviter, bool bForced ) // static { ADDTOCALLSTACK("CPartyDef::AcceptEvent"); // We are accepting the invite to join a party // No security checks if bForced -> true !!! // Party master is only one that can add ! GetChar(0) CChar *pCharInviter = uidInviter.CharFind(); if ( !pCharInviter || !pCharInviter->m_pClient || !pCharAccept || !pCharAccept->m_pClient || (pCharInviter == pCharAccept) ) return false; CPartyDef *pParty = pCharInviter->m_pParty; if ( !bForced ) { CVarDefCont *sTempVal = pCharInviter->GetTagDefs()->GetKey("PARTY_LASTINVITE"); if ( !sTempVal || (static_cast<CGrayUID>(sTempVal->GetValNum()) != pCharAccept->GetUID()) ) return false; pCharInviter->DeleteKey("PARTY_LASTINVITE"); if ( !pCharInviter->CanSee(pCharAccept) ) return false; } if ( pCharAccept->m_pParty ) // already in a party { if ( pParty == pCharAccept->m_pParty ) // already in this party return true; if ( bForced ) { pCharAccept->m_pParty->RemoveMember(pCharAccept->GetUID(), pCharAccept->GetUID()); pCharAccept->m_pParty = NULL; } else return false; } TCHAR *pszMsg = Str_GetTemp(); sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_PARTY_JOINED), pCharAccept->GetName()); if ( !pParty ) { // Create the party now. pParty = new CPartyDef(pCharInviter, pCharAccept); ASSERT(pParty); g_World.m_Parties.InsertHead(pParty); pCharInviter->SysMessage(pszMsg); } else { // Add to existing party if ( pParty->IsPartyFull() || (!bForced && !pParty->IsPartyMaster(pCharInviter)) ) return false; pParty->SysMessageAll(pszMsg); // tell everyone already in the party about this pParty->AcceptMember(pCharAccept); } pCharAccept->SysMessageDefault(DEFMSG_PARTY_ADDED); return true; }