Author Topic: A Henchmen Problem  (Read 1484 times)

Legacy_Mephisto Gladius

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
A Henchmen Problem
« on: August 31, 2010, 05:34:14 pm »


               Hello guys...

Well, I have a problem with henchmen in my module. Actually I am trying to build a Mercenary System by my own. Then I found some problems.

1- Somehow the function "RemoveHenchmen" does not work, so the henchmen disappears, but remains in the party dead.

2- I created one Item to make possible to players control when they want their henchs active or not, spawning and destroying their henchs. I suppose my scripts are correct, but there comes the problem. Somehow, when I export the system to my main module, when using this item, the mercenary (henchmen) disappears (when using to deactivate) and one appears dead in the ground!

As you can see, I need some help here. The second problem is not really important right now, I will se what can I do about that....

Any Ideas? 'Posted
               
               

               
            

Legacy_Genisys

  • Hero Member
  • *****
  • Posts: 961
  • Karma: +0/-0
A Henchmen Problem
« Reply #1 on: August 31, 2010, 05:41:43 pm »


               Henchmen, why does that word bring a bad taste to my mouth?

I suppose if this is going to be an online module, you will definitely want to check out a custom system already made on the nwvault.ign.com, seriously...

If it's just for your offline module, than that's another subject entirely different..

To answer your first problem, you can always remove any Plot / Immortal / or other Flags they may have, then kill their inventory, and then kill the Henchmen...

The second problem sounds two part, and I can answer one of them, without looking more indepth at your system, and that involves how they are to appear when they die, this is a setting in the NPC (forget where) basically you set it to be a body bag or what have you, and destroyable etc..

That may solve some of your issues..
               
               

               


                     Modifié par Genisys, 31 août 2010 - 04:47 .
                     
                  


            

Legacy_Mephisto Gladius

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
A Henchmen Problem
« Reply #2 on: August 31, 2010, 05:57:21 pm »


               Well it is an online module. I checked other systems in the nwvault but no one fits my module.

Let me explain better the first question. The henchmen dies, and his body disappears, but he still remains in the party, I don't know how! His status still appears below my character avatar like he were dead... but he's not there!...

PS: Thanks for help in second question. I didn't tested yet, but looks working..

I'm testing here my module and trying to figure out what the hell just happenned there... Your answer about my second question didn't worked, so every time I use the item, the mercenary leaves the party, but appears two dead mercenary's body. And when I spawn him, appears him (in the party, and close to me) and another one, out of the party and dead...

Any Idea?

Well, now looks the script runs three times!
               
               

               


                     Modifié par Mephisto Gladius, 31 août 2010 - 06:30 .
                     
                  


            

Legacy_Xovian

  • Full Member
  • ***
  • Posts: 158
  • Karma: +0/-0
A Henchmen Problem
« Reply #3 on: August 31, 2010, 10:27:03 pm »


               

Mephisto Gladius wrote...

1- Somehow the function "RemoveHenchmen" does not work, so the henchmen disappears, but remains in the party dead.

Sounds like you may not be using the proper includes.
x0_inc_henai is the one you want i believe.
Also bare in mind the remove function would have to happen prior to the "destroy" effect, if they are already destroyed, then they return as an invalid object and won't be removed.

Mephisto Gladius wrote...
2- I created one Item to make possible to players control when they want their henchs active or not, spawning and destroying their henchs. I suppose my scripts are correct, but there comes the problem. Somehow, when I export the system to my main module, when using this item, the mercenary (henchmen) disappears (when using to deactivate) and one appears dead in the ground!

Not sure of the necessity of needing an item to do this sort of thing, but to each their own.
If you're only getting the error when you export, it means one of your scripts are not carrying over.
Perhapse you are using an ExecuteScript(".....", <object>); in one of your scripts, if that's the case, those scripts will not automatically carry over like include files do. Might be something to look at.
               
               

               
            

Legacy_Genisys

  • Hero Member
  • *****
  • Posts: 961
  • Karma: +0/-0
A Henchmen Problem
« Reply #4 on: August 31, 2010, 10:29:44 pm »


               Isn't there something that controls the max # of henchmen you can have?
               
               

               
            

