Author Topic: OnDeath / Player Respawn.  (Read 452 times)

Legacy_Starbridge

  • Jr. Member
  • **
  • Posts: 57
  • Karma: +0/-0
OnDeath / Player Respawn.
« on: January 15, 2011, 03:32:45 am »


               Would anyone be able to assist me in getting an OnDeath / Respawn script.  Found another thing that my generator cant do.  '<img'>

Looking to get something takes 333exp and 100gp per level on respawn.
Free respawn if your character has a Life Stone.  (Special item I'm going to make)
And only 50exp if someone raises with a spell or scroll.
Also to port back to a waypoint.
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
OnDeath / Player Respawn.
« Reply #1 on: January 15, 2011, 04:41:27 am »


               here is a respawn script, and a include easly adjustable:

mod respawn event:
//:://////////////////////////////////////////////////////////////
//:: Title : mod_on_respawn  //On Pressed Respawn Button
//:: Author:  Greyfort
//:: Module: any who need
//:: Date  : Aug 20, 2010
//:: Vers  : 1.0
//:://////////////////////////////////////////////////////////////
// some scripts taken from default bioware script

// * Applies an XP and GP penalty
// * to the player respawning
// !!! careful changeing below!!!
void Custm_ApplyPenalty(object oDead)
{
   int nXP = GetXP(oDead);
   int nPenalty = 50 * GetHitDice(oDead);//change 50
   int nHD = GetHitDice(oDead);
   // * You can not lose a level with this respawning
   int nMin = ((nHD * (nHD - 1)) / 2) * 1000;

   int nNewXP = nXP - nPenalty;
   if (nNewXP
      nNewXP = nMin;
   SetXP(oDead, nNewXP);
   int nGoldToTake =    FloatToInt(0.10 * GetGold(oDead));
   // * a cap of 10 000gp taken from you
   if (nGoldToTake > 10000)
   {
       nGoldToTake = 10000;//change this to max
   }
   AssignCommand(oDead, TakeGoldFromCreature(nGoldToTake, oDead, TRUE));
   DelayCommand(4.0, FloatingTextStrRefOnCreature(58299, oDead, FALSE));
   DelayCommand(4.8, FloatingTextStrRefOnCreature(58300, oDead, FALSE));

}


//////////////////////////////////////////////////////////////////////////////
#include "nw_i0_plot"
#include "grey_func_inc"
void main()
{
//:://////////////////////////////////////////////////////////////
//:: Title : mod_on_respawn
//:: Author:  Greyfort
//:: Module: any who need
//:: Date  : Aug 20, 2010
//:: Vers  : 1.0
//:://////////////////////////////////////////////////////////////
object oRespawner = GetLastRespawnButtonPresser();
   ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oRespawner);
   ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oRespawner)), oRespawner);
   RemoveEffects(oRespawner);

object oSpawnPoint;
string sDestTag;

//DEBUG
//int iVobj=GetIsObjectValid( oRespawner);
//SendMessageToPC(oRespawner,"Valid Object.."+IntToString (iVobj)+".." );

////////////////////////////////////////////////
// GC_Get_C_Aling will not work GetLastRespawnButtonPresser()
//int nTestAlign= GC_Get_C_Aling(oRespawner);

////////////////////
// from lexicon
////////////////////


int nAlignGE = GetAlignmentGoodEvil(oRespawner);
int nAlignLC = GetAlignmentLawChaos(oRespawner);

int nAlign = 0;

//Calculate the IP_CONST_ALIGNMENT_* integer value
switch (nAlignGE) //Good is the default 0 [ethics unintended - ed.]
{
case ALIGNMENT_NEUTRAL: nAlign = 1; break;
case ALIGNMENT_EVIL: nAlign = 2;
}
switch (nAlignLC) //Lawful = 0
{
case ALIGNMENT_NEUTRAL: nAlign+=3; break; //increment nAlign by 3
case ALIGNMENT_CHAOTIC: nAlign+=6; break; //increment nAlign by 6
}

int nTestAlign = nAlign;
////////////////////
//end of int nTestAlign = nAlign;
////////////////////

//DEBUG
//SendMessageToPC(oRespawner,"alingment int"+IntToString (nTestAlign)+".." );

