Author Topic: How To?: Henchman repawn system like KOTOR  (Read 562 times)

Legacy_Dylan RPG

  • Newbie
  • *
  • Posts: 24
  • Karma: +0/-0
How To?: Henchman repawn system like KOTOR
« on: February 11, 2011, 04:46:14 am »


               KOTOR isn't the only example of course, this was done in KOTOR II, NWN 2, Dragon Age, etc..

I'd like to make a death/respawn system where

(A)When the PC dies, the player is NOT given the chance to respawn, only to load a previous saved game or exit.

AND

(B)When the henchman dies, the henchman stays dead until the battle is over or the PC dies. If the battle ends and the PC is still alive, I want the henchman to get back up (at low or full health, doesn't matter).

I've done a search on these topics, many searches actually, and can't find an answer to ('B)'. I have found an answer to (A), just want to clear up the kind of death system I'm going for. If you don't want to post a suggestion to (A), that's fine, but ('B)' is the head-scratcher for me.

This community has always been extremely helpful, and I am as always grateful for any input. I do apologize if this touches on problems with well documented solutions. If so, please just point me in that direction. '<img'>
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
How To?: Henchman repawn system like KOTOR
« Reply #1 on: February 11, 2011, 08:08:17 am »


               First thing that comes to mind. You could do something like this with all the area heartbeats. How you do it depends on whether or not this is a single or multiplayer module. Having a heartbeat in all of your areas that loops through players and then loops through faction members of each of the players can/will proabably cause some lag.

Could also put a recursive script on all of your players that gives each player a fake heartbeat to check if the player is NOT in combat and if any of their followers are dead...then heal/raise them.

But yeah just let us know if it is sigle or multi player and if you don't mind a little lag and I can put up some examples of how these might work.

Hope this helps get things rolling for ya.
               
               

               


                     Modifié par GhostOfGod, 11 février 2011 - 08:09 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How To?: Henchman repawn system like KOTOR
« Reply #2 on: February 11, 2011, 08:30:10 pm »


               Sounds like a modification to the henchmans heart beat would work to me.   First make the henchman to where he can not be distroyed.  First   SetIsDestroyable(FALSE)  onspawn to make sure he does not fade out of the picture.   Then  Add a check  to the begining of the OnHeartBeat  to Check if he is dead and if the PC is out of combat,   If he is raise him.  
               
               

               
            

Legacy_Dylan RPG

  • Newbie
  • *
  • Posts: 24
  • Karma: +0/-0
How To?: Henchman repawn system like KOTOR
« Reply #3 on: February 11, 2011, 08:44:14 pm »


               Thanks for the quick replies as always. Ghost, it's a single-player module.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How To?: Henchman repawn system like KOTOR
« Reply #4 on: February 11, 2011, 11:28:51 pm »


               I think the way Shadowlords 1 - The Message (v 1.20) handles there henchman is what you have asked for.
               
               

               
            

Legacy_Balduvard

  • Full Member
  • ***
  • Posts: 126
  • Karma: +0/-0
How To?: Henchman repawn system like KOTOR
« Reply #5 on: February 12, 2011, 05:20:11 am »


               A) This is handled by modifying the OnPlayerDeath script in module events (default nw_o0_death). I did this for a module where I wanted to use autosaves as a checkpoint system to provide challenge. This is the modification I made at the end of the script (commenting out the default command):


    //DelayCommand(2.5, PopUpGUIPanel(oPlayer,GUI_PANEL_PLAYER_DEATH));
    DelayCommand(2.0, PopUpDeathGUIPanel(oPlayer,FALSE,TRUE, 0, "You have died. If no one is able to save you, you must load your latest save."));

You'll want to change the last TRUE to FALSE and modify the popup message if intending to have the only options to load or exit.

'B)' In the interest of operating efficiency, you could alternatively use a pseudoheartbeat (DelayCommand loop) to perform the out of combat check, such that this check is not running constantly even when you're not in combat. The pseudoheartbeat would be triggered by the henchman's OnDeath, and persist until it was no longer necessary.
               
               

               
            

Legacy_Dylan RPG

  • Newbie
  • *
  • Posts: 24
  • Karma: +0/-0
How To?: Henchman repawn system like KOTOR
« Reply #6 on: February 12, 2011, 11:10:09 pm »


               Lightfoot and Balduvard, thank you for the suggestions. I'm very much new to scripting--could you give me an example of what those scripts might look like?
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
How To?: Henchman repawn system like KOTOR
« Reply #7 on: February 15, 2011, 04:26:27 am »


               I'm not very familiar with henchmen so hopefully this will at least steer you in the right direction.

Using the info that Lightfoot and Balduvard suggested, you would first add a line to the bottom of your henchman's OnSpawn script:

void main()
{
    blah blah
    blah blah
    blah blah

    SetIsDestroyable(FALSE, TRUE, TRUE);
}


Then you would makes its OnDeath script look like so:

void IfSafeHeal(object oSelf)
{
    object oMaster = GetMaster(oSelf);

    if (!GetIsInCombat(oMaster))
    {
        int iHP = GetMaxHitPoints(oSelf);
        effect eHeal = EffectHeal(iHP);
        AssignCommand(GetModule(), ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oSelf));
        return;
    }

    DelayCommand(6.0, IfSafeHeal(oSelf));
}