Legacy_Xovian

  • Full Member
  • ***
  • Posts: 158
  • Karma: +0/-0
A Henchmen Problem
« Reply #5 on: August 31, 2010, 10:31:13 pm »


               Yea.
SetMaxHenchman(#); (is placed in the on module load event, or at least I do)

Though if you use default NWN scripts (or conversation files), it doesn't change anything as those have preset limits.
               
               

               


                     Modifié par Xovian, 31 août 2010 - 09:32 .
                     
                  


            

Legacy_Mephisto Gladius

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
A Henchmen Problem
« Reply #6 on: August 31, 2010, 10:47:59 pm »


               I set the maximum of henchmen to 3.



I've fixed the first problem. The second one happens because the script run, somehow, four times! The script send a message over PC head, so I could see it 4 times... something with if conditions?
               
               

               
            

Legacy_Xovian

  • Full Member
  • ***
  • Posts: 158
  • Karma: +0/-0
A Henchmen Problem
« Reply #7 on: August 31, 2010, 11:17:52 pm »


               Should try adding a conditional for the run so it only runs once.

Runs if set at 0, doesn't if set to 1.

Probably be the easiest way to fix it.
               
               

               
            

Legacy_Mephisto Gladius

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
A Henchmen Problem
« Reply #8 on: August 31, 2010, 11:28:21 pm »


               Well, I made it but... Look, my script is somenthing like that:

if (GetLocalInt(oPC, "int_name")==1)

      if (condition that means merc = 3)
      {
      script
      }
      else if (condition that means merc = 2)
      {
      script
      }
      else if (condition that means merc = 1)
      {
      script
      }

else if (GetLocalInt(oPC, "int_name")==0)

then more 3 conditions.. because of 3 mercenaries

return;
Doing like that, storing the mercenaries work as it should be. But restoring them (what should be below the else if condition) doesn't work...
               
               

               


                     Modifié par Mephisto Gladius, 31 août 2010 - 10:30 .
                     
                  


            

Legacy_Redunct

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
A Henchmen Problem
« Reply #9 on: September 01, 2010, 12:06:59 am »


               

Mephisto Gladius wrote...

Well, I made it but... Look, my script is somenthing like that:


if (GetLocalInt(oPC, "int_name")==1)

      if (condition that means merc = 3)
      {
      script
      }
      else if (condition that means merc = 2)
      {
      script
      }
      else if (condition that means merc = 1)
      {
      script
      }

else if (GetLocalInt(oPC, "int_name")==0)

then more 3 conditions.. because of 3 mercenaries

return;
Doing like that, storing the mercenaries work as it should be. But restoring them (what should be below the else if condition) doesn't work...

You're missing a braket.

if (GetLocalInt(oPC, "int_name")==1)
 {
      if (condition that means merc = 3)
      {
      script
      }
      else if (condition that means merc = 2)
      {
      script
      }
      else if (condition that means merc = 1)
      {
      script
      }
}
else if (GetLocalInt(oPC, "int_name")==0)

then more 3 conditions.. because of 3 mercenaries

return;


If that doesn't work, try it this way:

if (GetLocalInt(oPC, "int_name")==1)
 {
      if (condition that means merc = 3)
      {
      script
      }
      else if (condition that means merc = 2)
      {
      script
      }
      else if (condition that means merc = 1)
      {
      script
      }
 return;
    }
if (GetLocalInt(oPC, "int_name")==0)

then more 3 conditions.. because of 3 mercenaries

return;


               
               

               


                     Modifié par Redunct, 31 août 2010 - 11:09 .
                     
                  


            

Legacy_Mephisto Gladius

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
A Henchmen Problem
« Reply #10 on: September 01, 2010, 12:26:42 am »


               

Redunct wrote...

If that doesn't work, try it this way:

if (GetLocalInt(oPC, "int_name")==1)
 {
      if (condition that means merc = 3)
      {
      script
      }
      else if (condition that means merc = 2)
      {
      script
      }
      else if (condition that means merc = 1)
      {
      script
      }
 return;
    }
if (GetLocalInt(oPC, "int_name")==0)

then more 3 conditions.. because of 3 mercenaries

return;



I've tried this one... But didn't worked too... Thanks for helping, but I have the same problem. In the if after the first return; I mean, the second condition of using the item (checking int = 0) doesn't run... But the PC HAVE this variable =0 at this time....

Any more ideas? 'Posted
               
               

               


                     Modifié par Mephisto Gladius, 31 août 2010 - 11:27 .
                     
                  


            

Legacy_Redunct

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
A Henchmen Problem
« Reply #11 on: September 01, 2010, 12:53:52 am »


               The whole script would be helpful.
               
               

               
            

Legacy_Mephisto Gladius

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
A Henchmen Problem
« Reply #12 on: September 01, 2010, 12:58:53 am »


               Sorry, here it is...


void main()
{
object oItem;
object oTarget;
object oPC;
location lTarget;
object oSpawn;
int nInt;
effect eEffect;
oPC = GetItemActivator();
if (GetLocalInt(oPC, "axs_merca")== 1)
   if (GetLocalInt(oPC, "axs_merc")== 3)
      {
   oTarget=GetHenchman(oPC);
   RemoveHenchman(oPC, oTarget);
   eEffect = EffectDeath();
   ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget);
   oTarget=GetHenchman(oPC);
   RemoveHenchman(oPC, oTarget);
   eEffect = EffectDeath();
   ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget);
   oTarget=GetHenchman(oPC);
   RemoveHenchman(oPC, oTarget);
   eEffect = EffectDeath();
   ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget);
   nInt = GetLocalInt(oPC, "axs_merca");
   nInt -= 1;
   SetLocalInt(oPC, "axs_merca", nInt);
   ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(oPC));
   CreateItemOnObject("axs_mercr3", oPC, 1);
   FloatingTextStringOnCreature("Mercenary Stored", oPC);
      }
   else if (GetLocalInt(oPC, "axs_merc")== 2)
      {
   oTarget=GetHenchman(oPC);
   RemoveHenchman(oPC, oTarget);
   eEffect = EffectDeath();
   ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget);
   oTarget=GetHenchman(oPC);
   RemoveHenchman(oPC, oTarget);
   eEffect = EffectDeath();
   ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget);
   nInt = GetLocalInt(oPC, "axs_merca");
   nInt -= 1;
   SetLocalInt(oPC, "axs_merca", nInt);
   ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(oPC));
   FloatingTextStringOnCreature("Mercenary Stored", oPC);
   CreateItemOnObject("axs_mercr2", oPC, 1);
      }
   else if (GetLocalInt(oPC, "axs_merc")==1)
      {
   oTarget=GetHenchman(oPC);
   RemoveHenchman(oPC, oTarget);
   eEffect = EffectDeath();
   ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget);
   nInt = GetLocalInt(oPC, "axs_merca");
   nInt -= 1;
   SetLocalInt(oPC, "axs_merca", nInt);
   ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(oPC));
   FloatingTextStringOnCreature("Mercenary Stored", oPC);
   CreateItemOnObject("axs_mercr1", oPC, 1);
      }
   return;
