Functions for disabling player control

The beginning of the new module I’m working on now has an intro where at first there’s a cutscene just with text, and then the PC is teleported to a new area where there’s an animation and I give the PC a new outfit and some XP.

When the PC is teleported to this new area I would have liked it if the player for about 5 seconds couldn’t do anything with the PC.

So my first thought was of course to use SetCutsceneMode like I use to (even though it’s technically not a cutscene since I don’t want any black borders like in an NWN2 converstaion/cutscene). However, when doing that there’s a “bug” that makes it so when you try to choose Explore mode after the cutscene is over, the camera won’t turn around, so I can’t use that.

Then I thought, ok, let’s use SetCommandable(FALSE,oPC); This would have worked if I didn’t want to change the outfit of the PC which is very important for this scene. Apparently SetCommandable won’t let you do stuff like that script-wise with the PC.

So here’s my question (finally): Is there some other function you could use to be able to stop the player from moving the PC?

Why is it that I don’t want the player to be able to move the PC? Well, I want the whole animation to play before you are able to move the character.

andgalf… I’ve got no idea about scripting this but if you jump the player into a speak trigger you can set it so there are no cutscene bars. So that might mean you could be able to do this with a script too.

1 Like

Thanks for the reply, @Tsongo!

I actually already solved it. I remembered I had used something in my 4th module. I tested it and it works great. What I did was using this function:

effect FREEZE = EffectCutsceneImmobilize();
	
ApplyEffectToObject(DURATION_TYPE_PERMANENT, FREEZE, oPC);

and then after about 5 seconds I used this (all in the same script with some delays):

#include "nw_i0_spells"

	RemoveSpecificEffect(EFFECT_TYPE_CUTSCENEIMMOBILIZE, oPC);

EDIT: Hmm, after more testing this actually didn’t work as well as I had hoped. You can’t move the PC with this, but if you click on the ground somewhere, even if you don’t move, it still interupts the animation. It’s not that big of a deal I guess, but I would have liked it if it would have worked fully.

EDIT2: @Tsongo I think I’ll check the scripts that are used in the Speak Triggers, and maybe copy some of that code to my own script and see what happens.

@andgalf

I don’t have much time to respond, but I think (if I understand you correctly), this relates to the cutscene mode not being cancelled on the last node of the conversation, iirc. It’s been a while since I have any need of this, but unless I have misunderstood, I thought there was a way we overcame this issue.

Also, you can use SetCommandable between AssignCommand function so that you force it on and off between other assigned actions. Its turning on and off happens so quick, that you can apply your other actions between it being on and off. I hope that made sense.

I’ll try to pop by later.

1 Like

@Lance_Botelle - I don’t think you quite understand me correctly. The cutscene mode is cancelled but another bug appears (and I have seen this appearing at other times) as in the camera won’t turn around but you can control everything else, so it’s a bug that makes the game practically unplayable.

Since when using EffectCutsceneImmobilize it effectively did the same thing as SetCommandeable, my belief is (but that’s untested) that SetCommandable will interrupt the animation also.

In any case, I chose to go the route @Tsongo suggested instead. However, it almost works like I want to. I found that I actually really wanted a cutscene there with a static camera and everything, zooming in on the PC and the animation. But like I said, it doesn’t quite work. What’s the problem now then? Well, it’s like this: When entering the new area with the Speak Trigger, it runs the conversation right away just as it should, but since I have a short delay in my script (good grief, this is so hard to explain)…

Ok, new try:

  1. Enter the first area. Cutscene/conversation. Using text on black background in a conversation. Not important. From here there’s a script at the end node teleporting the PC to a new area.
  2. Enter new area. We enter right inside a Speak Trigger. This new area has a script on the OnClientEnter. In this script I run the custom animation on the PC…BUT there’s a short delay on the animation which is a BIG problem. The custom animation is the PC laying down and then rising up. Now we see for a short milisecond the PC standing up before laying down. Hate that… Tried using FadeFromBlack. Won’t work as it should. Darn fricking NWN2!

I give up. It’s too hard to explain everything. Too tired. I think I have an idea of how to solve all this. Gonna just try that.

Tried my idea, but it doesn’t work.

Now, my sole problem is this: I want the area that I load to start from a FadeFromBlack. Why won’t that work? I’ve put a script with this on the OnClientEnter on the area I enter but it won’t do this. Does it have to do with me using a Speak Trigger? I wouldn’t be surprised if that was the case. This darn game!! I can try and script everything that’s supposed to happen, but I would rather not deep dive into the code to find the exact thing that makes the speak trigger fire a conversation that doesn’t have the black borders up and down in the cutscene mode. That’s why I use the Speak Trigger in this case, to not have to do everything myself. I’m so angry at the toolset and this game right now.

@andgalf

I’m back … OK, sorry I had the wrong idea in my mind … It is quite hard trying to grasp your situation in this instance. Let me get what you need in my head … Is it basically …

