Files
HeroesStone_PRC8/_removed/corpse_dying.nss
Jaysyn904 1eefc84201 Initial Commit
Initial Commit.
2025-09-14 15:40:46 -04:00

168 lines
4.8 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Name corpse_dying
//:: FileName
//::
//:://////////////////////////////////////////////
/*
Creates a corpse placeable and make the dying
creature corpse remain on the battle field.
*/
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 21/04/2003
//:://////////////////////////////////////////////
#include "corpse_lib"
#include "x2_inc_switches"
#include "x0_i0_henchman"
//::///////////////////////////////////////////////
//:: Name next
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Lets the pc resurect before continueing.
*/
//:://////////////////////////////////////////////
//:: Created By: Alexandre Brunel
//:: Created On: 24/04/2003
//:://////////////////////////////////////////////
void next(location pcPlace );
void main()
{
SetCommandable(TRUE);
if(!GetIsCorpseCopying())
{
string script = GetCorpseDeathHookScript();
if(script != "")
{
if(ExecuteScriptAndReturnInt(script,OBJECT_SELF) == X2_EXECUTE_SCRIPT_END)
{
return;
}
}
if(!GetIsPC(OBJECT_SELF))
{
if(GetObjectType(OBJECT_SELF) == OBJECT_TYPE_CREATURE)
{
if(!GetRaceCannotLeaveACorpse(GetRacialType(OBJECT_SELF)))
{
int resurectable = GetIsResurectable(OBJECT_SELF);
/*if(GetLocalInt(OBJECT_SELF,CorpseNoLoot))
{
setEquippementUndroppable();
}*/
SetIsDestroyable(FALSE,resurectable,FALSE);
SetLocalLocation(OBJECT_SELF,CorpseCorpseLocation,GetLocation(OBJECT_SELF));
CreateCorpsePlaceable();
}
}
}
else
{
if(!GetIsObjectValid(GetLocalObject(OBJECT_SELF,CorpsePCCorpse)) && GetIsDead(OBJECT_SELF))
{
location pcPlace = GetLocation(OBJECT_SELF);
effect resurrection = EffectResurrection();
effect death = EffectDeath(FALSE,FALSE);
object PC = OBJECT_SELF;
location moveTo = GetLocation(GetWaypointByTag(CorpseCryptWaypoint));
if(GetFireHenchMenOnDeath())
{
RemoveAllFollowers(PC,TRUE);
}
ApplyEffectToObject(DURATION_TYPE_INSTANT,resurrection,PC);
if(!GetUsePCPickableCorpse())
{
SetCantPickCorpse(TRUE,PC);
}
else
{
SetCantPickCorpse(FALSE,PC);
}
ClearAllActions(TRUE);
ActionJumpToLocation(moveTo);
ActionDoCommand(next(pcPlace));
}
}
}
else
{
SetIsCorpseCopying(FALSE);
}
}
void next(location pcPlace )
{
effect resurrection = EffectResurrection();
effect death = EffectDeath(FALSE,FALSE);
object PC = OBJECT_SELF;
//location moveTo = GetLocation(GetWaypointByTag(CorpseCryptWaypoint));
object copy = CopyObject(OBJECT_SELF,pcPlace);
SetCantPickCorpse(GetCantPickCorpse(PC),copy);
/*if(GetLocalInt(PC,CorpseNoLoot))
{
setEquippementUndroppable(copy);
}*/
AssignCommand(copy,SetIsDestroyable(FALSE,TRUE,FALSE));
ChangeToStandardFaction(copy,STANDARD_FACTION_COMMONER);
ClearPersonalReputation(OBJECT_SELF,copy);
//WriteTimestampedLogEntry("gold = "+IntToString(GetGold(copy)));
SetLocalObject(PC,CorpsePCCorpse,copy);
//ApplyEffectToObject(DURATION_TYPE_INSTANT,death,OBJECT_SELF);
ApplyEffectToObject(DURATION_TYPE_INSTANT,death,copy);
SetLocalLocation(copy,CorpseCorpseLocation,GetLocation(copy));
SetLocalObject(copy,CorpsePCCorpse,PC);
object corpse = CreateCorpsePlaceable(copy);
SetPlotFlag(corpse,TRUE);
object oldItem = GetFirstItemInInventory(copy);
while(GetIsObjectValid(oldItem))
{
//WriteTimestampedLogEntry("Destyroying item " + GetTag(oldItem));
if(!GetIsObjectValid(GetLocalObject(oldItem,CorpseOriginalObject)))
{
DestroyObject(oldItem);
}
oldItem = GetNextItemInInventory(copy);
}
if(!GetLocalInt(PC,CorpseNoLoot))
{
TakeGoldFromCreature(GetGold(PC),PC,TRUE);
}
else
{
TakeGoldFromCreature(GetGold(copy),copy,TRUE);
}
//giveBackItems(copy,FALSE);
AssignCommand(corpse,GetItemsInInventory(PC));
AssignCommand(corpse,SetCommandable(TRUE));
AssignCommand(corpse,ActionDoCommand(giveBackItems(copy,FALSE)));
AssignCommand(corpse,ActionDoCommand(SetCommandable(TRUE)));
AssignCommand(corpse,SetCommandable(FALSE));
}