Aller au contenu

Photo

A Henchmen Problem


  • Veuillez vous connecter pour répondre
36 réponses à ce sujet

#26
Redunct

Redunct
  • Members
  • 49 messages

Mephisto Gladius wrote...

Again, I got the same error. Script still firing 3 times...


How about...


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);
      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);
    return; 
    }
   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);
      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);
   return;
     }
   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);
      }

}
}


Modifié par Redunct, 01 septembre 2010 - 01:57 .


#27
Mephisto Gladius

Mephisto Gladius
  • Members
  • 20 messages
I can't believe it... Didn't work again... There's one thing wrong in your scripts.. Check when axs_merca = 0.. When oPC have the item axs_merc3, will spawn 3 mercenaries, when pc have the item axs_merc2, will be 2, etc.. But nevermind that now, we have to fix this strange problem..

#28
Redunct

Redunct
  • Members
  • 49 messages
What's calling the script?

#29
Mephisto Gladius

Mephisto Gladius
  • Members
  • 20 messages
The player uses one item to store the mercenary, as you can see in the script... So, the action of using the "UniquePowerSelf" on the item, calls one script with its tag, named "axs_mercreg". This one calls the "OnActivated" wich is ac_axs_mercreg, that is giving us problems...

Should I post "axs_mercreg"?

Modifié par Mephisto Gladius, 01 septembre 2010 - 02:10 .


#30
Redunct

Redunct
  • Members
  • 49 messages
Please do so.


#31
Mephisto Gladius

Mephisto Gladius
  • Members
  • 20 messages
Following Lilac Soul's Script Generator instructions it should look like this:

#include "x2_inc_switches"
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
switch (nEvent)
{
case X2_ITEM_EVENT_ACTIVATE:
ExecuteScript("ac_"+GetTag(GetItemActivated()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_EQUIP:
ExecuteScript("eq_"+GetTag(GetPCItemLastEquipped()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_UNEQUIP:
ExecuteScript("ue_"+GetTag(GetPCItemLastUnequipped())
, OBJECT_SELF); break;
case X2_ITEM_EVENT_ACQUIRE:
ExecuteScript("aq_"+GetTag(GetModuleItemAcquired()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_UNACQUIRE:
ExecuteScript("ua_"+GetTag(GetModuleItemLost()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_SPELLCAST_AT:
ExecuteScript("sp_"+GetTag(GetModuleItemLost()),
OBJECT_SELF); break;
case X2_ITEM_EVENT_ONHITCAST:
ExecuteScript("on_"+GetTag(GetSpellCastItem()),
OBJECT_SELF); break;
}
}

Modifié par Mephisto Gladius, 01 septembre 2010 - 02:14 .


#32
Redunct

Redunct
  • Members
  • 49 messages
I'm not seeing what's causing it. You're not executing the script anywhere else, are you? If not, then I'm stumped.


#33
Mephisto Gladius

Mephisto Gladius
  • Members
  • 20 messages
No. The only way to execute this script is by acrivating the item. There's nothing about him in the mercenary's death script or anywhere...

#34
Redunct

Redunct
  • Members
  • 49 messages
Well, we can see if it's that's the problem by changing the name of the script and executing it straight from the onitemactivate.


In onItemActivate of the Module Properties:

if (GetTag(oItem)=="axs_mercreg")
{
executescript("//NEWSCRIPTNAME",OBJECT_SELF);
}


Modifié par Redunct, 01 septembre 2010 - 02:37 .


#35
Mephisto Gladius

Mephisto Gladius
  • Members
  • 20 messages
Okay, now instead of the script executing 3 times.. It doesn't execute!

I'm starting to hate those henchmen...Posted Image

Well... Tomorrow I will face this nightmare again..

Modifié par Mephisto Gladius, 01 septembre 2010 - 02:55 .


#36
Redunct

Redunct
  • Members
  • 49 messages
We can try this:

if (GetTag(oItem)=="axs_mercreg")

{

executescript("//NEWSCRIPTNAME",oItem);

}



#37
Mephisto Gladius

Mephisto Gladius
  • Members
  • 20 messages
It didn't worked again.. But wait, I think I found the problem... This may be at my OnItemActivate script... I'll check it..

Edit: All the time, the problem was with the OnItemActivate Script! I've fixed it, and now my Mercenary System is working! Thanks for the help guys Posted Image

Modifié par Mephisto Gladius, 01 septembre 2010 - 06:27 .