Change portrait through scripting?

Just wanted to check with you all if this is possible. I had an idea where one of the companions changes looks (haircut in this case, by using a “haircut helmet”), and it would have been cool if one could change the portrait. My guess is this is not possible, but I thought I could at least ask.

At first glance, I can’t see any way it could be done through script, but that’s not to say the more advanced scripters amongst us can’t figure out a way :slight_smile:

Last resort, perhaps a quick switch of the old NPC for the new one?

I guess I could just spawn in a new character with the new portrait, but that will cause all sorts of problems, I’m afraid. Since this was just something to add for fun, and my module soon being finished for beta testing, I’m afraid that I would need a new tag for the character, which will mess with all conversations. Certain scripts (I think) sometimes use resref and template (even though I’ve never quite fully understood the difference of resource name, tag and template resref). The only thing I think I know is that you can have a blueprint of a character with a certain template resref and then change tag if you put this character into the world, thus be able to create several from the same template.

If I could spawn in a “new character” with the same tag then that might work, but I’m a bit afraid with the buggy NWN2, that it will cause unforseen problems.
Maybe I could do a copy of the character, which I did with @travus’ help in my third module, but that behaved somewhat weirdly in a scene afterwards. And copying a character wouldn’t help me change the portrait in this case, since I would need (I think) to have a different blueprint with the new portrait for this to work…

Naturally I don’t know the full in’s and out’s of your work, but would SetTag solve any issues if you were to create a new copy of the NPC? I don’t see any problems, if it is the only object carrying the tag.

I don’t know. I don’t think so. The only thing I think of that could maybe solve it, but I’m afraid that would create bugs, is if I made a new blueprint with a new resref but with the same tag, then destroy the first character and spawn in the new one that had the same tag. That still wouldn’t solve it because all items and everything like xp I would need to transfer to the new spawned character. The function CopyObject that I used in my third module won’t do much either, since that won’t change the portrait, which is what I really want.

So, a new copy of the companion, like you suggested, would still have the same portrait.

Ok, perhaps a more economical solution…

If you are supporting the custom portrait system featured here… Tchos' HD UI panels and dialogue compilation and expansion at Neverwinter 2 Nexus - mods and community

Perhaps nudge the player towards an updated version of the companion there. Depends how much immersion you want to break :slight_smile:

1 Like

resource name - filename of the resource on the harddrive, used w/ CreateObject()

template resref - related to resource name, a resource ‘inherits’ properties from an object (usually itself). This is used only by special apps and toolset commands that can make global changes to your resources.

tag - good ol’ tag is just an identifier ingame.

So specifying different tags is ok – SetTag() or CreateObject() allows a tag to be changed

 
but i don’t know of an easy way to change a portrait :\

2 Likes

If you’re really using a helmet, make sure its properties are set to “never show hair” (or something along these lines), and the portrait will be automatically updated (if you’re talking about the one shown by default on the upper right corner).

2 Likes

@4760 - As you may well be aware, I only use custom portraits on all my characters, so that’s not a solution sadly, I’m afraid.

I used a “hair-helmet” in ASW2, so I know how to apply this, but thank you for reminding me.

Yes, I use this. I have the NWN1 big style portraits which I very much enjoy.

Yeah, I could nudge the player but…well, it is quite immersion breaking. Maybe I’ll have to give up on this. I can’t come up with a solution sadly.

@andgalf

Funny enough, I was looking at this as well this week as part of a customization update for players. I managed to allow a player to add backgrounds to their PCs, including companions so far (during play and if not chosen at creation), but portraits is a bit more awkward … probably not easily achievable if at all.

However, from your description, it sounds like you are trying this for an NPC rather than a PC? If that is the case, then at first glance, I don’t see why spawning a new NPC (with the same tag - but different resref) should be an issue, depending on exactly what is going to happen moving forward with this NPC.

For instance, if this NPC is going to “replace” the older version, then you should be able to destroy the old copy and keep the new version with the same tag. Or, even if they have a new tag, is the point at which they arrive known … to allow scripting with the new tag? Caveat: I have never tried this, so maybe you are aware of some issues I am not, which I would be interested to learn if so.

