#include "x4_inc_functions"
void RetrieveClientData(string sDB, object oClient)
{
    int nHead = GetCampaignInt(sDB, "QUEST_CLI_HEAD");
    int nPheno = GetCampaignInt(sDB, "QUEST_CLI_PHENO");
    int nHair = GetCampaignInt(sDB, "QUEST_CLI_HAIR");
    int nSkin = GetCampaignInt(sDB, "QUEST_CLI_SKIN");
    string sCloth = GetCampaignString(sDB, "QUEST_CLI_CLOTH");
    int nLaw = GetCampaignInt(sDB, "QUEST_CLI_LAW");
    int nGood = GetCampaignInt(sDB, "QUEST_CLI_GOOD");

    SetColor(oClient, COLOR_CHANNEL_HAIR, nHair);
    SetColor(oClient, COLOR_CHANNEL_SKIN, nSkin);
    SetPhenoType(nPheno, oClient);
    SetCreatureBodyPart(CREATURE_PART_HEAD, nHead, oClient);

    AdjustAlignment(oClient, ALIGNMENT_CHAOTIC, 100, FALSE);
    AdjustAlignment(oClient, ALIGNMENT_EVIL, 100, FALSE);
    AdjustAlignment(oClient, ALIGNMENT_LAWFUL, nLaw, FALSE);
    AdjustAlignment(oClient, ALIGNMENT_GOOD, nGood, FALSE);

    object oCloth = CreateItemOnObject(sCloth, oClient);
    AssignCommand(oClient, ActionEquipItem(oCloth, INVENTORY_SLOT_CHEST));

}

void main()
{
    string sDB = CharacterDB(GetPCSpeaker());
    SetLocalString(GetArea(OBJECT_SELF), "sDB", sDB);

    //Get the waypoint in a tavern at which the client should spawn
    int nTavern = GetLocalInt(GetArea(OBJECT_SELF), "TavernNumber");
    string sTag;
    switch (nTavern)
        {
            case 1: sTag = "alverton_client_post"; break;
        }
    object oWaypoint = GetWaypointByTag(sTag);

    //Get the template of the client
    string sResRef = GetCampaignString(sDB, "QUEST_CLI_RESREF");

    //Spawn the client
    object oClient = CreateObject(OBJECT_TYPE_CREATURE, sResRef, GetLocation(oWaypoint));
    SetPlotFlag(oClient, TRUE);
    SetLocalInt(oClient, "Client", TRUE);

    //Disallow the innkeeper to introduce any more quest givers before the current one disappears
    //(either because of the specific PC leaving the area or by accepting/refusing the quest)
    SetLocalInt(GetPCSpeaker(), "ClientSpawned", TRUE);
    SetLocalInt(GetArea(OBJECT_SELF), "ClientSpawned", TRUE);

    //Retrieve NPC's name
    string sName = GetCampaignString(sDB, "QUEST_CLI_NAME");
    string sLastName = GetCampaignString(sDB, "QUEST_CLI_LASTNAME");

    //Set the NPC's name and last name
    SetName(oClient, sName+" "+sLastName);
    SetLocalString(oClient, "Name", sName);
    SetLocalString(oClient, "LastName", sLastName);

    //If the ANC_MARKS switch is set to TRUE, mark the NPC with a blue exclamation VFX
    effect eExclamation = EffectVisualEffect(VFX_QUESTION_BLUE, FALSE);
    if (GetLocalInt(GetModule(), "ANC_MARKS") == TRUE) ApplyEffectToObject(DURATION_TYPE_PERMANENT, eExclamation, oClient);

}