Author Topic: Help with merging CEP 2.4 with HABTD  (Read 368 times)

Legacy_Karvon

  • Sr. Member
  • ****
  • Posts: 430
  • Karma: +0/-0
Help with merging CEP 2.4 with HABTD
« on: July 13, 2011, 02:07:31 pm »


               I'm in the process of developing a builder's mod with CEP 2.4, and one thing I've not had any experience with is scripts related to horses.  I'm not really much of a scriptor, usually doing really simple stuff with Lilac is about all. I've taken an initial look at the ondeath scripts of the two systems, but a bit uncertain about how to correctly merge the two so they play nice, given the length of each. 

If anyone's done this already, and willing to share their work, or walk me thru it, it'd be much appreciated.  I can post the two scripts in question here, if that'd help.

Regards,

Karvon
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Help with merging CEP 2.4 with HABTD
« Reply #1 on: July 13, 2011, 02:26:31 pm »


               Post your scripts.
               
               

               
            

Legacy_Karvon

  • Sr. Member
  • ****
  • Posts: 430
  • Karma: +0/-0
Help with merging CEP 2.4 with HABTD
« Reply #2 on: July 13, 2011, 04:21:00 pm »


               Alrighty, first here's the CEP 2.4 script...

----------------------------------------------------------------------------------------------------------------------------------------------

//::///////////////////////////////////////////////
//:: Death Script
//:: NW_O0_DEATH.NSS
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
   This script handles the default behavior
   that occurs when a player dies.

   BK: October 8 2002: Overriden for Expansion

   Deva Winblood:  Feb 9th, 2008: Modified to
   handle dismounts when PC dies while mounted.

*/
//:://////////////////////////////////////////////
//:: Created By: Brent Knowles
//:: Created On: November 6, 2001
//:://////////////////////////////////////////////

#include "x3_inc_horse"
#include "zep_inc_phenos"
#include "x2_inc_switches"

