void Human_Stablemaster::handleTargetInput( P_PLAYER player, cUORxTarget* target ) { if ( !player ) return; P_ITEM pPack = m_npc->getBankbox(); if ( !pPack ) return; P_NPC pPet = dynamic_cast<P_NPC>( World::instance()->findChar( target->serial() ) ); if ( !pPet ) { m_npc->talk( tr( "I cannot stable that!" ) ); return; } if ( pPet->owner() != player ) { m_npc->talk( tr( "This does not belong to you!" ) ); return; } // we spawn a worldgem in the stablemasters bankbox for the pet // it does only hold the serial of it, the serial of the owner and the // number of refresh signals since begin of stabling // the pet becomes "free", which means, that it isnt in the world // but will still be saved. P_ITEM pGem = new cItem(); pGem->Init( true ); pGem->setTag( "player", cVariant( player->serial() ) ); pGem->setTag( "pet", cVariant( pPet->serial() ) ); pGem->setId( 0x1ea7 ); pGem->setName( tr( "petitem: %1" ).arg( pPet->name() ) ); pGem->setVisible( 2 ); // gm visible pPack->addItem( pGem ); pGem->update(); //pPet->free = true; MapObjects::instance()->remove( pPet ); pPet->setStablemasterSerial( this->m_npc->serial() ); pPet->removeFromView(); // we need this for db saves m_npc->talk( tr( "Say release to get your pet back!" ) ); }
bool cPlayer::mount( P_NPC pMount ) { if ( !pMount ) return false; if ( isDead() ) { return false; } unsigned short mountId = pMount->mountId(); if ( !mountId ) { return false; // Not mountable } cUOSocket* socket = this->socket(); if ( !inRange( pMount, Config::instance()->mountRange() ) && !isGM() ) { if ( socket ) socket->sysMessage( 500206 ); // That is too far away to ride. return true; // Mountable, but not in range } if ( pMount->owner() == this || isGM() ) { unmount(); P_ITEM pMountItem = new cItem; pMountItem->Init(); pMountItem->setId( mountId ); pMountItem->setColor( pMount->skin() ); if ( direction() != pMount->direction() ) { setDirection( pMount->direction() ); update(); } this->addItem( cBaseChar::Mount, pMountItem ); pMountItem->setTag( "pet", cVariant( pMount->serial() ) ); pMountItem->update(); // if this is a gm lets tame the animal in the process if ( isGM() ) { pMount->setOwner( this ); pMount->setTamed( true ); } // remove it from screen! pMount->bark( Bark_Idle ); pMount->removeFromView( false ); pMount->fight( 0 ); pMount->setStablemasterSerial( serial_ ); } else if ( pMount->owner() == 0 ) { socket->clilocMessage( 501263, 0, 0x3b2, 3, this ); // That mount does not look broken! You would have to tame it to ride it. } else socket->clilocMessage( 501264, 0, 0x3b2, 3, this ); // This isn't your mount; it refuses to let you ride. return true; }
void cPlayer::mount( P_NPC pMount ) { if ( !pMount ) return; cUOSocket* socket = this->socket(); if ( !inRange( pMount, 2 ) && !isGM() ) { if ( socket ) socket->sysMessage( tr( "You are too far away to mount!" ) ); return; } if ( pMount->owner() == this || isGM() ) { unmount(); P_ITEM pMountItem = new cItem; pMountItem->Init(); pMountItem->setId( 0x915 ); pMountItem->setColor( pMount->skin() ); switch ( static_cast<unsigned short>( pMount->body() & 0x00FF ) ) { case 0xC8: pMountItem->setId( 0x3E9F ); break; // Horse case 0xE2: pMountItem->setId( 0x3EA0 ); break; // Horse case 0xE4: pMountItem->setId( 0x3EA1 ); break; // Horse case 0xCC: pMountItem->setId( 0x3EA2 ); break; // Horse case 0xD2: pMountItem->setId( 0x3EA3 ); break; // Desert Ostard case 0xDA: pMountItem->setId( 0x3EA4 ); break; // Frenzied Ostard case 0xDB: pMountItem->setId( 0x3EA5 ); break; // Forest Ostard case 0xDC: pMountItem->setId( 0x3EA6 ); break; // LLama case 0x34: pMountItem->setId( 0x3E9F ); break; // Brown Horse case 0x4E: pMountItem->setId( 0x3EA0 ); break; // Grey Horse case 0x50: pMountItem->setId( 0x3EA1 ); break; // Tan Horse case 0x74: pMountItem->setId( 0x3EB5 ); break; // Nightmare case 0x75: pMountItem->setId( 0x3EA8 ); break; // Silver Steed case 0x72: pMountItem->setId( 0x3EA9 ); break; // Dark Steed case 0x7A: pMountItem->setId( 0x3EB4 ); break; // Unicorn case 0x84: pMountItem->setId( 0x3EAD ); break; // Kirin case 0x73: pMountItem->setId( 0x3EAA ); break; // Etheral case 0x76: pMountItem->setId( 0x3EB2 ); break; // War Horse-Brit case 0x77: pMountItem->setId( 0x3EB1 ); break; // War Horse-Mage Council case 0x78: pMountItem->setId( 0x3EAF ); break; // War Horse-Minax case 0x79: pMountItem->setId( 0x3EB0 ); break; // War Horse-Shadowlord case 0xAA: pMountItem->setId( 0x3EAB ); break; // Etheral LLama case 0x3A: pMountItem->setId( 0x3EA4 ); break; // Forest Ostard case 0x39: pMountItem->setId( 0x3EA3 ); break; // Desert Ostard case 0x3B: pMountItem->setId( 0x3EA5 ); break; // Frenzied Ostard case 0x90: pMountItem->setId( 0x3EB3 ); break; // Seahorse case 0xAB: pMountItem->setId( 0x3EAC ); break; // Etheral Ostard case 0xBB: pMountItem->setId( 0x3EB8 ); break; // Ridgeback case 0x17: pMountItem->setId( 0x3EBC ); break; // giant beetle case 0x19: pMountItem->setId( 0x3EBB ); break; // skeletal mount case 0x1a: pMountItem->setId( 0x3EBD ); break; // swamp dragon case 0x1f: pMountItem->setId( 0x3EBE ); break; // armor dragon } this->addItem( cBaseChar::Mount, pMountItem ); pMountItem->setTag( "pet", cVariant( pMount->serial() ) ); pMountItem->update(); // if this is a gm lets tame the animal in the process if ( isGM() ) { pMount->setOwner( this ); } // remove it from screen! pMount->bark( Bark_Idle ); pMount->removeFromView( false ); pMount->fight( 0 ); pMount->setStablemasterSerial( serial_ ); } else socket->sysMessage( tr( "You dont own that creature." ) ); }
// New Class implementation void DragAndDrop::grabItem( cUOSocket* socket, cUORxDragItem* packet ) { // Get our character P_PLAYER pChar = socket->player(); if ( !pChar ) return; float weight = pChar->weight(); // Fetch the grab information UI16 amount = packet->amount(); if ( !amount ) amount = 1; P_ITEM pItem = FindItemBySerial( packet->serial() ); // If it's an invalid pointer we can't even bounce if ( !pItem ) return; // Are we already dragging an item ? // Bounce it and reject the move // (Logged out while dragging an item) if ( socket->dragging() ) { socket->bounceItem( socket->dragging(), BR_ALREADY_DRAGGING ); return; } // Check if the item can be reached if (pItem->getOutmostChar() != pChar && !pChar->lineOfSight(pItem)) { socket->bounceItem( pItem, BR_OUT_OF_REACH ); return; } if ( pItem->onPickup( pChar ) ) return; if ( pChar->onPickup( pItem ) ) return; // Do we really want to let him break his meditation // When he picks up an item ? // Maybe a meditation check here ?!? pChar->disturbMed(); // Meditation P_CHAR itemOwner = pItem->getOutmostChar(); // Try to pick something out of another characters posessions if ( !pChar->isGM() && itemOwner && ( itemOwner != pChar ) && ( itemOwner->objectType() == enNPC && dynamic_cast<P_NPC>( itemOwner )->owner() != pChar ) ) { socket->bounceItem( pItem, BR_BELONGS_TO_SOMEONE_ELSE ); return; } // Check if the user can grab the item if ( !pChar->canPickUp( pItem ) ) { socket->bounceItem( pItem, BR_CANNOT_PICK_THAT_UP ); return; } // The user can't see the item // Basically thats impossible as the socket should deny moving the item // if it's not in line of sight but to prevent exploits /*if( !line_of_sight( socket->socket(), pChar->pos, pItem->pos, TREES_BUSHES|WALLS_CHIMNEYS|DOORS|ROOFING_SLANTED|FLOORS_FLAT_ROOFING|LAVA_WATER ) ) { socket->sysMessage( "You can't see the item." ); bounceItem( socket, pItem, true ); return; }*/ P_ITEM outmostCont = pItem->getOutmostItem(); // If the top-most container ( thats important ) is a corpse // and looting is a crime, flag the character criminal. if ( !pChar->isGM() && outmostCont && outmostCont->corpse() ) { // For each item we take out we loose carma // if the corpse is innocent and not in our guild bool sameGuild = true;//( GuildCompare( pChar, outmostCont->owner() ) != 0 ); if ( outmostCont->hasTag( "notoriety" ) && outmostCont->getTag( "notoriety" ).toInt() == 1 && !pChar->owns( outmostCont ) && !sameGuild ) { // pChar->karma -= 5; pChar->setKarma( pChar->karma() - 5 ); pChar->setCriminalTime( Server::instance()->time() + Config::instance()->crimtime() * MY_CLOCKS_PER_SEC ); socket->sysMessage( tr( "You lost some karma." ) ); } } // Check if the item is too heavy //if( !pc_currchar->isGMorCounselor() ) //{ //} << Deactivated (DarkStorm) // ==== Grabbing the Item is allowed here ==== // Send the user a pickup sound if we're picking it up // From a container/paperdoll if ( !pItem->isInWorld() ) socket->soundEffect( 0x57, pItem ); // If we're picking up a specific amount of what we got // Take that into account if ( amount < pItem->amount() ) { UI32 pickedAmount = QMIN( amount, pItem->amount() ); // We only have to split if we're not taking it all if ( pickedAmount != pItem->amount() ) { P_ITEM splitItem = pItem->dupe(); // Create a new item to pick that up splitItem->setAmount( pItem->amount() - pickedAmount ); // Add tags to the splitted item QStringList keys = pItem->getTags(); QStringList::const_iterator it = keys.begin(); for ( ; it != keys.end(); ++it ) { splitItem->setTag( *it, pItem->getTag( *it ) ); } P_ITEM pContainer = dynamic_cast<P_ITEM>( pItem->container() ); if ( pContainer ) pContainer->addItem( splitItem, false ); splitItem->SetOwnSerial( pItem->ownSerial() ); splitItem->setSpawnregion( pItem->spawnregion() ); // He needs to see the new item splitItem->update(); // If we're taking something out of a spawn-region it's spawning "flag" is removed isn't it? pItem->setAmount( pickedAmount ); } } // *normally* we should exclude the dragging socket here. but it works so as well. pItem->removeFromView( true ); // Remove from spawnregion pItem->setSpawnregion( 0 ); // Remove it from the World if it is in world, otherwise remove it from it's current container if ( pItem->isInWorld() ) MapObjects::instance()->remove( pItem ); else pItem->removeFromCont( true ); // Remove eventual item-bonusses if we're unequipping something if ( pItem->container() && pItem->container()->isChar() ) { P_CHAR wearer = dynamic_cast<P_CHAR>( pItem->container() ); // resend the stat window if ( wearer && wearer->objectType() == enPlayer ) { P_PLAYER pp = dynamic_cast<P_PLAYER>( wearer ); if ( pp->socket() ) pp->socket()->sendStatWindow(); } } pChar->addItem( cBaseChar::Dragging, pItem ); if ( weight != pChar->weight() ) { socket->sendStatWindow(); } }