////////////////////////////////////////////////////////////////////////////////
// cv_hmc_notenough - Horse Merchant Not Enough Gold
// By Deva B. Winblood.   November 14th, 2008.
////////////////////////////////////////////////////////////////////////////////

#include "x3_inc_horse"

int StartingConditional()
{
    object oPC=GetPCSpeaker();
    int nGold=GetGold(oPC);
    int nMode=GetLocalInt(oPC,"nMode");
    int nParm=GetLocalInt(oPC,"nParm");
    int nCost=1;
    if (nMode==0)
    { // horse
        if (nParm==1) nCost=100;
        else if (nParm<4) nCost=110;
        else if (nParm==4) nCost=125;
    } // horse
    else if (nMode==1)
    { // pony
        nCost=100;
    } // pony
    else if (nMode==2)
    { // war horse
        if (nParm==1) nCost=500;
        else if (nParm<4) nCost=525;
        else if (nParm==4) nCost=550;
    } // war horse
    else if (nMode==3)
    { // purchase equipment
        if (nParm==1) nCost=50;
        else if (nParm==3) nCost=250;
        else if (nParm==5) nCost=500;
        else if (nParm==4) nCost=1000;
        else if (nParm==6) nCost=150;
        else if (nParm==7) nCost=150;
        SetLocalInt(oPC,"nCost",nCost);
    } // purchase equipment
    else if (nMode==4)
    { // sell equipment
        object oHorse=HorseGetMyHorse(oPC);
        int nTail=GetCreatureTailType(oHorse);
        nParm=nTail-GetLocalInt(oHorse,"bDBW_HORSE");
        nCost=0;
        if (nParm==1) nCost=30;
        else if (nParm==3) nCost=175;
        else if (nParm==5) nCost=400;
        else if (nParm==4) nCost=800;
        else if (nParm==6) nCost=125;
        else if (nParm==7) nCost=125;
        SetLocalInt(oPC,"nCost",nCost);
        SetCustomToken(111408,IntToString(nCost));
    } // sell equipment
    else if (nMode==5)
    { // sell horse
        object oHorse=HorseGetMyHorse(oPC);
        int nTail=GetCreatureTailType(oHorse);
        nParm=nTail-GetLocalInt(oHorse,"bDBW_HORSE");
        nCost=0;
        if (nParm==1) nCost=30;
        else if (nParm==3) nCost=175;
        else if (nParm==5) nCost=400;
        else if (nParm==4) nCost=800;
        else if (nParm==6) nCost=125;
        else if (nParm==7) nCost=125;
        string sResRef=GetResRef(oHorse);
        if (sResRef=="horse1"||sResRef=="horse2"||sResRef=="horse3"||sResRef=="horse4") nCost=nCost+75;
        else if (sResRef=="pony1") nCost=nCost+70;
        else if (sResRef=="warhorse1"||sResRef=="warhorse2"||sResRef=="warhorse3"||sResRef=="warhorse4") nCost=nCost+400;
        SetLocalInt(oPC,"nCost",nCost);
        SetCustomToken(111408,IntToString(nCost));
    } // sell horse
    if (nGold<nCost&&nMode<4) return TRUE;
    return FALSE;
}