//:://///////////////////////////////////////////////////////////////////////////////////////////////
// This is from lexicon the nAlign switches derive from the following table:
/////// IP_CONST_ALIGNMENT ////////
//       0         1         2   //
// 0  LG = 0 // LN = 1 // LE = 2 //
// 3  NG = 3 // TN = 4 // NE = 5 //
// 6  CG = 6 // CN = 7 // CE = 8 //
/////////////////////////////////////////////////////////////
// Alingments...
// LG || LN || NG               // sDestTag ="WP_Gplain";
// TN                           // sDestTag ="WP_Nplain";
// LE || CG || CN || NE || CE   // sDestTag ="WP_Eplain";
////////////////////////////////////////////////////////////
// this switch chooses waypoint based on int nTestAlign = nAlign; value
switch (nTestAlign)
{
case 0:
    // ...LG
    sDestTag ="WP_Gplain";
    break;
case 1:
    // ...LN
    sDestTag ="WP_Gplain";
    break;
case 2:
    // ...LE
    sDestTag ="WP_Eplain";
    break;
case 3:
    // ...NG
    sDestTag ="WP_Gplain";
    break;
case 4:
    // ...NN
    sDestTag ="WP_Nplain";
    break;
case 5:
    // ...NE
    sDestTag ="WP_Eplain";
    break;
case 6:
    // ...CG
    sDestTag ="WP_Eplain";
    break;
case 7:
    // ...CN
    sDestTag ="WP_Eplain";
    break;
case 8:
    // ...CE
    sDestTag ="WP_Eplain";
    break;
default:
    // do nothing ...
    break;
}

/////////////////////////////////////
// Custm_ApplyPenalty()
Custm_ApplyPenalty(oRespawner);

/////////////////////////////////////
// jump to alingment plain

//DEBUG
SendMessageToPC(oRespawner,"alingment int"+IntToString (nTestAlign)+".." );
SendMessageToPC(oRespawner,"alingment waypoint"+sDestTag +".." );

oSpawnPoint = GetObjectByTag(sDestTag);
AssignCommand(oRespawner,JumpToLocation(GetLocation(oSpawnPoint)));

//end of script
}

include script:

//:://////////////////////////////////////////////////////////////
//:: Title : grey_func_inc
//:: Author:  Greyfort
//:: Module: any who need
//:: Date  : Aug 22, 2010
//:: Vers  : 1.0
//:://////////////////////////////////////////////////////////////
//!!!WARNING!!! !!!WARNING!!! !!!WARNING!!! !!!WARNING!!!
//!!! "custm_drop_inc" will cause duplicate errors if used with this include
//!!!WARNING!!! !!!WARNING!!! !!!WARNING!!! !!!WARNING!!!


//:://///////////////////////////////////////////////////////////////////////////////////////////////
// This is CONSTANTS for function Get_C_Aling
const int GC_LAWFUL_GOOD=0;
const int GC_LAWFUL_NEUTRAL=1;
const int GC_LAWFUL_EVIL=2;
const int GC_NEUTRAL_GOOD=3;
const int GC_TRUE_NEUTRAL=4;
const int GC_NEUTRAL_EVIL=5;
const int GC_CHAOTIC_GOOD=6;
const int GC_CHAOTIC_NEUTRAL=7;
const int GC_CHAOTIC_EVIL=8;



//:://///////////////////////////////////////////////////////////////////////////////////////////////
// This is from lexicon the nAlign switches derive from the following table:
/////// IP_CONST_ALIGNMENT ////////
//       0         1         2   //
// 0  LG = 0 // LN = 1 // LE = 2 //
// 3  NG = 3 // TN = 4 // NE = 5 //
// 6  CG = 6 // CN = 7 // CE = 8 //
//
/////////////////////////////////////////////////////
// This function gets object oCreature ALINGMENT
int GC_Get_C_Aling( object oCreature);//



//////////////////////////////////////////////////
// This function gets object oCreature ALINGMENT
int GC_Get_C_Aling( object oCreature)
{

object oCreature;


int nAlignGE = GetAlignmentGoodEvil(oCreature);
int nAlignLC = GetAlignmentLawChaos(oCreature);

int nAlign = 0;

//Calculate the IP_CONST_ALIGNMENT_* integer value

switch (nAlignGE) //Good is the default 0 [ethics unintended - ed.]
{
case ALIGNMENT_NEUTRAL: nAlign = 1; break;//return nAlign;//
case ALIGNMENT_EVIL: nAlign = 2; //break;
}


switch (nAlignLC) //Lawful = 0
{
case ALIGNMENT_NEUTRAL: nAlign+=3; break;// //increment nAlign by 3
case ALIGNMENT_CHAOTIC: nAlign+=6; break;// //increment nAlign by 6
}
return nAlign;

// end of GC_Get_C_Aling
}



//:://///////////////////////////////////////////////////////////////////////////////////////////////
// This function strips all items on object. An example of this can be found in lexicon.
// see lexicon cellowin strips all items with tag.
void GC_StripALLItems(object oStrippee);

//////////////////////////////////////
// This function strips all items on object
void GC_StripALLItems(object oStrippee)
{

 object oCurrentItem = GetFirstItemInInventory(oStrippee);

 while (oCurrentItem != OBJECT_INVALID)
 {
  DestroyObject(oCurrentItem);
  oCurrentItem = GetNextItemInInventory(oStrippee);
 }
}// end GC_StripItems function



