Author Topic: Request - Remove Henchmen on Player Death  (Read 318 times)

Legacy_Grieyls

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +0/-0
Request - Remove Henchmen on Player Death
« on: June 02, 2011, 09:13:01 am »


               I'm at a complete loss here I'm trying to make it so when the player dies all the henchmen get removed from his party. I'm running these sripts in the user defined event handle for the module. At this time when the player dies and then respawns the henchmen travel with him. As the player is heading to the nether world it doesn't make much sense that the perfectly well and alive hencman travels with player.

Anyway, I've tried...

    case 001:
        object oPC = GetLastPlayerDied();
        object oHench = GetAssociate(ASSOCIATE_TYPE_HENCHMAN, oPC);
        RemoveHenchman(GetMaster(oPC), oHench);
        break;

and this

    case 001:
        object oPC = GetLastPlayerDied();
        RemoveHenchman(GetMaster(oPC), GetObjectByTag("HENCHTAG"));
        break;

Neither work and I'm guessing I have it SOOOO wrong. Any help would be greatly appreciated.
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Request - Remove Henchmen on Player Death
« Reply #1 on: June 02, 2011, 12:14:15 pm »


               I would use something like this, but I'm also set for max 8 henchmen.

  object oPC = GetLastPlayerDied();
  object oHench = GetFirstFactionMember (oPC, FALSE);

 while (GetIsObjectValid (oHench))
        {
          if (GetAssociateType(oHench) == ASSOCIATE_TYPE_HENCHMAN && GetMaster(oHench) == oPC)
                {
                  RemoveHenchman (oPC, oHench);
                 }
          oHench = GetNextFactionMember (oPC, FALSE);
        }
               
               

               


                     Modifié par Failed.Bard, 02 juin 2011 - 11:15 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Request - Remove Henchmen on Player Death
« Reply #2 on: June 02, 2011, 02:13:49 pm »


               

Grieyls wrote...


        object oPC = GetLastPlayerDied();
        RemoveHenchman(GetMaster(oPC), GetObjectByTag("HENCHTAG"));



Question:  Who is the Master of the PC?  I guess that would be the player!   

   
    case 001:
        object oPC = GetLastPlayerDied();
        object oHench = GetAssociate(ASSOCIATE_TYPE_HENCHMAN, oPC);
        RemoveHenchman(oPC, oHench);
        break;
               
               

               
            

Legacy_Grieyls

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +0/-0
Request - Remove Henchmen on Player Death
« Reply #3 on: June 05, 2011, 07:52:15 pm »


               Failed.Bard, I can't get yours to work... It doesn't seem to do a thing so I'm not sure what is wrong there. Would be great if I could get it to work though as my module has a max of two henchmen so removing them both at once would be handy.

Lightfoot8, thanks for pointing my rather glaring error out.. I feel so silly now. Anyway your suggestion works fine. thing is though only one henchman is removed so still trying to figure out how to remove two of them.
               
               

               


                     Modifié par Grieyls, 05 juin 2011 - 06:53 .
                     
                  


            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Request - Remove Henchmen on Player Death
« Reply #4 on: June 05, 2011, 08:51:25 pm »


               I'd just compiled it to make sure there weren't any logic errors, and it looked right. I'm not actually sure why it doesn't work either, but now I'll have to play around with it for my own benefit to see what I did wrong.
In testing, adding a while loop to your initial (master fixed) script worked for me for multiple henchmen, though I didn't try it from within a case statement.

object oPC = GetLastPlayerDied();
object oHench = GetAssociate(ASSOCIATE_TYPE_HENCHMAN, oPC);
while (GetIsObjectValid (oHench))
{
RemoveHenchman (oPC, oHench);
oHench = GetAssociate(ASSOCIATE_TYPE_HENCHMAN, oPC);
}



Edit:

I figured out what was wrong with mine.  A silly mistake on my part, really.  Trying to remove the henchmen while it's still going through them doesn't work.  Adding a delay to the remove henchman part worked for me.
               
               

               


                     Modifié par Failed.Bard, 05 juin 2011 - 08:13 .
                     
                  


            

Legacy_Grieyls

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +0/-0
Request - Remove Henchmen on Player Death
« Reply #5 on: June 05, 2011, 10:29:11 pm »


               That did the trick Failed.Bard... Thank you so much 'Image
               
               

               


                     Modifié par Grieyls, 05 juin 2011 - 09:29 .