Example #1
0
bool CChar::NPC_OnTrainPay(CChar *pCharSrc, CItemMemory *pMemory, CItem * pGold)
{
	ADDTOCALLSTACK("CChar::NPC_OnTrainPay");
	SKILL_TYPE skill = static_cast<SKILL_TYPE>(pMemory->m_itEqMemory.m_Skill);
	if ( !IsSkillBase(skill) || !g_Cfg.m_SkillIndexDefs.IsValidIndex(skill) )
	{
		Speak(g_Cfg.GetDefaultMsg(DEFMSG_NPC_TRAINER_FORGOT));
		return false;
	}

	int iTrainCost = (int)GetKeyNum("OVERRIDE.TRAINSKILLCOST", true);
	if ( !iTrainCost )
		iTrainCost = g_Cfg.m_iTrainSkillCost;

	iTrainCost *= NPC_OnTrainCheck(pCharSrc, skill);
	if ( (iTrainCost <= 0) || !pGold )
		return false;

	Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_TRAINER_SUCCESS ) );

	// Can't ask for more gold than the maximum amount of the gold stack i am giving to the npc
	word iTrainCostFinal = (word)minimum(UINT16_MAX, iTrainCost);

	// Consume as much money as we can train for.
	if ( pGold->GetAmount() < iTrainCost )
	{
		iTrainCostFinal = pGold->GetAmount();
	}
	else if ( pGold->GetAmount() == iTrainCostFinal)
	{
		Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_TRAINER_THATSALL_1 ) );
		pMemory->m_itEqMemory.m_Action = NPC_MEM_ACT_NONE;
	}
	else
	{
		Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_TRAINER_THATSALL_2 ) );
		pMemory->m_itEqMemory.m_Action = NPC_MEM_ACT_NONE;

		// Give change back.
		pGold->UnStackSplit( iTrainCostFinal, pCharSrc );
	}
	GetPackSafe()->ContentAdd( pGold );	// take my cash.

	// Give credit for training.
	NPC_TrainSkill( pCharSrc, skill, iTrainCost );
	return true;
}
Example #2
0
/*************************************************
 Function:		InputItem
 Descroption:	 
 Input: 
	1.Key
 Output: 
 Return: 	
 Other:  
*************************************************/
static void InputItem(INT8U Key)
{
    INT8U uchar = 0;
    INT8U mMax[12] = {
    5,  // hour    0
    9,  // hour    1
    5,  // min     2
    9,  // min     3
    9,  // year    4
    9,  // year    5
    9,  // year    6
    9,  // year    7
    1,  // month   8
    9,  // month   9
    3,  // day     10
    9   // day     11
    };
    mInput[mIndex] = GetKeyNum(Key);

    if(mInput[8] == 1)
    {
        mMax[9] = 2;
    }

    if(mInput[10] == 3)
    {
        mMax[9] = 1;
    }

    uchar = mInput[mIndex]-'0';
    
    if(uchar > mMax[mIndex])
    {
       mInput[mIndex] = mMax[mIndex]+'0';
    }
    
    ChangeItem(1);
    InvalidateRect(NULL);
}