/*
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 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);
}



///////////////////////////////////////////////////////////////[ MAIN ]/////////
void main()
{
   object oPlayer = GetLastPlayerDied();
//////////////////////////////////////////////////////////////////////////////
   //zep_Dismount (oPlayer, "horse_dismt");//DISMOUNT the dead player
   //SetLocalInt(oPlayer, "VAR_HORSEMOUNT", 0);//horselord class variable
   //string sResRef = GetLocalString(oPlayer,"PONY_ID");
   if (GetLocalInt(oPlayer, "VAR_HORSEMOUNT")== 1)
  {
       zep_Dismount (oPlayer, "horse_dismt");
       SetLocalInt(oPlayer,"bX3_IS_MOUNTED",FALSE);
       DeleteLocalString(oPlayer,"X3_HORSE_SCRIPT_DISMOUNT");
       SetLocalInt(oPlayer, "VAR_HORSEMOUNT", 0);//horselord class variable
    //remove horse support DLA Style
   object oRider=GetLastPlayerDied();

   DelayCommand(1.0, HORSE_SupportOriginalSpeed(oRider));
   DelayCommand(1.0, HORSE_SupportRemoveMountedSkillDecreases(oRider));
   DelayCommand(1.0, HORSE_SupportRemoveACBonus(oRider));
   DelayCommand(1.0, HORSE_SupportRemoveHPBonus(oRider));

   object oTarget;
   location lPc = GetLocation(oPlayer);
   location lWyrmling = GetItemActivatedTargetLocation();

   //object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, sResRef, lPc, TRUE);
   }
/////////////////////////////////////////////////////////////////////////////////
   //object oPlayer = GetLastPlayerDied();
   object oHorse;
   object oInventory;
   string sID;
   int nC;
   string sT;
   string sR;
   int nCH;
   int nST;
   object oItem;
   effect eEffect;
   string sDB="X3SADDLEBAG"+GetTag(GetModule());
   if (GetStringLength(GetLocalString(GetModule(),"X3_SADDLEBAG_DATABASE"))>0) sDB=GetLocalString(GetModule(),"X3_SADDLEBAG_DATABASE");
   if (HorseGetIsMounted(oPlayer))
   { // Dismount and then die
       //SetCommandable(FALSE,oPlayer);
       //ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPlayer);
       DelayCommand(0.5,HORSE_SupportResetUnmountedAppearance(oPlayer));
       DelayCommand(1.0,HORSE_SupportCleanVariables(oPlayer));
       DelayCommand(1.1,HORSE_SupportRemoveACBonus(oPlayer));
       DelayCommand(1.2,HORSE_SupportRemoveHPBonus(oPlayer));
       DelayCommand(1.3,HORSE_SupportRemoveMountedSkillDecreases(oPlayer));
       DelayCommand(1.4,HORSE_SupportAdjustMountedArcheryPenalty(oPlayer));
       DelayCommand(1.5,HORSE_SupportOriginalSpeed(oPlayer));
       if (!GetLocalInt(GetModule(),"X3_HORSE_NO_CORPSES"))
       { // okay to create lootable horse corpses
           sR=GetLocalString(oPlayer,"sX3_HorseResRef");
           sT=GetLocalString(oPlayer,"sX3_HorseTag");
           nCH=GetLocalInt(oPlayer,"nX3_HorseAppearance");
           nST=GetLocalInt(oPlayer,"nX3_HorseTail");
           nC=GetLocalInt(oPlayer,"nX3_HorsePortrait");
           if (GetStringLength(sR)>0&&GetStringLeft(sR,GetStringLength(HORSE_PALADIN_PREFIX))!=HORSE_PALADIN_PREFIX)
           { // create horse
               oHorse=HorseCreateHorse(sR,GetLocation(oPlayer),oPlayer,sT,nCH,nST);
               SetLootable(oHorse,TRUE);
               SetPortraitId(oHorse,nC);
               SetLocalInt(oHorse,"bDie",TRUE);
               AssignCommand(oHorse,SetIsDestroyable(FALSE,TRUE,TRUE));
           } // create horse
       } // okay to create lootable horse corpses
       oInventory=GetLocalObject(oPlayer,"oX3_Saddlebags");
       sID=GetLocalString(oPlayer,"sDB_Inv");
       if (GetIsObjectValid(oInventory))
       { // drop horse saddlebags
           if (!GetIsObjectValid(oHorse))
           { // no horse created
               HORSE_SupportTransferInventory(oInventory,OBJECT_INVALID,GetLocation(oPlayer),TRUE);
           } // no horse created
           else
           { // transfer to horse
               HORSE_SupportTransferInventory(oInventory,oHorse,GetLocation(oHorse),TRUE);
           } // transfer to horse
       } // drop horse saddlebags
       else if (GetStringLength(sID)>0)
       { // database based inventory
           nC=GetCampaignInt(sDB,"nCO_"+sID);
           while(nC>0)
           { // restore inventory
               sR=GetCampaignString(sDB,"sR"+sID+IntToString(nC));
               sT=GetCampaignString(sDB,"sT"+sID+IntToString(nC));
               nST=GetCampaignInt(sDB,"nS"+sID+IntToString(nC));
               nCH=GetCampaignInt(sDB,"nC"+sID+IntToString(nC));
               DeleteCampaignVariable(sDB,"sR"+sID+IntToString(nC));
               DeleteCampaignVariable(sDB,"sT"+sID+IntToString(nC));
               DeleteCampaignVariable(sDB,"nS"+sID+IntToString(nC));
               DeleteCampaignVariable(sDB,"nC"+sID+IntToString(nC));
               if (!GetIsObjectValid(oHorse))
               { // no lootable corpse
                   oItem=CreateObject(OBJECT_TYPE_ITEM,sR,GetLocation(oPlayer),FALSE,sT);
               } // no lootable corpse
               else
               { // lootable corpse
                   oItem=CreateItemOnObject(sR,oHorse,nST,sT);
               } // lootable corpse
               if (GetItemStackSize(oItem)!=nST) SetItemStackSize(oItem,nST);
               if (nCH>0) SetItemCharges(oItem,nCH);
               nC--;
           } // restore inventory
           DeleteCampaignVariable(sDB,"nCO_"+sID);
           if (GetIsObjectValid(oHorse)&&GetLocalInt(oHorse,"bDie")) DelayCommand(1.0,ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDeath(),oHorse));
       } // database based inventory
       if (GetIsObjectValid(oHorse))
       { // no inventory
           DelayCommand(0.3,ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDeath(),oHorse));
       } // no inventory
       //eEffect=EffectDeath();
       //DelayCommand(1.6,ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oPlayer));
       //DelayCommand(1.7,SetCommandable(TRUE,oPlayer));
       //return;
   } // Dismount and then die
   // * 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));

}
///////////////////////////////////////////////////////////////[ MAIN ]/////////

-------------------------------------------------------------------------------------------------------------------------------

Next, here's the HABTD script...

================================================================

// Henchmen Always Bleed to Death
// By Demetrious, OldManWhistler and IntrepidCW
//
// PLEASE READ "habd_include" FOR MORE INFORMATION.
//
// OnPlayerDeath event handler.

#include "habd_include"


// ****************************************************************************


// USER DEFINED FUNCTION
// Called when the PC is properly death.
void HABDUserDefinedPCDeathNow(object oPC)
{
   /*
   //example aplication
   object oMod = GetModule();
   string sID = GetPCPlayerName(oPC)+GetName(oPC);
   if (GetLocalInt(GetModule(), HABD_MINHPLASTBLEED+sID)<=-20 )
       HABDSetCustomVar(oPC, "Permadeath_Hell_N1");
   else
   if (GetLocalInt(GetModule(), HABD_MINHPLASTBLEED+sID)<=-40 )
       HABDSetCustomVar(oPC, "Permadeath_Hell_N2");
   else
       HABDSetCustomVar(oPC, "");
  */
}
// ***************************************************************************


