Example #1
0
bool InputSpeech( cUOSocket* socket, P_PLAYER pChar, const QString& speech )
{
	if ( pChar->inputMode() == cPlayer::enNone )
		return false;

	P_ITEM pItem = FindItemBySerial( pChar->inputItem() );

	if ( !pItem )
		return false;

	//bool ok = false;
	//Q_INT32 num = speech.toInt( &ok ); // Generally try to convert it
	QString notification;

	switch ( pChar->inputMode() )
	{
		// Pricing an item - PlayerVendors
		case cPlayer::enPricing:
			socket->sysMessage( "Ops, sorry not implemented" );
			pChar->setInputMode( cPlayer::enDescription );
			socket->sysMessage( tr( "Enter a description for this item." ) );
			break;

			// Describing an item
		case cPlayer::enDescription:
			socket->sysMessage( "Description is not used anywhere :( not implemented right now" );
			socket->sysMessage( tr( "This item is now described as %1." ).arg( speech ) );
			pChar->setInputMode( cPlayer::enNone );
			pChar->setInputItem( INVALID_SERIAL );
			break;

			// Renaming ourself
		case cPlayer::enNameDeed:
			pChar->setName( speech );
			socket->sysMessage( tr( "Your new name is: %1" ).arg( speech ) );
			pChar->setInputMode( cPlayer::enNone );
			pChar->setInputItem( INVALID_SERIAL );
			break;

			// Renaming a house sign
		case cPlayer::enHouseSign:
			pItem->setName( speech );
			socket->sysMessage( tr( "Your house has been renamed to: %1" ).arg( speech ) );
			pChar->setInputMode( cPlayer::enNone );
			pChar->setInputItem( INVALID_SERIAL );
			break;

		default:
			break;	// do nothing
	}

	return true;
}
void DragAndDrop::dropItem( cUOSocket* socket, cUORxDropItem* packet )
{
	P_PLAYER pChar = socket->player();

	if ( !pChar )
		return;

	// Get the data
	//SERIAL contId = packet->cont();

	Coord_cl dropPos = pChar->pos(); // plane
	dropPos.x = packet->x();
	dropPos.y = packet->y();
	dropPos.z = packet->z();

	// Get possible containers
	P_ITEM pItem = FindItemBySerial( packet->serial() );

	if ( !pItem )
		return;

	P_ITEM iCont = FindItemBySerial( packet->cont() );
	P_CHAR cCont = FindCharBySerial( packet->cont() );

	// A completely invalid Drop packet
	if ( !iCont && !cCont && ( dropPos.x == 0xFFFF ) && ( dropPos.y == 0xFFFF ) )
	{
		socket->bounceItem( pItem, BR_NO_REASON );
		return;
	}

	float weight = pChar->weight();

	// Item dropped on Ground
	if ( !iCont && !cCont )
		dropOnGround( socket, pItem, dropPos );

	// Item dropped on another item
	else if ( iCont )
		dropOnItem( socket, pItem, iCont, dropPos );

	// Item dropped on char
	else if ( cCont )
		dropOnChar( socket, pItem, cCont );

	// Handle the sound-effect
	if ( pItem->id() == 0xEED )
		pChar->goldSound( pItem->amount() );

	// Update our weight.
	if ( weight != pChar->weight() )
		socket->sendStatWindow();
}
Example #3
0
bool cBounty::BountyWithdrawGold( P_CHAR pVictim, int nAmount )
{
	int has = pVictim->CountBankGold();
	if (has < nAmount)
		return false;

	P_ITEM pBox = pVictim->GetBankBox();
	if (!pBox)
		return false;	// shouldn't happen coz it's needed in CountBankGold...

	pBox->DeleteAmount(nAmount,0x0EED);
	return true;
}
Example #4
0
float Action_MoveToTarget::preCondition()
{
	/*
	 * Moving to the target has the following preconditions:
	 * - A target has been set.
	 * - The NPC is not in combat range.
	 *
	 * Here we take the fuzzy logic into account.
	 * If the npc is injured, the chance of fighting will decrease.
	 */

	if ( !m_ai )
	{
		return 0.0f;
	}

	P_CHAR currentVictim = m_ai->currentVictim();

	if ( !currentVictim || !validTarget( m_npc, currentVictim ) )
	{
		return 0.0f;
	}

	Q_UINT8 range = 1;
	P_ITEM weapon = m_npc->getWeapon();

	if ( weapon )
	{
		if ( weapon->hasTag( "range" ) )
		{
			range = weapon->getTag( "range" ).toInt();
		}
		else if ( weapon->basedef() )
		{
			range = weapon->basedef()->getIntProperty( "range", 1 );
		}
	}

	if ( m_npc->inRange( currentVictim, range ) )
		return 0.0f;

	// 1.0 = Full Health, 0.0 = Dead
	float diff = 1.0 - wpMax<float>( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );

	if ( diff <= m_npc->criticalHealth() / 100.0 )
	{
		return 0.0;
	}

	return 1.0;
}
Example #5
0
static bool ItemDroppedOnGuard(NXWCLIENT ps, PKGx08 *pp, P_ITEM pi)
{
	if (ps == NULL)
		return false;
	VALIDATEPIR(pi, false);
	char temp[TEMP_STR_SIZE]; //xan -> this overrides the global temp var
	NXWSOCKET  s=ps->toInt();
	P_CHAR pc = ps->currChar();
	VALIDATEPCR(pc,false);

	P_CHAR pc_t=pointers::findCharBySerial(pp->Tserial); //the guard
	VALIDATEPCR(pc_t,false);
	// Search for the key word "the head of"
	if( strstr( pi->getCurrentNameC(), "the head of" ) ) //!!! Wrong! it must check the ItemID, not the name :(
	{
		// This is a head of someone, see if the owner has a bounty on them
		P_CHAR own=pointers::findCharBySerial(pi->getOwnerSerial32());
		VALIDATEPCR(own,false);

		if( own->questBountyReward > 0 )
		{
			// Give the person the bounty assuming that they are not the
			// same person as the reward is for
			if( pc->getSerial32() != own->getSerial32() )
			{
				// give them the gold for bringing the villan to justice
				addgold( s, own->questBountyReward );
				pc->playSFX( goldsfx( own->questBountyReward ) );

				// Now thank them for their hard work
				sprintf( temp, TRANSLATE("Excellent work! You have brought us the head of %s. Here is your reward of %d gold coins."),
					own->getCurrentNameC(), own->questBountyReward );
				pc_t->talk( s, temp, 0);

				// Delete the Bounty from the bulletin board
				BountyDelete(own );

				// xan : increment fame & karma :)
				pc->modifyFame( ServerScp::g_nBountyFameGain );
				pc->IncreaseKarma(ServerScp::g_nBountyKarmaGain);
			}
			else
				pc_t->talk( s, TRANSLATE("You can not claim that prize scoundrel. You are lucky I don't strike you down where you stand!"),0);

			// Delete the item
			pi->Delete();
		}
	}
	return true;
}
void cAllSpawnRegions::postWorldLoading()
{
	cItemIterator iItems;
	for( P_ITEM pItem = iItems.first(); pItem; pItem = iItems.next() )
	{
		QString srname = pItem->spawnregion();
		if( !srname.isNull() )
		{
			cSpawnRegion* spawnregion = region( srname );
			if( spawnregion )
				spawnregion->add( pItem->serial() );
		}
	}
}
Example #7
0
	/*!
	\brief initializes pointer maps
	\author Luxor
	*/
	void init()
	{


		pStableMap.clear();
		pContMap.clear();
		pMounted.clear();
		pOwnCharMap.clear();
		pOwnItemMap.clear();
		//Chars and Stablers
		P_CHAR pc = 0;

		cAllObjectsIter objs;

		for( objs.rewind(); !objs.IsEmpty(); objs++ )
		{
			if( isCharSerial( objs.getSerial() ) ) {
				pc=(P_CHAR)objs.getObject();
				{
					if( pc->isStabled() ) {
						pStableMap[pc->getStablemaster()].push_back(pc);
					}
					if( pc->mounted )
						pMounted[pc->getOwnerSerial32()]=pc;

					P_CHAR own=pointers::findCharBySerial(pc->getOwnerSerial32());
					pc->setOwnerSerial32( DEREF_P_CHAR(own), true );
				}
			}
			else {

				P_ITEM pi = (P_ITEM)objs.getObject();

				updContMap(pi);

				P_CHAR own=pointers::findCharBySerial(pi->getOwnerSerial32());
				pi->setOwnerSerial32( DEREF_P_CHAR(own), true );
			}
		}

		std::map< SERIAL, P_CHAR >::iterator iter( pMounted.begin() ), end( pMounted.end() );
		for( ; iter!=end; iter++)
		{
			pc = pointers::findCharBySerial(iter->first);
			if(ISVALIDPC(pc))
				pc->setOnHorse();
		}
	}