if (GetLocalInt(oPC, "axs_merca")== 0)
   if (GetItemPossessedBy(oPC, "axs_mercr3")!= OBJECT_INVALID)
      {
      oTarget = oPC;
      lTarget = GetLocation(oTarget);
      oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "mercenario", lTarget);
      oTarget = GetObjectByTag("mercenario");
      AddHenchman(oPC, oTarget);
      oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "mercenario", lTarget);
      oTarget = GetObjectByTag("mercenario");
      AddHenchman(oPC, oTarget);
      oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "mercenario", lTarget);
      oTarget = GetObjectByTag("mercenario");
      AddHenchman(oPC, oTarget);
      nInt = GetLocalInt(oPC, "axs_merca");
      nInt += 1;
      SetLocalInt(oPC, "axs_merca", nInt);
      oItem = GetItemPossessedBy(oPC, "axs_mercr3");
      DestroyObject(oItem);
      ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(oPC));
      FloatingTextStringOnCreature("Mercenary Restored", oPC);
      }
   else if (GetItemPossessedBy(oPC, "axs_mercr2")!= OBJECT_INVALID)
      {
      oTarget = oPC;
      lTarget = GetLocation(oTarget);
      oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "mercenario", lTarget);
      oTarget = GetObjectByTag("mercenario");
      AddHenchman(oPC, oTarget);
      oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "mercenario", lTarget);
      oTarget = GetObjectByTag("mercenario");
      AddHenchman(oPC, oTarget);
      nInt = GetLocalInt(oPC, "axs_merca");
      nInt += 1;
      SetLocalInt(oPC, "axs_merca", nInt);
      oItem = GetItemPossessedBy(oPC, "axs_mercr2");
      DestroyObject(oItem);
      ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(oPC));
      FloatingTextStringOnCreature("Mercenary Restored", oPC);
      }
   else if (GetItemPossessedBy(oPC, "axs_mercr1")!= OBJECT_INVALID)
      {
      oTarget = oPC;
      lTarget = GetLocation(oTarget);
      oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "mercenario", lTarget);
      oTarget = GetObjectByTag("mercenario");
      AddHenchman(oPC, oTarget);
      nInt = GetLocalInt(oPC, "axs_merca");
      nInt += 1;
      SetLocalInt(oPC, "axs_merca", nInt);
      ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(oPC));
      oItem = GetItemPossessedBy(oPC, "axs_mercr1");
      DestroyObject(oItem);
      FloatingTextStringOnCreature("Mercenary Restored", oPC);
      }
   return;
}


               
               

               


                     Modifié par Mephisto Gladius, 31 août 2010 - 11:59 .
                     
                  


            

