I am trying to use this script to respawn at a temple or even the start location:
/*******************************
Script: Respawn At Start Location
Created By: Jaden Wagener
Created On: 08/30/02
*******************************/
//Respawns a player back at the start location.
//Script should be placed in the module's OnRespawn slot.
//NOTE: due to the current bug issue with the GetStartLocation function,
//a waypoint must be created at the starting location and its tag inserted
//in place of NW_WAYPOINT001.
#include "nw_i0_plot"
//Uses some in game default scripts
void main()
{
//Set variables
object xPC;
int xHP;
location xStart;
effect xRez, xHeal, xVisual, xBad;
//Populate variables
xPC = GetLastRespawnButtonPresser(); //Player respawning
xHP = GetMaxHitPoints(xPC); //Player's Max HP
xStart = GetLocation(GetWaypointByTag("NW_WAYPOINT001")); //Start location
xRez = EffectResurrection(); //Resurrect effect
xHeal = EffectHeal(xHP); //Heal effect
//Resurrect at start location
ApplyEffectToObject(DURATION_TYPE_INSTANT,xRez,xPC,0.0f);
ApplyEffectToObject(DURATION_TYPE_INSTANT,xHeal,xPC,0.0f);
RemoveEffects(xPC); //Removes Negative effects. Is defined in nw_i0_plot.
AssignCommand(xPC,ActionJumpToLocation(xStart));
}
However the character only respawns where he died. I have placed it in my module OnRespawn script.
What am I doing wrong?
Respawn script not working
Débuté par
twcheney
, févr. 03 2011 05:31
#1
Posté 03 février 2011 - 05:31
#2
Posté 03 février 2011 - 06:45
1)I don't think 'GetWaypointByTag' works, use 'GetObjectByTag' instead.
2)It would make a lot more sense to give your waypoint some other tag than the default "NW_WAYPOINT001".
3)It's also good practice to name your variables after the type of variable they are, i.e. drop the 'x' and instead use oPC, iHP, lStart, eRez, and eHeal. Your brain will hurt less, I promise you.
4)I don't think 'GetLastRespawnButtonPresser' works either. In a single-player module, you can just use GetFirstPC instead.
2)It would make a lot more sense to give your waypoint some other tag than the default "NW_WAYPOINT001".
3)It's also good practice to name your variables after the type of variable they are, i.e. drop the 'x' and instead use oPC, iHP, lStart, eRez, and eHeal. Your brain will hurt less, I promise you.
4)I don't think 'GetLastRespawnButtonPresser' works either. In a single-player module, you can just use GetFirstPC instead.
#3
Posté 03 février 2011 - 07:08
Lugaid of the Red Stripes wrote...
1)I don't think 'GetWaypointByTag' works, use 'GetObjectByTag' instead.
2)It would make a lot more sense to give your waypoint some other tag than the default "NW_WAYPOINT001".
3)It's also good practice to name your variables after the type of variable they are, i.e. drop the 'x' and instead use oPC, iHP, lStart, eRez, and eHeal. Your brain will hurt less, I promise you.
4)I don't think 'GetLastRespawnButtonPresser' works either. In a single-player module, you can just use GetFirstPC instead.
I definitely agree with #2 and #3 (don't know anything about #4) but I'm pretty sure #1 isn't true. Strangely, GetWaypointByTag seems to be a duplicate function given the presence of GetObjectByTagAndType (which isn't mentioned in the Broken Functions List but I seem to recall there were problems with it anyway).
As LotRS implies, you definitely need to test this piece-by-piece. Is the PC object found? Use this to tell you if it's not:
if (!GetIsObjectValid(oPC) {
SendMessageToPC(GetFirstPC(), "No valid respawner");
return;
}Is the waypoint valid? You can use a simple script to test it that you then just run from the console with the "rs" command:
void main()
{
object oPC = GetFirstPC();
object oWP = GetWaypointByTag("waypoint_name");
AssignCommand(oPC, ActionJumpToLocation(GetLocation(oWP));
}My suspicion is that you might need to put in a delay for the jump action after respawning. Use DelayCommand.
#4
Posté 03 février 2011 - 11:13
MasterChanger is right - you won't be able to jump the player while they are still technically dead. Try delaying ActionJumpToLocation by 0.1 seconds, so that the player has been fully revived first.





Retour en haut