// do one spawn and reset the timer
void cSpawnRegion::reSpawn( void )
{
	this->checkForDeleted();

	UI16 i = 0;
	for( i = 0; i < this->npcsPerCycle_; i++ )
	{
		if( this->npcSerials_.size() < this->maxNpcAmt_ )
		{
			// spawn a random npc
			// first find a valid position for the npc
			Coord_cl pos;
			if( this->findValidSpot( pos ) )
			{
				QString NpcSect = this->npcSections_[ RandomNum( 1, this->npcSections_.size() ) - 1 ];
				P_NPC pc = cCharStuff::createScriptNpc( NpcSect, pos );
				if( pc != NULL )
				{
					this->npcSerials_.push_back( pc->serial() );
					pc->setSpawnregion( this->name_ );
				}
			}
		}
	}

	for( i = 0; i < this->itemsPerCycle_; i++ )
	{
		if( this->itemSerials_.size() < this->maxItemAmt_ )
		{
			// spawn a random item
			// first find a valid position for the item
			Coord_cl pos;
			if( this->findValidSpot( pos ) )
			{
				QString ItemSect = this->itemSections_[ RandomNum( 1, this->itemSections_.size() ) - 1 ];
				P_ITEM pi = cItem::createFromScript( ItemSect );
				if( pi != NULL )
				{
					pi->moveTo( pos );
					this->itemSerials_.push_back( pi->serial() );
//					pi->setSpawnRegion( this->name_ );
				}
			}
		}
	}

	this->nextTime_ = uiCurrentTime + RandomNum( this->minTime_, this->maxTime_ ) * MY_CLOCKS_PER_SEC;
}
void cSpawnRegion::spawnSingleItem()
{
	Coord_cl pos;
	if ( findValidSpot( pos ) )
	{
		QString ItemSect = this->itemSections_[RandomNum( 1, this->itemSections_.size() ) - 1];
		P_ITEM pi = cItem::createFromScript( ItemSect );
		if ( pi )
		{
			pi->moveTo( pos, true );
			pi->setSpawnregion( this );
			pi->update();
			onSpawn( pi );
		}
	}
}
Example #10
0
static void item_bounce4(const NXWSOCKET  socket, const P_ITEM pi)
{
	VALIDATEPI( pi );
	item_bounce3(pi);
	if( (pi->getId() >>8) < 0x40)
		senditem( socket, pi );
}
Example #11
0
static LOGICAL canMine( P_CHAR pc, P_ITEM weapon )
{

	VALIDATEPCR(pc,false);
	
	if( !ISVALIDPI(weapon) && ( pc->CountItemsByType(ITYPE_MINING) <= 0 ) )
			pc->sysmsg( TRANSLATE("You must have a pickaxe or shovel in hand in order to mine."));
	else
	{
		if ( (ISVALIDPI(weapon) && ( weapon->getType() == ITYPE_MINING )) || (pc->CountItemsByType(ITYPE_MINING) > 0 ))
		// Let's see if he has a shovel in his pack
		{
			if (pc->isMounting())
				pc->sysmsg( TRANSLATE("You cant mine while on a horse!"));
			else
				if( !pc->IsGM() && (ores.stamina<0) && (abs( ores.stamina )>pc->stm) )
					pc->sysmsg( TRANSLATE("You are too tired to mine."));
				else
					return true;
					
		}
	}

	return false;
}
static bool ItemDroppedOnBeggar(P_CLIENT ps, PKGx08 *pp, P_ITEM pi)
{
	UOXSOCKET s=ps->GetSocket();
	CHARACTER cc=ps->GetCurrChar();
	P_CHAR pc_currchar = MAKE_CHARREF_LRV(cc,false);
	int t=calcCharFromSer(pp->Tserial);
	if(pi->id()!=0x0EED)
	{
		sprintf((char*)temp,"Sorry %s i can only use gold",pc_currchar->name);
		npctalk(s,t,(char*)temp,0);
		return false;
	}
	sprintf((char*)temp,"Thank you %s for the %i gold!",pc_currchar->name,pi->amount);
	npctalk(s,t,(char*)temp,0);
	if(pi->amount<=100)
	{
		pc_currchar->karma += 10;
		sysmessage(s,"You have gain a little karma!");
	}
	else
	{
		pc_currchar->karma += 50;
		sysmessage(s,"You have gain some karma!");
	}
		Items->DeleItem(pi);
	    return true;
}
Example #13
0
static bool ItemDroppedOnBeggar(NXWCLIENT ps, PKGx08 *pp, P_ITEM pi)
{
	if (ps == NULL)
		return false;

	VALIDATEPIR(pi, false);

	char temp[TEMP_STR_SIZE]; //xan -> this overrides the global temp var

	NXWSOCKET  s=ps->toInt();
	P_CHAR pc=ps->currChar();
	VALIDATEPCR(pc,false);

	P_CHAR pc_t=pointers::findCharBySerial(pp->Tserial); //beggar
	VALIDATEPCR(pc_t,false);

	if(pi->getId()!=ITEMID_GOLD)
	{
		sprintf(temp,TRANSLATE("Sorry %s i can only use gold"), pc->getCurrentNameC());
		pc_t->talk( s,temp,0);
		Sndbounce5(s);
		if (ps->isDragging())
		{
			ps->resetDragging();
			item_bounce5(s,pi);
			return true;
		}
	}
	else
	{
		sprintf(temp,TRANSLATE("Thank you %s for the %i gold!"), pc->getCurrentNameC(), pi->amount);
		pc_t->talk( s,temp,0);
		if(pi->amount<=100)
		{
			pc->IncreaseKarma(10);
			ps->sysmsg(TRANSLATE("You have gain a little karma!"));
		}
		else if(pi->amount>100)
		{
			pc->IncreaseKarma(50);
			ps->sysmsg(TRANSLATE("You have gain some karma!"));
		}
		pi->Delete();
		return true;
	}
	return true;
}
// Food was dropped on a pet
void cDragItems::dropFoodOnChar( cUOSocket* socket, P_ITEM pItem, P_CHAR pChar )
{
	// Feed our pets
	if( pChar->hunger() >= 6 || pItem->type2() == 0 || !( pChar->nutriment() & ( 1 << (pItem->type2()-1) ) ) )
	{
		socket->sysMessage( tr("It doesn't seem to want your item") );
		bounceItem( socket, pItem );
		return;
	}

	// We have three different eating-sounds (I don't like the idea as they sound too human)
	pChar->soundEffect( 0x3A + RandomNum( 1, 3 ) );

	// If you want to poison a pet... Why not
	if( pItem->poisoned() && pChar->poisoned() < pItem->poisoned() )
	{
		pChar->soundEffect( 0x246 );
		pChar->setPoisoned( pItem->poisoned() );
		
		// a lev.1 poison takes effect after 40 secs, a deadly pois.(lev.4) takes 40/4 secs - AntiChrist
		pChar->setPoisonTime( uiCurrentTime + ( MY_CLOCKS_PER_SEC * ( 40 / pChar->poisoned() ) ) );
		
		//wear off starts after poison takes effect - AntiChrist
		pChar->setPoisonWearOffTime(pChar->poisonTime() + ( MY_CLOCKS_PER_SEC * SrvParams->poisonTimer() ) );
		
		// Refresh the health-bar of our target
		pChar->resend( false );
	}

	// *You see Snowwhite eating some poisoned apples*
	// Color: 0x0026
	pChar->emote( tr( "*You see %1 eating %2*" ).arg( pChar->name() ).arg( pItem->getName() ) );

	// We try to feed it more than it needs
	if( pChar->hunger() + pItem->amount() > 6 )
	{
		pItem->setAmount( pItem->amount() - ( 6 - pChar->hunger() ) );
		pChar->setHunger( 6 );

		// Pack the rest into his backpack
		bounceItem( socket, pItem );
		return;
	}

	pChar->setHunger( pChar->hunger() + pItem->amount() );
	Items->DeleItem( pItem );
}
Example #15
0
bool cCharStuff::cBankerAI::BankCheck(int c, P_CHAR pBanker, const string& comm)
{
	P_CHAR pc_currchar = currchar[c];
	int beginoffset ;
	int endoffset ;
	int value =0 ;
	string value2;
	if ((beginoffset=comm.find_first_of("0123456789")) != string::npos)
	{
		if ((endoffset=comm.find_first_not_of("0123456789",beginoffset))== string::npos)
			endoffset = comm.length();
		value2= comm.substr(beginoffset,endoffset-beginoffset) ;
		value = str2num(value2) ;
	}

	int d = pc_currchar->CountBankGold();
	{
		int goldcount = value;
		if (goldcount < 5000 || goldcount > 1000000)
		{
			sprintf(temp, "%s you can only get checks worth 5000gp to 1000000gp.", pc_currchar->name.c_str());
			npctalk(c, pBanker, temp, 1);
			return false;
		}
		if (d >= goldcount)
		{
			const P_ITEM pi = Items->SpawnItem(c, pc_currchar, 1, "bank check", 0, 0x14, 0xF0, 0, 0, 0); // bank check
			if (pi != NULL)
			pi->type = 1000;
			pi->setId(0x14F0);
			pi->color = 0x0099;
			pi->priv |= 0x02;
			pi->value = goldcount;
			DeleBankItem(pc_currchar, 0x0EED, 0, goldcount);
			P_ITEM bankbox = pc_currchar->GetBankBox();
			bankbox->AddItem(pi);
			statwindow(c, pc_currchar);
			sprintf(temp, "%s your check has been placed in your bankbox, it is worth %i.", pc_currchar->name.c_str(), goldcount);
			npctalk(c, pBanker, temp, 1);
			return true;
		}
		else
			sprintf(temp, "%s you have insufficent funds!", pc_currchar->name.c_str());
		npctalk(c, pBanker, temp, 1);
		return true;
	}
}
void cItem::SetRandPosInCont(P_ITEM pCont)
{

	setPosition("z", 9);
	CONTINFOMAP::iterator iter( contInfo.find( pCont->getId() ) );
	if( iter==contInfo.end() || iter->second==contInfoGump.end()) {
		setPosition("x", RandomNum(18, 118));
		setPosition("y", RandomNum(50, 100));
		LogWarning("trying to put something INTO a non container, id=0x%X",pCont->getId() );
	}
	else {
		setPosition("x", RandomNum(iter->second->second.upperleft.x, iter->second->second.downright.x));
		setPosition("y", RandomNum(iter->second->second.upperleft.y, iter->second->second.downright.y));
		
	}
	
}
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!" ) );
}
Example #18
0
bool cRemoveTarget::responsed( cUOSocket* socket, cUORxTarget* target )
{
	P_CHAR pChar = FindCharBySerial( target->serial() );
	P_ITEM pItem = FindItemBySerial( target->serial() );

	if ( pChar )
	{
		pChar->remove();
	}
	else if ( pItem )
	{
		pItem->remove();
	}
	else
		socket->sysMessage( tr( "You need to select either an item or a character" ) );
	return true;
}
Example #19
0
bool cSetTarget::responsed( cUOSocket* socket, cUORxTarget* target )
{
	P_CHAR pChar = FindCharBySerial( target->serial() );
	P_ITEM pItem = FindItemBySerial( target->serial() );

	cUObject* pObject = NULL;

	if ( pItem )
		pObject = pItem;
	else if ( pChar )
		pObject = pChar;

	// Only characters and items
	if ( !pObject )
	{
		socket->sysMessage( tr( "Please select a valid character or item" ) );
		return true;
	}

	// check for rank
	if ( pChar && pChar->objectType() == enPlayer )
	{
		P_PLAYER pp = dynamic_cast<P_PLAYER>( pChar );
		if ( pp->account()->rank() >= socket->player()->account()->rank() && pp != socket->player() )
		{
			socket->sysMessage( tr( "Better do not try that!" ) );
			return true;
		}
	}

	cVariant value( this->value );
	stError* error = pObject->setProperty( key, value );

	if ( error )
	{
		socket->sysMessage( error->text );
		delete error;
	}

	if ( pChar )
		pChar->resend();
	else if ( pItem )
		pItem->update();

	return true;
}
// TESTED: OKAY
// guildnamechange(character, text) copies the text info the guildstones name field 
// (guildnumber gets calculated from the double clicked guildstones), and notifies all online
// guildmambers about the change.
void cGuildStone::ChangeName(UOXSOCKET s, char *text)
{
	list<SERIAL>::iterator it;
	for (it = guilds.begin(); it != guilds.end(); ++it)
	{
		P_ITEM pStone = FindItemBySerial(*it);
		if (pStone->name() == text) 
		{
			sysmessage(s,"This name is already taken by another guild.");
			return;
		}
	}
	this->setName( text );
	char txt[200];
	sprintf(txt, "Your guild got renamed to %s", this->name().ascii() );
	this->Broadcast(txt);
}
Example #21
0
float Action_MoveToTarget::postCondition()
{
	/*
	 * Moving to the target has the following postconditions:
	 * - The target is not set anymore.
	 * - The NPC is within fight range.
	 * - The NPC is not injured above the critical line.
	 */

	if ( !m_ai )
	{
		return 1.0f;
	}

	P_CHAR currentVictim = m_ai->currentVictim();

	if ( !currentVictim || !validTarget( m_npc, currentVictim ) )
		return 1.0f;

	Q_UINT8 range = 1;
	P_ITEM weapon = m_npc->getWeapon();
	if ( weapon )
	{
		if ( weapon->hasTag( "range" ) )
		{
			range = weapon->getTag( "range" ).toInt();
		}
		else if ( weapon->basedef() )
		{
			range = weapon->basedef()->getIntProperty( "range", 1 );
		}
	}

	if ( m_npc->inRange( currentVictim, range ) )
		return 1.0f;

	// 1.0 = Full Health, 0.0 = Dead
	float diff = 1.0 - wpMax<float>( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );

	if ( diff <= m_npc->criticalHealth() / 100.0 )
	{
		return 1.0;
	}

	return 0.0;
}
Example #22
0
void cWeight::NewCalc(P_CHAR pc)
{
	float totalweight=0.0;

	//get weight for items on players
	unsigned int ci = 0;
	P_ITEM pi;
	vector<SERIAL> vecContainer = contsp.getData(pc->serial);
	for ( ci = 0; ci < vecContainer.size(); ci++)
	{
		pi = FindItemBySerial(vecContainer[ci]);
		if (pi == NULL || (pi != NULL && pi->id() == 0x1E5E))	// trade window ?
			continue;
		if ((pi->layer()!=0x0B) && (pi->layer()!=0x10) && //no weight for hair/beard
			(pi->layer()!=0x1D) && (pi->layer()!=0x19))   //no weight for steed/bank box
		{
			totalweight+=(pi->getWeight()/100.0f);
		}
	}

	// Items in players pack
	P_ITEM pBackpack = Packitem(pc);
	if (pBackpack != NULL) totalweight += RecursePacks(pBackpack); //LB

	pc->weight = (int)totalweight;

	return;
}
Example #23
0
Q_UINT16 DynTile( const Coord& pos )
{
	MapItemsIterator ri = MapObjects::instance()->listItemsInCircle( pos, 18 );
	for ( P_ITEM mapitem = ri.first(); mapitem; mapitem = ri.next() )
	{
		if ( mapitem->isMulti() )
		{
			MultiDefinition* def = MultiCache::instance()->getMulti( mapitem->id() - 0x4000 );
			if ( !def )
				return 0;

			QValueVector<multiItem_st> multi = def->getEntries();
			for ( Q_UINT32 j = 0; j < multi.size(); ++j )
			{
				if ( ( multi[j].visible && ( mapitem->pos().x + multi[j].x == pos.x ) && ( mapitem->pos().y + multi[j].y == pos.y ) && ( abs( mapitem->pos().z + multi[j].z - pos.z ) <= 1 ) ) )
				{
					return multi[j].tile;
				}
			}
		}
		else if ( mapitem->pos() == pos )
		{
			return mapitem->id();
		}
	}
	return ( Q_UINT16 ) - 1;
}
Example #24
0
/*!
	Sends items which came in range and handles collisions with teleporters
	or damaging items.
*/
void handleItems( P_CHAR pChar, const Coord& oldpos )
{
	P_PLAYER player = dynamic_cast<P_PLAYER>( pChar );

	MapItemsIterator iter = MapObjects::instance()->listItemsInCircle( pChar->pos(), VISRANGE );
	for ( P_ITEM pItem = iter.first(); pItem; pItem = iter.next() )
	{
		// Check for item collisions here.
		if ( pChar->pos().x == pItem->pos().x && pChar->pos().y == pItem->pos().y )
		{
			if ( pItem->pos().z >= pChar->pos().z - 15 && pItem->pos().z <= pChar->pos().z + 15 )
			{
				if ( handleItemCollision( pChar, pItem ) )
				{
					break;
				}
			}
		}

		// If we are a connected player then send new items
		if ( player && player->socket() )
		{
			UI32 oldDist = oldpos.distance( pItem->pos() );
			if ( oldDist >= player->visualRange() )
			{
				// was out of range before and now is in range
				pItem->update( player->socket() );
			}
		}
	}
}
void DragAndDrop::dropOnGround( cUOSocket* socket, P_ITEM pItem, const Coord_cl& pos )
{
	P_PLAYER pChar = socket->player();

	// Check if the destination is in line of sight
	if ( !pChar->lineOfSight( pos.losItemPoint(pItem->id()) ) )
	{
		socket->bounceItem( pItem, BR_OUT_OF_SIGHT );
		return;
	}

	if ( !pChar->canPickUp( pItem ) )
	{
		socket->bounceItem( pItem, BR_CANNOT_PICK_THAT_UP );
		return;
	}

	if ( pItem->onDropOnGround( pos ) )
	{
		// We're still dragging something
		if ( socket->dragging() )
			socket->bounceItem( socket->dragging(), BR_NO_REASON );

		return;
	}

	pItem->removeFromCont();
	pItem->moveTo( pos );
	pItem->update();

	// Play Sounds for non gold items
	if (pItem->id() != 0xEED) {
		pItem->soundEffect(0x42);
	}
}
static bool ItemDroppedOnBanker(P_CLIENT ps, PKGx08 *pp, P_ITEM pi)
{
	UOXSOCKET s=ps->GetSocket();
	CHARACTER cc=ps->GetCurrChar();
	P_CHAR pc_currchar = MAKE_CHARREF_LRV(cc,true);
	int t=calcCharFromSer(pp->Tserial);
	P_ITEM bankbox = pc_currchar->GetBankBox();
	int amt = pi->amount;
	int value = pi->value;
	
	if (pi->id() == 0x14F0 && pi->type == 1000)
	{
		 const P_ITEM pi_n = Items->SpawnItem(DEREF_P_CHAR(pc_currchar), DEREF_P_CHAR(pc_currchar),value,"#",1,0x0E,0xED,0,0,0,0);
	     if(pi_n == NULL) return false;
		 sprintf((char*)temp,"%s I have cashed your check and deposited %i gold.",pc_currchar->name, value);
		 npctalk(s,t,(char*)temp,0);
		 bankbox->AddItem(pi_n);
	     statwindow(s, DEREF_P_CHAR(pc_currchar));
		 return true;
	}
    else
	{	    
	if (pi->id() == 0x0EED)
	{
		sprintf((char*)temp,"%s you have deposited %i gold.",pc_currchar->name, amt);
		npctalk(s,t,(char*)temp,0);
		bankbox->AddItem(pi);
	    statwindow(s, DEREF_P_CHAR(pc_currchar));
		return true;
	}
    else
	{
		  sprintf((char*)temp,"Sorry %s i can only deposit gold",pc_currchar->name);
		  npctalk(s,t,(char*)temp,0);
		  Sndbounce5(s);
		  if (ps->IsDragging())
		  {
			 ps->ResetDragging();
			 item_bounce5(s,pi);
			 return true;
		  }
	}
	return true;
	}
}
Example #27
0
Coord Coord::losTargetPoint( cUORxTarget* target, unsigned char map )
{
	SERIAL serial = target->serial();
	P_ITEM pItem = World::instance()->findItem( serial );
	P_CHAR pChar = World::instance()->findChar( serial );

	if ( pItem )
	{
		pItem = pItem->getOutmostItem();

		if ( pItem->container() && pItem->container()->isChar() )
		{
			return pItem->container()->pos().losCharPoint();
		}
		else
		{
			return pItem->pos().losItemPoint( pItem->id() );
		}
	}
	else if ( pChar )
	{
		return pChar->pos().losCharPoint();
	}
	else
	{
		return Coord( target->x(), target->y(), target->z(), map );
	}
}
Example #28
0
Q_UINT16 DynTile( const Coord_cl& pos )
{
	RegionIterator4Items ri( pos );
	for ( ri.Begin(); !ri.atEnd(); ri++ )
	{
		P_ITEM mapitem = ri.GetData();
		if ( mapitem )
		{
			if ( mapitem->isMulti() )
			{
				MultiDefinition* def = MultiCache::instance()->getMulti( mapitem->id() - 0x4000 );
				if ( !def )
					return 0;
				QValueVector<multiItem_st> multi = def->getEntries();
				for ( Q_UINT32 j = 0; j < multi.size(); ++j )
				{
					if ( ( multi[j].visible && ( mapitem->pos().x + multi[j].x == pos.x ) && ( mapitem->pos().y + multi[j].y == pos.y ) && ( abs( mapitem->pos().z + multi[j].z - pos.z ) <= 1 ) ) )
					{
						return multi[j].tile;
					}
				}
			}
			else if ( mapitem->pos() == pos )
				return mapitem->id();
		}
	}
	return ( Q_UINT16 ) - 1;
}
Example #29
0
/*!
	Begins CH customization
*/
static PyObject* wpSocket_customize( wpSocket* self, PyObject* args )
{
	Q_UNUSED( args );
	if ( !self->pSock )
		return PyFalse();

	if ( !checkArgItem( 0 ) )
	{
		PyErr_BadArgument();
		return NULL;
	}
	P_ITEM signpost = getArgItem( 0 );

	cUOTxStartCustomHouse custom;
	custom.setSerial( signpost->getTag( "house" ).toInt() ); // Morex of signpost contain serial of house
	self->pSock->send( &custom );
	Py_RETURN_NONE;
}
Example #30
0
/*!
	This is called when a character
	collides with an item and this
	checks for special effects the item could have.
*/
bool handleItemCollision( P_CHAR pChar, P_ITEM pItem )
{
	Coord dPos = pChar->pos();

	if ( pItem->onCollide( pChar ) )
		return true;

	return false;
}