// Report that a player died. OBJECT_SELF is the dead player.
void ReportPlayerDeath();

void ReportPlayerDeath()
{
   object oPC = OBJECT_SELF;

   // Abort is not a player
   if (!GetIsPC(oPC)) return;

   int iHPs = GetCurrentHitPoints(oPC);
   // Abort if player isn't dying
   if (iHPs > 0) return;

   // Display notification.
   if(HABD_USERLANGUAGE==0)
       FloatingTextStringOnCreature(GetName(oPC)+" HAS DIED!", oPC);
   else if(HABD_USERLANGUAGE==1)
       FloatingTextStringOnCreature(GetName(oPC)+" HA MUERTO!", oPC);
   // Vocal notification.
   AssignCommand(oPC, PlayVoiceChat(VOICE_CHAT_DEATH, oPC));
   if (HABD_DM_NOTIFICATION_ON_DEATH)
   {
       if(HABD_USERLANGUAGE==0)
           SendMessageToAllDMs("DEAD: "+GetName(oPC)+" HAS DIED");
       else if(HABD_USERLANGUAGE==1)
           SendMessageToAllDMs("MUERTO: "+GetName(oPC)+" HA MUERTO!");
   }
   if(HABD_USERLANGUAGE==0)
       DelayCommand(0.2,FloatingTextStringOnCreature("OOC: YOU HAVE JUST DIED, SO BE QUIET UNTIL YOU ARE RAISED. -DM", oPC, FALSE));
   else if(HABD_USERLANGUAGE==1)
       DelayCommand(0.2,FloatingTextStringOnCreature("OOC: HAS MUERTO, ASI QUE TU PJ NO PUEDE HABLAR HASTA QUE SEA RESUCITADO. -DM", oPC, FALSE));
}

// ****************************************************************************

// Recover a player from instant death. This is one of the key functions of
// this death system. Instant death isn't possible, you always bleed.
//   oPC - the player who instantly died.
void RecoverInstantDeath(object oPC);

void RecoverInstantDeath(object oPC)
{
   // Should regeneration items be removed from bleeding players?
   if (HABD_NERF_REGENERATION_ITEMS)
   {
       AssignCommand(oPC, HABDRegenerationItemsUnequip(oPC));
   }

   // Bring the player back from death and make them bleed.
   ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPC);

   int iCap = HABD_BLEEDING_START_LIMIT;
       if (iCap>-1) iCap = -1;
           if (iCap<=-10) iCap = -9;
   /*eg, if HABD_BLEEDING_START_LIMIT was -5   int iBleed = 6+Random(4);*/
   int iBleed = - iCap + 1 + Random(10+iCap-1);
       if (iBleed >=10) iBleed = 9;
           if (iBleed<=0) iBleed = 1;

   SetPlotFlag(oPC, FALSE);
   //eg Will leave player at -6 to -9, if HABD_BLEEDING_START_LIMIT was -5
   ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDamage(iBleed, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_PLUS_FIVE), oPC);
   SetPlotFlag(oPC, TRUE);
   if(HABD_USERLANGUAGE==0)
       FloatingTextStringOnCreature("You nearly died! Bleeding starts at -"+IntToString(iBleed), oPC, FALSE);
   else if(HABD_USERLANGUAGE==1)
       FloatingTextStringOnCreature("Casi mueres! El desangramiento empieza a -"+IntToString(iBleed), oPC, FALSE);
}


