Aller au contenu

Photo

Need Help with Mod Death Scripts


  • Veuillez vous connecter pour répondre
5 réponses à ce sujet

#1
Alupinu

Alupinu
  • Members
  • 528 messages
Hi!
I just realized that I still have not done my PC death for Fanglewood yet. I have been using the default system for ease of testing.
I down loaded the following scripts (by Zheldon) and have been screwing around with them all morning trying to get them to do the following:
1)      Let PC die without showing the respawn button.
2)      Let PC respawn at the end of combat along with any other dead party members.
3)      Have PC respawn with only *one* HP.
4)      In case of party wipe, go to load screen.
I have posted the scripts below in hopes that some kind soul can help me with this. Or if somebody just by chance has the script that does what I stated above that would work too.
 

 /*
 mod_onplayerdeath
*/
const string GUI_DEFAULT_DEATH_SCREEN = "SCREEN_DEATH_DEFAULT";
// Display death pop-up to oPlayer
void ShowDefaultDeathScreen( object oPlayer );
void main()
{
 object oPlayer = GetLastPlayerDied(); 
 DelayCommand( 2.5f, ShowDefaultDeathScreen( oPlayer ) );
}
// Display death pop-up to oPlayer
void ShowDefaultDeathScreen( object oPlayer )
{
 //DisplayGuiScreen( oPlayer, GUI_DEFAULT_DEATH_SCREEN, FALSE );
 DisplayMessageBox( oPlayer, 0, GetStringByStrRef(181408), "gui_death_respawn_self", "", FALSE, "", 6603, "", 0, "" );
}

 

/*
 mod_onplayerrespawn
*/
#include "nw_i0_plot"
#include "ginc_death"
#include "x0_i0_transport"
//::  Applies an XP and GP penalty
//:: to the player respawning
//::  object oDead - Player who died.
void ApplyPenalty(object oDead);
//::  Gets the tag of the destination waypoint
//::  object oDead - Player who died.
string GetDestinationTag(object oDead);
//::  Gets the respawning player
object GetRespawningPlayer();
//::  Gets the respawn point, if any
//::  sDestTag - tag of the destination waypoint
//::  oDead - Player who died
object GetRespawnPoint(string sDestTag, object oDead);
//::  Gets the number of hit points to restore to the player
//::  oRespawner - Player who is respawning
//::  bFull - True restores to full hp, false does not
int  GetHPHealed(object oRespawner, int bFull = TRUE);
void main()
{
 //Create initial variables
    object oRespawner = GetRespawningPlayer();
 object oArea = GetArea(oRespawner);
 string sDestTag = GetDestinationTag(oRespawner);
 object oRespawnPoint = GetRespawnPoint(sDestTag, oRespawner);
 location lDeathSpot = GetLocation(GetLastRespawnButtonPresser());
 location lRespawnPoint;
 int nHPHealed = GetHPHealed(oRespawner, TRUE);
 
 //Apply effects to PC
    ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oRespawner);
    ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(nHPHealed), oRespawner);
    RemoveEffects(oRespawner);
 
 //Apply death penalty
 ApplyPenalty(oRespawner);
 
 //Transport PC
    if (GetIsObjectValid(oRespawnPoint))
    {
  lRespawnPoint = GetLocation(oRespawnPoint);
  TransportToLocation(oRespawner,lRespawnPoint);
    }
 
 //Bring PC back to life
 //DelayCommand(1.5,ResurrectCreature(oRespawner));
 }
 
void ApplyPenalty(object oDead)
{
 location lDeathSpot = GetLocation(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 < nMin)
       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));
}
string GetDestinationTag(object oDead)
{
 //You can go about determining where the respawn waypoint
 //is located a number of ways.  In here I have two examples.
 // Determined by setting a string variable on the area called sRespawn
 // Manually set it.
 string sTag = "";
 object oArea = GetArea(oDead);
 //Get tag based on area level variable
 sTag = GetLocalString(oArea,"sRespawnTag");
 //Check for tag and default to a module level variable
 if(sTag == "")
 {
  sTag = GetLocalString(GetModule(),"sRespawnTag");
 }
 //Manually set tag
 //sTag = "";
 return sTag;
}
object GetRespawningPlayer()
{
 //This should be OBJECT_SELF, however if not then
 //we can use the player that last pressed the respawn
 //button.
 object oPlayer = OBJECT_INVALID;
 oPlayer = OBJECT_SELF;
 //Make sure this is a PC
 if(!GetIsPC(oPlayer))
 {
  oPlayer = GetLastRespawnButtonPresser();
 }
 return oPlayer;
}
object GetRespawnPoint(string sDestTag, object oDead)
{
 //Get the waypoint object by using the destination
 //tag.  First we try for one in the current area by
 //using GetNearestObjectByTag, otherwise we jsut get
 //an object with that tag.
 object oRespawnPoint = OBJECT_INVALID;
 oRespawnPoint = GetNearestObjectByTag(sDestTag,oDead);
 if(!GetIsObjectValid(oRespawnPoint))
 {
  oRespawnPoint = GetWaypointByTag(sDestTag);
 }
 return oRespawnPoint;
}
int GetHPHealed(object oRespawner, int bFull = TRUE)
{
 int nHP = 0;
 if(bFull)
 {
  nHP = GetMaxHitPoints(oRespawner);
 }
 else
 {
  //Set up custom number of HP to heal
  //In this case it is equal to their level.
  nHP = GetHitDice(oRespawner);
 }
 //Make sure it is at least 1 HP
 if(nHP < 1)
 {
  nHP = 1;
 }
 
 return nHP;
}


Thank you.

#2
Morbane

Morbane
  • Members
  • 1 883 messages
Check out the OC - in it you will see some kmod* scripts - they are stored in the campaign folder - I think you can get the results you want with them.

#3
Alupinu

Alupinu
  • Members
  • 528 messages
It’s funny Morbane but I haven’t played the game mods in so long that I had totally forgotten how their death scripts worked. Thank you.

One last question though, I only changed the “On Player Death Script”, do I need to change any of the other scripts like “On player Spawn Script”, ect for everything to work smoothly or is that it?

PS. I hope you get a chance to play Fangle, Morbane, after all you’ve put a lot of work into it. LOL

#4
Morbane

Morbane
  • Members
  • 1 883 messages
The spawn will need to be handled as well since you dont want the party to have the option of respawning in the event of total party death. The kmod scripts are easily tweaked to perform in a custom way if their configuration isnt up to snuff.

#5
kevL

kevL
  • Members
  • 4 078 messages
you shouldn't have to change the onSpawn scripts, but it might be worth noting that when the PC dies uncontrolled its death event uses the companion death script, usually 'gb_comp_death' ( heck, it always uses that script but the condition is different - controlled, uncontrolled )

have a peek at 'nwn2_scriptsets.2da' - it lists the various PC/NPC event scripts (defaults, of some sort). But the main thing you're likely to run up against, with a custom death/wipeout system, is adjusting and integrating your scripts with the Gui windows.


/ and of course module onRespawn doesn't work ... ie, use a callback from the Gui Respawn button

good luck, Alu, if you come up against problems it's probably best to ask them one at a time

#6
Alupinu

Alupinu
  • Members
  • 528 messages
Thanks kevL and Morbane, yes I decided to go with the OC-kmod scripts as Morbane suggested. I went ahead and changed the On Spawn Script just to be safe. TS test show everything working fine. But haven’t had a chance to test them out in-game yet so we shell see.