Skip to content

SetCreatureAppearanceType() Question

ZephiriusZephirius Member Posts: 419
edited February 2022 in Builders - Scripting
Right now, the player is cursed and in the form of a werebear.
How do I Change the appearance back into the PC? I looked for an appropriate constant but didn't find what I was looking for.
DelayCommand(3.0, SetCreatureAppearanceType(oPC, ???));

Comments

  • ProlericProleric Member Posts: 1,316
    The appearance parameter for this function is the line number in appearance.2da.

    Some lines have pre-defined constants APPEARANCE_TYPE_* for legibility.

    Be careful, though. This will change the appearance, but nothing else.

    Typically, the method used to curse the player will store the original appearance and other properties for reference, and provide a reverse function. For example, EffectPolymorph is entirely reversed by removing the effect.
  • ZephiriusZephirius Member Posts: 419
    I've the appearance.2da cracked open but honestly, I'm uncertain what I'm looking for. What for example, would the line contain i.e. "BUGBEAR". Is there a line explicitly referring to the original state of the PC?



  • ForSeriousForSerious Member Posts: 466
    Proleric is right. Before you even change the player into a wereboar, you need to save their appearance somewhere.
  • ZephiriusZephirius Member Posts: 419
    Got it thanks guys.
  • ZephiriusZephirius Member Posts: 419
    OK. I've got it working - sort of.
    I've stored the appearance but when I recall the PC's original state, she comes back headless. Now as far as I know it's original head model and not a custom one...
    void main()
    {
    object oPC = GetPCSpeaker();
    
    object oTarget;
    oTarget = oPC;
    
    effect eEffect;
    eEffect = GetFirstEffect(oTarget);
    while (GetIsEffectValid(eEffect))
       {
       if (GetEffectType(eEffect)==EFFECT_TYPE_CURSE) RemoveEffect(oTarget, eEffect);
       eEffect = GetNextEffect(oTarget);
       effect eRemCurseFX = EffectVisualEffect(VFX_FNF_WAIL_O_BANSHEES);
       ApplyEffectToObject(DURATION_TYPE_INSTANT, eRemCurseFX, oTarget);
    
       int nInt = GetLocalInt(oPC, "start_appearance");
       if (nInt == 1)
       {
       DelayCommand(3.0, SetCreatureAppearanceType(oPC, nInt));
       }
       oTarget = GetObjectByTag("STUFFED_BEAR");
    
       DestroyObject(oTarget, 0.0);
       GiveXPToCreature(oPC, 1000);
       }
    }
    
  • ForSeriousForSerious Member Posts: 466
    I have not looked into it, but I feel like there should be more than just one variable to define the original appearance.
  • ProlericProleric Member Posts: 1,316
    ForSerious wrote: »
    I have not looked into it, but I feel like there should be more than just one variable to define the original appearance.

    Well, there is, behind the scenes. When a part-based creature changes appearance type, the old component parts are still held in the creature object. You can see this if you examine the files in a saved game. Restoring the original appearance (one number) recovers all that stored detail.

    That can have unintended consequences if the wrong part-based appearance number is used. For example, if start_appearance doesn't exist, it will return zero (dwarf iirc) and the head may disappear if not defined for that race.
  • ZephiriusZephirius Member Posts: 419
    edited February 2022
    Oh. Well, I had become so accustomed to using the new head models from Beamdog that I'd literally forgot that I was using them...
    Would that also explain the missing head?
  • ProlericProleric Member Posts: 1,316
    edited February 2022
    I wouldn't have thought that was a problem if you're running EE.

    I notice that if the PC has multiple effects, the appearance is changed multiple times - maybe try doing that just once, outside the effects loop?

    Did you verify that start_appearance is returning the correct value?
  • ZephiriusZephirius Member Posts: 419
    I tried the effects outside of the loop with no luck. I don't know the first thing about debug stuff unfortunately...
  • ZephiriusZephirius Member Posts: 419
    edited February 2022
    Hmmm, I tried a work-around with EffectPolymorph(). Same thing. Returns without a head.

    When I saved the appearance, this is what it looks like. Is this correct?
    void main()
    {
    
     object oPC = GetEnteringObject();
     if (!GetIsPC(oPC)) return;
    
     SetLocalInt(oPC, "start_appearance", 1);
    
  • ProlericProleric Member Posts: 1,316
    The constant 1 is only correct for elf. If human, for example, you will lose your head.

    You need
    SetLocalInt(oPC, "start_appearance", GetAppearanceType(oPC));
    

    then restore with
    SetCreatureAppearanceType(oPC, GetLocalInt(oPC, "start_appearance"));
    
  • ZephiriusZephirius Member Posts: 419
    Proleric, this makes sense now. Gonna give it a try. Thanks as always.
  • ZephiriusZephirius Member Posts: 419
    SUCCESS!
Sign In or Register to comment.