コード例 #1
0
ファイル: dragdrop.cpp プロジェクト: nox-wizard/noxwizard
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;
}
コード例 #2
0
static bool ItemDroppedOnGuard(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);
	// Search for the key word "the head of"
	if( strstr( pi->name, "the head of" ) )
	{
		// This is a head of someone, see if the owner has a bounty on them
		int nCharIdx = calcCharFromSer( pi->ownserial );
		
		if( chars[nCharIdx].questBountyReward > 0 )
		{
			// Give the person the bounty assuming that they are not the
			// same person as the reward is for
			if( pc_currchar->serial != chars[nCharIdx].serial )
			{
				// give them the gold for bringing the villan to justice
				addgold( s, chars[nCharIdx].questBountyReward );
				goldsfx( s, chars[nCharIdx].questBountyReward );
				
				// Now thank them for their hard work
				sprintf((char*) temp, "Excellent work! You have brought us the head of %s. Here is your reward of %d gold coins.",
					chars[nCharIdx].name,
					chars[nCharIdx].questBountyReward );
				npctalk( s, t, (char*)temp, 0);
				
				// Delete the Bounty from the bulletin board
				BountyDelete( chars[nCharIdx].serial );
				
				// Adjust their karma and fame back to what it was before the beheading!
				pc_currchar->fame   += 100;
				pc_currchar->karma  += 100;
			}
			else
				npctalk(s, t, "You can not claim that prize scoundrel. You are lucky I don't strike you down where you stand!",0);
			
			// Delete the item
			Items->DeleItem(pi);
			return true;
		}
	}
	return true;
}
コード例 #3
0
//////////////////////////////////////////////////////////////////////////////
// FUNCTION:    BountyCreate( int nMurdererSerial, int nRewardAmount )
//
// PURPOSE:     Used to create the bounty posting message on the global
//              bulletin board for all to see.
// 
// PARAMETERS:  nMurdererSerial Murderer characters serial number
//              nRewardAmount   Bounty placed on the murderers head
//
// RETURNS:     TRUE  Bounty post successfully created
//              FALSE Bounty post could not be created
//////////////////////////////////////////////////////////////////////////////
bool cBounty::BountyCreate( int nMurdererSerial, int nRewardAmount )
{
  int   nIndex      = calcCharFromSer( nMurdererSerial );
  int   nPostSerial = 0;
  
  P_CHAR pc_nIndex = MAKE_CHARREF_LOGGED(nIndex,err);
  if (err) return false;

  // Check that we have a reward amount greater than zero
  if( nRewardAmount > 0 )
  {
    // Check that this murderer doesn't already have a bounty on them
    if( pc_nIndex->questBountyReward > 0 )
    {
      // This murderer already has a bounty on them because they 
      // have a reward amount on their head, so delete old bounty
      // and add the new (updated) one
      nRewardAmount += pc_nIndex->questBountyReward;
      BountyDelete( nMurdererSerial );
    }

    // Attempt to post the message first
    pc_nIndex->questBountyReward = nRewardAmount;
    nPostSerial = MsgBoardPostQuest( nMurdererSerial, BOUNTYQUEST );

    // If we received a valid serial number then the post was successfull
    if( nPostSerial > 0 )
    {
      pc_nIndex->questBountyPostSerial = nPostSerial;
      return true;
    }
  }

  // Failed to post bounty
  sprintf((char*)temp, "BountyCreate():  FAILED to place a bounty of %i on %s (PostSerial=%x)\n",
          nRewardAmount,
          pc_nIndex->name,
          nPostSerial );
  LogWarning((char*)temp);

  // Post must have failed
  return false;

} // BountyCreate()