We have a fade from black where we are then in a conversation where we see the PC laying down, and then have them get up?

Is that it? I.e. You need a conversation to open with the PC already lying down?

I’m just trying to establish your needs here first.

P.S. I’ve had my fair share of black fade issues … they’re even worse in MP coding. :wink:

In my experience, having the code BlackScreen a player as soon as they enter the area is the best approach, and then have the conversation (that then automatically starts) control the FadeFromBlack after having any animations do their thing first.

EDIT: I think there may also be an auto “unfade” if a game loads into the area from a fresh start as opposed to simply transferring to an area when the game is already underway. Therefore, if you are trying to test an area and it is being tested from a game load, it may not fade in a way compared to if you are jumping to it from another area.

I have a few areas where I fade from black straight into a conversation after a transition. I would have thought it possible to have it start with the PC lying down.

Just another approach that may work … Can we copy a PC and have that the focus of the camera? I.e. the actual player PC is watching the copy, which you do stuff on?

@Lance_Botelle - Yes, that’s basically it. Sorry, really hard to explain stuff sometimes, and I don’t want to put all my code here, with pictures explaining stuff in even more detail, because then many will come and critisize my coding. That has happened before and I’m not in the mood for that kind of stuff right now.

The fade from black wouldn’t work whatever I did. I’ve had it work many times before in the middle of conversations or when entering areas that doesn’t start with a conversation right away(I bet that the Speak Trigger is the culprit to this not working (having its own code), because when I don’t have control of how the code has been written in my modules, stuff like this happens all the time).

Anyway, like many times with NWN2, you have to somehow fool the game into doing what you want. That’s what I finally did here and it finally works now. What solved it for me was: In the first node of the conversation where the animation starts, I put an alpha.tga in the TGA to Display, put a Delay of 1 where it says delay and then the PC is already laying down when you see him, instead of a very short ugly blip of him first standing and then laying down.

Great! If it does the job, then that sounds like a perfectly acceptable way of doing it to me. :+1:

EDIT: Is there a way to use BlackScreen as a command on the opening node? Maybe that would amount to the same thing?

I just found a script called ga_blackout. Maybe that would do something similar.

1 Like

Yeah, as far as I can see, it does the job. It disguises the game beginning the animation of the character, which was what I was trying to achieve with the fade from black anyway. I also tried the BlackScreen function before and that did nothing either, so in my brain it has to do something with how the Speak Trigger code is setup.

@Lance_Botelle Anyway, thanks for trying to help. Sorry, that I’m really irritable tonight.

EDIT: Never tried ga_blackout. Will try that then too. Good to know if it also ends up doing the job.

I was also going to try it my end too. Let me know if it also does work your end. :slight_smile:

It seems to do some kind of black screen…I think…but it goes away so fast that the alpha stuff is a lot better since then I can control how long I want it to be black but increasing the delay on the node.

@andgalf

I just tested the same on a first node of a conversation and it stayed black for a few seconds. In fact, I thought I was going to have to ctr-alt-del, but it eventually came out.

I suspect that something else is causing that (*)… but if you are happy with as you have it, then go with it. I just think that the function (with the fadefromblack to bring out again). may be available as well.

My own test was also fired from a trigger, starting a conversation with an NPC.

(*) Possibly the delay or another node function?

Did you also use the Speak Trigger then without the black borders and with a Ip Speaker as the NPC? Maybe check that because that’s my exact setting.

EDIT: Wait, I did something wrong. I had a fadetoblack in the other script. Forgot to erase that. Now it’s black a long time. Doing so much testing now that everything gets totally jumbled and confusing. Urrgh!

@andgalf

I use my own script for triggers that start conversations … I’m not sure how much it differs from the OC version. Basically, mine just ensures a conversation starts with the NPC. I’ll take a look to see if I notice anything … However, if both start the conversation, and it is the conversation that controls the Blackscreen, then I would not have thought the trigger script had any impact … but … ?

@Lance_Botelle - I normally use my own stuff too, but I wanted the cutscene without the black borders which is the only reason I used the Speak Trigger this time.

I’ll try again now and see what I have done. I’m doing things too fast now which makes me make mistakes.

For testing purposes I suggest you try the Speak Trigger too and see if that changes anything.

Is it the one that fires gtr_speak_node? If it is, what parameters do you pass?

Yes, that’s the one. Here are my settings:

speaktrigger

I did a new test with ga_blackout, making sure I had no other FadeFromBlack or FadeToBlack anywhere else. Now it worked, and just like in your case it went on way too long, so I’ll do with the alpha.tga instead.

Ah, OK, so it sounds like we have the same result anyway then … But, don’t forget that you then follow this function with the ga_fade_from_black on the same node with the time you want it to come back.

i.e. On the same initial node …

ga_blackout (no parameters)
ga_fade_from_black (pass fSpeed in seconds to return from black.)

1 Like

Ah, ok. I see. I can try that too then.