Author Sticky: Post Working Scripts Here
jamos Posted: Tuesday, 25 June 04:13PM
Script for modifying respawn to work on custom maps

this just modifies the existing onrespawn script
to take out the gold penalty:

NWScript:
// * Applies an XP and GP penalty

// * to the player respawning

void 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 < nMin)

       nNewXP = nMin;

    SetXP(oDead, nNewXP);

    // remarked out gold penalty

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

//Remarked out lost gold message

//DelayCommand(4.8, FloatingTextStrRefOnCreature( 58300,  oDead, FALSE));

}



this is where i added some code to allow a penalty on the respawn. the else was already in the default script.
it also allows the respawner to respawn at a waypoint instead of where he or she died. it is at the end of the respawn event:

NWScript:
else

    {

         ApplyPenalty( oRespawner);

         sDestTag = "way_one";

         object oSpawnPoint = GetObjectByTag( sDestTag);

         AssignCommand( oRespawner, JumpToLocation(GetLocation( oSpawnPoint)));

        // * do nothing, just 'res where you are.

    }

 }




Lastly i modified the on death script to change the pop up gui panel to the popupguideath panel. i can control the time delay before the window pops up, whether to display the respawn button, whether to display the wait for help button, 0 for not using a predifined text message, and the text that is displayed. (notice i took out the lose gold message). This is put in the end of the ondeath event...notice the default message is remarked out.

NWScript:
DelayCommand(2.5, PopUpDeathGUIPanel(oPlayer, TRUE, TRUE, 0, "If You Respawn You Will Lose Some Experience!"));

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