//:://///////////////////////////////////////////////////////////////////////////////////////////////
// this funtion generates gold, based on pc lvl, and area.
// put int iGold; before use of GenGoldValues, dont give number will add it to total.
// EXAMPLE:
// int iGold;
// CreateItemOnObject("NW_IT_GOLD001",oPC,GenGold_Values(iGold),"");
// Also see file:"rat_drop_death" for an example of use.
//
// You should only generate values within include "rat_drop_inc".
// make backup named "rat_drop_inc_bu" if you do alter you will always have old file to refer to.
// marked CHANGE ONLY, or add more areas ware marked instruction within include "rat_drop_inc".
//
//// MUST INCLUDE "int iValue;"
// BEFOR "GC_GenGoldValues(iValue);" FUNCTION
// NO NEED TO GIVE A VALUE WILL POSSIBLY ADD TO TOTAL
// SET IN THE INCLUDE FILE.
// you can also just use 0 GC_GenGoldValues(0);
// I think so....
int GC_GenGoldValues(int iRGold);

//////////////////////////////////////
// this funtion generates gold
int GC_GenGoldValues(int iRGold)
{
//
// generate values for gold based on areas
int iPClvl1  = GetLevelByPosition(1,GetLastKiller());
int iPClvl2  = GetLevelByPosition(2,GetLastKiller());
int iPClvl3  = GetLevelByPosition(3,GetLastKiller());
int iTPClvl = iPClvl1+iPClvl2+iPClvl3;

int iRGMax;
   if (GetTag(GetArea(OBJECT_SELF))=="vampy")
   {
   // for area "vampy" ...name="Twilight Misty Lands"
   iRGMax=200;// CHANGE ONLY iRGMax value only
   }
   else if (GetTag(GetArea(OBJECT_SELF))=="vampIsle2")
   {
   // for area "vampIsle2" ...name="VampIsle2"
   iRGMax=300;// CHANGE ONLY iRGMax value only
   }
   else if (GetTag(GetArea(OBJECT_SELF))=="vampgard")
   {
   // for area "vampgard" ...name="Forboding Cave"
   iRGMax=500;// CHANGE ONLY iRGMax value only
   }// you can add more areas buy another else if
   // EXAMPLE:
   //else if (GetTag(GetArea(OBJECT_SELF))=="tag of your area")
   //{
   // for area "tag of your area" ...name=""
   //iRGMax=number value here;// CHANGE ONLY iRGMax value only
   //{
   // EXAMPLE:
   //else if (GetTag(GetArea(OBJECT_SELF))=="tag of your area")
   //{
   // for area "tag of your area" ...name=""
   //iRGMax=number value here;// CHANGE ONLY iRGMax value only
   //{
   // EXAMPLE:
   //else if (GetTag(GetArea(OBJECT_SELF))=="tag of your area")
   //{
   // for area "tag of your area" ...name=""
   //iRGMax=number value here;// CHANGE ONLY iRGMax value only
   //{
   else
   {
   // default if no area or error ...
   iRGMax=100;// CHANGE ONLY iRGMax value only
   }

int iRnum = iRGMax + iTPClvl;
int iRGold= Random(iRnum);
return (iRGold);
}// end GC_GenGoldValues

//:://////////////////////////////////////////////////////
// * Applies an XP and GP penalty
// * to the player respawning
void GC_Dfault_ApplyPenalty(object oDead);


