Author Topic: Help improving a death/respawn script  (Read 450 times)

Legacy_Rowwena

  • Jr. Member
  • **
  • Posts: 62
  • Karma: +0/-0
Help improving a death/respawn script
« on: July 06, 2011, 05:20:21 am »


               Hi,

I am looking for some help improving this script I created. It was inspired by my many years playing EQ. The script is called from a conversation (in this case the temple cleric) that allows the PC to "bind" themself to the new location - while destroying previously placed "Death Temple" waypoints.  The script works fine so far, but as it is set up, you need to place a waypoint in the temple where the new Death Temple WP will be spawned. The problem being that to avoid problems, each temple would need a different named waypoint - and thus a different script. Any suggestions on how to set it to work so I can use the same script at every temple?

Here is the full script that includes the extra bells and whistles (visual effects etc)

//Death Temple Soul Binder
//Allows PC to Choose a specific temple where she/he will respawn
//and remove any previously placed death temple waypoints.
//Base Script compiled by Lilac Soul's NWN Script Generator, v. 2.3
//Modified by Rowwena

//Script is called on from a conversation.

//What you will need is
// 1)An NPC to have the conversation with, obviously.
// 2)Create a new "NW_DEATH_TEMPLE" waypoint with an easy to remember
//ResRef id as you will need to spawn it using the ResRef and not the tag.
// 3) A waypoint to place in the temple where the new "NW_DEATH_TEMPLE"
//waypoint will be spawned, along with any visual effect you desire.

//The first part of this script destroys any existing "NW_DEATH_TEMPLE"
//waypoints in the module, so you will only have one.

void main()
{

object oPC = GetPCSpeaker();

object oTarget;
oTarget = GetWaypointByTag("NW_DEATH_TEMPLE");

DestroyObject(oTarget, 0.0);

//The second part places the new "NW_DEATH_TEMPLE" waypoint at the location of
//another preplaced waypoint in the temple. I added some FX visuals but they
//are obviously just for show and not necessary.

oTarget = oPC;

int nInt;
nInt = GetObjectType(oTarget);

effect eEffect;
eEffect = EffectVisualEffect(VFX_FNF_STRIKE_HOLY);

if (nInt != OBJECT_TYPE_WAYPOINT)
   DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget));
else
   DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eEffect, GetLocation(oTarget)));

object oSpawn;
location lTarget;
oTarget = GetWaypointByTag("temple1wp_1");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_WAYPOINT, "deathtemple_wp", lTarget);
oTarget = oSpawn;

nInt = GetObjectType(oTarget);

if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(2.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_STRIKE_HOLY), oTarget));
else DelayCommand(2.0, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_STRIKE_HOLY), GetLocation(oTarget)));

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "respawnportal", lTarget);

}
               
               

               
            

Legacy__Knightmare_

  • Full Member
  • ***
  • Posts: 191
  • Karma: +0/-0
Help improving a death/respawn script
« Reply #1 on: July 06, 2011, 12:31:16 pm »


               Why not spawn the new WP at the PC's location? They are at an appropriate spot in order to have your convo in the first place right?
               
               

               


                     Modifié par _Knightmare_, 06 juillet 2011 - 11:31 .
                     
                  


            

Legacy_Rowwena

  • Jr. Member
  • **
  • Posts: 62
  • Karma: +0/-0
Help improving a death/respawn script
« Reply #2 on: July 07, 2011, 08:10:04 am »


               That was my original model. I just wanted something a bit more flashy '<img'> and the ability to decide exactly where in the temple respawn occurs (like in the holy pool).

 I had wanted a script that could also spawn in a new Portal and eliminate the old one, but it was just too buggy. I finally gave up (for now) and reworked it again, deciding to just to place a portal as the spot where the new WP is spawned.
               
               

               
            

Legacy__Knightmare_

  • Full Member
  • ***
  • Posts: 191
  • Karma: +0/-0
Help improving a death/respawn script
« Reply #3 on: July 07, 2011, 12:30:35 pm »


               If you want a specific spot for them to spawn, change the line:

oTarget = GetWaypointByTag("temple1wp_1");

To:

oTarget = GetNearestObjectByTag("temple1wp_1");

Then in each area that you want the player to be able to designate a new respawn point, place down a waypoint tagged "temple1wp_1". Now you will be able to reuse the same script for each area as well as the same waypoint tag. The script will only then look for the one that is closest to the PC at the time the script is fired, which should be the one that is in the area the PC is currently standing in, providing you only have a single waypoint of that same tag per respawn area..
               
               

               
            

Legacy_Tonden_Ockay

  • Hero Member
  • *****
  • Posts: 891
  • Karma: +0/-0
Help improving a death/respawn script
« Reply #4 on: August 09, 2015, 01:19:19 pm »


               

Are there more scripts to this or is this just one script does it all?


 


I tried putting this one script on a conversation but it didn't work for me.


 


 


I'm using HCR death script which sends players to waypoint XX. Is there a way to use these together. Player could bind at a Church or Gave stone and then when they died it would take them to their last bind point.


 


 


 


Wait better yet is there a way to add a line to the HCR scripts to respawn player at the closest waypoint XX. then I would have to mess with bind points.



               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Help improving a death/respawn script
« Reply #5 on: August 09, 2015, 09:02:05 pm »


               

Holy thread necromancy, Batman!


 


Which version of HCR are you using? If it's HRC2, go into Module Properties and check the string variables named with OnPlayerRespawnX (where X is a number). Find the one respawning players at the static waypoint and swap it out with a dynamic one.


 


There's lots of different scripts on the Vault that might have what you're looking for.



               
               

               
            