Messing with the XML for player characters though looked a bit heavy/messy with how it updates other areas, but I have yet to explore this possibility any further yet. I did “fix” the portrait chooser to be more user-friendly, but I was also hoping to find a way to redirect the link to the campaign folder rather than the portrait folder. But. as I say, I’m not sure I will dig much deeper.

I am assuming your “character” is a potential companion perhaps? i.e. An NPC until either picked up by the player or given to the player by you?

PS: I note that you and I are the only two who voted for “building NWN2” mods. :slight_smile:

1 Like

This character is a companion. She is already in the party. My thought was to have a silly thing, similar to what you can do in The Witcher 3, where you go to a hairdresser and she cuts her hair. To illustrate that, I wanted to also change her portrait.
At this stage in the module there is quite a bit of free roam, so this can happen (a bit) at any time. I need the companion to have the same tag since there are a lot of conversations where this tag is used, and also scripts and triggers.

The problems I see are:

  1. You need, so that the player won’t go berserk, to copy this character with all its inventory and everything. Or, maybe one could do as I do later in the module, strip her of all her items, and somehow transfer to the new one. But, this will cause annoyance with the player having to level up her from the beginning again to get to where she’s at at this point in the adventure. So there’s quite a lot of hazzle for this tiny litte “quest”.
  2. Since you need to copy the character, you can’t just spawn in a new one with the new portrait.

I have just played through my module and there are only tiny bugs (apart from two CTD, just like in my previous module) and it is approximately 9 hours long. I don’t know if I need this thing, but I always like these silly kind of things. Story and characters and dialogue always comes first to me. I couldn’t care less about stats and weapons and armor and game rules, although that is always a big part of these kind of games.

1 Like

@andgalf

Yes, I understand your position now, as you have a conflict with these two points: I mean the type of player who does like to take time to level up the PC is normally the same type who has some interest in their stats and kit. But, as the builder, you may have to take a stance and let the player know. (I mean I do recall testing one of your previous games and there were “stat” issues where one could not develop the PC as normal. At that time you pointed out to me that was how your games worked.) Your players may be confused unless they understand your position.

So, you could simply continue to stress this about your modules and just go with the new spawn and leave it to the player to redevelop (from added XP) … or, you can use the function to re-level the PC automatically, but this may not reflect what the player would have done.

However, there are some (perhaps) alternative ideas … (untested) …

  1. Have a prepared “haircut” version already in the world in an inaccessible area with currently a different TAG and its own ResRef. When required, copy all items from original to haircut, destroy original. SetTag of haircut to original. Jump and auto-level (or allow player to level) on arrival. This preserves all items, but does impact potential stats due to different choices … Although, maybe the haircut version is reassessing her life, and asks the player to help here develop? (Role-play the change in stats.) … or explains some of the stats differences if auto-levelled. (*)

(*) Sell the point that with a new haircut comes some life changes. :wink:

  1. ADDENDUM ALTERNATIVE STAT ADVICE: As you or the player update the original PC, do the changes to the “Haircut” version at the same time via scripting. i.e. Keep all level or stat changes the same for both versions as they are made. That should solve your stat issue. We have plenty of functions to ensure we can d that sort of thing, from adding levels, adding and removing feats and skills, even changing ability scores.

  2. Approach your issue from the other direction. (A bit more prep work, but simplifies the change-over.) Basically, add a NEW “or” TAG to all those conditions where the original was being checked to now also check for the new tag of the haircut version. Without knowing exactly how and where this tag is checked makes it hard to tell just how significant step this would require from you as to whether it was worth it or not … or even possible in every situation.

Like anything like this, you may have some loops (and scripting) to go through, but with some time and attention and beta-testing, I think it should be possible. Personally, I would go with option 1 with its addendum at this stage of thinking.

1 Like

This way would be the best way I think, but it’s still WAY too much work for this little tiny thing. If I could just switch the portrait by scripting, then I would have included this “quest”, but not now that my whole module is essentially finished, I would be going over A LOT of scripts and things to make just this work. Bottom line, I’ll skip this for now. If I were to do a new module where I had this in mind from the beginning, then it would be a totally different thing.

