/////////////////////////////////////////////////////////////////////////////// // Real Time Strategy - NWN - Player Died //============================================================================ // By Deva Bryson Winblood. 02/28/2003 // modified 06/16/2004 Jeremy Greene // modified 04/25/2005 Deva Winblood /////////////////////////////////////////////////////////////////////////////// #include "hos_respawn_h" void fnCheckForForceRespawn(object oPC) { // PURPOSE: Check for force respawn object oEnemy=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oPC,1,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY); object oFriend=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,oPC,1,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_FRIEND); int bForceRespawn=FALSE; float fDistE=GetDistanceBetween(oPC,oEnemy); float fDistF=GetDistanceBetween(oPC,oFriend); if (oEnemy!=OBJECT_INVALID&&fDistE<30.0) bForceRespawn=TRUE; if (oFriend!=OBJECT_INVALID&&fDistF<20.0) bForceRespawn=FALSE; if (GetIsDead(oPC)==FALSE) bForceRespawn=FALSE; if (bForceRespawn) { // respawn SendMessageToPC(oPC,"You were forced to respawn due to presence of an enemy after 60 seconds and no friends nearby to assist you."); RespawnPlayer(oPC); } // respawn else if (GetIsDead(oPC)==TRUE) { // no force DelayCommand(12.0,fnCheckForForceRespawn(oPC)); } // no force } // fnCheckForForceRespawn() void main() { // Main <----------------------------------------------------- object oPC=OBJECT_SELF; object oKiller; int nKills; int nPCLevel; int nXP; object oItem; object oNew; object oMod=GetModule(); string sTag; object oCloth; int nGold; int nDeath; int nC; int nKillerLevel; int nLvlDif; object oHench; effect eEffect; object oKilledBy; int bOkay=TRUE; if (GetIsObjectValid(oPC)==FALSE) bOkay=FALSE; if (bOkay&&GetIsPC(oPC)==FALSE) bOkay=FALSE; if (bOkay&&GetIsDead(oPC)==FALSE) bOkay=FALSE; if (GetLocalInt(oMod,"bPlayerBleeding")&&GetCurrentHitPoints(oPC)>-10) bOkay=FALSE; if (bOkay) { // okay to handle death PrintString("rts_pc_death called by "+GetName(oPC)+"."); oKiller=GetLastKiller(); if(oKiller==OBJECT_INVALID||oKiller==oMod)oKiller=GetLastHostileActor(oPC); nKills=GetLocalInt(oKiller,"nKills"); nPCLevel=fnLevel(oPC); nXP=nPCLevel*2*FloatToInt(GetLocalFloat(oMod,"fXPMultiplier")); sTag=GetTag(oKiller); nGold=GetGold(oPC); nDeath=GetLocalInt(oPC,"nDied"); nKillerLevel=fnLevel(oKiller); nLvlDif=nPCLevel-nKillerLevel; oHench=GetAssociate(ASSOCIATE_TYPE_HENCHMAN,oPC,1); oKilledBy=oKiller; if(fnDeathShouldLock(oPC))fnDeathSetLock(oPC); oItem=GetItemPossessedBy(oPC,"MANA_CRYSTAL_5"); if (GetIsObjectValid(oItem)) { // drop mana crystal CreateObject(OBJECT_TYPE_PLACEABLE,"strongmanapool",GetLocation(oPC)); DestroyObject(oItem); } // drop mana crystal oItem=GetItemPossessedBy(oPC,"MANA_CRYSTAL_2"); if (GetIsObjectValid(oItem)) { // drop mana crystal CreateObject(OBJECT_TYPE_PLACEABLE,"manapool",GetLocation(oPC)); DestroyObject(oItem); } // drop mana crystal oItem=GetItemPossessedBy(oPC,"MANA_CRYSTAL_1"); if (GetIsObjectValid(oItem)) { // drop mana crystal CreateObject(OBJECT_TYPE_PLACEABLE,"minormanapool",GetLocation(oPC)); DestroyObject(oItem); } // drop mana crystal if (GetItemPossessedBy(oPC,"rts_powerres")!=OBJECT_INVALID) { // drop Power Reservoir CreateObject(OBJECT_TYPE_PLACEABLE,"plc_phylact001",GetLocation(oPC)); DestroyObject(GetItemPossessedBy(oPC,"rts_powerres")); } // drop Power Reservoir if (GetIsPC(oKiller)==FALSE&&(GetMaster(oKiller)!=OBJECT_INVALID)) { // killed by an associate oKiller=GetMaster(oKilledBy); nKillerLevel=fnLevel(oKiller); nLvlDif=nPCLevel-nKillerLevel; } // killed by an associate if (nDeath==0) { // have not already run death script // set kills nKills++; SetLocalInt(oKiller,"nKills",nKills); nKills=GetLocalInt(oKiller,"nPKills"); nKills++; SetLocalInt(oKiller,"nPKills",nKills); // award experience if (GetIsPC(oKiller)==TRUE&&oKiller!=oPC) { // award extra XP SendMessageToPC(oKiller,"You killed another player!!"); SendMessageToPC(oPC,"You were killed by another player!!"); nXP=nPCLevel*100; GiveXPToCreature(oKiller,nXP); if (nGold>0) AssignCommand(oKiller,TakeGoldFromCreature(fnLevel(oPC)*5,oPC,FALSE)); //// check for vampire if(GetLocalInt(oKiller,"nIsVampire")==TRUE) { // killed by a vampire SendMessageToPC(oPC,"You were killed by a player vampire!"); nC=d100(); if (nC<16) { // might have been infected DelayCommand(60.0,ExecuteScript("player_vampire",oPC)); } // might have been infected } // killed by a vampire } // award extra XP else { // set XP sTag=GetLocalString(oKiller,"sTeamID"); if (GetStringLength(sTag)>2) { // possible NPC unit oKiller=GetLocalObject(GetModule(),"oTeamLead"+sTag); if(oKiller==oPC) oKiller=OBJECT_INVALID; } // possible NPC unit /* else { // possible henchman, summoned, familiar, or animal companion oKiller=GetMaster(oKiller); if (oKiller!=OBJECT_INVALID) nXP=nXP*10; } // possible henchman, summoned, familiar, or animal companion */ if (oKiller!=OBJECT_INVALID) { // award XP GiveXPToCreature(oKiller,nXP); } // award XP } // set XP SetLocalInt(oPC,"nDied",1); nC=GetLocalInt(oPC,"nDeaths"); nC++; SetLocalInt(oPC,"nDeaths",nC); SendMessageToPC(oPC,"You have died "+IntToString(nC)+" times in this game."); if (GetLocalInt(oMod,"nGameType")==0) DelayCommand(5.5,fnMessageDeath(oPC,oKilledBy)); DelayCommand(60.0,fnCheckForForceRespawn(oPC)); DelayCommand(2.5, PopUpDeathGUIPanel(oPC,TRUE,TRUE)); } // have not already run death script } // okay to handle death } // Main <-----------------------------------------------------