Script appears to be crashing the game.

Post » Sat Aug 14, 2010 5:15 pm

Well, after about a month of doing nothing but NPC packages and cluttering, I got back to work on the other areas of my mod. Mainly, making a script to control a cutscene in which the players controls are disabled, they are moved, they hear a sound (played with playsound), then their controls are reinabled, and they see they finished one quest, and obtained another. Also two doors in front of them are supposed to slide open, using SetPos, but they dont move at all. I think I'm just being stupid and rusty at scripting.

Here is the script as is:

scn PGMQ4TestStartTrigScript ;The players controls are disabled earlier in a previous script, and they are moved then as well, thus triggering this script.Short StageShort DoorsOpenFloat FposFloat Fpos2Float TimerBegin GameMode	If Timer > 0		Set Timer to Timer - GetSecondsPassed	ElseIf Stage == 1 ;Set to one by the other script		;Bishop message 1, this is will be the audio the player hears		Set Stage to 2		Set Timer to 1	ElseIf Stage == 2		Set DoorsOpen to 1 ;after the audio, the doors ahead should slide sideways		Set Stage to 3		Set Timer to 6	ElseIf Stage == 3		SetStage PGMQ3 47 ; this quest is ended		Set DoorsOpen to 0 ; the doors stop sliding		Set Stage to 4		SetStage PGMQ4 1 ; this quest is started		EnablePlayerControls 1 0 0 0 1 0 0 ; partial controls are re-enabled	EndIf	If DoorsOpen == 1 ; this should slide each door open away from eachother, but for some reason they dont move at all			Set fPos to PGMQ4Test1GlassDoor1Ref.Getpos Y - (24 * GetSecondsPassed)			PGMQ4Test1GlassDoor1Ref.SetPos Y fPos			Set fPos2 to PGMQ4Test1GlassDoor2Ref.Getpos Y + (24 * GetSecondsPassed)			PGMQ4Test1GlassDoor2Ref.SetPos Y fPos2	EndIfEnd


There it is, commented out with the issues. Can anyone help me? This all happens, (the script is being executed) and then controls are enabled, then PGMQ3 is ended and it starts saying "QUEST COMPLETE, FINDING BISHOP" but once its about fully faded in, the game freezes, then CTD's. Also, the two glass panes (doors) dont slide or move at all. This script is attached to a trigger thats placed just above the player, just so its on a loaded object. I also tried making it end the quest sooner, then add the other, incase doing both at once crashed it or something, but it still froze. Thanks for any help.
User avatar
WTW
 
Posts: 3313
Joined: Wed May 30, 2007 7:48 pm

Post » Sat Aug 14, 2010 4:46 pm

Gunmaster,

Most of your script looks good, but the moving door part gets a wee-bit tricky. What is the significance of subtracting (24 * GetSecondsPassed) from the position? It seems to me that would produce some wildly erratic movements ont he door, it would move some crazy amount of space depending on how many seconds have elapsed. I recommend finding a fixed value for this, determine exactly where you need the doors to be and through testing determine exactly how many units you need to move each door, then use those values in your SetPos. If however you want the doors to move smoothly instead of all at once, then you need to get a bit more sixy in how you implement the door movement. Right now you are calling for the door movement in one frame only, so at best it would "flash" to its new position without any fluidity to the movement, and that 24 * GetSecondsPassed is too random.

I have copied below the Secret Door script I use in my mod, which causes the door (a wall object or anything really) to move a few units at a time from point A to B. This gives the object a smooth movement that looks more realisticic:

scn SecretWallScript02; This version is designed for E/W walls, the secret wall slides W slightly, then S out of the way.float CURXfloat CURYfloat STARTXfloat STARTYfloat STOPXfloat STOPYshort MOVEMEshort Ashort BBegin OnActivate	if STOPX == 0                                                  ;  FIRST ACTIVATION		set STARTX to GetPos X		set STARTY to GetPos Y		set STOPX to GetPos X - 30		set STOPY to GetPos Y - 180		PlaySound SecretDoorSound3Sec		set MOVEME to 1	elseif ( GetPos Y == STOPY ) && ( GetPos X == STOPX )          ;  IF DOOR IS OPEN		PlaySound SecretDoorSound3Sec		set MOVEME to -1	elseif ( GetPos Y == STARTY ) && ( GetPos X == STARTX )        ;  IF DOOR IS CLOSED		PlaySound SecretDoorSound3Sec		set MOVEME to 1	else		Return                                                      ;  IF DOOR IS MOVING	endifEndBegin GameMode	if ( MOVEME == 1 ) && ( GetPos X > STOPX )                     ;  MOVE FROM POS 2 TO 3		set CURX to GetPos X		set CURX to ( CURX + ( MOVEME - ( 2 * MOVEME) ) )		SetPos X CURX	else		if ( MOVEME == 1 ) && ( GetPos Y > STOPY )                     ;  MOVE FROM POS 1 TO POS 2			set CURY to GetPos Y			set CURY to ( CURY + ( MOVEME - ( 2 * MOVEME) ) )			SetPos Y CURY		else			if ( MOVEME == -1 ) && ( GetPos Y < STARTY )                   ;  MOVE TO POS 2 TO 1				set CURY to GetPos Y				set CURY to ( CURY + ( MOVEME - ( 2 * MOVEME) ) )				SetPos Y CURY			else				if ( MOVEME == -1 ) && ( GetPos X < STARTX )                   ;  MOVE FROM POS 3 TO 2					set CURX to GetPos X					set CURX to ( CURX + ( MOVEME - ( 2 * MOVEME) ) )					SetPos X CURX				else					set MOVEME to 0                                            ; RESET MOVEME AFTER COMPLETING A SEQUENCE				endif			endif		endif	endif	if MOVEME == 0 && A == 0 && B == 0                             ; ENABLE & DISABLE OBJECT TO WORK AROUND THE COLLISION ISSUE WITH SETPOS		Disable		set A to 1	elseif MOVEME == 0 && A == 1 && B == 0		Enable 0		set B to 1	elseif MOVEME != 0		set A to 0		set B to 0	endifEnd