// ****************************************************************************

// Warn player that they will auto-respawn in fTime seconds.
//   oPC - the dead player.
//   fTime - the amount of time until auto-respawn.
void AutoRespawnWarning(object oPC, float fTime);

void AutoRespawnWarning(object oPC, float fTime)
{
   // If the player is no longer dead then kill the warning.
   if (!GetIsDead(oPC)) return;
   if ( HABDGetHABD_PLAYER_STATE("", oPC) != HABD_STATE_PLAYER_DEAD) return;
   // Store  -no longer used, can cause problems
   //SetLocalInt(GetModule(), HABD_RESPAWN_TIMER+GetPCPlayerName(oPC)+GetName(oPC), FloatToInt(fTime));
   // Warn the player.
   if(fTime > 1.0)
   {
     if(HABD_USERLANGUAGE==0)
       FloatingTextStringOnCreature("OOC: "+GetName(oPC)+" will automatically respawn in "+FloatToString(fTime,4,1)+" seconds.", oPC, TRUE);
     else if(HABD_USERLANGUAGE==1)
       FloatingTextStringOnCreature("OOC: "+GetName(oPC)+" respawnara automaticamente en "+FloatToString(fTime,4,1)+" segundos.", oPC, TRUE);
   }
   return;
}

// ****************************************************************************

// Warn player that they will auto-raise in fTime seconds.
//   oPC - the dead player.
//   fTime - the amount of time until auto-raise.
void AutoRaiseWarning(object oPC, float fTime);

void AutoRaiseWarning(object oPC, float fTime)
{
   // If the player is no longer dead then kill the warning.
   if (!GetIsDead(oPC)) return;
   if (HABDGetHABD_PLAYER_STATE("", oPC) != HABD_STATE_PLAYER_DEAD)
       return;
   // Store  -no longer used, can cause problems
   //SetLocalInt(GetModule(), HABD_RAISE_TIMER+GetPCPlayerName(oPC)+GetName(oPC), FloatToInt(fTime));
   // Warn the player.
   if(fTime > 1.0)
   {
       if(HABD_USERLANGUAGE==0)
       FloatingTextStringOnCreature("OOC: "+GetName(oPC)+" will automatically raise in "+FloatToString(fTime,4,1)+" seconds.", oPC, TRUE);
       else if(HABD_USERLANGUAGE==1)
       FloatingTextStringOnCreature("OOC: "+GetName(oPC)+" resucitara automaticamente en "+FloatToString(fTime,4,1)+" segundos.", oPC, TRUE);

   }
   return;
}

// ****************************************************************************


// Check if a player has spontaneously come back to life.
//   oPC - the dead player.
//   fTime - the duration to wait until the next health check.

void CheckForDMHeal(object oPC, float fTime)
{
   object oMod = GetModule();
   string sID = GetPCPlayerName(oPC)+GetName(oPC);
   // Check to see if the player is still alive.
   int iState = HABDGetHABD_PLAYER_STATE(sID, oPC);
   if (
       (iState == HABD_STATE_RESPAWNED_GHOST) ||
       (iState == HABD_STATE_PLAYER_ALIVE) ||
       (iState == HABD_STATE_PC_PERMADEATH)
       ) return;

   // Quick little timer to check that PCs recover from a DM heal properly.
   if (GetIsDead(oPC))
   {
       DelayCommand(fTime, CheckForDMHeal(oPC, fTime));
   } else {
       // Player has been DM healed.
       SetPlotFlag(oPC, FALSE);
       HABDSetHABD_PLAYER_STATE(HABD_STATE_PLAYER_ALIVE, sID, oPC);
       //Save info to DB (and maybe export PC) to avoid server crash problems,
       //now that we are sure the PC is Alive.
       if ( HABD_SMART_SAVETODB == TRUE )
           HABDSetDBString(oPC);
   }
}

// ****************************************************************************

// This is the OnPlayerDeath event handler.

