Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Stunning an NPC via Script

Page: 1 of 1
 Fallen Guardian
12-21-2011, 3:42 PM
#1
So, in KotOR 1 &2 in combat you'll sometimes get a lucky hit with a critical strike or a certain upgrade and your enemy will be stunned for a few rounds of combat? How would I make an enemy be stunned by a script in KotOR 1, rather than combat?
 JCarter426
12-21-2011, 10:57 PM
#2
It would look something like this:

ApplyEffectToObject(2, EffectStunned(), oTarget, 0.0);

To unstun them:

AssignCommand(oTarget, ClearAllEffects());

I don't know if this would work in cutscenes; there appears to be another function in the code, but there is a lot of stuff that either doesn't work or is redundant in the code, so that might not mean anything.
 Fallen Guardian
12-22-2011, 12:29 AM
#3
Well, it's not for use in a cutscene so I shouldn't have a problem there (at least for now). When it states: ApplyEffectToObject(2, What does the 2 represent?

Thanks for the script by the way.
 JCarter426
12-22-2011, 12:42 AM
#4
The 2 represents the duration type. 0 = instantaneous (like death), 1 = temporary (like stun if you want to set a specific length, which you would do by changing the 0.0 to a length), 2 = permanent (stays on until you clear the effect).
 Fallen Guardian
12-22-2011, 1:17 AM
#5
Alright, that makes sense. Thanks again for the script!

EDIT: Is there a way to set a conditional to check if an NPC is stunned? Say if I wanted to start a conversation after 5 NPC's are stunned, what would I do?
 JCarter426
12-22-2011, 3:16 AM
#6
Hmm... I think the easiest thing would be to set a local boolean at the same time you trigger the stun. It would go something like:

SetLocalBoolean(oTarget, 21, TRUE);

21 is the boolean number - anything between 20 and 63 should be safe.

And then for the script to check whether all of of the NPCs have been stunned, something like:

if(
GetLocalBoolean(oTarget1, 21) &&
GetLocalBoolean(oTarget2, 21) &&
GetLocalBoolean(oTarget3, 21) &&
GetLocalBoolean(oTarget4, 21) &&
GetLocalBoolean(oTarget5, 21) ) {
return TRUE;
}

else return FALSE;

There's probably a more elegant way to do it, but that should get the job done. And of course if you wanted to be able to do this more than once, you'd have to set all the booleans back to false afterwards.
 Fallen Guardian
12-22-2011, 3:27 AM
#7
Thanks for your help.
 JCarter426
12-22-2011, 3:47 AM
#8
No problemo. Good practice for me too. :)
 Ӄhrizby
12-22-2011, 4:47 AM
#9
I'm afraid I don't know much about scripting, but I've been curious about this. Does anybody know where to find the stun scripts used when you are in combat? So the on-hit properties?

Mainly, is there a way to modify or make new on-hit effects?

Thanks,
Ӄhrizby
 JCarter426
12-23-2011, 12:24 AM
#10
I'm not sure... I think that stuff is hard coded. But it might be possible to do what you want with a heartbeat script; the only catch is it would only affect whatever NPCs you apply it to - unless you modify the generic heartbeat script, but of course that's risky. Not saying it's impossible... but the engine is very sensitive.
 Ӄhrizby
12-24-2011, 1:00 AM
#11
Alright, that's what I was afraid of. Maybe someday. Thanks!


Edit: I almost have it! And you're right, I used the heartbeat script, it did exactly what I needed, thank you! Perhaps you could help me out here, finishing it up?

http://www.lucasforums.com/showthread.php?p=2799334#post2799334)
Page: 1 of 1