crunchyboy05 Posted August 4, 2007 Share Posted August 4, 2007 hey guys i was wondering if there was a script that would change the name of an NPC. Like in a dialogue, the NPC reveals who they really are and their name changes. I kinda need this for my mod. help please? Link to comment Share on other sites More sharing options...
stoffe Posted August 4, 2007 Share Posted August 4, 2007 hey guys i was wondering if there was a script that would change the name of an NPC. Like in a dialogue, the NPC reveals who they really are and their name changes. I kinda need this for my mod. You can't change the name of an NPC directly, unfortunately. There are two possible workarounds for this though that I can think of: Use two separate templates that look identical but have different names set. When the NPC should "change their name" you destroy the NPC based on the first template and spawn in the NPC based on the second template in the same location and, if needed, copy the values of any local variables set on the first NPC variant to the second one. There may be a brief flicker/fade in/out effect when you destroy the NPC and spawn in the other copy so it won't be entirely seamless. It can be lessened somewhat by having both copies of the NPC in the area already from the start, but the second in a hidden location the player can't see/reach them in. And then just switch locations of the two NPCs when the name change should take place. There would still be a slight flicker, but you wouldn't get any fade-in effect at least. The second method uses just one NPC template, but has the name set to a custom token rather than the name of the NPC directly. If, for example, you set the name of the NPC to <CUSTOM2400> you could then set the apparent name of the NPC being displayed via a script like:First case, set their generic name: void main() { SetCustomToken(2400, "Some Person"); } Second case, set their real name: void main() { SetCustomToken(2400, "John Doe"); } Note the numeric part of the custom token tag, and the corresponding number used as the first parameter in the SetCustomToken() function. If you use this for more than one NPC you'll need to use an unique number for each since tokens are set for a module, not individual objects within it. This will make the game substitute the <CUSTOM2400> tag in the name field with whatever text you have set token 2400 to. As indicated you must set the token to their generic/unknown name initially for them to have a name at all (first script), and then you can change the value of the token (second script) in exactly the same manner whenever you want their displayed name to change. The drawback of this is that custom tokens are set per module, so if it's used on someone that can join the party you must re-set the value of the token when you transition to a new area. For normal non-party NPCs this is not as much a problem though since they're always stuck in the area they where spawned. This works in Kotor2:TSL at least. I haven't tested it in the first game, but I guess it should work there too. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.