void RestoreCharacter(ref chCorpse)
{
if(!CheckAttribute(chCorpse,"corpse")) return;
else DeleteAttribute(chCorpse,"corpse");
if(CharacterIsDead(chCorpse)) { LAi_CharacterLogoff(chCorpse); return; }
int tmpNameFileID = LanguageOpenFile("characters_names.txt");
bool bNoName;
if(CheckAttribute(chCorpse,"old.name"))
{
if(chCorpse.old.name!="")
{
if(LanguageConvertString(tmpNameFileID,chCorpse.old.name)!="") { chCorpse.name = LanguageConvertString(tmpNameFileID,chCorpse.old.name); bNoName = false; }
else { chCorpse.name = chCorpse.old.name; bNoName = false; }
}
else { chCorpse.name = chCorpse.old.name; bNoName = false; }
}
else { bNoName = true; }
if(CheckAttribute(chCorpse,"old.lastname"))
{
if(chCorpse.old.lastname!="")
{
if(LanguageConvertString(tmpNameFileID,chCorpse.old.lastname)!="") { chCorpse.lastname = LanguageConvertString(tmpNameFileID,chCorpse.old.lastname); bNoName = false; }
else { chCorpse.lastname = chCorpse.old.lastname; }
}
else { chCorpse.lastname = chCorpse.old.lastname; bNoName = false; }
}
else { bNoName = true; }
if(CheckAttribute(chCorpse,"old.firstname"))
{
if(chCorpse.old.firstname!="")
{
if(LanguageConvertString(tmpNameFileID,chCorpse.old.firstname)!="") { chCorpse.firstname = LanguageConvertString(tmpNameFileID,chCorpse.old.firstname); }
else { chCorpse.firstname = chCorpse.old.firstname; }
}
else { chCorpse.firstname = chCorpse.old.firstname; }
}
if(CheckAttribute(chCorpse,"old.middlename"))
{
if(chCorpse.old.middlename!="")
{
//if(LanguageConvertString(tmpNameFileID,chCorpse.old.middlename)!="") { chCorpse.middlename = LanguageConvertString(tmpNameFileID,chCorpse.old.middlename); }
//else { chCorpse.middlename = chCorpse.old.middlename; }
chCorpse.middlename = TranslateString("", chCorpse.old.middlename); // KK
}
else { chCorpse.middlename = chCorpse.old.middlename; }
}
LanguageCloseFile(tmpNameFileID);
if(CheckAttribute(chCorpse,"old.title"))
{
if(chCorpse.old.title!="")
{
if(TranslateString("",chCorpse.old.title)!="") { chCorpse.title = TranslateString("",chCorpse.old.title); }
else { chCorpse.title = chCorpse.old.title; }
}
else { chCorpse.title = chCorpse.old.title; }
}
if(bNoName) { SetRandomNameToCharacter(chCorpse); }
if(CheckAttribute(chCorpse,"deathx")) { DeleteAttribute(chCorpse,"deathx"); }
if(CheckAttribute(chCorpse,"deathy")) { DeleteAttribute(chCorpse,"deathy"); }
if(CheckAttribute(chCorpse,"deathz")) { DeleteAttribute(chCorpse,"deathz"); }
if(CheckAttribute(chCorpse,"deathay")) { DeleteAttribute(chCorpse,"deathay"); }
if(!CheckAttribute(chCorpse,"storedAttributes")) { LAi_CharacterLogoff(chCorpse); return; }
if(bAllies(chCorpse)) { DeleteAttribute(chCorpse,"storedAttributes"); LAi_CharacterLogoff(chCorpse); return; }
if(LAi_IsBoardingProcess()) { DeleteAttribute(chCorpse,"storedAttributes"); LAi_CharacterLogoff(chCorpse); return; }
if(CheckAttribute(chCorpse,"old.dialog.filename")) { chCorpse.dialog.filename = chCorpse.old.dialog.filename; }
if(CheckAttribute(chCorpse,"old.dialog.currentnode")) { chCorpse.dialog.currentnode = chCorpse.old.dialog.currentnode; }
if(CheckAttribute(chCorpse,"old.dialog.tempnode")) { chCorpse.dialog.tempnode = chCorpse.old.dialog.tempnode; }
if(CheckAttribute(chCorpse,"old.chr_ai.type.dialog")) { chCorpse.chr_ai.type.dialog = chCorpse.old.chr_ai.type.dialog; }
if(CheckAttribute(chCorpse,"old.chr_ai.dmgbldmin")) { chCorpse.chr_ai.dmgbldmin = chCorpse.old.chr_ai.dmgbldmin; }
if(CheckAttribute(chCorpse,"old.chr_ai.dmgbldmax")) { chCorpse.chr_ai.dmgbldmax = chCorpse.old.chr_ai.dmgbldmax; }
if(CheckAttribute(chCorpse,"old.chr_ai.piercing")) { chCorpse.chr_ai.piercing = chCorpse.old.chr_ai.piercing; }
if(CheckAttribute(chCorpse,"old.chr_ai.block")) { chCorpse.chr_ai.block = chCorpse.old.chr_ai.block; }
if(CheckAttribute(chCorpse,"old.chr_ai.charge_max")) { chCorpse.chr_ai.charge_max = chCorpse.old.chr_ai.charge_max; }
if(CheckAttribute(chCorpse,"old.chr_ai.charge_dlt")) { chCorpse.chr_ai.charge_dlt = chCorpse.old.chr_ai.charge_dlt; }
if(CheckAttribute(chCorpse,"old.chr_ai.dmggunmin")) { chCorpse.chr_ai.dmggunmin = chCorpse.old.chr_ai.dmggunmin; }
if(CheckAttribute(chCorpse,"old.chr_ai.dmggunmax")) { chCorpse.chr_ai.dmggunmax = chCorpse.old.chr_ai.dmggunmax; }
if(CheckAttribute(chCorpse,"old.chr_ai.accuracy")) { chCorpse.chr_ai.accuracy = chCorpse.old.chr_ai.accuracy; }
if(CheckAttribute(chCorpse,"old.items"))//MAXIMUS: I'm not sure that it's needed
{
aref ifrom; makearef(ifrom, chCorpse.old.items);
DeleteAttribute(chCorpse,"items");
chCorpse.items = "";
aref ito; makearef(ito, chCorpse.items);
CopyAttributes(&ito, &ifrom);
}
// KK -->
if (CheckAttribute(chCorpse, "old.chr_ai.group")) {
if (chCorpse.old.chr_ai.group != LAI_GROUP_CORPSES) {
chCorpse.chr_ai.group = chCorpse.old.chr_ai.group;
} else {
DeleteAttribute(chCorpse, "old.chr_ai.group");
LAi_group_MoveCharacter(chCorpse, LAI_DEFAULT_GROUP);
}
}
if (CheckAttribute(chCorpse, "old.chr_ai.type")) { LAi_group_MoveCharacter(chCorpse, chCorpse.old.chr_ai.type); }
//if (CheckAttribute(chCorpse, "old.chr_ai.hp")) { chCorpse.chr_ai.hp = chCorpse.old.chr_ai.hp; }//Removed by levis cause it isn't used anymore.
//if (CheckAttribute(chCorpse, "old.chr_ai.hp_max")) { chCorpse.chr_ai.hp_max = chCorpse.old.chr_ai.hp_max; }//Removed by levis cause it isn't used anymore.
if (CheckAttribute(chCorpse, "passenger")) { DeleteAttribute(chCorpse, "passenger"); } // KK
if (CheckAttribute(chCorpse, "prisoned")) { DeleteAttribute(chCorpse, "prisoned"); }
if (CheckAttribute(chCorpse, "actions")) { DeleteAttribute(chCorpse, "actions"); }
if (CheckAttribute(chCorpse, "killer")) { DeleteAttribute(chCorpse, "killer"); }
if (CheckAttribute(chCorpse, "status")) { DeleteAttribute(chCorpse, "status"); }
if (CheckAttribute(chCorpse, "position")) { DeleteAttribute(chCorpse, "position"); }
if (CheckAttribute(chCorpse, "fight")) { DeleteAttribute(chCorpse, "fight"); }
if (CheckAttribute(chCorpse, "surrendered")) { DeleteAttribute(chCorpse, "surrendered"); }
// <-- KK
if (CheckAttribute(chCorpse, "corpse")) { DeleteAttribute(chCorpse, "corpse"); }
for(int c = 0; c < 10; c++)
{
string curSkillName = GetSkillName(c);
if(CheckAttribute(chCorpse,"old.skill."+curSkillName+".mod")) { chCorpse.skill.(curSkillName).mod = chCorpse.old.skill.(curSkillName).mod; }
else { if(CheckAttribute(chCorpse,"skill."+curSkillName+".mod")) { DeleteAttribute(chCorpse,"skill."+curSkillName+".mod"); } }
}
DeleteAttribute(chCorpse,"storedAttributes");
LAi_CharacterLogoff(chCorpse);
}