Hi there!
I want to make a Game character which changes his appearance several times in the game,
e.g. unarmored, battle gear, tournament gear, monk's robe, etc.
My first idea was to use multiple characters. Then I realized that I always have to check for the current character in the script, have to meddle with the Inventories whenever I change etc.
I know how to do it the way described above. But since QFG 4 1/2 does similar things with the cloaks, I hope there is an easier way to achieve my goal....
SetCharacterView(EGO,5); //will set character 'EGO' to view 5
you can use this to set all the characters views
just remember "ReleaseCharacterView(EGO);" will return the character to its original view, if it needs to return to a different view just use the SetCharacterView again
It goes in the script where you want it to change.
Note: it's probably a good idea to keep track of which view you are in using global ints, as you may only be able to interact with certain objects/hotspots in a certain view, or if you run an animation that can occur in different views.
eg. If you press a button when you have armor on, the animation might use the characters normal view for pressing the button, instead of the armor view. (note: you'd have to make a view that contains the animation in each of the characters costumes)
eg2.
SetGlobalInt(10,0); //unarmored (set to this when he/she returns to normal view)
SetGlobalInt(10,1); //battle gear (set to this when he/she is set to battle gear view)
SetGlobalInt(10,2); // tournament gear
SetGlobalInt(10,3); //monk's robe
etc
Hope that helps
~Tim
Thanks a lot! ;D
Using ChangeCharacterView, SetCharacterSpeech and maybe SetCharacterIdle might do the job better, since then the character could be able to walkalk in the right appearance for sure...
You may want to reconsider using multiple characters. You can use the GetPlayerCharacter() function to return the player character ID in place of a constant such as EGO. So, for example you would do this:
character[GetPlayerCharacter()].room = 42;
instead of this:
character[EGO].room = 42;
RickJ, what you suggest is just what I used to do.
As I said, it works, but the greatest problem is the inventory.
Multiple characters each have their own inventory, which means I have to use a global array to keep track of the inventory and update each character's inventory every time I change. This, however, is more difficult and error-prone than using just diferent views.
ChangeCharacterView is the easiest solution for this problem, and is in fact designed for this very scenario.
I hadn't thought about the inventory. Good point.
Cool, I wasn't aware of ChangeCharacterView, I've been using the method I mentioned and never thought of looking for any other solution, and I've never noticed anyone mentioning it before.
I guess it's one of those things that I'll see being mentioned all the time now.
It'll save a little bit of scripting from now on, thanks Tk and CJ, It's those little things you pick up all the time that can help save time in the future.
I've forgotten the command like that before. :-) that's why we're here. All of us miss a command, occasionally.