There may be simpler ways to do it, but I have found this one to be effective. You'll have to find the right movement distance for your doors and set those in the script, then time the movement. I had to go into Audacity and edit the grinding-movement sound of the door to be exactly X seconds long, after determining via testing in-game how long the door took to complete the movement. You can get as little or as fancy as you want with this.

I'm not entirely sure why the game is CTDing on you, but I would start by commenting out your door movement code and seeing if the rest of the sequence plays-out okay, then comment other sections if that's not it until you find the offending bit. Feel free to use this code as much as you need in your mod, the original script was developed by BossPlaya and I adapted it from there.

Luck!

Miax
User avatar
Josephine Gowing
 
Posts: 3545
Joined: Fri Jun 30, 2006 12:41 pm

Post » Sat Aug 14, 2010 10:15 am

Oh my. Well, hmmm. First off, I do not believe its only telling the doors to move for one frame. I set DoorOpen to 1, then it doesnt change it for 6 seconds. That should give me 6 seconds of door moving goodness. And the If DoorsOpen == 1 statement is its own block within gamemode, so shouldnt it run every single frame? On top of that, I know this script will work to move the door smoothly, I used it before in a player cutscene where the player is 'flown' around several rooms. Let me explain.

	If DoorsOpen == 1 ; this should slide each door open away from eachother, but for some reason they dont move at all			Set fPos to PGMQ4Test1GlassDoor1Ref.Getpos Y - (24 * GetSecondsPassed)			PGMQ4Test1GlassDoor1Ref.SetPos Y fPos			Set fPos2 to PGMQ4Test1GlassDoor2Ref.Getpos Y + (24 * GetSecondsPassed)			PGMQ4Test1GlassDoor2Ref.SetPos Y fPos2


For as long as DoorOpen == 1, the game slides the glass doors in the + or - direction of the Y axis, at a rate of 24 frames per second. If I just said move like .5 units per frame, if your game ran at 30fps, it would move farther than if you game ran at 15fps. This way the movement distance overall is consistant. Since it takes 24 * how ever many seconds passed since the last frame. This actually gives smooth consistant speed with moving the object. But it doesnt move it at all for some reason.

I guess after school I will try by commenting out the door part. I know the crash is script caused, its consistant across both my computer and my friends computer.
User avatar
Cheville Thompson
 
Posts: 3404
Joined: Sun Mar 25, 2007 2:33 pm

Post » Sat Aug 14, 2010 9:42 am

Well it appears that section was the issue, somehow. After cutting the script down to just the following, I was able to run around a good 45 seconds with no crashing (then I exited) so it was the problem. I will just have a door that opens instead. :P I'm not sure what was wrong with that. Thanks for the suggestion anyway Miaximus.

scn PGMQ4TestStartTrigScriptShort StageFloat FposFloat Fpos2Float TimerBegin GameMode	If Timer > 0		Set Timer to Timer - GetSecondsPassed	ElseIf Stage == 1		;Bishop message 1		Set Stage to 2		Set Timer to 1	ElseIf Stage == 2		Set Stage to 3		Set Timer to 6	ElseIf Stage == 3		SetStage PGMQ3 47		Set Stage to 4		SetStage PGMQ4 1		EnablePlayerControls 1 0 0 0 1 0 0	EndIfEnd

User avatar
Charlotte Lloyd-Jones
 
Posts: 3345
Joined: Fri Jun 30, 2006 4:53 pm

Post » Sat Aug 14, 2010 6:45 pm

Cool. :)

I'm glad you found it, I apologize for misreading the timing on your door (I thought it was frame-by-frame but you had the loop delay set, doh?!).

Script looks good!

Cheers
User avatar
Rhi Edwards
 
Posts: 3453
Joined: Fri Jul 28, 2006 1:42 am


Return to Fallout 3