// Updated 7/22/2011 by Zunath // Added Linux support for the REO module. There is no OnPlayerLeaving event in the Linux version of NWNX_Funcs // so instead, we have to use Letoscript to make the changes. The PC's BodyBag value is used to store this info. // This set up isn't applicable to all servers since most high level characters have massive amounts of HP and // the BodyBag field only holds up to 116 HP. But for a server like REO, this should do just fine. // Windows support remains to be used, too. // Linux requires the LetoScript pluging and the NWNX_Funcs plugin. // Windows only requires the NWNX_Funcs plugin. //#include "nwnx_funcs_l" #include "inc_mysql_tables" #include "inc_system_const" // Windows: This is fired on the OnPlayerLeaving event provided by NWNX_Funcs // Linux: This is fired on the OnClientExit event. // Will store the PC's current HP either on their database item (Windows) or on the BodyBag slot of the .bic file. void PHP_SaveHitPoints(object oPC); // Intended for use OnClientEnter // Will reduce a player's hit points so that they match the last time // they logged off. void PHP_LoadHitPoints(object oPC); void PHP_SaveHitPoints(object oPC) { int iHP = GetCurrentHitPoints(oPC); // Linux if(ADV_USING_LINUX) { object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE); int iPCID = GetLocalInt(oDatabase, PC_ID_NUMBER); SetMySQLData(PHP_MYSQL_TABLE, "HitPoints", iPCID, IntToString(iHP)); } // Windows else { object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE); SetLocalInt(oDatabase, "PHP_STORED_HP", iHP); } } void PHP_LoadHitPoints(object oPC) { object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE); int iFirstRun = GetLocalInt(oDatabase, "PHP_FIRSTRUN"); int iHP = GetCurrentHitPoints(oPC); // Prevents new characters from being damaged if(iFirstRun < 2) { SetLocalInt(oDatabase, "PHP_FIRSTRUN", 2); return; } int iStoredHP; // Linux if(ADV_USING_LINUX) { int iPCID = GetLocalInt(oDatabase, PC_ID_NUMBER); iStoredHP = StringToInt(GetMySQLData(PHP_MYSQL_TABLE, "HitPoints", iPCID)); } // Windows else { iStoredHP = GetLocalInt(oDatabase, "PHP_STORED_HP"); } int iDamage; // If the stored HP is in the negatives, we need to bring the PC down to 0 HP, and then apply the HP if(iStoredHP < 0) { iDamage = iHP + abs(iStoredHP); } // Otherwise the stored HP is in the positives, so we simply need to take current HP and subtract it by the stored HP else { iDamage = iHP - iStoredHP; } // Deal damage only if the HP of oPC needs to be lowered. if(iDamage != 0) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(iDamage), oPC); } // Error checking //void main(){}