// * Applies an XP and GP penalty
// * to the player respawning
void GC_Dfault_ApplyPenalty(object oDead)
{
   int nXP = GetXP(oDead);
   int nPenalty = 50 * GetHitDice(oDead);
   int nHD = GetHitDice(oDead);
   // * You can not lose a level with this respawning
   int nMin = ((nHD * (nHD - 1)) / 2) * 1000;

   int nNewXP = nXP - nPenalty;
   if (nNewXP
      nNewXP = nMin;
   SetXP(oDead, nNewXP);
   int nGoldToTake =    FloatToInt(0.10 * GetGold(oDead));
   // * a cap of 10 000gp taken from you
   if (nGoldToTake > 10000)
   {
       nGoldToTake = 10000;
   }
   AssignCommand(oDead, TakeGoldFromCreature(nGoldToTake, oDead, TRUE));
   DelayCommand(4.0, FloatingTextStrRefOnCreature(58299, oDead, FALSE));
   DelayCommand(4.8, FloatingTextStrRefOnCreature(58300, oDead, FALSE));

}// end GC_Dfault_ApplyPenalty



//:://////////////////////////////////////////////////////
// * Applies an XP and GP penalty
// * to the player respawning
void GC_Custm_ApplyPenalty(object oDead);

// * Applies an XP and GP penalty
// * to the player respawning
void GC_Custm_ApplyPenalty(object oDead)
{

int icustm1 = 50;// CHANGE ONLY xp penalty
int icustmMaxGP = 10000;// CHANGE ONLY max gold taken

   int nXP = GetXP(oDead);
   int nPenalty = icustm1 * GetHitDice(oDead);
   int nHD = GetHitDice(oDead);
   // * You can not lose a level with this respawning
   int nMin = ((nHD * (nHD - 1)) / 2) * 1000;

   int nNewXP = nXP - nPenalty;
   if (nNewXP
      nNewXP = nMin;
   SetXP(oDead, nNewXP);
   int nGoldToTake =    FloatToInt(0.10 * GetGold(oDead));
   // * a cap of 10 000gp taken from you
   if (nGoldToTake > icustmMaxGP)
   {
       nGoldToTake = icustmMaxGP;
   }
   AssignCommand(oDead, TakeGoldFromCreature(nGoldToTake, oDead, TRUE));
   DelayCommand(4.0, FloatingTextStrRefOnCreature(58299, oDead, FALSE));
   DelayCommand(4.8, FloatingTextStrRefOnCreature(58300, oDead, FALSE));

}// end GC_Custm_ApplyPenalty

////////////////////////////////////
// add new funtions below
////////////////////////////////////

Note these scripts dont do exactly what you want but you can adjust them or if unsure how i can make them more to what you described just drop me a pm
               
               

               


                     Modifié par Greyfort, 15 janvier 2011 - 04:43 .
                     
                  


            

Legacy_Starbridge

  • Jr. Member
  • **
  • Posts: 57
  • Karma: +0/-0
OnDeath / Player Respawn.
« Reply #2 on: January 16, 2011, 02:01:32 am »


               I cant even begin to decode that.  Good thing I read your note at the bottom, I just about C&Ped all of it.  lol

If you have free time to make the script I requested that would be a big help.  Thank you a ton!
Possible to request the item and waypoint tag/ref highlited so I can change that if I have to, as well as the exp and gold values?
               
               

               


                     Modifié par Starbridge, 16 janvier 2011 - 02:05 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
OnDeath / Player Respawn.
« Reply #3 on: January 16, 2011, 04:40:58 am »


               Everything you want needs to be done in about 4 places/scripts.
First one is your OnPlayerRespawn script. You could use something like this. I took what I made for myself and added a bit for what you needed:

//::////////////////////////////////////////////////////////////////////////////
//:: me_respawn
//::////////////////////////////////////////////////////////////////////////////

#include "nw_i0_plot"

//Tag of the waypoint to respawn at:
const string RESPAWN_WP = "RESPAWN_WP";

//XP loss per level"
const int XP_PER_LEVEL = 50;

//% Gold loss:
const float GOLD_LOSS = 0.05;

//No penalty if possesses item
const int POSSESS_ITEM = TRUE;

//Tag of above item:
const string ITEM_TAG = "LifeStone";

//::////////////////////////////////////////////////////////////////////////////

// * Applies an XP and GP penalty
// * to the player respawning
void ApplyPenalty(object oDead)
{
    int nXP = GetXP(oDead);
    int nPenalty = XP_PER_LEVEL * GetHitDice(oDead);
    int nHD = GetHitDice(oDead);
    // * 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;
    SetXP(oDead, nNewXP);
    int nGoldToTake = FloatToInt(GOLD_LOSS * GetGold(oDead));
    //a cap of 10,000gp taken from you
    if (nGoldToTake > 10000)
    {
        nGoldToTake = 10000;
    }
    AssignCommand(oDead, TakeGoldFromCreature(nGoldToTake, oDead, TRUE));
    DelayCommand(4.0, FloatingTextStrRefOnCreature(58299, oDead, FALSE));
    DelayCommand(4.8, FloatingTextStrRefOnCreature(58300, oDead, FALSE));

}

void main()
{
    object oRespawner = GetLastRespawnButtonPresser();
    ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oRespawner);
    ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oRespawner)), oRespawner);
    RemoveEffects(oRespawner);
    //ApplyPenalty(oRespawner);
    
    if (POSSESS_ITEM == TRUE)
    {
        if (GetItemPossessedBy(oPC, ITEM_TAG) == OBJECT_INVALID)
        ApplyPenalty(oRespawner);
    }
    else ApplyPenalty(oRespawner);
    
    //Return PC to module respawn point
    object oSpawnPoint = GetWaypointByTag(RESPAWN_WP);

    if (GetIsObjectValid(oSpawnPoint))
    AssignCommand(oRespawner,JumpToObject(oSpawnPoint));

    else
    {
    //do nothing, just 'res where you are.
    }
}


You will also need to alter your OnPlayerDeath script. I use the default one(nw_o0_death) with one change. Since you want custom penalties for xp and gold, you need to alter the message that the players see when the death GUI pops up, to let them know about your modules penalties. So if you look at that script at the very bottom, the last line will look like this:

DelayCommand(2.5, PopUpGUIPanel(oPlayer,GUI_PANEL_PLAYER_DEATH));

So I just commented that line out and then you put your own pop up command with a custom message. This is what mine looks like:

//DelayCommand(2.5, PopUpGUIPanel(oPlayer,GUI_PANEL_PLAYER_DEATH));
string sDeath = "~Choose Wisely~\\n" + "Respawning will incur a penalty of " +
                    "50XP per character level and the loss of 5% of your gold.";
DelayCommand(2.5, PopUpDeathGUIPanel(oPlayer, TRUE, TRUE, 0, sDeath));


Now since you also want custom penalties for being raised or resurrected you will also need to alter the scripts for those spells. I can't remember what they are off the top of my head but Ill poke around and see if i can find em. In the meantime if anyone knows already they could go ahead and post it.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
OnDeath / Player Respawn.
« Reply #4 on: January 16, 2011, 04:43:59 am »


               IMPORTANT NOTE ABOUT ABOVE REPLY:



Just a reminder that these forums always double this symbol when you type it here "\\" There should only be one but there is always 2. So above where it says "Choose Wisely" in the script followed by "\\n", there should only be one not 2 "\\".
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
OnDeath / Player Respawn.
« Reply #5 on: January 16, 2011, 09:27:56 pm »


               here is ghosts script fixed to take 333xp per level and 100gp and life stone as discribed in your post:

//::////////////////////////////////////////////////////////////////////////////
//:: mod_respawnv1
//::////////////////////////////////////////////////////////////////////////////

#include "nw_i0_plot"

//Tag of the waypoint to respawn at:
const string RESPAWN_WP = "RESPAWN_WP";

//XP loss per level"
const int XP_PER_LEVEL = 333;//50;

//% Gold loss:
const float GOLD_LOSS = 100.0;//0.05;

//No penalty if possesses item
const int POSSESS_ITEM = TRUE;

//Tag of above item:
const string ITEM_TAG = "LifeStone";

//::////////////////////////////////////////////////////////////////////////////

// * Applies an XP and GP penalty
// * to the player respawning
void ApplyPenalty(object oDead)
{
   int nXP = GetXP(oDead);
   int nPenalty = XP_PER_LEVEL * GetHitDice(oDead);
   int nHD = GetHitDice(oDead);
   // * You can not lose a level with this respawning
   int nMin = ((nHD * (nHD - 1)) / 2) * 1000;

   int nNewXP = nXP - nPenalty;
   if (nNewXP
      nNewXP = nMin;
   SetXP(oDead, nNewXP);
   int nGoldToTake = FloatToInt(GOLD_LOSS * GetGold(oDead));
   //a cap of 10,000gp taken from you
   if (nGoldToTake > 10000)
   {
       nGoldToTake = 10000;
   }
   AssignCommand(oDead, TakeGoldFromCreature(nGoldToTake, oDead, TRUE));
   DelayCommand(4.0, FloatingTextStrRefOnCreature(58299, oDead, FALSE));
   DelayCommand(4.8, FloatingTextStrRefOnCreature(58300, oDead, FALSE));

}

void main()
{
   object oRespawner = GetLastRespawnButtonPresser();
   ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oRespawner);
   ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oRespawner)), oRespawner);
   RemoveEffects(oRespawner);
   //ApplyPenalty(oRespawner);

   if (POSSESS_ITEM == TRUE)
   {
       if (GetItemPossessedBy(oRespawner, ITEM_TAG) == OBJECT_INVALID)
       ApplyPenalty(oRespawner);
   }
   else ApplyPenalty(oRespawner);

   //Return PC to module respawn point
   object oSpawnPoint = GetWaypointByTag(RESPAWN_WP);

   if (GetIsObjectValid(oSpawnPoint))
   AssignCommand(oRespawner,JumpToObject(oSpawnPoint));

   else
   {
   //do nothing, just 'res where you are.
   }
}

I'm looking into the spell issue also will post that soon...

EDIT: Here are the names of the core nwn files you must change ...
nw_s0_raisdead
nw_s0_resserec

I will post altered scripts if you would like.
               
               

               


                     Modifié par Greyfort, 16 janvier 2011 - 09:40 .
                     
                  


            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
OnDeath / Player Respawn.
« Reply #6 on: January 16, 2011, 10:08:22 pm »


               Here is the edits you must do to the raise dead/reserection spells.  Remember these will over write your orginal versions if you want the original version you only have to add the /* and */ back ware they are now in the script that I posted. to use the 50xp pen choose wich version you want and remove the /* and */ if I missed anything just let me know

raise dead script:

//::///////////////////////////////////////////////
//:: [Raise Dead]
//:: [NW_S0_RaisDead.nss]
//:: nw_s0_raisdead
//:: raisdead_core
//:: Copyright © 2000 Bioware Corp.
//:://////////////////////////////////////////////
//:: Brings a character back to life with 1 HP.
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Jan 31, 2001
//:://////////////////////////////////////////////
//:: Last Updated By: Preston Watamaniuk, On: April 11, 2001
//:: VFX Pass By: Preston W, On: June 22, 2001

#include "x2_inc_spellhook"

void main()
{

/*
 Spellcast Hook Code
 Added 2003-06-20 by Georg
 If you want to make changes to all spells,
 check x2_inc_spellhook.nss to find out more

*/

   if (!X2PreSpellCastCode())
   {
   // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
       return;
   }

// End of Spell Cast Hook


   //Declare major variables
   object oTarget = GetSpellTargetObject();
   effect eRaise = EffectResurrection();
   effect eVis = EffectVisualEffect(VFX_IMP_RAISE_DEAD);

   //Fire cast spell at event for the specified target
   SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_RAISE_DEAD, FALSE));
   if(GetIsDead(oTarget))
   {
       //Apply raise dead effect and VFX impact
       ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(oTarget));
       ApplyEffectToObject(DURATION_TYPE_INSTANT, eRaise, oTarget);
       //::///////////////////////////////////
       /*
       // * If you use this version...
       // * You can lose a level with spell raisedead/reserection
       int iPCxp=GetXP(oTarget);
       int iXPPenilty=50;
       int nNewXP = iPCxp - iXPPenilty;
       SetXP(oTarget, nNewXP);
       */
       //::///////////////////////////////////
       /*
       // * If you use this version...
       // * This taken from respawn script
       int nXP = GetXP(oTarget);
       int nPenalty = 50;
       int nHD = GetHitDice(oTarget);
       // * You can not lose a level with spell raisedead/reserection
       int nMin = ((nHD * (nHD - 1)) / 2) * 1000;
       int nNewXP = nXP - nPenalty;
       if (nNewXP
       nNewXP = nMin;
       SetXP(oTarget, nNewXP);
       */
       //::///////////////////////////////////
   }
}

reserect script:

//::///////////////////////////////////////////////
//:: [Ressurection]
//:: [NW_S0_Ressurec.nss]
//:: nw_s0_resserec
//:: resserec_core
//:: Copyright © 2000 Bioware Corp.
//:://////////////////////////////////////////////
//:: Brings a character back to life with full
//:: health.
//:: When cast on placeables, you get a default error message.
//::   * You can specify a different message in
//::      X2_L_RESURRECT_SPELL_MSG_RESREF
//::   * You can turn off the message by setting the variable
//::     to -1
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Jan 31, 2001
//:://////////////////////////////////////////////
//:: Last Updated By: Georg Z on 2003-07-31
//:: VFX Pass By: Preston W, On: June 22, 2001

#include "x2_inc_spellhook"

void main()
{

/*
 Spellcast Hook Code
 Added 2003-06-20 by Georg
 If you want to make changes to all spells,
 check x2_inc_spellhook.nss to find out more

*/

   if (!X2PreSpellCastCode())
   {
   // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
       return;
   }

// End of Spell Cast Hook


   //Get the spell target
   object oTarget = GetSpellTargetObject();
   //Check to make sure the target is dead first
   //Fire cast spell at event for the specified target
   if (GetIsObjectValid(oTarget))
   {
       SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_RESURRECTION, FALSE));
       if (GetIsDead(oTarget))
       {
           //Declare major variables
           int nHealed = GetMaxHitPoints(oTarget);
           effect eRaise = EffectResurrection();
           effect eHeal = EffectHeal(nHealed + 10);
           effect eVis = EffectVisualEffect(VFX_IMP_RAISE_DEAD);
           //Apply the heal, raise dead and VFX impact effect
           ApplyEffectToObject(DURATION_TYPE_INSTANT, eRaise, oTarget);
           ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
           ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(oTarget));
       //::///////////////////////////////////
       /*
       // * If you use this version...
       // * You can lose a level with spell raisedead/reserection
       int iPCxp=GetXP(oTarget);
       int iXPPenilty=50;
       int nNewXP = iPCxp - iXPPenilty;
       SetXP(oTarget, nNewXP);
       */
       //::///////////////////////////////////
       /*
       // * If you use this version...
       // * This taken from respawn script
       int nXP = GetXP(oTarget);
       int nPenalty = 50;
       int nHD = GetHitDice(oTarget);
       // * You can not lose a level with spell raisedead/reserection
       int nMin = ((nHD * (nHD - 1)) / 2) * 1000;
       int nNewXP = nXP - nPenalty;
       if (nNewXP
       nNewXP = nMin;
       SetXP(oTarget, nNewXP);
       */
       //::///////////////////////////////////
       }
       else
       {
           if (GetObjectType(oTarget) == OBJECT_TYPE_PLACEABLE)
           {
               int nStrRef = GetLocalInt(oTarget,"X2_L_RESURRECT_SPELL_MSG_RESREF");
               if (nStrRef == 0)
               {
                   nStrRef = 83861;
               }
               if (nStrRef != -1)
               {
                    FloatingTextStrRefOnCreature(nStrRef,OBJECT_SELF);
               }
           }
       }
   }
}

