Aschbourne_PRC8/_module/nss/nw_o0_death.nss
Jaysyn904 903f023230 Major update
Created top hak for crafting dialog.  Moved Bioware creature abilities to top hak.  Fixed DMFI wand handouts.  Added DMFI language handouts.  Added CCOH 6.  Disabled PC corpse system.  Modified new player startup system.  Full compile.  Updated release archive.
2024-09-17 13:24:57 -04:00

190 lines
7.4 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Death Script
//:: NW_O0_DEATH.NSS
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
This script handles the default behavior
that occurs when a player dies.
BK: October 8 2002: Overriden for Expansion
*/
//:://////////////////////////////////////////////
//:: Created By: Brent Knowles
//:: Created On: November 6, 2001
//:://////////////////////////////////////////////
/*
void ClearAllFactionMembers(object oMember, object oPlayer)
{
// AssignCommand(oMember, SpeakString("here"));
AdjustReputation(oPlayer, oMember, 100);
SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
object oClear = GetFirstFactionMember(oMember, FALSE);
while (GetIsObjectValid(oClear) == TRUE)
{
ClearPersonalReputation(oPlayer, oClear);
oClear = GetNextFactionMember(oMember, FALSE);
}
} */
void onDeathApplyPenalty(object oDied)
{
int nXP = GetXP(oDied);
int nPenalty = 50 * GetHitDice(oDied);
int nHD = GetHitDice(oDied);
// * You can not lose a level with this respawning
int nMin = ((nHD * (nHD - 1)) / 2) * 1000;
int nNewXP = nXP - nPenalty;
if (nNewXP < nMin)
nNewXP = nMin;
if (nXP != nNewXP)
SetXP(oDied, nNewXP);
int nGoldToTake = FloatToInt(0.10 * GetGold(oDied));
// * a cap of 10 000gp taken from you
if (nGoldToTake > 10000)
nGoldToTake = 10000;
TakeGoldFromCreature(nGoldToTake, oDied, TRUE);
}
void Raise(object oPlayer)
{
effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION);
effect eBad = GetFirstEffect(oPlayer);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPlayer);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oPlayer)), oPlayer);
//Search for negative effects
while(GetIsEffectValid(eBad))
{
if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL)
{
//Remove effect if it is negative.
RemoveEffect(oPlayer, eBad);
}
eBad = GetNextEffect(oPlayer);
}
//Fire cast spell at event for the specified target
SignalEvent(oPlayer, EventSpellCastAt(OBJECT_SELF, SPELL_RESTORATION, FALSE));
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oPlayer);
}
void main()
{
//Set variables
int xCount, xGold;
object xPC, xCorpse, xItem;
location xLoc;
//Get player and find locations
xPC = GetLastPlayerDying();
xLoc = GetLocation(xPC);
//Create corpse at player's feet
/* xCorpse = CreateObject(OBJECT_TYPE_PLACEABLE,"corpse002",xLoc);
//Drop equipment on corpse
for (xCount = 1; xCount < 15; xCount++)
{
switch (xCount)
{
case 1: xItem = GetItemInSlot(INVENTORY_SLOT_ARMS,xPC); break;
case 2: xItem = GetItemInSlot(INVENTORY_SLOT_ARROWS,xPC); break;
case 3: xItem = GetItemInSlot(INVENTORY_SLOT_BELT,xPC); break;
case 4: xItem = GetItemInSlot(INVENTORY_SLOT_BOLTS,xPC); break;
case 5: xItem = GetItemInSlot(INVENTORY_SLOT_BOOTS,xPC); break;
case 6: xItem = GetItemInSlot(INVENTORY_SLOT_BULLETS,xPC); break;
case 7: xItem = GetItemInSlot(INVENTORY_SLOT_CHEST,xPC); break;
case 8: xItem = GetItemInSlot(INVENTORY_SLOT_CLOAK,xPC); break;
case 9: xItem = GetItemInSlot(INVENTORY_SLOT_HEAD,xPC); break;
case 10: xItem = GetItemInSlot(INVENTORY_SLOT_LEFTHAND,xPC); break;
case 11: xItem = GetItemInSlot(INVENTORY_SLOT_LEFTRING,xPC); break;
case 12: xItem = GetItemInSlot(INVENTORY_SLOT_NECK,xPC); break;
case 13: xItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,xPC); break;
case 14: xItem = GetItemInSlot(INVENTORY_SLOT_RIGHTRING,xPC); break;
}
if (GetIsObjectValid(xItem))
{
AssignCommand(xCorpse,ActionTakeItem(xItem,xPC));
}
}
//Now drop half of player's gold.
xGold = (GetGold(xPC)/2);
AssignCommand(xItem,TakeGoldFromCreature(xGold,xPC,FALSE)); */
onDeathApplyPenalty(xPC);
//Now let's pop the death GUI
DelayCommand(2.5, PopUpDeathGUIPanel(xPC,TRUE,TRUE));
object oPlayer = GetLastPlayerDied();
// * increment global tracking number of times that I died
//SetLocalInt(oPlayer, "NW_L_PLAYER_DIED", GetLocalInt(oPlayer, "NW_L_PLAYER_DIED") + 1);
// * BK: Automation Control. Autopcs ignore death
/* if (GetLocalInt(oPlayer, "NW_L_AUTOMATION") == 10)
{ */
Raise(oPlayer);
DelayCommand(1.0, ExecuteScript("crawl", OBJECT_SELF));
return; // Raise and return
//}
// * Handle Spirit of the Wood Death
string sArea = GetTag(GetArea(oPlayer));
/*
if (sArea == "MAP_M2Q2F2" && GetDistanceBetweenLocations(GetLocation(GetObjectByTag("M2Q2F2_M2Q2G")), GetLocation(oPlayer)) < 5.0 && GetLocalInt(GetModule(),"NW_M2Q2E_WoodsFreed") == 0)
{
int bValid;
Raise(oPlayer);
string sDestTag = "WP_M2Q2GtoM2Q2F";
object oSpawnPoint = GetObjectByTag(sDestTag);
AssignCommand(oPlayer,JumpToLocation(GetLocation(oSpawnPoint)));
return;
}
*/
// * in last level of the Sourcestone, move the player to the beginning of the area
// * May 16 2002: or the main area of the Snowglobe (to prevent plot logic problems).
// * May 21 2002: or Castle Never
if (sArea == "M4Q1D2" || sArea == "M3Q3C" || sArea == "MAP_M1Q6A")
{
//Raise(oPlayer);
//string sDestTag = "M4QD07_ENTER";
//object oSpawnPoint = GetObjectByTag(sDestTag);
// AssignCommand(oPlayer, DelayCommand(1.0, JumpToLocation(GetLocation(oSpawnPoint))));
// * MAY 2002: Just popup the YOU ARE DEAD panel at this point
DelayCommand(2.5, PopUpDeathGUIPanel(oPlayer,FALSE, TRUE, 66487));
return;
}
// * make friendly to Each of the 3 common factions
AssignCommand(oPlayer, ClearAllActions());
// * Note: waiting for Sophia to make SetStandardFactionReptuation to clear all personal reputation
if (GetStandardFactionReputation(STANDARD_FACTION_COMMONER, oPlayer) <= 10)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_COMMONER, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_MERCHANT, oPlayer) <= 10)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_MERCHANT, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_DEFENDER, oPlayer) <= 10)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_DEFENDER, 80, oPlayer);
}
DelayCommand(2.5, PopUpGUIPanel(oPlayer,GUI_PANEL_PLAYER_DEATH));
}