/*! If source is 0 and silent is true, nothing happens. Otherwise the canidate is removed from the party without notification. */ void Dispel( P_CHAR /*source*/, bool silent ) { P_PLAYER player = dynamic_cast<P_PLAYER>( World::instance()->findChar( destSer ) ); P_PLAYER leader = dynamic_cast<P_PLAYER>( World::instance()->findChar( this->leader ) ); if ( leader && leader->party() && !silent ) leader->party()->removeMember( player ); }
/*! Remove the canidate from the party and notify him. */ void Expire() { // Check if the player is still waiting for the party acceptance P_PLAYER leader = dynamic_cast<P_PLAYER>( World::instance()->findChar( this->leader ) ); P_PLAYER player = dynamic_cast<P_PLAYER>( World::instance()->findChar( destSer ) ); // Only send a decline party invitation packet if the player really is // still invited to join the party if ( leader && leader->party() && player && player->socket() && leader->party()->canidates().contains( player ) ) { player->socket()->log( LOG_TRACE, tr( "Party invitation from '%1' timed out.\n" ).arg( leader->account()->login() ) ); leader->party()->removeMember( player ); // This automatically resends and checks the party } }
void cParty::addMember( P_PLAYER player, bool update ) { // Remove him from his old party if ( player->party() ) player->party()->removeMember( player ); else removeCanidate( player ); if ( update ) send( 1008094, QString::null, player->name(), true ); members_.append( player ); player->setParty( this ); // Send the new memberlist to all members if ( update ) { this->update(); if ( player != leader_ && player->socket() ) player->socket()->clilocMessage( 1005445 ); } }
void cParty::handlePacket( cUOSocket* socket, cUOPacket* packet ) { unsigned char subcommand = ( *packet )[5]; QString message; P_PLAYER leader = 0; P_PLAYER player = socket->player(); switch ( subcommand ) { // Add a member to the party case 1: socket->clilocMessage( 1005454 ); socket->attachTarget( new cPartyInvitation( player->serial() ) ); break; // Remove member from party. case 2: if ( packet->size() == 10 ) { P_PLAYER target = dynamic_cast<P_PLAYER>( World::instance()->findChar( packet->getInt( 6 ) ) ); if ( target && player->party() && target->party() ) { if ( player->party() == target->party() && player->party()->leader() == player ) { socket->log( LOG_TRACE, tr( "Removed '%1' from the party.\n" ).arg( target->account()->login() ) ); player->party()->removeMember( target ); } else if ( target == player ) { socket->log( LOG_TRACE, tr( "Left the party.\n" ).arg( player->account()->login() ) ); player->party()->removeMember( target ); } } } break; // Send a single party member a message case 3: if ( player->party() ) { P_PLAYER target = dynamic_cast<P_PLAYER>( World::instance()->findChar( packet->getInt( 6 ) ) ); if ( target ) { socket->log( LOG_TRACE, tr( "Told '%1' in party '%2'.\n" ).arg( target->account()->login() ).arg( message ) ); QString message = packet->getUnicodeString( 10, packet->size() - 10 ); player->party()->send( player, target, message ); } } break; // Send the whole party a message case 4: if ( player->party() ) { QString message = packet->getUnicodeString( 6, packet->size() - 6 ); socket->log( LOG_TRACE, tr( "Told the whole party: '%1'.\n" ).arg( message ) ); player->party()->send( player, message ); } break; // Allow or Disallow my party from looting my corpse case 6: if ( player->party() && packet->size() == 7 ) { bool allowed = ( *packet )[6] != 0; player->party()->setLootingAllowed( player, allowed ); socket->clilocMessage( allowed ? 1005447 : 1005448 ); } break; // Accept party invitation case 8: Timers::instance()->dispel( player, 0, "cancelpartyinvitation", true, false ); leader = dynamic_cast<P_PLAYER>( World::instance()->findChar( packet->getInt( 6 ) ) ); if ( leader && leader->party() && leader->party()->canidates().contains( player ) ) { leader->party()->addMember( player ); socket->log( tr( "Accepted party invitation from '%1'.\n" ).arg( leader->account()->login() ) ); } break; // Decline party invitation case 9: Timers::instance()->dispel( player, 0, "cancelpartyinvitation", true, false ); leader = dynamic_cast<P_PLAYER>( World::instance()->findChar( packet->getInt( 6 ) ) ); if ( leader && leader->party() && leader->party()->canidates().contains( player ) ) { leader->socket()->clilocMessageAffix( 1008091, 0, player->name(), 0x3b2, 3, 0, false, true ); leader->party()->removeMember( player ); socket->clilocMessage( 1008092 ); socket->log( LOG_TRACE, tr( "Declined party invitation from '%1'.\n" ).arg( leader->account()->login() ) ); } break; default: message.sprintf( "Receieved unknown party subcommand: 0x%02x", subcommand ); message += packet->dump( packet->uncompressed() ) + "\n"; socket->log( LOG_WARNING, message ); break; }; }
bool responsed( cUOSocket* socket, cUORxTarget* target ) { if ( !isCharSerial( target->serial() ) ) { socket->clilocMessage( 1005442 ); } else { P_PLAYER leader = dynamic_cast<P_PLAYER>( World::instance()->findChar( this->player ) ); P_CHAR character = World::instance()->findChar( target->serial() ); P_NPC npc = dynamic_cast<P_NPC>( character ); P_PLAYER player = dynamic_cast<P_PLAYER>( character ); if ( !leader || ( leader->party() && leader->party()->leader() != leader ) ) { socket->clilocMessage( 1005453 ); } else if ( leader->party() && leader->party()->members().count() + leader->party()->canidates().count() >= 10 ) { socket->clilocMessage( 1008095 ); // NPC targetted } else if ( npc ) { if ( npc->isHuman() ) socket->clilocMessage( 1005443, 0, npc->saycolor(), 3, npc ); else socket->clilocMessage( 1005444 ); } else if ( leader == player ) { socket->clilocMessage( 1005439 ); } else if ( player && player->party() && player->party() == leader->party() ) { socket->clilocMessage( 1005440 ); } else if ( player && leader->party() && leader->party()->canidates().contains( player ) ) { socket->clilocMessage( 1005440 ); } else if ( player && player->party() ) { socket->clilocMessage( 1005441 ); } else if ( player && player->socket() ) { if ( !leader->party() ) { new cParty( leader ); leader->party()->update(); } player->socket()->clilocMessageAffix( 1008089, 0, leader->name(), 0x3b2, 3, 0, false, true ); leader->party()->addCanidate( player ); socket->log( LOG_TRACE, tr( "Invited '%1' to join his party.\n" ).arg( player->account()->login() ) ); // Send a party invitation request cUOTxPartyInvitation invitation; invitation.setSerial( leader->serial() ); player->socket()->send( &invitation ); // Attach a tempeffect that'll cancel the invitation after ten seconds Timers::instance()->insert( new cPartyCancelInvitation( leader->serial(), player->serial() ) ); } } return true; }
void dbl_click_item(cUOSocket* socket, SERIAL target_serial) throw() { SERIAL serial = target_serial; P_PLAYER pc_currchar = socket->player(); if( !pc_currchar->isGM() && /*pc_currchar->objectDelay() > 10 && ???*/ pc_currchar->objectDelay() >= uiCurrentTime ) { socket->sysMessage(tr("You must wait to perform another action.")); return; } else pc_currchar->setObjectDelay( SrvParams->objectDelay() * MY_CLOCKS_PER_SEC + uiCurrentTime ); P_ITEM pi = FindItemBySerial( serial ); if( !pi ) return; if( pi->container() && pi->container()->isItem() && pi->type() != 1 && !pi->isInWorld()) { // Cant use stuff that isn't in your pack. P_CHAR pc_p = pi->getOutmostChar(); if( pc_p && pc_currchar != pc_p ) return; } else if( pi->container() && pi->container()->isChar() && pi->type() != 1 && !pi->isInWorld() ) { // in a character. P_CHAR pc_p = dynamic_cast<P_CHAR>(pi->container()); if (pc_p != NULL) if( pc_p != pc_currchar && pi->layer() != 15 && pi->type() != 1 ) return; } // Criminal for looting an innocent corpse & unhidden if not owner... if( pi->corpse() ) { if (!pc_currchar->Owns(pi) && !pc_currchar->isGM()) { pc_currchar->unhide(); } // TODO: Add a XML option for this if(!pc_currchar->Owns(pi) && !pc_currchar->isGM() && pc_currchar->isInnocent()) { // Innocent Corpse and not in the same party && party allowance for looting? if (pi->hasTag("notoriety") && pi->getTag("notoriety").toInt() == 0x01) { P_PLAYER owner = dynamic_cast<P_PLAYER>(pi->owner()); bool allowed = false; if (owner && owner->party() && owner->party() == pc_currchar->party()) { // Check if the player allowed looting his corpse by party members if (owner->party()->lootingAllowed().contains(owner)) { allowed = true; } } if (!allowed) { pc_currchar->makeCriminal(); } } } } // Secure containers if( pi->isLockedDown() && pi->secured() ) { if( !pc_currchar->Owns( pi ) && !pc_currchar->isGM() ) { socket->sysMessage( tr( "That is a secured chest!" ) ); return; } } // Dead ppl can only use ankhs if( pc_currchar->isDead() && pi->type() != 16 ) { socket->sysMessage( tr( "Your ghostly hand passes trough the object." ) ); return; } // You can only use equipment on your own char if( !pc_currchar->isGM() && pi->container() && pi->container()->isChar() && pi->container() != pc_currchar ) { if( pi->layer() != 15 || !SrvParams->stealingEnabled() ) { socket->sysMessage( tr( "You cannot use items equipped by other players." ) ); return; } } // Call both events here if( pc_currchar->onUse( pi ) ) return; if( pi->onUse( pc_currchar ) ) return; // Check item behaviour by it's tpye switch (pi->type()) { case 1: // normal containers { pc_currchar->setObjectDelay( 0 ); // no delay for opening containers if( pc_currchar->isGM() ) { socket->sendContainer( pi ); return; } if( pi->layer() > 0x18 ) { socket->sysMessage( tr( "You can't see this." ) ); return; } if( isInLockedItem( pi ) ) { socket->sysMessage( tr( "You have to unlock it before taking a look." ) ); return; } if( !pi->container() ) { if( !pi->inRange( pc_currchar, 2 ) ) { socket->clilocMessage( 0x7A258, "", 0x3b2 ); // You cannot reach that return; } else if(!pc_currchar->lineOfSight(pi, true)) { socket->clilocMessage( 0x7A258, "", 0x3b2 ); // You cannot reach that return; } socket->sendContainer( pi ); return; } else if( pi->container()->isItem() ) { P_ITEM pOCont = pi->getOutmostItem(); // Check if we can reach the top-container if( !pOCont->container() ) { if( !pOCont->inRange( pc_currchar, 2 ) ) { socket->clilocMessage( 0x7A258, "", 0x3b2 ); // You cannot reach that return; } socket->sendContainer( pi ); } else { P_CHAR pChar = dynamic_cast< P_CHAR >( pOCont->container() ); if( pChar && pChar != pc_currchar ) { if( !pChar->inRange( pc_currchar, 2 ) ) socket->sysMessage( tr( "You must stand nearer to snoop!" ) ); else Skills->Snooping( pc_currchar, pi ); } else if( pChar == pc_currchar ) socket->sendContainer( pi ); } return; } else if( pi->container()->isChar() ) { // Equipped on another character P_CHAR pChar = dynamic_cast< P_CHAR >( pi->container() ); if( pChar && pChar != pc_currchar ) { if( !pChar->inRange( pc_currchar, 2 ) ) socket->sysMessage( tr( "You must stand nearer to snoop!" ) ); else Skills->Snooping( pc_currchar, pi ); } else if( pChar == pc_currchar ) socket->sendContainer( pi ); return; } socket->sysMessage( tr( "You can't open this container." ) ); return; } return; case 16: // Check for 'resurrect item type' this is the ONLY type one can use if dead. if( pc_currchar->isDead() ) { pc_currchar->resurrect(); socket->sysMessage( tr( "You have been resurrected." ) ); return; } else { socket->sysMessage( tr( "You are already living!" ) ); return; } // Drinks case 105: pc_currchar->soundEffect( 0x30 + RandomNum( 0, 1 ) ); pi->reduceAmount( 1 ); // Remove a drink pc_currchar->message( "Gulp!" ); return; // 1001: Sword Weapons (Swordsmanship) case 1001: // 1002: Axe Weapons (Swordsmanship + Lumberjacking) case 1002: // 1005: Fencing case 1005: // 1003: Macefighting (Staffs) case 1003: // 1004: Macefighting (Maces/WarHammer) case 1004: // 1006: Bows case 1006: // 1007: Crossbows case 1007: // 1008: Shields case 1008: break; default: break; } socket->sysMessage( tr( "You can't think of a way to use that item." ) ); }