Author Topic: Player Respawn!  (Read 368 times)

Legacy_Omega27

  • Sr. Member
  • ****
  • Posts: 255
  • Karma: +0/-0
Player Respawn!
« on: February 06, 2014, 07:06:52 am »


                Ok i know neverwinter is kinda not the place to be building major story mods and all so im really hoping someone can help me remedy this brain fart.

I've recently went back into my previous project that i had started. 

In this project im using CEP, the latest version of NWN and expansion, my game version is Diamond so i have all that extra jazzy stuff. 
(To the Point(

I've had it done before but somehow my mods are wacked and the script and stuff for this is missing.

Im trying to create a custom Respawn location for the player and it's henchmen for when the player dies. Rather than having a NWN death temple single location. i want to have (In a set area) a specific spot (Ex: Far Left Corner ) of an area the player respawns at.

So for a bigger ex:

Final  boss, player and hechmen team is fighting, player goes down first, the default death GUI pops up, player clicks "Respawn", now rather then spawn back in a temple of some sort, or at the exact same spot they died at. I want to set a specefic location that. If the player dies in this area, respawn at set waypoint.

this is the only thing that delaying the re-release of my projects '<img'>(
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Player Respawn!
« Reply #1 on: February 06, 2014, 07:24:22 am »


               Are you using the vanilla OnPlayerRespawn script (nw_o0_respawn)? If so, this functionality is already built into the script. Just add a waypoint tagged "WP_BOSS_RESPAWN" where you want the PC to respawn and add the following between lines 150 and 151:

else if (sArea == "TagOfFinalBossArea")
{
    sDestTag = "WP_BOSS_RESPAWN";
}

               
               

               


                     Modifié par Squatting Monk, 06 février 2014 - 07:24 .
                     
                  


            

Legacy_Omega27

  • Sr. Member
  • ****
  • Posts: 255
  • Karma: +0/-0
Player Respawn!
« Reply #2 on: February 06, 2014, 07:27:24 am »


               Thanks i knew it was something i just forgot the steps and order. I couldnt get it on google either -.-
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Player Respawn!
« Reply #3 on: February 06, 2014, 07:53:03 am »


               There are a couple different things that you can do that come mind.

You can place an object in each area that you want the player to respawn at and then make a custom OnPlayerRespawn script that checks for that object in each area and spawns the player to that object.

You could also set a couple of float variables directly on each area that will point to the exact x, y coordinates that you want for the respawn location. Then in your OnPlayerRespawn script you would just retrieve those floats and build the location for them to respawn at. I'd actually prefer this second method.

You could also use the function GetAreaSize to get the width and height to figure out where you want the location to be.

Using the second method you would just load the area in the toolset, then go to Edit, Area Properties, Advanced, Variables and add 2 floats. One for X and one for Y. Call them whatever...RESPAWN_X, RESPAWN_Y.

Then in your OnPlayerSpawn script do something like so:

void main()
{
    object oRespawner = GetLastRespawnButtonPresser();
    //string sDestTag = "NW_DEATH_TEMPLE";
    //object oSpawnPoint = GetWaypointByTag(sDestTag);
    object oArea = GetArea(oRespawner);
    float fAreaX = GetLocalFloat(oArea, "RESPAWN_X");
    float fAreaY = GetLocalFloat(oArea, "RESPAWN_Y");
    vector vRespawn = Vector(fAreaX, fAreaY, 0.0);
    location lJump = Location(oArea, vRespawn, 0.0);

    ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oRespawner);
    ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oRespawner)), oRespawner);
    RemoveEffects(oRespawner);

    if (GetLocalInt(GetModule(), "RESPAWN_PENALTY") == TRUE)
    ApplyPenalty(oRespawner);

    //if (GetIsObjectValid(oSpawnPoint))
    //AssignCommand(oRespawner,JumpToObject(oSpawnPoint));
    AssignCommand(oRespawner, JumpToLocation(lJump));
}

Only other thing you might want to do is put a check in to make sure there are float variables set for these specific coordinates and if not then go ahead and jump to temple or what not. Hope this helps.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Player Respawn!
« Reply #4 on: February 06, 2014, 07:54:10 am »


               Errr...or just do what Monk said. '<img'>