Legacy_Xovian

  • Full Member
  • ***
  • Posts: 158
  • Karma: +0/-0
A Henchmen Problem
« Reply #13 on: September 01, 2010, 01:11:01 am »


               Just off hand your logic order seems off.

if (GetLocalInt(oPC, "axs_merca")== 1)
   if (GetLocalInt(oPC, "axs_merc")== 3)


Should be something like this:

if (GetLocalInt(oPC, "axs_merca")== 1)
{
  [script to run for the if statment]
  set local integer to 1
}
else if (GetLocalInt(oPC, "axs_merca")== 2)
{
  [script to run for the if statment]
set local integer to 1 (or any number other then 0)
}
else if (GetLocalInt(oPC, "axs_merca")== 3)
{
  [script to run for the if statment]
  set local integer to 1 (or any number other then 0)
}
else
 {
   return; // or whatever else you may desire.
   Set local integer to 0, because it was not meeting the above conditions
   This part can act as a wrap around if needed.
 }


               
               

               


                     Modifié par Xovian, 01 septembre 2010 - 12:13 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
A Henchmen Problem
« Reply #14 on: September 01, 2010, 01:15:52 am »


               Well the very first two line after the definitions are:
if (GetLocalInt(oPC, "axs_merca")== 1)
if (GetLocalInt(oPC, "axs_merc")== 3)

Indicating you want something to occur if int is either 1 or 3, why not just write it as an or instead.
Then next you go to if the int ==2.
Then you go back to 1 again:
else if (GetLocalInt(oPC, "axs_merc")==1)
{
oTarget=GetHenchman(oPC);
RemoveHenchman(oPC, oTarget);
eEffect = EffectDeath();
ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oTarget);
nInt = GetLocalInt(oPC, "axs_merca");
nInt -= 1;
SetLocalInt(oPC, "axs_merca", nInt);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1), GetLocation(oPC));
FloatingTextStringOnCreature("Mercenary Stored", oPC);
CreateItemOnObject("axs_mercr1", oPC, 1);
}
return;
if (GetLocalInt(oPC, "axs_merca")== 0)

and finally to 0, which is not really needed since you could just use and else and do something, since if it's not 1,2, or 3 it's 0. Maybe write it if 0,.. else if 1... else if 2..etc..Sorry that's all I noticed in a quick glance, though I seem to recall a bug with removing dead henchies as you desribe. Are you patched up?

though when I look at it I notice you differentiate merc and merca so it is a different local. Just a bit confusing in that format.
               
               

               


                     Modifié par ffbj, 01 septembre 2010 - 12:19 .