PDA

View Full Version : Disguise Script


Mandalore_The_Great
02-17-2009, 08:01 PM
I found a script called qa_setanim and it says it's a disguise script

void main()
{
int nX = GetRunScriptVar();
effect eDisguise = EffectDisguise(nX);
ClearAllEffects();
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDisguise, GetFirstPC());
}


What do I replace to make this into a working disguise script? I'm guessing it would be a line in appearance.2da or the tag, but I'm not sure where to put all the info

Star Admiral
02-17-2009, 10:03 PM
This script is designed to change the PC's appearance. As it stands, it should work just fine. Where to put it depends on what you want to do with it. You can attach it to a dialog to change the PC's appearance at the end of the conversation, for example. There's no need to edit the appearance.2da file; I doubt it even has a column for scripts.

- Star Admiral

Mandalore_The_Great
02-18-2009, 07:57 PM
when I use it as is my game crashes

Silveredge9
02-18-2009, 08:12 PM
You could try something like this:

void main()
{
effect eDisguise = EffectDisguise(APPEARANCE.2DA LINE NUMBER GOES HERE);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDisguise, GetFirstPC());
}

To clear the effect, you could use the "ClearAllEffects();" function.

Mandalore_The_Great
02-18-2009, 08:17 PM
Oh... I think I understand what some of this stuff actually means. effect eDisguise=... is telling the script what to do when eDisguise is mentioned in another line... then the second line is activating the eDisguise specified in the first line. for some reason I never saw it that way

Edit: well thanks, it works. Kind of odd that script didn't work, though

Star Admiral
02-18-2009, 09:09 PM
I believe that it didn't work because of the lines:

int nX = GetRunScriptVar();
effect eDisguise = EffectDisguise(nX);

If you attached the script to a dialog file, but did not pass in any variables from the dialog, the script would not know which appearance to change the main character to. That might have crashed the game.

- Star Admiral

Mandalore_The_Great
02-20-2009, 08:06 PM
pass in any variables?

Star Admiral
02-20-2009, 09:16 PM
The neat thing about the dialog file in TSL is that it allows you to pass in up to 4 numbers and 1 string when executing a script, allowing the same script to be used multiple times, depending on what was passed in. K1, unfortunately, lacked this ability.

- Star Admiral

glovemaster
02-21-2009, 05:16 AM
I had tried using GetRunScriptVar() with little success, it always seemed to return 2001 no matter what. The alternative that I used was a LocalNumber, setting the number in the first script and getting it again in the second.

stoffe
02-21-2009, 07:40 AM
I had tried using GetRunScriptVar() with little success, it always seemed to return 2001 no matter what.

The GetRunScriptVar() function is not used to get dialog parameters as was stated above. It's used in conjunction with with ExecuteScript() function. This function takes 3 parameters; the name of the script to run, an object reference to the object that should run the script (OBJECT_SELF inside the script), and an optional numeric parameter. This number you pass as the third parameter to ExecuteScript() can then be retrieved inside that script by using the GetRunScriptVar() function.


(A wild guess as to why you'd get 2001 is that if you call the GetRunScriptVar() function inside a script that you haven't run with the ExecuteScript() function it will return the parameter from the last script that was run via that method, which in your case presumably would be the general AI script, k_ai_master, which will run a party member heartbeat script if passed 2001 as parameter, which happens for each active party member roughly every 3 seconds.)

glovemaster
02-21-2009, 07:51 AM
:lol: Sorry that wasn't a very clear post, I was using ExecuteScript() though despite passing numbers like 300 or just 1, in the executed script GetRunScriptVar() just returned 2001. IIRC The NWscript mentions something about it being used for debugging?

stoffe
02-21-2009, 07:56 AM
:lol: Sorry that wasn't a very clear post, I was using ExecuteScript() though despite passing numbers like 300 or just 1, in the executed script GetRunScriptVar() just returned 2001. IIRC The NWscript mentions something about it being used for debugging?

It works as intended, otherwise the general AI that runs every creature in the game would be utterly broken. All the specific AI scripts set on the event trigger hooks on creatures do little other than ExecuteScript() the k_ai_master script, passing it a numeric parameter to tell it what to do (2001 = run party member heartbeat script, for example, as mentioned above). This applies to both games.

I've used it in several mods I've made as well with the intended results. :)

Mandalore_The_Great
02-21-2009, 02:03 PM
Wow... I have no idea what you guys are talking about. I like scripting but I'm not good with the lingo
thanks for the help, Silveredge9. Works fine. Is there a resource somewhere that has lists of these sort of things besides NWscript.nss? to me, it doesn't give enough information on how to use the functions and how to write it. scripting is somewhat over my head

Star Admiral
02-21-2009, 03:03 PM
Whoops, got the GetRunScriptVar() mixed with GetScriptParameter() :migraine:. Sorry about that, and thanks for correcting me.

Regarding other sites where you can find some explanations of how to use the script functions, you could try the NWN Lexicon here (http://nwn1.nwn2lexicon.com/). Although it was written for NeverWinter Nights, most of it applies to KOTOR as well.

- Star Admiral

Mandalore_The_Great
02-21-2009, 08:26 PM
Thanks SA, helps a lot. Now I know what all that mess means....
just a random question, but when using CastFakeSpellAt-whatever, does it use the animation as well as the sparkles and shimmer? Or would I need to specify that before the void main()?

Star Admiral
02-21-2009, 09:30 PM
Not 100% sure, as I've never used this function before, but judging from its description, only the casting animations specified for the spell in the spells.2da file will be used. The actual script for the spell will be ignored. So no, you don't need to specify the animations before.

Correct me if I'm wrong.

- Star Admiral

Mandalore_The_Great
02-22-2009, 09:27 PM
More scripting woes....
void main()
{
object oPC=GetPCSpeaker();
ActionPauseConversation();

//Make it seem like I'm casting the
//spell in line 15 of spells.2da
ActionCastFakeSpellAtObject(15, oPC);

//Apply a couple of visual effects to the PC
int nDur=DURATION_TYPE_INSTANT;
effect e1=EffectVisualEffect(3010);
effect e2=EffectVisualEffect(3016);
effect e3=EffectVisualEffect(1018);

ActionDoCommand(ApplyEffectToObject(nDur, e2, oPC));
ActionDoCommand(ApplyEffectToObject(nDur, e1, oPC));
ActionDoCommand(ApplyEffectToObject(nDur, e3, oPC));
ActionResumeConversation();
}


I've tried this script in two different conversations(one with and one without the ActionPause/ResumeConversation() ) and neither worked. Ideas?

Star Admiral
02-23-2009, 12:05 AM
Not sure how needed the ActionPauseConversation() is, as I've never used it before. Do you want your character to fake cast a power at a target, or do you want the target to fake cast a power at your character? The ActionDoCommand() looks suspicious to me.

- Star Admiral

Mandalore_The_Great
02-23-2009, 09:05 PM
well, I made it so that whoever's talking to the PC casts it. This was originally an example from the downloadable version of the NWN Lexicon that I edited a little to add in an extra effect.
I used the ActionPauseConversation() to give it a cinematic effect.