It’s really sad that these things, these tiny things, that I really want in the game, just as I want new and better animations for every-day things, isn’t included in the game. It really mostly just is a focus on fighting and leveling all the time, and that doesn’t interest me that much. It’s like when I read some document from a guy (don’t remember who now) who thought he was going to be able to do different facial expressions and all that, and noticed the game didn’t support that at all, even though when looking at the dialogue tree and the list of animations, it seems that way, was really devastated.
This is one of the reasons why I never played the Storm of Zehir expansion, or Infinite Dungeons expansion for NWN1. Those things just doesn’t appeal for me when it’s mostly about action, getting loot, leveling up your character and fight. One module series that really managed to get close to what I’m after in these types of games is Daniel Miller’s Dark Waters (if I remember the title and the name of the author correctly) that had new great mini games, good story and voice acting. Really neat stuff.
And, of course, MotB was really good in this aspect. Heavy emphasis on story and characters and role play.
Ok, enough rambling, this has nothing to do with changing portraits through scripting. It is obvious that can’t be done in NWN2, otherwise you guys that have been around the module making for a long time would have known about it.

EDIT: Maybe one could break the fourth wall by asking the player: “Now go to your override folder and put the tga file that was in this folder that you downloaded there, and then come back to the game and continue playing”. Whould actually have been pretty funny, but probably emmersion breaking as heck. :slightly_smiling_face: It’s actually pretty close to what @MERP_UK suggested.

2 Likes

The more I think about it, perhaps this wouldn’t be that bad. If I had a portrait that you put in your portrait folder, or maybe it could be in the hak as all the other portraits, and it had a name like “aaaaaaa.tga” maybe it would be first in the list of portraits, and you could suggest to the player to switch the portrait if he or she likes, because it now looks more like the character with the new haircut.

2 Likes

@andgalf

Ah! I can’t resist it … I think I am going to play around with the “portrait_change.xml” and see if I can come up with something that forces the portrait change.

It’s something I want for players to be able to do from my own included portraits to save them having to do the work of downloading … and I may have other reasons … and now I know someone else (you) may also make use of it, it seems an appropriate time to investigate it.

Don’t worry, I know you are happy with your mod as it currently stands, but if I get it working, you can decide if it is something you will use or not. :slight_smile:

I will update this post with any progress reports …

@Lance_Botelle - Interesting. Yeah, maybe something can be done through xml coding (this confusing stuff that I’ll never be able to master).

After I decided to try my simple route, there was another problem. I can’t find another haircut that fits the character. LOL! I’m extremely picky when it comes to this stuff, and I know absolutely nothing of 3D modelling, and I can’t put more stuff on 4760, 'cause I feel like he’s drowning in stuff that I’ve requested of him. It’s better that I let him finish what he’s working on the moment. I’ve found two haircuts that are almost what I want, but I would really like to tinker with them. Stuff like “this haircut is a bit too high” or “I want to remove those three strands of hair to make it fit better”. Sigh…I really should just let this go, I think.

@andgalf

That’s the trouble when we cannot stop tinkering with the stuff … I guess we want things perfect in our own ways … You with images and stuff like that, me with code … :slight_smile:

I will keep you updated … I am beginning to think there may be just some way to do this, but XML is not easy for me either.

:sweat_smile: Don’t worry about that, only one week before I go on holidays!

If you’re talking about hair162 and hair236, I can make this happen :wink:
I thought we’d try with resizing head155 and head169 first though.

1 Like

As far as portrait changes in NWN1 was concerned, I believe you had to employ NWNX to make that happen. NWN2 does have a similar extension, but I have no experience using it. Maybe it could be done, but it depends how much time you want to sink into this. You say it was something of an indulgence for immersion purposes, so I suppose you just have to weigh it up.

Back to portrait changer that I mentioned before, which I think is the best option in this situation. Giving it the top position in the changer screen would be helpful. Immersion is clearly important to you, and you don’t want to alienate players who feel the same way. There will be other players who value other parts of the experience. So a low-key message in the chat/action log would be a good middle ground. “New portrait available for xyz”. Simple and not too intrusive.

1 Like