let us know how it went, I just remembered reading about going to a respawn point did you want the spells to do that also? or just when they respawn?
               
               

               


                     Modifié par Greyfort, 16 janvier 2011 - 10:09 .
                     
                  


            

Legacy_Starbridge

  • Jr. Member
  • **
  • Posts: 57
  • Karma: +0/-0
OnDeath / Player Respawn.
« Reply #7 on: January 17, 2011, 01:34:50 am »


               Just on the respawn button.  If you get raised, you should be where you died.
               
               

               
            

Legacy_Starbridge

  • Jr. Member
  • **
  • Posts: 57
  • Karma: +0/-0
OnDeath / Player Respawn.
« Reply #8 on: January 17, 2011, 01:42:29 am »


               

Greyfort wrote...

Here is the edits you must do to the raise dead/reserection spells.  Remember these will over write your orginal versions if you want the original version you only have to add the /* and */ back ware they are now in the script that I posted. to use the 50xp pen choose wich version you want and remove the /* and */ if I missed anything just let me know


*confused*

I'll try it out.
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
OnDeath / Player Respawn.
« Reply #9 on: January 17, 2011, 02:16:14 am »


               ok what you will do is open files :
nw_s0_raisdead
nw_s0_resserec

and replace the script with the script I posted with the same file name.
right now the scripts work like they did. buy removeing the /* and */ in the script you can choose to have a pc loose a level when they are raised or rezed or not loose a level as described in the script.

Example:
//::///////////////////////////////////
/*
// * If you use this version...
// * You can lose a level with spell raisedead/reserection
int iPCxp=GetXP(oTarget);
int iXPPenilty=50;
int nNewXP = iPCxp - iXPPenilty;
SetXP(oTarget, nNewXP);
*/
//::///////////////////////////////////
/*
// * If you use this version...
// * This taken from respawn script
int nXP = GetXP(oTarget);
int nPenalty = 50;
int nHD = GetHitDice(oTarget);
// * You can not lose a level with spell raisedead/reserection
int nMin = ((nHD * (nHD - 1)) / 2) * 1000;
int nNewXP = nXP - nPenalty;
if (nNewXP
nNewXP = nMin;
SetXP(oTarget, nNewXP);
*/
//::///////////////////////////////////
if you delete or backspace the /* and the */ the script above will take away 50xp or what ever xp player has with out player loosing level. if you remove the /*  */ others and leave highlighted in red player will loose 50xp and possibly loose a level

That a better explanation?
               
               

               


                     Modifié par Greyfort, 17 janvier 2011 - 02:20 .
                     
                  


            

Legacy_Starbridge

  • Jr. Member
  • **
  • Posts: 57
  • Karma: +0/-0
OnDeath / Player Respawn.
« Reply #10 on: January 18, 2011, 02:17:36 am »


               //::////////////////////////////////////////////////////////////////////////////
//:: mod_respawnv1
//::////////////////////////////////////////////////////////////////////////////

#include "nw_i0_plot"

//Tag of the waypoint to respawn at:
const string RESPAWN_WP = "RESPAWN_WP";

//XP loss per level"
const int XP_PER_LEVEL = 333;//50;

//% Gold loss:
const float GOLD_LOSS = 100.0;//0.05;

//No penalty if possesses item
const int POSSESS_ITEM = TRUE;

//Tag of above item:
const string ITEM_TAG = "LifeStone";

//::////////////////////////////////////////////////////////////////////////////

// * Applies an XP and GP penalty
// * to the player respawning
void ApplyPenalty(object oDead)
{
   int nXP = GetXP(oDead);
   int nPenalty = XP_PER_LEVEL * GetHitDice(oDead);
   int nHD = GetHitDice(oDead);
   // * You can not lose a level with this respawning
   int nMin = ((nHD * (nHD - 1)) / 2) * 1000;

   int nNewXP = nXP - nPenalty;
   if (nNewXP
      nNewXP = nMin;
   SetXP(oDead, nNewXP);
   int nGoldToTake = FloatToInt(GOLD_LOSS * GetGold(oDead));
   //a cap of 10,000gp taken from you
   if (nGoldToTake > 10000)
   {
       nGoldToTake = 10000;
   }
   AssignCommand(oDead, TakeGoldFromCreature(nGoldToTake, oDead, TRUE));
   DelayCommand(4.0, FloatingTextStrRefOnCreature(58299, oDead, FALSE));
   DelayCommand(4.8, FloatingTextStrRefOnCreature(58300, oDead, FALSE));

}

void main()
{
   object oRespawner = GetLastRespawnButtonPresser();
   ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oRespawner);
   ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oRespawner)), oRespawner);
   RemoveEffects(oRespawner);
   //ApplyPenalty(oRespawner);

   if (POSSESS_ITEM == TRUE)
   {
       if (GetItemPossessedBy(oRespawner, ITEM_TAG) == OBJECT_INVALID)
       ApplyPenalty(oRespawner);
   }
   else ApplyPenalty(oRespawner);

   //Return PC to module respawn point
   object oSpawnPoint = GetWaypointByTag(RESPAWN_WP);

   if (GetIsObjectValid(oSpawnPoint))
   AssignCommand(oRespawner,JumpToObject(oSpawnPoint));

   else
   {
   //do nothing, just 'res where you are.
   }
}