Legacy_Tonden_Ockay

  • Hero Member
  • *****
  • Posts: 891
  • Karma: +0/-0
Help improving a death/respawn script
« Reply #6 on: August 09, 2015, 09:39:57 pm »


               

I am using this HCR system



/*
Filename:           h2_fuguedeath_i
System:             FuguePlayerDeath (include script)
Author:             Edward Beck (0100010)
Date Created:       Mar. 25, 2006
Summary:
HCR2 h2_fuguedeath system function definition file.
This script is consumed by the FuguePlayerDeath hook-in scripts as an include file.

Revision Info should only be included for post-release revisions.
-----------------
Revision Date: Sept 11th, 2006
Revision Author: Edward Beck (0100010)
Revision Summary: v1.3
Edited H2_FUGUE_PLANE const value to accurately reflect altered tag of the area.

*/

#include "h2_core_i"

const string H2_FUGUE_PLANE = "h2_fugueplane";
const string H2_WP_FUGUE = "H2_FUGUE";

void h2_SendPlayerToFugue(object oPC)
{
    object oFugueWP = GetObjectByTag(H2_WP_FUGUE);
    SendMessageToPC(oPC, H2_TEXT_YOU_HAVE_DIED);
    ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oPC);
    ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(GetMaxHitPoints(oPC)), oPC);
    h2_RemoveEffects(oPC);
    ClearAllActions();
    AssignCommand(oPC, JumpToObject(oFugueWP));
}



/*
Filename:           h2_fuguedeathopd
System:             FuguePlayerDeath (player death hook-in script)
Author:             Edward Beck (0100010)
Date Created:       Mar. 25, 2006
Summary:

This script should be called via ExecuteScript from the
RunModuleEventScripts(H2_EVENT_ON_PLAYER_DEATH, oPC) function that is called from h2_playerdeath_e.

To make this script execute, a string variable, named OnPlayerDeathX where X is a number that
indicates the order in which you want this player death script to execute.
Ir should be assigned the value "h2_fuguedeathopd" under the variables section of Module properties.

Variables available to all event hook player death scripts:

GetLocalLocation(GetLastPlayerDied(), H2_LOCATION_LAST_DIED);  returns the location the player last died.

You should not overwrite the above variables, or they will not remain consistant
for any other executing player death script which might rely on them.

Revision Info should only be included for post-release revisions.
-----------------
Revision Date: Jun 30th, 2006
Revision Author: Edward Beck (0100010)
Revision Summary: v1.2
Added check to verify the player state is dead before script will continue.

*/
#include "h2_fuguedeath_i"

void main()
{
    object oPC = GetLastPlayerDied();

    //if some other death subsystem set the player state back to alive before this one, no need to continue
    if (h2_GetPlayerPersistentInt(oPC, H2_PLAYER_STATE) != H2_PLAYER_STATE_DEAD)
        return;

    if (GetTag(GetArea(oPC)) == H2_FUGUE_PLANE)
    {
        ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oPC);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(GetMaxHitPoints(oPC)), oPC);
        return;
    }
    else
    {
        h2_DropAllHenchmen(oPC);
        h2_SendPlayerToFugue(oPC);
    }
}



/*
Filename:           h2_fuguedeathopy
System:             FuguePlayerDeath (player dying hook-in script)
Author:             Edward Beck (0100010)
Date Created:       Mar. 25, 2006
Summary:

This script should be called via ExecuteScript from the
RunModuleEventScripts(H2_EVENT_ON_PLAYER_DYING, oPC) function that is called from h2_playerdying_e.

To make this script execute, a string variable, named OnPlayerDyingX where X is a number that indicates
the order in which you want this player dying script to execute.
It should be assigned the value "h2_fuguedeathopy" under the variables section of Module properties.

Revision Info should only be included for post-release revisions.
-----------------
Revision Date:
Revision Author:
Revision Summary:

*/
#include "h2_fuguedeath_i"

void main()
{
    object oPC = GetLastPlayerDying();
    if (GetTag(GetArea(oPC)) == H2_FUGUE_PLANE)
    {
        ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oPC);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(GetMaxHitPoints(oPC)), oPC);
        return;
    }
}

               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Help improving a death/respawn script
« Reply #7 on: August 09, 2015, 09:42:17 pm »


               

Yeah, that's the one I linked to. Check the variables on your module. Any behavior taken on respawn is happening because the module variables are telling it to.



               
               

               
            

Legacy_Tonden_Ockay

  • Hero Member
  • *****
  • Posts: 891
  • Karma: +0/-0
Help improving a death/respawn script
« Reply #8 on: August 09, 2015, 09:56:29 pm »


               

Here is my module Variables


 


358urvb.jpg



               
               

               
            

Legacy_Tonden_Ockay

  • Hero Member
  • *****
  • Posts: 891
  • Karma: +0/-0
Help improving a death/respawn script
« Reply #9 on: August 09, 2015, 09:58:59 pm »


               

I would like it so if there is City A, B, and C that when a player died they would respawn at the closest city to where they died.



               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Help improving a death/respawn script
« Reply #10 on: August 09, 2015, 10:53:56 pm »


               

Ah, I see. You're using the Fugue subsystem. This bypasses the standard respawn system by rezzing the PC and sending them to the fugue plane's waypoint. You have two options:


  1. Remove the fugue subsystem and replace the OnPlayerRespawn1 variable with the name of a script that will handle your respawning.

  2.    
  3. Use a placeable or conversation inside the fugue plane to send your player back to the waypoint of your choosing.

You should check the various death systems on the vault and see which one most closely fits your needs.