void main()
{
   object oMod = GetModule();
   object oPC = GetLastPlayerDied();
   int iNPC = GetLocalInt(OBJECT_SELF, HABD_NPC_BLEED);
   if (iNPC == 1) oPC = OBJECT_SELF;
   string sID = GetPCPlayerName(oPC)+GetName(oPC);

   // If an NPC is running this script, then set up its master. The master was
   // automatically wiped out when the henchman died.
   if (iNPC)
   {
       if (!GetIsObjectValid(GetAssociate(ASSOCIATE_TYPE_HENCHMAN, GetLocalObject(OBJECT_SELF, HABD_NPC_MASTER))))
           AddHenchman(GetLocalObject(OBJECT_SELF, HABD_NPC_MASTER), oPC);
       //if HABD Death is disabled for Henchmen
       if ( HABD_HENCHMEN_DEATH == FALSE )
           return;
   }

   //Register minimun hit points
   SetLocalInt(GetModule(), HABD_MINHPLASTBLEED+sID,GetCurrentHitPoints(oPC) );

   int iState = HABDGetHABD_PLAYER_STATE(sID, oPC);
   if ( iState == HABD_STATE_PC_PERMADEATH )
   {
       ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(1 - (GetCurrentHitPoints(oPC))), oPC);
       ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oPC);
       HABDJumpToPermaDeathPoint(oPC, HABD_EVENTDEATHSIGNAL);
       return;
   }

   if (HABD_DEBUG) //DEBUG: Not Translated to Spanish
   SpeakString("DEBUG: HABD OnDeath, "+GetName(oPC)+", HP: "+IntToString(GetCurrentHitPoints(oPC))+", master: "+GetName(GetMaster(oPC))+", state:"+HABDGetPlayerStateName(oPC), TALKVOLUME_SHOUT);

   int iSafeArea = HABD_GetIsSafeArea(oPC);
   int iKillingHit = FALSE;
       if ( HABD_KILLING_HIT > GetCurrentHitPoints(oPC) && HABD_KILLING_HIT<0)
           iKillingHit = TRUE;

   // Check to see if they have bled at all - if not then give them a chance to bleed.
   if ( iNPC == FALSE || iNPC == TRUE && HABD_HENCHMEN_BLEED !=3 )
   if ( HABD_ALLOW_INSTANT_DEATH != TRUE || iSafeArea == TRUE ||
       GetHitDice(oPC) < HABD_NO_DEATH_UNTIL_LEVEL )
   if ( HABD_GetIsHardArea(oPC) == FALSE )
   if ( HABDCoupDeGraceAloneInArea(oPC) == FALSE || iSafeArea == TRUE ||
       GetHitDice(oPC) < HABD_NO_DEATH_UNTIL_LEVEL )
   if (iKillingHit == FALSE || GetHitDice(oPC) < HABD_NO_DEATH_UNTIL_LEVEL)
   if (HABDGetHABD_PLAYER_STATE(sID, oPC) != HABD_STATE_PLAYER_DEAD)
   {
       // Player died without going through bleeding.

       // Keep the player from taking additional damage while bleeding.
       SetPlotFlag(oPC, TRUE);
       // Special state for this circumstance.
       HABDSetHABD_PLAYER_STATE(HABD_STATE_PLAYER_INSTANT_DEATH, sID, oPC);
       // Bring the player to near-death.
       AssignCommand(oPC, RecoverInstantDeath(oPC));
       // Force friendly to hostile faction.
       if (!GetLocalInt(oPC, HABD_OLD_FACTION_SET))
       {
           SetLocalInt(oPC, HABD_OLD_FACTION, GetStandardFactionReputation(STANDARD_FACTION_HOSTILE, oPC));
           SetLocalInt(oPC, HABD_OLD_FACTION_SET, 1);
       }
       SetStandardFactionReputation(STANDARD_FACTION_HOSTILE, 100, oPC);
       // stop nearby attackers
       HABDStopNearbyAttackers(oPC);
       return;
   }
   // If Restored from Instant Death code below there will not be executed

   //:: If that part of the script runs: Player has properly died.

   // Check for a DM Heal.
   AssignCommand(oPC, DelayCommand(6.0, CheckForDMHeal(oPC, 6.0)));

   // Ensure that plot is not still set.
   SetPlotFlag(oPC, FALSE);
   // Set playerstate to dead not dying.
   HABDSetHABD_PLAYER_STATE(HABD_STATE_PLAYER_DEAD, sID, oPC);
   // Alert that the player died.
   AssignCommand(oPC, ReportPlayerDeath());

   //Save info to DB (and maybe export PC) to avoid server crash problems,
   //now that we are sure the PC is death.
   if ( HABD_SMART_SAVETODB == TRUE )
       HABDSetDBString(oPC);

   int iDrop = FALSE;
   if ( GetLocalInt(oPC, HABD_PERSISTANT_REAPPLY) != 1 )
       iDrop = TRUE;

   // Check if we are re-entering this state from persistence.
   if (GetLocalInt(oPC, HABD_PERSISTANT_REAPPLY) != 1)
   {
       if (iNPC == FALSE) //Player Character
       {
           // Set the auto-respawn/raise timers to maximum (not entering form persist).
           SetLocalInt(oMod, HABD_RESPAWN_TIMER+sID, FloatToInt(HABD_FORCE_RESPAWN_TIMER));
           if ((HABD_SOLO_FORCE_RAISE_TIMER > 0.0) && (HABDPlayerIsSolo(oPC)==TRUE)  )
           {
               SetLocalInt(oMod, HABD_RAISE_TIMER+sID, FloatToInt(HABD_SOLO_FORCE_RAISE_TIMER));
           } else {
               SetLocalInt(oMod, HABD_RAISE_TIMER+sID, FloatToInt(HABD_FORCE_RAISE_TIMER));
           }
           // Increment the counters.
           SetLocalInt(oMod, HABD_CURRENT_DEATH_COUNT+sID, GetLocalInt(oMod, HABD_CURRENT_DEATH_COUNT+sID) + 1);
           SetLocalInt(oMod, HABD_DEATH_COUNT+sID, GetLocalInt(oMod, HABD_DEATH_COUNT+sID) + 1);
       }
       else if (iNPC == TRUE) //NPC (henchman)
       {
           // Set the auto-respawn/raise timers to maximum (not entering form persist).
           //SetLocalInt(oMod, HABD_RESPAWN_TIMER+sID, FloatToInt(HABD_NPC_FORCE_RESPAWN_TIMER));
           SetLocalInt(oPC, HABD_RESPAWN_TIMER, FloatToInt(HABD_NPC_FORCE_RESPAWN_TIMER));
           SetLocalInt(oPC, HABD_RAISE_TIMER, FloatToInt(HABD_NPC_FORCE_RAISE_TIMER));
           // Increment the counters.
           SetLocalInt(oMod, HABD_CURRENT_DEATH_COUNT+sID, GetLocalInt(oMod, HABD_CURRENT_DEATH_COUNT+sID) + 1);
           SetLocalInt(oMod, HABD_DEATH_COUNT+sID, GetLocalInt(oMod, HABD_DEATH_COUNT+sID) + 1);
       }
   } else {
       // State was reapplied, do not increment the counters.
       DeleteLocalInt(oPC, HABD_PERSISTANT_REAPPLY);
       // Autoraise timers will use their persistent values.
   }

   // Should we reequip any regeneraton items?
   if (HABD_NERF_REGENERATION_ITEMS)
   {
       AssignCommand(oPC, HABDRegenerationItemsReEquip(oPC));
   }

   // Drop items
   if (iDrop == TRUE)
       AssignCommand(oPC, HABDDropItems(oPC));

   // Respawn option by PC using the GUI panel can be disabled.
   if (HABD_RESPAWN_ALLOWED)
   {
       PopUpDeathGUIPanel (oPC, HABD_INSTANT_RESPAWN_ALLOWED, TRUE, 0, "Press the Respawn button to respawn as a DM controlled ghost. "+IntToString(HABD_RESPAWN_XP_LOSS)+"% XP & "+IntToString(HABD_RESPAWN_GP_LOSS)+"% GP penalty applies.");
   } else
   {
       if(HABD_USERLANGUAGE==0)
       FloatingTextStringOnCreature("OOC: Respawn is turned off. You must wait for your party to help you, DM intervention or automatic respawn/raise.", oPC, FALSE);
       else if(HABD_USERLANGUAGE==1)
       FloatingTextStringOnCreature("OOC: Respawn esta desactivado. Debes esperar a que tu equipo de PJs te ayude, a la intervencion del DM o a respawn/resurreccion automaticas.", oPC, FALSE);
   }

   //User defined function
   HABDUserDefinedPCDeathNow(oPC);

   // Handle the auto-respawn and auto-raise timers.
   float fRespawn = 0.0;
   float fRaise = 0.0;
   if (iNPC)    //NPC/Henchman
   {
       fRespawn = IntToFloat(GetLocalInt(oPC, HABD_RESPAWN_TIMER));
       fRaise = IntToFloat(GetLocalInt(oPC, HABD_RAISE_TIMER));
       // The respawn timer must be less than the raise timer for it to execute.
       if ((fRespawn > 0.0) && ((fRespawn < fRaise) || (fRaise == 0.0)))
       {
           AssignCommand(oPC, DelayCommand(HABD_NPC_FORCE_RESPAWN_TIMER, HABDForceAutoRespawn(oPC)));
       }
       if (fRaise > 0.0)
       {
           if (HABD_FORCE_RAISE_USES_SCROLLS)
           {
               if (HABDCheckForRaiseRezScrolls(oPC) <= 0)
               {
                   return;
               }
           }
           AssignCommand(oPC, DelayCommand(HABD_NPC_FORCE_RAISE_TIMER, HABDForceAutoRaise(oPC)));
       }
   }
   else    //Player character
   {
       fRespawn = IntToFloat(GetLocalInt(oMod, HABD_RESPAWN_TIMER+sID));
       fRaise = IntToFloat(GetLocalInt(oMod, HABD_RAISE_TIMER+sID));
       // The respawn timer must be less than the raise timer for it to execute.
       if ((fRespawn > 0.0) && ((fRespawn < fRaise) || (fRaise == 0.0)))
       {
           AssignCommand(oPC, AutoRespawnWarning(oPC, fRespawn));
           AssignCommand(oPC, DelayCommand(0.5 * fRespawn, AutoRespawnWarning(oPC, 0.5 * fRespawn)));
           AssignCommand(oPC, DelayCommand(0.75*fRespawn, AutoRespawnWarning(oPC, 0.25*fRespawn)));
           AssignCommand(oPC, DelayCommand(9*fRespawn, AutoRespawnWarning(oPC, 0.1*fRespawn)));
           //AssignCommand(oPC, DelayCommand(fRespawn, ForceAutoRespawn(oPC)));
               AssignCommand(oPC, DelayCommand(IntToFloat(HABD_AUTOTIMERS_UPDATE), HABDAutoRespawnTimerUpdater(oPC, FloatToInt(fRespawn))));
       }
       if (fRaise > 0.0)
       {
           if (HABD_FORCE_RAISE_USES_SCROLLS)
           {
               if (HABDCheckForRaiseRezScrolls(oPC) <= 0)
               {
                   if(HABD_USERLANGUAGE==0)
                       FloatingTextStringOnCreature("OOC: Out of scrolls. You have to wait for help.", oPC, FALSE);
                   else if(HABD_USERLANGUAGE==1)
                       FloatingTextStringOnCreature("OOC: Sin Pergaminos. Tendras que esperar a que llegue ayuda.", oPC, FALSE);
                   return;
               }
           }
           AssignCommand(oPC, AutoRaiseWarning(oPC, fRaise));
           AssignCommand(oPC, DelayCommand(0.5 * fRaise, AutoRaiseWarning(oPC, 0.5 * fRaise)));
           AssignCommand(oPC, DelayCommand(0.75*fRaise, AutoRaiseWarning(oPC, 0.25*fRaise)));
           AssignCommand(oPC, DelayCommand(9*fRaise, AutoRaiseWarning(oPC, 0.1*fRaise)));
           //AssignCommand(oPC, DelayCommand(fRaise, HABDForceAutoRaise(oPC)));
               AssignCommand(oPC, DelayCommand(IntToFloat(HABD_AUTOTIMERS_UPDATE), HABDAutoRaiseTimerUpdater(oPC,FloatToInt(fRaise)) )  );
       }
   }
   // DO NOT ADD ANY CODE HERE. IT MIGHT NOT BE EXECUTED.
}

======================================================================

Thanks for any and all help and suggestions,

Regards,

Karvon
               
               

               
            

Legacy_Karvon

  • Sr. Member
  • ****
  • Posts: 430
  • Karma: +0/-0
Help with merging CEP 2.4 with HABTD
« Reply #3 on: July 16, 2011, 11:05:11 am »


               [bump]

Anyone have any advice on this?

Regards

Karvon