Does not compile right, says line 36 has an error, says incorrect symbol.
Having both you guys giving me posts on the script is confusing the crap out of me.  I'm just a lowly hardware sales man.  Stop being so brainy.  '<img'>  lol

This script does go in respawn slot or on death?

  ?
':blush:'
               
               

               
            

Legacy_Starbridge

  • Jr. Member
  • **
  • Posts: 57
  • Karma: +0/-0
OnDeath / Player Respawn.
« Reply #11 on: January 18, 2011, 02:18:53 am »


               Yes, sometimes I'm semi retarded.  Ok, so most of the time I am, but thats not the point.
               
               

               


                     Modifié par Starbridge, 18 janvier 2011 - 02:32 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
OnDeath / Player Respawn.
« Reply #12 on: January 18, 2011, 02:30:14 am »


               That one gos in the respawn. And somewhere along the way that line got cut. If you look at my first post you will see it the way its supposed to be.

I just figured you could use it cause you can customize it at the top with the constants. One of the things you asked for.

Good luck.
               
               

               
            

Legacy_Starbridge

  • Jr. Member
  • **
  • Posts: 57
  • Karma: +0/-0
OnDeath / Player Respawn.
« Reply #13 on: January 18, 2011, 02:33:37 am »


               Ok.  Thanks.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
OnDeath / Player Respawn.
« Reply #14 on: January 18, 2011, 07:45:10 am »


               Reposting this. Slightly altered and now will destroy the Lifestone.

//::////////////////////////////////////////////////////////////////////////////
//:: me_respawn
//::////////////////////////////////////////////////////////////////////////////

#include "nw_i0_plot"

//Tag of the waypoint to respawn at:
const string RESPAWN_WP = "RESPAWN_WP";

//XP loss per level"
const int XP_PER_LEVEL = 333;

//% Gold loss:
const float GOLD_LOSS = 0.10;

//No penalty if possesses item
const int POSSESS_ITEM = TRUE;

//Tag of above item:
const string ITEM_TAG = "Lifestone";

//::////////////////////////////////////////////////////////////////////////////

//Applies an XP and GP penalty to the player respawning
void ApplyPenalty(object oDead)
{
    int nXP = GetXP(oDead);
    int nPenalty = XP_PER_LEVEL * GetHitDice(oDead);
    int nHD = GetHitDice(oDead);
    int nMin = ((nHD * (nHD - 1)) / 2) * 1000;
    int nNewXP = nXP - nPenalty;
    if (nNewXP < nMin) nNewXP = nMin;
    int nGoldToTake = FloatToInt(GOLD_LOSS * GetGold(oDead));
    //a cap of 10,000gp taken from you
    if (nGoldToTake > 10000)
    {
        nGoldToTake = 10000;
    }

    SetXP(oDead, nNewXP);
    AssignCommand(oDead, TakeGoldFromCreature(nGoldToTake, oDead, TRUE));
    DelayCommand(4.0, FloatingTextStrRefOnCreature(58299, oDead, FALSE));
    DelayCommand(4.8, FloatingTextStrRefOnCreature(58300, oDead, FALSE));
}

void main()
{
    object oRespawner = GetLastRespawnButtonPresser();\\
    object oLifestone = GetItemPossessedBy(oRespawner, ITEM_TAG);
    ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oRespawner);
    ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oRespawner)), oRespawner);
    RemoveEffects(oRespawner);
    //ApplyPenalty(oRespawner);

    if (POSSESS_ITEM == TRUE)
    {
        if (oLifestone != OBJECT_INVALID)
        DestroyObject(oLifestone, 0.1);
        else ApplyPenalty(oRespawner);
    }
    else ApplyPenalty(oRespawner);

    //Return PC to module respawn point
    object oSpawnPoint = GetWaypointByTag(RESPAWN_WP);

    if (GetIsObjectValid(oSpawnPoint))
    AssignCommand(oRespawner,JumpToObject(oSpawnPoint));

    else
    {
    //do nothing, just 'res where you are.
    }
}