Aller au contenu

Photo

Belt of polymorph does not work if the player saves the game.(RESOLVED)


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

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I have a belt in my mod that changes the player into a succubus.  It works fine and when the player removes the belt, the appearance is restored, unless the player saves the game and then re-loads.  If the player saves while wearing the belt, on re-loading, the player will retain the form of the succubus upon removing the belt. 

I save the appearance on the creature that equips the belt as nAppearance. 


Here is the code for the on equip event:

void main ()
{
//Do not apply the SEF to the user because it comes back on re-loads
//even if you have removed the belt.
object oTarget = GetPCItemLastEquippedBy();
int nAppearance = GetAppearanceType(oTarget);
effect eEffect = EffectNWN2SpecialEffectFile("sp_skin_ice_twa2");
eEffect = ExtraordinaryEffect(eEffect);
eEffect = SupernaturalEffect (eEffect);
SetCreatureAppearanceType(oTarget,APPEARANCE_TYPE_SUCCUBUS);
SetLocalInt(oTarget,"nAppearance",nAppearance);
//ApplyEffectToObject(DURATION_TYPE_PERMANENT,eEffect,oTarget);
}





Here is the code for the unequip event




void main ()
{
object oTarget = GetPCItemLastUnequippedBy();
object oEffectCreator;
int nAppearance = GetLocalInt(oTarget,"nAppearance");
effect eEffect = GetFirstEffect(oTarget);
string sTag;
SetCreatureAppearanceType(oTarget,nAppearance);

while (GetIsEffectValid(eEffect))
 {
 oEffectCreator = GetEffectCreator(eEffect);
 sTag = GetTag(oEffectCreator);
 if (sTag =="belt_of_morphing")
  {
  RemoveEffect(oTarget,eEffect);
  eEffect = GetFirstEffect(oTarget);
  }
  
 else
  {
  eEffect = GetNextEffect(oTarget);
  }
 }

RemoveSEFFromObject(oTarget,"sp_skin_ice_twa2");
}
 
 
 

Modifié par M. Rieder, 30 janvier 2012 - 12:56 .


#2
kamal_

kamal_
  • Members
  • 5 259 messages
Put in a bit of code to tell you what nAppearance is before you run the SetCreatureAppearance line in the unequip. It will tell you if you're not removing the appearance, or the appearance is being set to succubus because the int is the succubus value somehow.

Also, I'd put the
int nAppearance = GetAppearanceType(oTarget);
SetLocalInt(oTarget,"nAppearance",nAppearance);
lines together in the onEquip event, it makes for easier reading of the progression of what you want to do with the script, and guarantees something weird won't happen with the integer in the bits between the lines.You can do the same for the similar lines getting the int and setting the appearance in the Unequip.

#3
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
Set the characters appearance when it's not found with your variable, to the appearance defined in racialsubtypes.2da. Then in the module load, if the belt is not present, or on the unload, you can set the correct appearance. ( sometimes in rare cases it might miss the unequip ). Only in rare cases ( ie a player sets their appearance to something off the wall such as a skeleton )

return StringToInt( Get2DAString("racialsubtypes", "AppearanceIndex", GetSubRace(oPC) ) );

Modifié par painofdungeoneternal, 30 janvier 2012 - 12:36 .


#4
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
That did it pain, thanks.