void main()
{
    IfSafeHeal(OBJECT_SELF);
}


Something like that anyway. I haven't tested this though. There may be other things you need to include like an execute script line for the default henchman death script or just execute the script above from the default henchman death script. I'm not 100%certain but hopefully this gets things working for you or steers things in the right direction.

Good luck.
               
               

               


                     Modifié par GhostOfGod, 15 février 2011 - 04:27 .
                     
                  


            

Legacy_Snarkblat

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
How To?: Henchman repawn system like KOTOR
« Reply #8 on: June 24, 2011, 09:42:02 pm »


               This is the script you're looking for, from Adam Miller's Shadowlords 1. All credit goes to Adam. Modify as you need.

The henchman will die in combat, and resurrect a few seconds later. Like above posters said, you can add a conditional so they only do so at the end of combat.


#include "nw_i0_generic"
#include "nw_i0_plot"


void BringBack()
{
   string sReturn = "";
   if(GetTag(OBJECT_SELF) == "Nooble")
     sReturn = "I'm not dead yet!";
   if(GetTag(OBJECT_SELF) == "Teira")
     sReturn = "Well, there goes one of my nine lives.";
   if(GetTag(OBJECT_SELF) == "Anera")
     sReturn = "By Kelemvor's faith, I return.";

   SetLocalObject(OBJECT_SELF,"NW_L_FORMERMASTER", GetMaster());
   // : REMINDER: The delay is here   for a reason
   DelayCommand(0.1, RemoveEffects(OBJECT_SELF));
   DelayCommand(30.2, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectResurrection(), OBJECT_SELF));
   DelayCommand(30.3, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectHeal(GetMaxHitPoints(OBJECT_SELF)), OBJECT_SELF));
   DelayCommand(31.0, AssignCommand(OBJECT_SELF, ActionSpeakString(sReturn)));
//    AssignCommand(OBJECT_SELF, ActionWait(30.0));
//    DelayCommand(31.0, FloatingTextStringOnCreature(sReturn, OBJECT_SELF));
   DelayCommand(35.1, SetIsDestroyable(TRUE, TRUE, TRUE));

}

void main()
{

   object oMe = GetAssociate(ASSOCIATE_TYPE_HENCHMAN, GetMaster());
   if (oMe == OBJECT_SELF
       // * this is to prevent 'double hits' from stopping
       // * the henchmen from moving to the temple of tyr
       // * I.e., henchmen dies 'twice', once after leaving  your party
       || GetLocalInt(OBJECT_SELF, "NW_L_HEN_I_DIED") == TRUE)
   {
      SetPlotFlag(oMe, TRUE);
      SetAssociateState(NW_ASC_IS_BUSY, TRUE);
      AddJournalQuestEntry("Henchmen", 99, GetMaster(), FALSE, FALSE, FALSE);
      SetIsDestroyable(FALSE, TRUE, TRUE);
      SetLocalInt(OBJECT_SELF, "NW_L_HEN_I_DIED", TRUE);
       ClearAllActions();
       DelayCommand(0.5, ActionDoCommand(SetCommandable(TRUE)));
       DelayCommand(5.0, ActionDoCommand(SetAssociateState(NW_ASC_IS_BUSY, FALSE)));

       DelayCommand(5.0, SetPlotFlag(oMe, FALSE));

       BringBack();
       SetCommandable(FALSE);


   }
   else
   {
     BringBack();
   }
}
               
               

               


                     Modifié par Snarkblat, 24 juin 2011 - 09:24 .
                     
                  


            

Legacy_Snarkblat

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
How To?: Henchman repawn system like KOTOR
« Reply #9 on: June 24, 2011, 10:27:02 pm »


               Okay... I did what Ghost of God had suggested and added an IF statement so the henchman would only resurrect when the PC was no longer in combat. It works well when I DM kill the henchman, they pop right back up and rejoin a few moments later.

Edit: Ah... nevermind. I need to add a check to the heartbeat script. ':whistle:'
               
               

               


                     Modifié par Snarkblat, 24 juin 2011 - 10:13 .
                     
                  


            

Legacy_Snarkblat

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
How To?: Henchman repawn system like KOTOR
« Reply #10 on: June 24, 2011, 11:27:34 pm »


               I added a conditional to the Henchman heartbeat which should fire a resurrect script if the I_DIED variable is true, and the PC is also not in combat. However, they remain dead. Forever. What am I doing wrong? The resurrection script is the same as the one above and it works fine when using a delay, instead of the PC combat conditional.

//Heartbeat
if (GetLocalInt(OBJECT_SELF, "NW_L_HEN_I_DIED")== 1)
  { if (!GetIsInCombat(oPC))
     {
     ExecuteScript("hen_resurrect", OBJECT_SELF); return;
     }
  }
               
               

               
            

Legacy_Snarkblat

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
How To?: Henchman repawn system like KOTOR
« Reply #11 on: June 25, 2011, 05:16:37 pm »


               I tried adding a module heartbeat that cycles through dead henchmen and revives them to no avail. I think it's the combat conditional that's causing me trouble. It's the same as the one above if anyone cares to comment. I'd really appreciate some advice.

Tomi Undergallows' mother awaits your response with baited breath. She's still devestated over the loss of her son.
               
               

               


                     Modifié par Snarkblat, 25 juin 2011 - 04:17 .