Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "inc_common"
- #include "inc_player"
- #include "X0_I0_POSITION"
- const string DEATH_ITEMVARPERSIST = "kemo_scry";
- const string DEATH_ITEMCORPSE = "corpse_token";
- const string DEATH_ITEMRAISE = "NW_IT_SPDVSCR501";
- const string DEATH_ITEMRESURRECT = "NW_IT_SPDVSCR702";
- const int DEATH_SPELLRAISE = SPELL_RAISE_DEAD;
- const int DEATH_SPELLRESURRECT = SPELL_RESURRECTION;
- const int DEATH_FEATRAISE = 2027;
- const string DEATH_PLACEABLECORPSEMALE = "pc_corpse_male";
- const string DEATH_PLACEABLECORPSEFEMALE = "pc_corpse_female";
- const string DEATH_VARISDEAD = "IsDead";
- const string DEATH_VARLOCATION = "LocationDeath";
- const string DEATH_VARCORPSECREATURE = "MY_CORPSE_CREATURE";
- const string DEATH_VARCORPSEITEM = "MY_CORPSE_ITEM";
- const string DEATH_VAROWNER = "MY_OWNER";
- const string DEATH_VARCORPSELOCATION = "LocationCorpse";
- const string DEATH_VARKILLERISPC = "SUBDUAL";
- const string DEATH_VARMDEATHS = "Count_MDeaths";
- const string DEATH_VARPDEATHS = "Count_PDeaths";
- const string DEATH_VARTOTALDEATHS = "Count_Deaths";
- const string DEATH_VARMKILLS = "Count_MKills";
- const string DEATH_VARPKILLS = "Count_PKills";
- const string DEATH_VARTOTALKILLS = "Count_Kills";
- const string DEATH_WPDEATHAREA = "WP_FUGUE1";
- const string DEATH_WPDEFAULTSPAWNUD = "sshamath_glouras_wings";
- const string DEATH_WPDEFAULTSPAWNNORMAL = "WP_TownportalElfsong";
- /*
- ********************************
- */
- // OnLogin event specific to PCs
- void Death_OnPcLogin(object oPC);
- // OnDying event specific to PCs
- void Death_OnPcDying(object oPC);
- // OnDyingBleed event specific to PCs
- void Death_OnPcDyingBleed(object oPC);
- // OnDeath event common to all monsters, NPCs, and PCs
- void Death_OnDeath(object oCreature, object oKiller);
- // OnDeath event add-on specific to PCs
- void Death_OnPcDeath(object oPC, object oKiller);
- // OnSpawn event specific to PCs
- void Death_OnPcRespawn(object oPC);
- // Returns wether or not the PC is dead
- int Death_GetIsPcDead(object oPC);
- // Returns the owner of oCorpse
- object Death_GetCorpseOwner(object oCorpse);
- // Sets the corpse properties for oPC
- void Death_SetCorpse(object oPC, object oCorpse);
- // Create an interactive corpse of oPC at location lLoc
- void Death_CreateCorpseAtLocation(object oPC, location lLocation, int PlaceToken = TRUE, int iGruesome = FALSE);
- // Create an interactive corpse of oPC in oCreature's inventory
- void Death_CreateCorpseOnCreature(object oPC, object oCreature, int iDestroyCreatureCorpse = TRUE);
- // Forces oPC to drop any corpses it may be carrying
- void Death_DropAllCorpses(object oPC);
- // Remove any existing corpse of oPC
- void Death_RemoveCorpse(object oPC, int iCorpseItemToo = 0);
- // Returns whether or not oCreature can raise oCorpse by the specified nRaiseType
- // nRaiseType = 0 : Raise Dead by Spell
- // 1 : Raise Dead by Scroll
- // 2 : Raise Dead by Recall Spirit
- // 4 : Resurrect by Spell
- // 5 : Resurrect by Scroll
- int Death_CanRaiseCorpse(object oCreature, object oCorpse, int nRaiseType);
- // Attempts to have oCreature raise the corpse by using nRaiseType, returns true if successful
- // nRaiseType = 0 : Raise Dead by Spell
- // 1 : Raise Dead by Scroll
- // 2 : Raise Dead by Recall Spirit
- // 4 : Resurrect by Spell
- // 5 : Resurrect by Scroll
- int Death_RaiseCorpse(object oCreature, object oCorpse, int nRaiseType);
- // Brings oPC back to the world of the living
- // nDestination = 1 : DefaultRespawn
- // 2 : Corpse
- // 3 : Module Starting Location
- void Death_BringToLife(object oPC, int nDestination);
- // Apply death penalty consequences to oCreature
- void Death_ApplyConsequences(object oCreature, int bIsPvP);
- /*
- Implementations
- */
- //reset death override
- void ResetDeathLocationVar(object oPC)
- {
- SetLocalInt(oPC, "death_override", 0);
- }
- void Death_OnPcLogin(object oPC)
- {
- object oItem;
- object oCorpse;
- location lLocation;
- oItem = GetRequiredItem(oPC, DEATH_ITEMVARPERSIST);
- if (GetIsObjectValid(oItem) == FALSE)
- { return; }
- if (GetLocalInt(oItem, DEATH_VARISDEAD))
- {
- location lLoc = GetLocalLocation(oItem, "last_death_location");
- if(GetIsLocationValid(lLoc) == TRUE) {SetLocalInt(oPC, "death_override", 1);}
- //oCorpse = GetLocalObject(oItem, DEATH_VARCORPSE);
- DelayCommand(0.5, ResetDeathLocationVar(oPC));
- effect eDeath = EffectDeath(FALSE, FALSE, TRUE, TRUE);
- ApplyEffectToObject(DURATION_TYPE_INSTANT, eDeath, oPC, 0.0);
- //if (GetIsObjectValid(oCorpse) == FALSE)
- //{
- //lLocation = GetLocalLocation(oItem, DEATH_VARCORPSELOCATION);
- //Death_CreateCorpseAtLocation(oPC, lLocation);
- /*
- if (GetIsLocationValid(lLocation))
- { Death_CreateCorpseAtLocation(oPC, lLocation); }
- else
- {
- lLocation = GetLocalLocation(oItem, DEATH_VARLOCATION);
- if (GetIsLocationValid(lLocation))
- { Death_CreateCorpseAtLocation(oPC, lLocation); }
- else
- { WriteTimestampedLogEntry("[Death System]: No corpse or death location available for '" + GetName(oPC) + "'."); }
- }
- */
- //}
- // todo: Seems to me that we should automatically port anyone that is dead to the Fugue if they aren't there already.
- }
- }
- void Death_OnPcDying(object oPC)
- {
- }
- void Death_OnPcDyingBleed(object oPC)
- {
- }
- void Death_OnDeath(object oCreature, object oKiller)
- {
- //SendMessageToPC(oCreature, "Death onDeath");
- object oItemKiller;
- object oMaster;
- int iKills;
- if (GetIsObjectValid(oCreature) == FALSE)
- { return; }
- if (GetIsObjectValid(oKiller))
- {
- oMaster = GetMaster(oKiller);
- if (GetIsObjectValid(oMaster))
- { oKiller = oMaster; }
- }
- //set killer to be trap creator
- if(GetBaseItemType(GetLastDamager(oCreature))==BASE_ITEM_TRAPKIT)
- {
- object oTrapCreator = GetTrapCreator(GetLastDamager(oCreature));
- if(GetIsPC(oTrapCreator) && GetIsObjectValid(oTrapCreator) == TRUE)
- {
- oKiller = oTrapCreator;
- }
- }
- if (GetIsPC(oCreature) == TRUE)
- {
- // drop all corpses before the next piece of code
- Death_DropAllCorpses(oCreature);
- Death_OnPcDeath(oCreature, oKiller);
- }
- if (GetIsObjectValid(oKiller) == TRUE && GetIsPC(oKiller) == TRUE)
- {
- oItemKiller = GetRequiredItem(oKiller, DEATH_ITEMVARPERSIST);
- if (GetIsObjectValid(oItemKiller))
- {
- iKills = GetLocalInt(oItemKiller, DEATH_VARTOTALKILLS);
- iKills++;
- SetLocalInt(oItemKiller, DEATH_VARTOTALKILLS, iKills);
- if (GetIsPC(oCreature) == FALSE)
- {
- iKills = GetLocalInt(oItemKiller, DEATH_VARMKILLS);
- iKills++;
- SetLocalInt(oItemKiller, DEATH_VARMKILLS, iKills);
- }
- }
- }
- }
- //remove this variable after a delay
- void RemovePvPKiller(object oPC)
- {
- DeleteLocalObject(oPC, "MyKiller");
- }
- //send messages and set subdual status
- void UnPlot(object oPC)
- {
- if(GetArea(oPC) == OBJECT_INVALID) {DelayCommand(4.0, UnPlot(oPC)); return;}
- else
- {
- SetImmortal(oPC,FALSE);
- }
- }
- //send messages and set subdual status
- void CoupDeGracePeriod(object oPC, object oKiller)
- {
- SetLocalInt(oPC,"SUBDUAL", 2); //set to status 2 so can be coup de graced
- SetImmortal(oPC,FALSE);
- SendMessageToPC(oKiller, "You can now perform a coup de grâce action on "+GetName(oPC));
- SendMessageToPC(oPC, "A coup de grâce action can be performed on you by "+GetName(oKiller));
- }
- void Death_OnPcDeath(object oPC, object oKiller)
- {
- //SendMessageToPC(oPC, "Death on PC Death");
- object oItemPC;
- object oItemKiller;
- object oCorpsePlaceable;
- object oWaypoint;
- location lLocation;
- location lWpLocation;
- int iKills;
- int iDeaths;
- int bIsPvP;
- int iHpCurrent;
- effect eEffect;
- string sReport;
- int iTrapDeath=0;
- object oDamager = GetLastDamager(oPC);
- if(GetBaseItemType(oDamager)==BASE_ITEM_TRAPKIT)
- {
- object oTrapCreator = GetTrapCreator(oDamager);
- if(GetIsPC(oTrapCreator) && GetIsObjectValid(oTrapCreator) == TRUE)
- {
- iTrapDeath=1;
- oKiller = oTrapCreator;
- }
- }
- //counts creatures as attacking for their masters
- if(GetMaster(oKiller) != OBJECT_INVALID)
- {
- oKiller = GetMaster(oKiller);
- }
- if(GetIsObjectValid(oKiller) == FALSE && iTrapDeath == 0 && GetIsObjectValid(GetLastDamager(oPC)) == TRUE)
- {oKiller = GetLastDamager(oPC);}
- bIsPvP = FALSE;
- oItemPC = GetRequiredItem(oPC, DEATH_ITEMVARPERSIST);
- if (GetIsObjectValid(oItemPC) == FALSE)
- {SendMessageToPC(oPC, "Invalid Persistent kemo scry item"); return;}
- //this person is already dead...
- if (GetLocalInt(oItemPC, DEATH_VARISDEAD) == TRUE)
- {
- SendMessageToPC(oPC, "You are supposed to be dead already...");
- ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oPC);
- ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(GetMaxHitPoints(oPC)), oPC);
- ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectEthereal(), oPC, 10.0);
- SetImmortal(oPC, TRUE);
- DelayCommand(8.0, UnPlot(oPC));
- DeleteLocalInt(oPC,"SUBDUAL"); //remove subdual
- DeleteLocalInt(oPC,"SUB_COOL"); //remove subdual
- oWaypoint = GetWaypointByTag(DEATH_WPDEATHAREA);
- lWpLocation = GetLocation(oWaypoint);
- DelayCommand(0.8, AssignCommand(oPC, ClearAllActions(TRUE)));
- DelayCommand(0.81, AssignCommand(oPC, JumpToLocation(lWpLocation)));
- object oMyCorpse = GetLocalObject(oItemPC, DEATH_VARCORPSECREATURE);
- if(GetIsObjectValid(oMyCorpse) == FALSE) {oMyCorpse = GetLocalObject(oItemPC, DEATH_VARCORPSEITEM);}
- //I am just entering the server but am dead...or I am dead but have no corpse
- if(GetLocalInt(oPC, "death_override") == 1 || GetIsObjectValid(oMyCorpse) == FALSE)
- {
- SetLocalInt(oPC, "death_override", 0);
- location lDeath = GetLocalLocation(oItemPC, "last_death_location");
- //make sure we have a location
- if(GetIsLocationValid(lDeath) == FALSE) {lDeath = GetLocalLocation(oItemPC, DEATH_VARCORPSELOCATION);}
- if(GetIsLocationValid(lDeath) == FALSE) {lDeath = GetLocalLocation(oItemPC, DEATH_VARLOCATION);}
- if(GetIsLocationValid(lDeath) == FALSE) {lDeath = CalcSafeLocation(oPC, GetLocation(oPC), 2.2, FALSE, TRUE);}
- Death_CreateCorpseAtLocation(oPC, lDeath, TRUE);
- }
- return;
- }
- lLocation = GetLocation(oPC);
- //already subdued, can we coup de grace?
- if(GetLocalInt(oPC,"SUBDUAL") == 2)
- {
- object oSubduer = GetLocalObject(oPC, "MyKiller");
- //death
- if(GetLastDamager(oPC) == oSubduer)
- {
- ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oPC);
- ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectEthereal(), oPC, 10.0);
- ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(GetMaxHitPoints(oPC)), oPC);
- SetImmortal(oPC,TRUE);
- DelayCommand(8.0, UnPlot(oPC));
- SetLocalInt(oItemPC, DEATH_VARISDEAD, TRUE);
- DeleteLocalInt(oPC,"SUBDUAL"); //remove subdual
- DeleteLocalInt(oPC,"SUB_COOL"); //remove subdual
- //upon PvP Death don't deduct XP
- SetLocalInt(oItemPC, "free_xp_death", TRUE);
- SendMessageToPC(oSubduer, "You performed Coup de grâce action on "+GetName(oPC));
- SendMessageToPC(oPC, "A Coup de grâce action was performed on you by "+GetName(oSubduer));
- //die
- SendMessageToPC(oPC, "You feel yourself being drawn to the light...");
- oWaypoint = GetWaypointByTag(DEATH_WPDEATHAREA);
- lWpLocation = GetLocation(oWaypoint);
- AssignCommand(oPC, ClearAllActions(TRUE));
- AssignCommand(oPC, JumpToLocation(lWpLocation));
- Death_CreateCorpseAtLocation(oPC, lLocation, TRUE, TRUE);
- return;
- }
- //no death - rez if killed by unauthorized player
- else
- {
- SendMessageToPC(oKiller, GetName(oPC)+" cannot be killed while incapacitated except through a coup de grâce action by his subduer");
- effect eRessurect = EffectResurrection();
- ApplyEffectToObject(DURATION_TYPE_INSTANT, eRessurect, oPC, 0.0);
- SetLocalInt(oItemPC, DEATH_VARISDEAD, FALSE);
- if(GetIsDead(oPC, FALSE) == TRUE)
- {
- int iHP = GetCurrentHitPoints(oPC);
- if(iHP < 3)
- {
- effect eHeal = EffectHeal(13);
- ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oPC, 0.0);
- }
- else if(iHP > 3)
- {
- effect eDamage = EffectDamage(iHP - 3, DAMAGE_TYPE_POSITIVE, DAMAGE_POWER_PLUS_TWENTY, TRUE);
- ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC, 0.0);
- }
- //ExecuteScript("subdual_cooldown",oPC);
- //enable subdual again
- }
- //effect eParalyze = EffectCutsceneDominated();
- //eParalyze = SetEffectSpellId(eParalyze, 147000); //any effect
- //DelayCommand(0.15, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eParalyze, oPC, IntToFloat(GetLocalInt(oPC,"SUB_COOL")) - 0.15));
- SendMessageToPC(oPC, "You can only be killed by your subduer");
- return;
- }
- }
- SetLocalInt(oItemPC, DEATH_VARISDEAD, TRUE);
- iDeaths = GetLocalInt(oItemPC, DEATH_VARTOTALDEATHS);
- iDeaths++;
- SetLocalInt(oItemPC, DEATH_VARTOTALDEATHS, iDeaths);
- //Killed by PC and not Subdued yet, trap death too
- if(GetIsPC(GetLastHostileActor(oPC)) == TRUE || GetIsPC(GetMaster(GetLastHostileActor(oPC))) == TRUE || iTrapDeath == 1 && GetLocalInt(oPC,"SUBDUAL") == 0)
- {
- if (GetIsPC(oKiller) == TRUE)
- {
- bIsPvP = TRUE;
- SetLocalInt(oItemPC, DEATH_VARKILLERISPC, TRUE);
- oItemKiller = GetRequiredItem(oKiller, DEATH_ITEMVARPERSIST);
- if (GetIsObjectValid(oItemKiller))
- {
- iKills = GetLocalInt(oItemKiller, DEATH_VARPKILLS);
- iKills++;
- SetLocalInt(oItemKiller, DEATH_VARPKILLS, iKills);
- }
- iDeaths = GetLocalInt(oItemPC, DEATH_VARPDEATHS);
- iDeaths++;
- SetLocalInt(oItemPC, DEATH_VARPDEATHS, iDeaths);
- }
- else
- {
- SetLocalInt(oItemPC, DEATH_VARKILLERISPC, FALSE);
- iDeaths = GetLocalInt(oItemPC, DEATH_VARMDEATHS);
- iDeaths++;
- SetLocalInt(oItemPC, DEATH_VARMDEATHS, iDeaths);
- }
- }
- else
- {
- SetLocalInt(oItemPC, DEATH_VARKILLERISPC, FALSE);
- iDeaths = GetLocalInt(oItemPC, DEATH_VARMDEATHS);
- iDeaths++;
- SetLocalInt(oItemPC, DEATH_VARMDEATHS, iDeaths);
- }
- SetLocalLocation(oItemPC, "last_death_location", lLocation);
- SetLocalLocation(oItemPC, DEATH_VARLOCATION, lLocation);
- SetLocalLocation(oItemPC, DEATH_VARCORPSELOCATION, lLocation);
- sReport = "<c=skyblue>You have died " + IntToString(GetLocalInt(oItemPC, DEATH_VARTOTALDEATHS)) + " times. ";
- sReport = sReport + IntToString(GetLocalInt(oItemPC, DEATH_VARPDEATHS)) + " times from players and ";
- sReport = sReport + IntToString(GetLocalInt(oItemPC, DEATH_VARMDEATHS)) + " times from monsters.</c>";
- SendMessageToPC(oPC, sReport);
- eEffect = GetFirstEffect(oPC);
- while (GetIsEffectValid(eEffect))
- {
- RemoveEffect(oPC, eEffect);
- eEffect = GetNextEffect(oPC);
- }
- if (bIsPvP == TRUE && GetLocalInt(oPC,"SUBDUAL") == 0)
- {
- ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oPC);
- ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectEthereal(), oPC, 20.0);
- //ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(GetMaxHitPoints(oPC)), oPC);
- effect eParalyze1 = EffectCutsceneParalyze();
- eParalyze1 = EffectLinkEffects(eParalyze1, EffectKnockdown());
- eParalyze1 = SetEffectSpellId(eParalyze1, 147000); //any effect
- ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eParalyze1, oPC, 90.0);
- DeleteLocalInt(oPC,"SUB_COOL"); //remove subdual
- SetImmortal(oPC,TRUE);
- SetLocalInt(oPC,"SUBDUAL", 1); //set to status 1 so cannot die
- SetLocalObject(oPC, "MyKiller", oKiller);
- SetLocalObject(oKiller, "LastPvPKilled", oPC);
- DelayCommand(90.0, RemovePvPKiller(oPC)); //delete after subdual period
- SendMessageToPC(oPC, "You are incapacitated...");
- SetLocalInt(oItemPC, DEATH_VARISDEAD, FALSE);
- SendMessageToAllDMs("PVP DEATH: "+GetFirstName(oKiller)+" "+GetLastName(oKiller)+" "+IntToString(GetHitDice(oKiller))+" has killed "+GetFirstName(oPC)+" "+GetLastName(oPC)+" ("+IntToString(GetHitDice(oPC))+") at "+GetName(GetArea(oKiller)));
- int iHP = GetCurrentHitPoints(oPC);
- if(iHP < 3)
- {
- effect eHeal = EffectHeal(13);
- ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oPC, 0.0);
- }
- else if(iHP > 3)
- {
- effect eDamage = EffectDamage(iHP - 3, DAMAGE_TYPE_POSITIVE, DAMAGE_POWER_PLUS_TWENTY, TRUE);
- ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC, 0.0);
- }
- //after 20 seconds a coup de grace can be done
- DelayCommand(20.0, CoupDeGracePeriod(oPC, oKiller));
- //set subdual
- ExecuteScript("subdual_cooldown",oPC);
- return;
- }
- else
- {
- ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oPC);
- ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectEthereal(), oPC, 10.0);
- ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(GetMaxHitPoints(oPC)), oPC);
- SendMessageToPC(oPC, "You feel yourself being drawn to the light...");
- oWaypoint = GetWaypointByTag(DEATH_WPDEATHAREA);
- lWpLocation = GetLocation(oWaypoint);
- AssignCommand(oPC, ClearAllActions(TRUE));
- AssignCommand(oPC, JumpToLocation(lWpLocation));
- Death_CreateCorpseAtLocation(oPC, lLocation, TRUE);
- }
- }
- void Death_OnPcRespawn(object oPC)
- {
- }
- int Death_GetIsPcDead(object oPC)
- {
- object oItem;
- if (GetIsObjectValid(oPC) == FALSE)
- { return FALSE; }
- oItem = GetRequiredItem(oPC, DEATH_ITEMVARPERSIST);
- if (GetIsObjectValid(oItem) == FALSE)
- { return FALSE; }
- if (GetLocalInt(oItem, DEATH_VARISDEAD) == TRUE)
- { return TRUE; }
- return FALSE;
- }
- object Death_GetCorpseOwner(object oCorpse)
- {
- object oOwner;
- if (GetIsObjectValid(oCorpse) == FALSE)
- { return OBJECT_INVALID; }
- oOwner = GetLocalObject(oCorpse, DEATH_VAROWNER);
- if (GetIsObjectValid(oOwner) == FALSE)
- { return OBJECT_INVALID; }
- return oOwner;
- }
- void Death_SetCorpse(object oPC, object oCorpse)
- {
- //SendMessageToPC(oPC, "Setting Corpse");
- object oItem;
- string sName;
- string sDescription;
- string sAppearance;
- int iAppearance;
- string sScale;
- float fScaleX;
- float fScaleY;
- float fScaleZ;
- if (GetIsObjectValid(oPC) == FALSE
- || GetIsObjectValid(oCorpse) == FALSE)
- {
- SendMessageToPC(oPC, "<color=RED><b>ERROR_1_: PC OR CORPSE INVALID. Please report this to a DM.</b></color>");
- return;
- }
- oItem = GetRequiredItem(oPC, DEATH_ITEMVARPERSIST);
- if (GetIsObjectValid(oItem) == FALSE)
- {
- SendMessageToPC(oPC, "<color=RED><b>ERROR_2_: INVALID DEATH_ITEMVARPERSIST. Please report this to a DM.</b></color>");
- return;
- }
- sName = GetName(oPC); //GetFirstName(oPC) + " " + GetLastName(oPC);
- sDescription = "This is the corpse of " + sName;
- SetDescription(oCorpse, sDescription);
- int iType = GetObjectType(oCorpse);
- if(iType == OBJECT_TYPE_CREATURE) {SetLocalObject(oItem, DEATH_VARCORPSECREATURE, oCorpse); SendMessageToPC(oPC, "Set Corpse Creature");} //set creature
- else {SetLocalObject(oItem, DEATH_VARCORPSEITEM, oCorpse); SetFirstName(oCorpse, sName); SendMessageToPC(oPC, "Set Corpse Item");} //set item
- SetLocalObject(oCorpse, DEATH_VAROWNER, oPC);
- SendMessageToPC(oPC, "Owner of "+GetName(oCorpse)+" = "+GetName(oPC));
- }
- //destroy all items on corpse oPC
- void Unlootable(object xPC)
- {
- //Set variables
- int xGold, xCount;
- xGold = GetGold(xPC);
- AssignCommand(xPC, ClearAllActions(TRUE));
- DelayCommand(0.5, AssignCommand(xPC, TakeGoldFromCreature( xGold,xPC,TRUE)));
- object xItem;
- //Let's see who we're ripping off today..
- //Destroy the inventory items
- xItem = GetFirstItemInInventory(xPC);
- while(GetIsObjectValid(xItem))
- {
- //DestroyObject(xItem);
- SetDroppableFlag(xItem, FALSE);
- xItem = GetNextItemInInventory(xPC);
- }
- // Empty all inventory slots
- // Change 18 to 14 to not strip creature slots
- for (xCount = 0; xCount < 18; xCount++)
- //DestroyObject( GetItemInSlot( xCount, xPC));
- SetDroppableFlag(GetItemInSlot( xCount, xPC), FALSE );
- //Now let's get greedy and take the gold!
- }
- void Death_CreateCorpseAtLocation(object oPC, location lLocation, int PlaceToken = TRUE, int iGruesome = FALSE)
- {
- //SendMessageToPC(oPC, "Creating Corpse at Location");
- object oItem;
- object oCorpse;
- string sPlaceable;
- //string sId = GetLocalString(oPC, "SID");
- string sId = GetName(oPC);
- int nGender = GetGender(oPC);
- string sResRef;
- if (nGender == GENDER_MALE)
- sResRef = "pc_corpse_male";
- else
- sResRef = "pc_corpse_female";
- string sTag = sId + "_corpse";
- if (GetIsObjectValid(oPC) == FALSE)
- {
- SendMessageToPC(oPC, "<color=RED><b>ERROR1: INVALID PC. Please report this to a DM.</b></color>");
- return;
- }
- oItem = GetRequiredItem(oPC, DEATH_ITEMVARPERSIST);
- if (GetIsObjectValid(oItem) == FALSE)
- {
- SendMessageToPC(oPC, "<color=RED><b>ERROR2: INVALID DEATH_ITEMVARPERSIST. Please report this to a DM.</b></color>");
- return;
- }
- oCorpse = GetLocalObject(oItem, DEATH_VARCORPSECREATURE);
- if(GetIsLocationValid(lLocation) == FALSE)
- {
- lLocation = CalcSafeLocation(oPC, lLocation, 2.2, FALSE, TRUE);
- }
- //destroy corpse item if it already exists
- int iSetToDestroy = 0;
- object oCorpse2 = GetLocalObject(oItem, DEATH_VARCORPSEITEM);
- if (GetIsObjectValid(oCorpse2) == TRUE)
- {
- //SendMessageToPC(oPC, "<color=RED><b>Corpse already detected</b></color>");
- SetImmortal(oCorpse2, FALSE);
- AssignCommand(oCorpse2, SetIsDestroyable(TRUE, FALSE, FALSE));
- object oTalker2 = GetObjectByTag(GetTag(oCorpse2)+"_conv", 0);
- if(GetIsObjectValid(oTalker2) == TRUE)
- {
- AssignCommand(oTalker2, SetIsDestroyable(TRUE, FALSE, FALSE));
- DestroyObject(oTalker2);
- oTalker2 = OBJECT_INVALID;
- }
- DestroyObject(oCorpse2, 2.5);
- oCorpse2 = OBJECT_INVALID; //set corpse to be invalid again
- SetLocalObject(oItem, DEATH_VARCORPSEITEM, OBJECT_INVALID);
- iSetToDestroy = 1;
- }
- //destroy corpse body if it already exists
- if (GetIsObjectValid(oCorpse) == TRUE)
- {
- Unlootable(oCorpse);
- //SendMessageToPC(oPC, "<color=RED><b>Corpse already detected</b></color>");
- SetImmortal(oCorpse, FALSE);
- AssignCommand(oCorpse, SetIsDestroyable(TRUE, FALSE, FALSE));
- object oTalker = GetObjectByTag(GetTag(oCorpse)+"_conv", 0);
- if(GetIsObjectValid(oTalker) == TRUE)
- {
- AssignCommand(oTalker, SetIsDestroyable(TRUE, FALSE, FALSE));
- DestroyObject(oTalker);
- oTalker = OBJECT_INVALID;
- }
- DestroyObject(oCorpse, 2.5);
- oCorpse = OBJECT_INVALID; //set corpse to be invalid again
- SetLocalObject(oItem, DEATH_VARCORPSECREATURE, OBJECT_INVALID);
- iSetToDestroy = 1;
- }
- if (GetGender(oPC) == GENDER_FEMALE)
- { sPlaceable = DEATH_PLACEABLECORPSEFEMALE; }
- else
- { sPlaceable = DEATH_PLACEABLECORPSEMALE; }
- if(GetIsObjectValid(oCorpse) == FALSE || iSetToDestroy == 1)
- {
- lLocation = CalcSafeLocation(oPC, lLocation, 3.0, FALSE, FALSE);
- //SendMessageToPC(oPC, "<color=RED><b>Creating Corpse</b></color>");
- //corpse
- oCorpse = CopyObject(oPC, lLocation, OBJECT_INVALID, sTag);
- if(GetIsObjectValid(oCorpse) == TRUE)
- {
- SetLocalInt(oCorpse, "is_player_lookalike_corpse", 1); //allow ressurection
- DelayCommand(0.1, Unlootable(oCorpse));
- //place corpse token on the corpse
- if(PlaceToken == TRUE) {DelayCommand(0.5, Death_CreateCorpseOnCreature(oPC, oCorpse, FALSE));}
- SetLootable(oCorpse, TRUE);
- SetCreatureScriptsToSet(oCorpse, 0);
- ChangeToStandardFaction(oCorpse, STANDARD_FACTION_DEFENDER);
- SetBumpState(oCorpse, BUMPSTATE_UNBUMPABLE);
- effect eDeath = EffectDeath(FALSE, FALSE, TRUE, TRUE);
- if(iGruesome == TRUE) {eDeath = EffectDeath(TRUE, FALSE, TRUE, TRUE);}
- DelayCommand(1.1, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDeath, oCorpse, 0.0));
- AssignCommand(oCorpse, SetIsDestroyable(FALSE, FALSE, TRUE));
- //placeable blood
- string sBlueprint = "pc_corpse_talker1";
- int i4 = d6();
- if(i4 == 4) {sBlueprint = "pc_corpse_talker4";}
- if(i4 == 6) {sBlueprint = "pc_corpse_talker5";}
- if(i4 == 5) {sBlueprint = "pc_corpse_talker6";}
- else if(i4 == 3) {sBlueprint = "pc_corpse_talker3";}
- else if(i4 == 2) {sBlueprint = "pc_corpse_talker2";}
- //spawn backup plc
- object oPlc = CreateObject(OBJECT_TYPE_PLACEABLE, sBlueprint, lLocation, FALSE, sTag+"_conv");
- if(GetIsObjectValid(oPlc) == FALSE)
- {
- lLocation = CalcSafeLocation(oPC, lLocation, 3.0, FALSE, TRUE);
- oPlc = CreateObject(OBJECT_TYPE_PLACEABLE, sBlueprint, lLocation, FALSE, sTag+"_conv");
- }
- if(GetIsObjectValid(oPlc) == TRUE)
- {
- AssignCommand(oPlc, SetFacing(IntToFloat(Random(360) + 1), FALSE));
- SetLocalObject(oPlc, "pc_corpse_talker", oCorpse);
- SetFirstName(oPlc, GetName(oPC)+"'s Grave");
- AssignCommand(oPlc, SetIsDestroyable(FALSE, FALSE, TRUE));
- }
- if (GetIsObjectValid(oPlc) == FALSE)
- {
- object oMe = GetPrimaryPlayer();
- SendMessageToPC(oMe, "<color=RED><b>ERROR3: INVALID BLOOD POOL. Please report this to a DM.</b></color>");
- }
- }
- }
- if (GetIsObjectValid(oCorpse) == FALSE)
- {
- oCorpse = CreateObject(OBJECT_TYPE_PLACEABLE, sPlaceable, lLocation, FALSE, sTag);
- }
- if (GetIsObjectValid(oCorpse) == FALSE)
- {
- oCorpse = GetObjectByTag(sTag);
- if (GetIsObjectValid(oCorpse) == FALSE)
- {
- //Add a safe location search if the original is invalid for some reason
- location lSafe = CalcSafeLocation(oPC, lLocation, 2.0, FALSE, FALSE);
- if(GetIsLocationValid(lLocation) == TRUE)
- {
- oCorpse = CreateObject(OBJECT_TYPE_PLACEABLE, sPlaceable, lLocation, FALSE, sTag);
- if (GetIsObjectValid(oCorpse) == FALSE)
- {
- oCorpse = GetObjectByTag(sTag);
- if (GetIsObjectValid(oCorpse) == FALSE)
- {
- SendMessageToPC(oPC, "<color=RED><b>ERROR3: Corpse is Invalid. Please report this to a DM.</b></color>");
- }
- }
- }
- }
- else
- {
- SendMessageToPC(oPC, "<color=RED><b>ERROR3: Corpse is Invalid, backup location failed. Please report this to a DM.</b></color>");
- }
- }
- if(GetEventHandler(oCorpse, 12) != "p_corpse_us")
- {
- SetEventHandler(oCorpse, 12, "p_corpse_us"); //on used dialogue
- }
- if (GetIsObjectValid(oCorpse) == FALSE)
- {
- SendMessageToPC(oPC, "<color=RED><b>ERROR3: Corpse is Invalid, backup location failed. Please report this to a DM.</b></color>");
- }
- SetLocalLocation(oItem, DEATH_VARLOCATION, lLocation);
- SetLocalLocation(oItem, DEATH_VARCORPSELOCATION, lLocation);
- Death_SetCorpse(oPC, oCorpse);
- SaveCharacter(oPC);
- }
- void Death_CreateCorpseOnCreature(object oPC, object oCreature, int iDestroyCreatureCorpse = TRUE)
- {
- object oItem;
- object oCorpse;
- if (GetIsObjectValid(oPC) == FALSE || GetIsObjectValid(oCreature) == FALSE)
- { return; }
- oItem = GetRequiredItem(oPC, DEATH_ITEMVARPERSIST);
- if (GetIsObjectValid(oItem) == FALSE)
- { return; }
- object oCorpse2 = GetLocalObject(oItem, DEATH_VARCORPSEITEM);
- if (GetIsObjectValid(oCorpse2) == TRUE && iDestroyCreatureCorpse == TRUE)
- {
- SetImmortal(oCorpse2, FALSE);
- AssignCommand(oCorpse2, SetIsDestroyable(TRUE, FALSE, FALSE));
- object oTalker2 = GetObjectByTag(GetTag(oCorpse2)+"_conv", 0);
- if(GetIsObjectValid(oTalker2) == TRUE)
- {
- AssignCommand(oTalker2, SetIsDestroyable(TRUE, FALSE, FALSE));
- DestroyObject(oTalker2);
- oTalker2 = OBJECT_INVALID;
- }
- int iType = GetObjectType(oCorpse2);
- if(iType == OBJECT_TYPE_CREATURE) {DeleteLocalObject(oItem, DEATH_VARCORPSECREATURE);} //set creature
- else {DeleteLocalObject(oItem, DEATH_VARCORPSEITEM);} //set item
- DestroyObject(oCorpse2);
- oCorpse2 = OBJECT_INVALID;
- }
- oCorpse = GetLocalObject(oItem, DEATH_VARCORPSECREATURE);
- if (GetIsObjectValid(oCorpse) == TRUE && iDestroyCreatureCorpse == TRUE)
- {
- Unlootable(oCorpse);
- SetImmortal(oCorpse, FALSE);
- AssignCommand(oCorpse, SetIsDestroyable(TRUE, FALSE, FALSE));
- object oTalker = GetObjectByTag(GetTag(oCorpse)+"_conv", 0);
- if(GetIsObjectValid(oTalker) == TRUE)
- {
- AssignCommand(oTalker, SetIsDestroyable(TRUE, FALSE, FALSE));
- DestroyObject(oTalker);
- oTalker = OBJECT_INVALID;
- }
- int iType = GetObjectType(oCorpse);
- if(iType == OBJECT_TYPE_CREATURE) {DeleteLocalObject(oItem, DEATH_VARCORPSECREATURE);} //set creature
- else {DeleteLocalObject(oItem, DEATH_VARCORPSEITEM);} //set item
- DestroyObject(oCorpse);
- oCorpse = OBJECT_INVALID;
- }
- object oCorpseItem = CreateItemOnObject(DEATH_ITEMCORPSE, oCreature);
- Death_SetCorpse(oPC, oCorpseItem);
- SaveCharacter(oPC);
- }
- void Death_DropAllCorpses(object oPC)
- {
- //SendMessageToPC(oPC, "Dropping Corpses");
- object oCorpseItem;
- object oCorpsePlaceable;
- object oCorpseOwner;
- location lLocation;
- if (GetIsObjectValid(oPC) == FALSE)
- {SendMessageToPC(oPC, "Invalid PC"); return; }
- lLocation = GetLocation(oPC);
- //only loop inventory if there is a corpse
- oCorpseItem = GetItemPossessedBy(oPC, DEATH_ITEMCORPSE);
- while (GetIsObjectValid(oCorpseItem) == TRUE)
- {
- oCorpseOwner = GetLocalObject(oCorpseItem, DEATH_VAROWNER);
- string sName = GetName(oCorpseOwner);
- SendMessageToPC(oPC, "Dropping Corpse "+sName);
- if (GetIsObjectValid(oCorpseOwner) == TRUE)
- {
- Death_CreateCorpseAtLocation(oCorpseOwner, lLocation);
- }
- else
- {
- DestroyObject(oCorpseItem);
- }
- oCorpseItem = GetNextItemInInventory(oPC);
- //oCorpseItem = GetItemPossessedBy(oPC, DEATH_ITEMCORPSE);
- }
- }
- void Death_RemoveCorpse(object oPC, int iCorpseItemToo = 0)
- {
- object oItem;
- object oCorpse;
- if (GetIsObjectValid(oPC) == FALSE)
- { return; }
- oItem = GetRequiredItem(oPC, DEATH_ITEMVARPERSIST);
- if (GetIsObjectValid(oItem) == FALSE)
- { return; }
- object oCorpse2 = GetLocalObject(oItem, DEATH_VARCORPSEITEM);
- if (GetIsObjectValid(oCorpse2) == TRUE && iCorpseItemToo == TRUE)
- {
- SetImmortal(oCorpse2, FALSE);
- AssignCommand(oCorpse2, SetIsDestroyable(TRUE, FALSE, FALSE));
- object oTalker2 = GetObjectByTag(GetTag(oCorpse2)+"_conv", 0);
- if(GetIsObjectValid(oTalker2) == TRUE)
- {
- AssignCommand(oTalker2, SetIsDestroyable(TRUE, FALSE, FALSE));
- DestroyObject(oTalker2);
- oTalker2 = OBJECT_INVALID;
- }
- int iType = GetObjectType(oCorpse2);
- if(iType == OBJECT_TYPE_CREATURE) {DeleteLocalObject(oItem, DEATH_VARCORPSECREATURE);} //set creature
- else {DeleteLocalObject(oItem, DEATH_VARCORPSEITEM);} //set item
- DestroyObject(oCorpse2);
- oCorpse2 = OBJECT_INVALID;
- }
- oCorpse = GetLocalObject(oItem, DEATH_VARCORPSECREATURE);
- if (GetIsObjectValid(oCorpse))
- {
- Unlootable(oCorpse);
- SetImmortal(oCorpse, FALSE);
- AssignCommand(oCorpse, SetIsDestroyable(TRUE, FALSE, FALSE));
- object oTalker = GetObjectByTag(GetTag(oCorpse)+"_conv", 0);
- if(GetIsObjectValid(oTalker) == TRUE)
- {
- AssignCommand(oTalker, SetIsDestroyable(TRUE, FALSE, FALSE));
- DestroyObject(oTalker);
- oTalker = OBJECT_INVALID;
- }
- int iType = GetObjectType(oCorpse);
- if(iType == OBJECT_TYPE_CREATURE) {DeleteLocalObject(oItem, DEATH_VARCORPSECREATURE);} //set creature
- else {DeleteLocalObject(oItem, DEATH_VARCORPSEITEM);} //set item
- DestroyObject(oCorpse);
- oCorpse = OBJECT_INVALID;
- }
- }
- int Death_CanRaiseCorpse(object oCreature, object oCorpse, int nRaiseType)
- {
- object oCorpseOwner;
- object oItem;
- int bCanRaise;
- if (GetIsObjectValid(oCreature) == FALSE
- || GetIsObjectValid(oCorpse) == FALSE)
- {
- return FALSE;
- }
- oCorpseOwner = GetLocalObject(oCorpse, DEATH_VAROWNER);
- if (GetIsObjectValid(oCorpseOwner) == FALSE)
- {
- return FALSE;
- }
- oItem = GetRequiredItem(oCorpseOwner, DEATH_ITEMVARPERSIST);
- if (GetIsObjectValid(oItem))
- {
- if (GetLocalInt(oItem, DEATH_VARISDEAD) == FALSE)
- {
- SetImmortal(oCorpse, FALSE);
- AssignCommand(oCorpse, SetIsDestroyable(TRUE, FALSE, FALSE));
- object oTalker = GetObjectByTag(GetTag(oCorpse)+"_conv", 0);
- if(GetIsObjectValid(oTalker) == TRUE)
- {
- AssignCommand(oTalker, SetIsDestroyable(TRUE, FALSE, FALSE));
- DestroyObject(oTalker);
- oTalker = OBJECT_INVALID;
- }
- int iType = GetObjectType(oCorpse);
- if(iType == OBJECT_TYPE_CREATURE) {DeleteLocalObject(oItem, DEATH_VARCORPSECREATURE);} //set creature
- else {DeleteLocalObject(oItem, DEATH_VARCORPSEITEM);} //set item
- DestroyObject(oCorpse);
- oCorpse = OBJECT_INVALID;
- return FALSE;
- }
- }
- bCanRaise = FALSE;
- switch (nRaiseType)
- {
- case 0:
- if (GetHasSpell(DEATH_SPELLRAISE, oCreature) > 0)
- { bCanRaise = TRUE; }
- break;
- case 1:
- if (GetIsObjectValid(GetItemPossessedBy(oCreature, DEATH_ITEMRAISE)))
- { bCanRaise = TRUE; }
- break;
- case 2:
- if (GetHasFeat(DEATH_FEATRAISE, oCreature))
- { bCanRaise = TRUE; }
- break;
- case 4:
- if (GetHasSpell(DEATH_SPELLRESURRECT, oCreature) > 0)
- { bCanRaise = TRUE; }
- break;
- case 5:
- if (GetIsObjectValid(GetItemPossessedBy(oCreature, DEATH_ITEMRESURRECT)))
- { bCanRaise = TRUE; }
- break;
- }
- //debug code added yyrkoon -11-19-2009 to be removed begin
- if(!bCanRaise)
- {
- //SendMessageToPC(oCreature, "<c=red>[Error] Raise method is not identified or failed </c>");
- //SendMessageToPC(oCreature, "<c=red>[Error] Raise method is </c>" + IntToString(nRaiseType) + " please pm yyrkoon on forums with this error" );
- //WriteTimestampedLogEntry("[Death System] yyrk error - Raise method is not identified or failed and nRaiseType = " + IntToString(nRaiseType) );
- }
- //debug code added by yyrkoon -11-19-2009 end
- return bCanRaise;
- }
- void RaiseCorpseDelay(object oCreature, object oCorpse, int nRaiseType)
- {
- Death_RaiseCorpse(oCreature, oCorpse, nRaiseType);
- }
- int Death_RaiseCorpse(object oCreature, object oCorpse, int nRaiseType)
- {
- object oCorpseOwner;
- object oItem;
- effect eHeal;
- location lLocation;
- if (GetIsObjectValid(oCreature) == FALSE)
- {
- return FALSE;
- }
- if (GetIsObjectValid(oCorpse) == FALSE)
- {
- return FALSE;
- }
- //transition?
- location lCurrent = GetLocation(oCreature);
- if(GetArea(oCreature) == OBJECT_INVALID)
- {
- return FALSE;
- }
- oCorpseOwner = GetLocalObject(oCorpse, DEATH_VAROWNER);
- if (GetIsObjectValid(oCorpseOwner) == FALSE)
- {
- return FALSE;
- }
- oItem = GetRequiredItem(oCorpseOwner, DEATH_ITEMVARPERSIST);
- /*
- if (GetIsObjectValid(oItem) == TRUE)
- {
- if (GetLocalInt(oItem, DEATH_VARISDEAD) == FALSE)
- {
- SetImmortal(oCorpse, FALSE);
- AssignCommand(oCorpse, SetIsDestroyable(TRUE, FALSE, FALSE));
- object oTalker = GetObjectByTag(GetTag(oCorpse)+"_conv", 0);
- if(GetIsObjectValid(oTalker) == TRUE)
- {
- AssignCommand(oTalker, SetIsDestroyable(TRUE, FALSE, FALSE));
- DestroyObject(oTalker);
- oTalker = OBJECT_INVALID;
- }
- int iType = GetObjectType(oCorpse);
- if(iType == OBJECT_TYPE_CREATURE) {DeleteLocalObject(oItem, DEATH_VARCORPSECREATURE);} //set creature
- else {DeleteLocalObject(oItem, DEATH_VARCORPSEITEM);} //set item
- DestroyObject(oCorpse);
- oCorpse = OBJECT_INVALID;
- return FALSE;
- }
- }
- */
- //full heal
- if (nRaiseType == 4 || nRaiseType == 5)
- {
- eHeal = EffectHeal(GetMaxHitPoints(oCorpseOwner));
- ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oCorpseOwner);
- }
- //Reincarnate
- else if(nRaiseType == 6)
- {
- eHeal = EffectHeal(GetMaxHitPoints(oCorpseOwner));
- ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oCorpseOwner);
- //chance of complication
- int iChance = d100();
- if(iChance <= 10)
- {
- //change gender
- int iGender = GetGender(oCorpseOwner);
- if(iGender == GENDER_FEMALE) {iGender = GENDER_MALE;}
- else {iGender = GENDER_FEMALE;}
- SetGender(oCorpseOwner, iGender);
- SendMessageToPC(oCorpseOwner, "<c=pink><i>Your gender has changed as a result of the Reincarnation spell!");
- }
- }
- //bring back at 1 HP
- else if(GetCurrentHitPoints(oCorpseOwner) >= 2)
- {
- eHeal = EffectDamage(GetCurrentHitPoints(oCorpseOwner) - 1, DAMAGE_TYPE_POSITIVE, DAMAGE_POWER_PLUS_TWENTY, TRUE);
- ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oCorpseOwner);
- }
- lLocation = GetLocation(oCreature);
- SetLocalLocation(oItem, DEATH_VARLOCATION, lLocation);
- SetLocalLocation(oItem, DEATH_VARCORPSELOCATION, lLocation);
- Death_BringToLife(oCorpseOwner, 2);
- return TRUE;
- }
- void Death_BringToLife(object oPC, int nDestination)
- {
- object oItem;
- object oCorpse;
- object oCarrier;
- object oWayPoint;
- location lLocation;
- int bSuccess;
- //PC left the game
- if (GetIsObjectValid(oPC) == FALSE)
- {
- return;
- }
- //transition?
- if(GetArea(oPC) == OBJECT_INVALID)
- {
- return;
- }
- bSuccess = TRUE;
- oItem = GetRequiredItem(oPC, DEATH_ITEMVARPERSIST);
- if (GetIsObjectValid(oItem) == FALSE)
- {
- return;
- }
- if (GetLocalInt(oItem, DEATH_VARISDEAD) == FALSE)
- {
- return;
- }
- switch (nDestination)
- {
- //jump to default spawn place
- case 1:
- if (GetIsUnderdarkRace(oPC))
- { oWayPoint = GetWaypointByTag(DEATH_WPDEFAULTSPAWNUD); }
- else
- { oWayPoint = GetWaypointByTag(DEATH_WPDEFAULTSPAWNNORMAL); }
- if (GetIsObjectValid(oWayPoint))
- {
- AssignCommand(oPC, ActionJumpToObject(oWayPoint));
- }
- else
- {
- bSuccess = FALSE;
- WriteTimestampedLogEntry("[Death System]: Waypoint does not exist.");
- }
- break;
- //jump to corpse / carrier of corpse
- case 2:
- oCorpse = GetLocalObject(oItem, DEATH_VARCORPSECREATURE);
- if (GetIsObjectValid(oCorpse) == FALSE) {oCorpse = GetLocalObject(oItem, DEATH_VARCORPSEITEM);}
- if (GetIsObjectValid(oCorpse) == TRUE)
- {
- if (GetObjectType(oCorpse) == OBJECT_TYPE_PLACEABLE || GetObjectType(oCorpse) == OBJECT_TYPE_CREATURE)
- {
- AssignCommand(oPC, JumpToObject(oCorpse));
- }
- else
- {
- oCarrier = GetItemPossessor(oCorpse);
- if (GetIsObjectValid(oCarrier))
- {
- AssignCommand(oPC, JumpToObject(oCarrier));
- }
- else
- {
- bSuccess = FALSE;
- WriteTimestampedLogEntry("[Death System]: Corpse carrier is invalid.");
- }
- }
- }
- else
- {
- WriteTimestampedLogEntry("[Death System]: " + GetName(oPC) + "'s corpse is invalid.");
- lLocation = GetLocalLocation(oItem, DEATH_VARCORPSELOCATION);
- AssignCommand(oPC, JumpToLocation(lLocation));
- }
- break;
- //jump to starting location
- case 3:
- {
- lLocation = GetStartingLocation();
- object oWPStart = GetWaypointByTag("wp_lobby_place");
- if(oWPStart == OBJECT_INVALID)
- {
- oWPStart = CreateObject(OBJECT_TYPE_WAYPOINT, "nw_waypoint001", lLocation, FALSE, "wp_lobby_place");
- }
- //AssignCommand(oPC, JumpToLocation(lLocation));
- AssignCommand(oPC, JumpToObject(oWPStart));
- break;
- }
- case 4:
- {
- if (GetIsUnderdarkRace(oPC))
- { oWayPoint = GetWaypointByTag("VARALLA_FROM_FUGUE"); }
- else
- { oWayPoint = GetWaypointByTag("FAI_NEXUS_JUMP"); }
- if (GetIsObjectValid(oWayPoint))
- {
- AssignCommand(oPC, JumpToObject(oWayPoint));
- }
- else
- {
- bSuccess = FALSE;
- WriteTimestampedLogEntry("[Death System]: Waypoint does not exist.");
- }
- break;
- }
- }
- if (bSuccess)
- {
- SendMessageToPC(oPC, "<c=pink><i>You feel groggy and light-headed having life flow through your veins once again.");
- //delete PvP no XP penalty variable
- if(GetLocalInt(oItem, "free_xp_death") != 0)
- {DeleteLocalInt(oItem, "free_xp_death");}
- SetLocalInt(oItem, DEATH_VARISDEAD, FALSE);
- SaveCharacter(oPC);
- DelayCommand(2.0, Death_RemoveCorpse(oPC, TRUE));
- DelayCommand(10.0, SaveCharacter(oPC));
- }
- }
- void Death_ApplyConsequences(object oCreature, int bIsPvP)
- {
- int iLevel;
- int iXpCurrent;
- int iXpMinimum;
- int iXpConsequence;
- int iGoldConsequence;
- //upon PvP Death don't deduct XP
- object oItemPC = GetRequiredItem(oCreature, DEATH_ITEMVARPERSIST);
- if(bIsPvP != TRUE && GetLocalInt(oItemPC, "free_xp_death") != 0)
- {bIsPvP = TRUE; DeleteLocalInt(oItemPC, "free_xp_death");}
- if (GetIsObjectValid(oCreature) == FALSE || bIsPvP != FALSE)
- { return; }
- iXpCurrent = GetXP(oCreature);
- iLevel = GetLevelFromXp(oCreature);
- iXpMinimum = GetXpForLevel(oCreature, iLevel);
- iXpConsequence = iLevel * 100;
- if (iXpCurrent - iXpConsequence < iXpMinimum)
- { iXpConsequence = iXpCurrent - iXpMinimum; }
- iGoldConsequence = GetGold(oCreature) * 5 / 100;
- /* Commented until a banking system is in place */
- //TakeGoldFromCreature(iGoldConsequence, oCreature, TRUE);
- SetXP(oCreature, iXpCurrent - iXpConsequence);
- SaveCharacter(oCreature);
- }
Add Comment
Please, Sign In to add comment