static bool ItemDroppedOnTrainer(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);

	if( pi->id() ==0x0EED )
	{ // They gave the NPC gold
		char sk=chars[t].trainingplayerin;
		npctalk(s, t, "I thank thee for thy payment. That should give thee a good start on thy way. Farewell!",0);

		int sum = pc_currchar->getSkillSum();
		int delta = chars[t].getTeachingDelta(pc_currchar, sk, sum);

		if(pi->amount>delta) // Paid too much
		{
			pi->amount-=delta;
			Sndbounce5(s);
			if (ps->IsDragging())
			{
				ps->ResetDragging();
				item_bounce5(s,pi);
			}
		}
		else
		{
			if(pi->amount < delta)		// Gave less gold
				delta = pi->amount;		// so adjust skillgain
			Items->DeleItem(pi);
		}
		pc_currchar->baseskill[sk]+=delta;
		Skills->updateSkillLevel(DEREF_P_CHAR(pc_currchar), sk);
		updateskill(s,sk);

		pc_currchar->trainer=-1;
		chars[t].trainingplayerin='\xFF';
		itemsfx(s, pi->id());//AntiChrist - do the gold sound
		return true;
	}
	else // Did not give gold
	{
		npctalk(s, t, "I am sorry, but I can only accept gold.",0);
		Sndbounce5(s);
		if (ps->IsDragging())
		{
			ps->ResetDragging();
			item_bounce5(s,pi);
			return true;
		}
		else
			return true;
	}//if items[i]=gold
	return true;
}
示例#2
0
static bool ItemDroppedOnTrainer(NXWCLIENT ps, PKGx08 *pp, P_ITEM pi)
{
	if (ps == NULL) return false;
	VALIDATEPIR(pi, false);
	NXWSOCKET  s = ps->toInt();
	P_CHAR pc = ps->currChar();
	VALIDATEPCR(pc,false);
	P_CHAR pc_t = pointers::findCharBySerial(pp->Tserial);
	VALIDATEPCR(pc_t,false);

	if( pi->getId() == ITEMID_GOLD )
	{ // They gave the NPC gold
		UI08 sk=pc_t->trainingplayerin;
		pc_t->talk( s, TRANSLATE("I thank thee for thy payment. That should give thee a good start on thy way. Farewell!"),0);

		int sum = pc->getSkillSum();
		int delta = pc_t->getTeachingDelta(pc, sk, sum);

		if(pi->amount>delta) // Paid too much
		{
			pi->amount-=delta;

			Sndbounce5(s);
			if (ps->isDragging())
			{
				ps->resetDragging();
				item_bounce5(s,pi);
			}
		}
		else
		{
			if(pi->amount < delta)		// Gave less gold
				delta = pi->amount;		// so adjust skillgain
			pi->Delete();
		}
		pc->baseskill[sk]+=delta;
		Skills::updateSkillLevel(pc, sk);
		updateskill(s,sk);

		pc->trainer=-1;
		pc_t->trainingplayerin=0xFF;
		pc->playSFX( itemsfx(pi->getId()) );
	}
	else // Did not give gold
	{
		pc_t->talk( s, TRANSLATE("I am sorry, but I can only accept gold."),0);
		Sndbounce5(s);
		if (ps->isDragging())
		{
			ps->resetDragging();
			item_bounce5(s,pi);
		}
	}//if items[i]=gold
	return true;
}
void cDragItems::dropOnTrainer( P_CLIENT client, P_ITEM pItem, P_CHAR pTrainer )
{
	P_CHAR pChar = client->player();

	if( pItem->id() != 0xEED )
	{
		pTrainer->talk( "You need to give me gold if you want me to train you!" );
		bounceItem( client, pItem );
		return;
	}

	pTrainer->talk( "I thank thee for thy payment. That should give thee a good start on thy way. Farewell!" );

	Q_UINT8 skill = pTrainer->trainingplayerin();
	Q_INT32 skillSum = pChar->getSkillSum();
	Q_INT32 skillDelta = pTrainer->getTeachingDelta( pChar, skill, skillSum );

	goldsfx( client->socket(), pItem->amount() );

	if( pItem->amount() > skillDelta )
	{
		pItem->ReduceAmount( skillDelta );
		bounceItem( client, pItem );
	}
	else
	{
		skillDelta = pItem->amount();
		Items->DeleItem( pItem );
	}
	
	pChar->setBaseSkill( skill, pChar->baseSkill( skill ) + skillDelta );
	Skills->updateSkillLevel( pChar, skill );
	updateskill( client->socket(), skill );

	// we will not reset the trainer id here because he may want to give him more money
}