// HCR v3.2.0 -
//::////////////////////////////////////////////////////////////////////////////
//:: FileName:  HC_Inc
//::////////////////////////////////////////////////////////////////////////////
/*
     This script contains default values for PlayerState and is included in
    any file where PlayerState must be checked.  Other PlayerState's could be
    added here.
*/
//::////////////////////////////////////////////////////////////////////////////
#include "HC_Inc_PWDB_Func"
//::////////////////////////////////////////////////////////////////////////////


// * CONSTANTS


object oMod = GetModule();
const int PWS_PLAYER_STATE_ALIVE       = 0;
const int PWS_PLAYER_STATE_DYING       = 1;
const int PWS_PLAYER_STATE_DEAD        = 2;
const int PWS_PLAYER_STATE_STABLE      = 3;
const int PWS_PLAYER_STATE_STABLEHEAL  = 6;
const int PWS_PLAYER_STATE_RESURRECTED = 7;
const int PWS_PLAYER_STATE_RESTRUE     = 8;
const int PWS_PLAYER_STATE_RAISEDEAD   = 9;


// * FUNCTION PROTOTYPES


// Set oPC's state to nPS.
void SPS(object oPC, int nPS);

// Returns the current player state of oPC.
int GPS(object oPC);

// Sets the Unique Player ID of oPC to oPC.
void SetPlayerID(object oPC);

// Returns the Unique Player ID of oPC.
string GetPlayerID(object oPC);


// * FUNCTION DEFINITIONS


//::////////////////////////////////////////////////////////////////////////////
void SPS(object oPC, int nPS)
{
    //SendMessageToPC(oPC, "Set Player State = " + IntToString(nPS));
    if (GetLocalInt(oMod, "PERSIST"))
        SetCampaignInt("HCRPC" + GetPlayerID(oPC), "PlayerState", nPS);
    else
        SetPersistentInt(oMod, "PlayerState" + GetPlayerID(oPC), nPS);
}
//::////////////////////////////////////////////////////////////////////////////
int GPS(object oPC)
{
    if (GetLocalInt(oMod, "PERSIST"))
        return GetCampaignInt("HCRPC" + GetPlayerID(oPC), "PlayerState");
    else
        return GetPersistentInt(oMod, "PlayerState" + GetPlayerID(oPC));
}
//::////////////////////////////////////////////////////////////////////////////
void SetPlayerID(object oPC)
{
    string sID = GetName(oPC) + GetPCPlayerName(oPC);
    SetLocalString(oPC, "sID", sID);
}
//::////////////////////////////////////////////////////////////////////////////
string GetPlayerID(object oPC)
{
    string sID = GetLocalString(oPC, "sID");
    if (sID == "")
    {
        SetPlayerID(oPC);
        sID = (GetName(oPC) + GetPCPlayerName(oPC));
    }
    return sID;
}
//::////////////////////////////////////////////////////////////////////////////
//void main(){}
