Overview | Package | Class | Source | Class tree | Glossary | Deus Ex UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 00351 00352 00353 00354 00355 00356 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366 00367 00368 00369 00370 00371 00372 00373 00374 00375 00376 00377 00378 00379 00380 00381 00382 00383 00384 00385 00386 00387 00388 00389 00390 00391 00392 00393 00394 00395 00396 00397 00398 00399 00400 00401 00402 00403 00404 00405 00406 00407 00408 00409 00410 00411 00412 00413 00414 00415 00416 00417 00418 00419 00420 00421 00422 00423 00424 00425 00426 00427 00428 00429 00430 00431 00432 00433 00434 00435 00436 00437 00438 00439 00440 00441 00442 00443 00444 00445 00446 00447 00448 00449 00450 00451 00452 00453 00454 00455 00456 00457 00458 00459 00460 00461 00462 00463 00464 00465 00466 00467 00468 00469 00470 00471 00472 00473 00474 00475 00476 00477 00478 00479 00480 00481 00482 00483 00484 00485 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 00498 00499 00500 00501 00502 00503 00504 00505 00506 00507 00508 00509 00510 00511 00512 00513 00514 00515 00516 00517 00518 00519 00520 00521 00522 00523 00524 00525 00526 00527 00528 00529 00530 00531 00532 00533 00534 00535 00536 00537 00538 00539 00540 00541 00542 00543 00544 00545 00546 00547 00548 00549 00550 00551 00552 00553 00554 00555 00556 00557 00558 00559 00560 00561 00562 00563 00564 00565 00566 00567 00568 00569 00570 00571 00572 00573 00574 00575 00576 00577 00578 00579 00580 00581 00582 00583 00584 00585 00586 00587 00588 00589 00590 00591 00592 00593 00594 00595 00596 00597 00598 00599 00600 00601 00602 00603 00604 00605 00606 00607 00608 00609 00610 00611 00612 00613 00614 00615 00616 00617 00618 00619 00620 00621 00622 00623 00624 00625 00626 00627 00628 00629 00630 00631 00632 00633 00634 00635 00636 00637 00638 00639 00640 00641 00642 00643 00644 00645 00646 00647 00648 00649 00650 00651 00652 00653 00654 00655 00656 00657 00658 00659 00660 00661 00662 00663 00664 00665 00666 00667 00668 00669 00670 00671 00672 00673 00674 00675 00676 00677 00678 00679 00680 00681 00682 00683 00684 00685 00686 00687 00688 00689 00690 00691 00692 00693 00694 00695 00696 00697 00698 00699 00700 00701 00702 00703 00704 00705 00706 00707 00708 00709 00710 00711 00712 00713 00714 00715 00716 00717 00718 00719 00720 00721 00722 00723 00724 00725 00726 00727 00728 00729 00730 00731 00732 00733 00734 00735 00736 00737 00738 00739 00740 00741 00742 00743 00744 00745 00746 00747 00748 00749 00750 00751 00752 00753 00754 00755 00756 00757 00758 00759 00760 00761 00762 00763 00764 00765 00766 00767 00768 00769 00770 00771 00772 00773 00774 00775 00776 00777 00778 00779 00780 00781 00782 00783 00784 00785 00786 00787 00788 00789 00790 00791 00792 00793 00794 00795 00796 00797 00798 00799 00800 00801 00802 00803 00804 00805 00806 00807 00808 00809 00810 00811 00812 00813 00814 00815 00816 00817 00818 00819 00820 00821 00822 00823 00824 00825 00826 00827 00828 00829 00830 00831 00832 00833 00834 00835 00836 00837 00838 00839 00840 00841 00842 00843 00844 00845 00846 00847 00848 00849 00850 00851 00852 00853 00854 00855 00856 00857 00858 00859 00860 00861 00862 00863 00864 00865 00866 00867 00868 00869 00870 00871 00872 00873 00874 00875 00876 00877 00878 00879 00880 00881 00882 00883 00884 00885 00886 00887 00888 00889 00890 00891 00892 00893 00894 00895 00896 00897 00898 00899 00900 00901 00902 00903 00904 00905 00906 00907 00908 00909 00910 00911 00912 00913 00914 00915 00916 00917 00918 00919 00920 00921 00922 00923 00924 00925 00926 00927 00928 00929 00930 00931 00932 00933 00934 00935 00936 00937 00938 00939 00940 00941 00942 00943 00944 00945 00946 00947 00948 00949 00950 00951 00952 00953 00954 00955 00956 00957 00958 00959 00960 00961 00962 00963 00964 00965 00966 00967 00968 00969 00970 00971 00972 00973 00974 00975 00976 00977 00978 00979 00980 00981 00982 00983 00984 00985 00986 00987 00988 00989 00990 00991 00992 00993 00994 00995 00996 00997 00998 00999 01000 01001 01002 01003 01004 01005 01006 01007 01008 01009 01010 01011 01012 01013 01014 01015 01016 01017 01018 01019 01020 01021 01022 01023 01024 01025 01026 01027 01028 01029 01030 01031 01032 01033 01034 01035 01036 01037 01038 01039 01040 01041 01042 01043 01044 01045 01046 01047 01048 01049 01050 01051 01052 01053 01054 01055 01056 01057 01058 01059 01060 01061 01062 01063 01064 01065 01066 01067 01068 01069 01070 01071 01072 01073 01074 01075 01076 01077 01078 01079 01080 01081 01082 01083 01084 01085 01086 01087 01088 01089 01090 01091 01092 01093 01094 01095 01096 01097 01098 01099 01100 01101 01102 01103 01104 01105 01106 01107 01108 01109 01110 01111 01112 01113 01114 01115 01116 01117 01118 01119 01120 01121 01122 01123 01124 01125 01126 01127 01128 01129 01130 01131 01132 01133 01134 01135 01136 01137 01138 01139 01140 01141 01142 01143 01144 01145 01146 01147 01148 01149 01150 01151 01152 01153 01154 01155 01156 01157 01158 01159 01160 01161 01162 01163 01164 01165 01166 01167 01168 01169 01170 01171 01172 01173 01174 01175 01176 01177 01178 01179 01180 01181 01182 01183 01184 01185 01186 01187 01188 01189 01190 01191 01192 01193 01194 01195 01196 01197 01198 01199 01200 01201 01202 01203 01204 01205 01206 01207 01208 01209 01210 01211 01212 01213 01214 01215 01216 01217 01218 01219 01220 01221 01222 01223 01224 01225 01226 01227 01228 01229 01230 01231 01232 01233 01234 01235 01236 01237 01238 01239 01240 01241 01242 01243 01244 01245 01246 01247 01248 01249 01250 01251 01252 01253 01254 01255 01256 01257 01258 01259 01260 01261 |
//============================================================================= // ConPlay //============================================================================= class ConPlay expands ConPlayBase; var ConEvent currentEvent; var transient HUDConWindowFirst conWinFirst; // Third-Person Conversation Window var Actor currentSpeaker; var Actor currentSpeakingTo; var Bool SetupInitialCamera; var Actor speakingActor; // Currently Animating speaking Actor var ConCamera cameraInfo; // Camera Information var Bool randomCamera; // True if random camera placement var Bool interactiveCamera; // True when we have interactive camera control var ConEventMoveCamera pendingCameraEvent; var Bool bSetupInitialCamera; var Bool bEndingConversation; var Bool bWaitingForConWin; var Bool bActorsTurned; var Bool bSaveContinueSpeech; var Bool bSaveNoPlayedFlag; // If starting a third-person convo, then we want to temporarily // put away whatever the player may have been holding until the // conversation is over. This variable holds that item. var Inventory playerInHand; // These variables are used to calculate length of time to display text // if there is no audio for the text or the player has speech dialog // disabled. var Float perCharDelay; var Float minimumTextPause; // Conversation fonts for third-person convos var Font ConversationSpeechFonts[2]; var Font ConversationNameFonts[2]; // ---------------------------------------------------------------------- // StartConversation() // // Starts a conversation. // // 1. Initializes the Windowing system // 2. Gets a pointer to the first Event // 3. Jumps into the 'PlayEvent' state // ---------------------------------------------------------------------- function Bool StartConversation(DeusExPlayer newPlayer, optional Actor newInvokeActor, optional bool bForcePlay) { if ( Super.StartConversation(newPlayer, newInvokeActor, bForcePlay) == False ) return False; bEndingConversation = False; // Check to see if this conversation uses random camera placement randomCamera = con.bRandomCamera; // Based on whether we're in first-person or third-person mode, // we need to derive our conversation window differently. First-person // conversation mode is non-interactive and only allows speech, for // the most part. if ( con.bFirstPerson ) { displayMode = DM_FirstPerson; conWinFirst = rootWindow.hud.CreateConWindowFirst(); // Initialize Windowing System conWinFirst.conPlay = Self; } else { displayMode = DM_ThirdPerson; // Hide the hud display if this is a third-person convo rootWindow.hud.Hide(); conWinThird = ConWindowActive(rootWindow.NewChild(Class'ConWindowActive', False)); conWinThird.SetForcePlay(bForcePlay); // Setup default camera information, but only if bForcePlay is set to false if (!bForcePlay) { cameraInfo = con.CreateConCamera(); cameraInfo.InitializeCameraValues(Self); if ( randomCamera ) cameraInfo.SetupRandomCameraPosition(); } // Initialize Windowing System conWinThird.conPlay = Self; // Align the conversation window conWinThird.SetWindowAlignments(HALIGN_Full, VALIGN_Full); conWinThird.Show(); } // Check to see if this is a passive or interactive conversation // Passive conversations are beyond the PC's control and do not have // things like Choices, etc. in them. if ( con.bNonInteractive ) playMode = PM_Passive; else playMode = PM_Active; // Grab the first event! currentEvent = con.eventList; // Create a ConHistory object if (!bForcePlay) SetupHistory(player.GetDisplayName(startActor, True)); // Play this event! GotoState('PlayEvent'); return True; } // ---------------------------------------------------------------------- // SetInHand() // ---------------------------------------------------------------------- function SetInHand(Inventory newInHand) { playerInHand = newInHand; } // ---------------------------------------------------------------------- // TerminateConversation() // // Time to go away to that nice happy place! // ---------------------------------------------------------------------- function TerminateConversation(optional bool bContinueSpeech, optional bool bNoPlayedFlag) { // Save this for when we call Super.TerminateConversation() later bSaveContinueSpeech = bContinueSpeech; bSaveNoPlayedFlag = bNoPlayedFlag; // Some protection to make sure this doesn't happen // more than once. if (!bEndingConversation) { bEndingConversation = True; // Tell the Conversation Window to shut down if ((conWinThird != None) && (!bForcePlay)) GotoState('WaitForConWin'); else ConWinFinished(); } } // ---------------------------------------------------------------------- // PostTerminateConversation() // ---------------------------------------------------------------------- function PostTerminateConversation() { // Notify the player we're no longer inside // a conversation player.EndConversation(); // Remove the highlights if (cameraInfo != None) cameraInfo.DestroyHighlights(); // Save the conversation history if ( history != None ) { history.next = player.conHistory; player.conHistory = history; history = None; // in case we get called more than once!! } // If the player was holding something when // the conversation started, put the item back // in his hand. if (playerInHand != None) player.PutInHand(playerInHand); Super.TerminateConversation(bSaveContinueSpeech, bSaveNoPlayedFlag); } // ---------------------------------------------------------------------- // ConWinFinished() // // Called when the conversation window has finished moving and we // can destroy the ConPlay actor. // ---------------------------------------------------------------------- function ConWinFinished() { // Nuke the conversation window if (displayMode == DM_FirstPerson) { if (conWinFirst != None) conWinFirst.Destroy(); } else { if (conWinThird != None) conWinThird.Destroy(); // Show the hud display if this was a third-person convo if (!bForcePlay) rootWindow.hud.Show(); } PostTerminateConversation(); // Now nuke ourself. Destroy(); } // ---------------------------------------------------------------------- // JumpToConversation() // // Jumps to another conversation // ---------------------------------------------------------------------- function JumpToConversation( Conversation jumpCon, String startLabel ) { assert( jumpCon != None ); // If this is a new conversation, assign it to our "Con" variable // and set the con.conName $ "_Played" flag to True. if (jumpCon != con) { SetPlayedFlag(); // Some cleanup for the existing conversation con.ClearBindEvents(); con.radiusDistance = saveRadiusDistance; // Assign the new conversation and bind the events con = jumpCon; con.BindEvents(ConActorsBound, startActor); } // Get the event to start at, or the beginning if one wasn't // passed in. However, if a label is passed in *and* it's not // found, then abort the conversation!! currentEvent = con.GetEventFromLabel( startLabel ); if (( currentEvent == None ) && ( startLabel != "" )) { Log("ConPlay::JumpToConversation() --------------------------------------"); Log(" WARNING! Label [" $ startLabel $ "] NOT FOUND in Conversation [" $ jumpCon.conName $ "]"); log(" Conversation Terminated."); TerminateConversation(); return; } if ( currentEvent == None ) currentEvent = con.eventList; // Start the conversation! GotoState('PlayEvent'); } // ---------------------------------------------------------------------- // GetNextEvent() // // Returns the next event // ---------------------------------------------------------------------- function ConEvent GetNextEvent() { return currentEvent.nextEvent; } // ---------------------------------------------------------------------- // GetDisplayMode() // ---------------------------------------------------------------------- function EDisplayMode GetDisplayMode() { return displayMode; } // ---------------------------------------------------------------------- // PlayChoice() // // Called from ConWindow object when a choice is selected // ---------------------------------------------------------------------- function PlayChoice( ConChoice choice ) { local ConSpeech choiceSpeech; // First, save the choice text, but only if the DisplayAsSpeech // flag isn't set, in which case the speech will be setup as a // speech event and saved that way. if ( !choice.bDisplayAsSpeech ) { choiceSpeech = new(None) Class'ConSpeech'; choiceSpeech.speech = choice.choiceText; choiceSpeech.soundID = choice.soundID; AddHistoryEvent(player.GetDisplayName(player, True), choiceSpeech ); } // If this choice has a label, then jump to it. Otherwise just // continue with the conversation. if ( choice.choiceLabel != "" ) ProcessAction( EA_JumpToLabel, choice.choiceLabel ); else ProcessAction( EA_NextEvent, "" ); } // ---------------------------------------------------------------------- // PlayNextEvent() // // Called from the ConWindow object when the user clicks to // continue with Conversation // ---------------------------------------------------------------------- function PlayNextEvent() { // Restrict input again until we've finished processing this event if (conWinThird != None) conWinThird.RestrictInput(True); // Stop any sound that was playing StopSpeech(); ProcessAction( EA_NextEvent, "" ); } // ---------------------------------------------------------------------- // ProcessAction() // // Processes the current Action // ---------------------------------------------------------------------- function ProcessAction( EEventAction nextAction, string nextLabel ) { // Don't do squat if the currentEvent is NONE if (currentEvent == None) return; switch( nextAction ) { case EA_NextEvent: // Proceed to the next event. lastEvent = currentEvent; currentEvent = currentEvent.nextEvent; GotoState('PlayEvent'); break; case EA_JumpToLabel: // Use the label passed back and jump to it lastEvent = currentEvent; currentEvent = con.GetEventFromLabel( nextLabel ); if ( currentEvent == None ) { Log("ConPlay::ProcessAction() - EA_JumpToLabel ----------------------------"); Log(" WARNING! Label " $ nextLabel $ " NOT FOUND in Conversation " $ con.conName); log(" Conversation Terminated."); } GotoState('PlayEvent'); break; case EA_JumpToConversation: lastEvent = currentEvent; JumpToConversation( ConEventJump(currentEvent).jumpCon, nextLabel ); break; case EA_WaitForInput: // We need to wait for some user input before // proceeding any further, so jump into a wait state lastEvent = currentEvent; GotoState('WaitForInput'); break; case EA_WaitForSpeech: // Wait for a piece of audio to finish playing lastEvent = currentEvent; GotoState('WaitForSpeech'); break; case EA_WaitForText: lastEvent = currentEvent; GotoState('WaitForText'); break; case EA_PlayAnim: lastEvent = currentEvent; GotoState('ConPlayAnim'); break; case EA_ConTurnActors: GotoState('ConTurnActors'); break; case EA_End: TerminateConversation(); break; } } // ---------------------------------------------------------------------- // PlaySpeech() // ---------------------------------------------------------------------- function PlaySpeech( int soundID, Actor speaker ) { local Sound speech; speech = con.GetSpeechAudio(soundID); // Keep a pointer to the current speaking pawn so we can stop // the speech animation when we're finished. if (speech != None) { // If this is an intro/endgame, force speech to play through // the player so we can *hear* it. if (bForcePlay) { // Check how close the player is to this actor. If the player is // close enough to the speaker, play through the speaker. if ((speaker == None) || (VSize(player.Location - speaker.Location) > 400)) { playingSoundID = player.PlaySound(speech, SLOT_Talk,,,65536.0); } else { playingSoundID = speaker.PlaySound(speech, SLOT_Talk,,,65536.0); } } else { // If this is a forced conversation (bCannotBeInterrupted = True) // then set the radius higher. This is a hack. Yes, a hack, // in some situations where the PC is far from one or more speaking // NPCs but needs to be able to overhear them. Also, want to make // this reasonably loud for letterbox convos if ((con.bCannotBeInterrupted) || (!con.bFirstPerson)) playingSoundID = speaker.PlaySound(speech, SLOT_Talk,,,65536.0); else playingSoundID = speaker.PlaySound(speech, SLOT_Talk,,,512.0 + initialRadius); } } StartSpeakingAnimation(); } // ---------------------------------------------------------------------- // StopSpeech() // ---------------------------------------------------------------------- function StopSpeech() { Super.StopSpeech(); StopSpeakingAnimation(); } // ---------------------------------------------------------------------- // StartSpeakingAnimation() // // Start the speaking animation. We only have animations for Pawns, so if a // decoration is speaking there's nothing to animate (this may change). // // If this is a speech event, then grab ahold of the speaker. Otherwise, // if it's a choice event that's playing the selected choice, the PC // is speaking. // ---------------------------------------------------------------------- function StartSpeakingAnimation() { if ( ConEventSpeech(currentEvent) != None ) speakingActor = Pawn(ConEventSpeech(currentEvent).speaker); else speakingActor = player; if ( speakingActor != None ) { Pawn(speakingActor).bIsSpeaking = True; Pawn(speakingActor).bWasSpeaking = True; } } // ---------------------------------------------------------------------- // StopSpeakingAnimation() // // Stop the speaking animation // ---------------------------------------------------------------------- function StopSpeakingAnimation() { if ( Pawn(speakingActor) != None ) { Pawn(speakingActor).bIsSpeaking = False; speakingActor = None; } } // ---------------------------------------------------------------------- // PlayEvent() // // Plays an event // Assumes currentEvent is already setup // ---------------------------------------------------------------------- state PlayEvent { function SetupEvent() { local EEventAction nextAction; local String nextLabel; switch( currentEvent.EventType ) { case ET_Speech: if ( !bActorsTurned ) nextAction = SetupEventSpeechPre( ConEventSpeech(currentEvent), nextLabel ); else nextAction = SetupEventSpeechPost( ConEventSpeech(currentEvent), nextLabel ); break; case ET_Choice: // Not allowed in passive mode if ( playMode == PM_Active ) { nextAction = SetupEventChoice( ConEventChoice(currentEvent), nextLabel ); } break; case ET_SetFlag: nextAction = SetupEventSetFlag( ConEventSetFlag(currentEvent), nextLabel ); break; case ET_CheckFlag: nextAction = SetupEventCheckFlag( ConEventCheckFlag(currentEvent), nextLabel ); break; case ET_CheckObject: nextAction = SetupEventCheckObject( ConEventCheckObject(currentEvent), nextLabel ); break; case ET_TransferObject: nextAction = SetupEventTransferObject( ConEventTransferObject(currentEvent), nextLabel ); break; case ET_MoveCamera: // Not allowed in passive mode if ( playMode == PM_Active ) { nextAction = SetupEventMoveCamera( ConEventMoveCamera(currentEvent), nextLabel ); } break; case ET_Animation: nextAction = SetupEventAnimation( ConEventAnimation(currentEvent), nextLabel ); break; case ET_Trade: // Not allowed in passive mode if ( playMode == PM_Active ) { nextAction = SetupEventTrade( ConEventTrade(currentEvent), nextLabel ); } break; case ET_Jump: nextAction = SetupEventJump( ConEventJump(currentEvent), nextLabel ); break; case ET_Random: nextAction = SetupEventRandomLabel( ConEventRandomLabel(currentEvent), nextLabel ); break; case ET_Trigger: nextAction = SetupEventTrigger( ConEventTrigger(currentEvent), nextLabel ); break; case ET_AddGoal: nextAction = SetupEventAddGoal( ConEventAddGoal(currentEvent), nextLabel ); break; case ET_AddNote: nextAction = SetupEventAddNote( ConEventAddNote(currentEvent), nextLabel ); break; case ET_AddSkillPoints: nextAction = SetupEventAddSkillPoints( ConEventAddSkillPoints(currentEvent), nextLabel ); break; case ET_AddCredits: nextAction = SetupEventAddCredits( ConEventAddCredits(currentEvent), nextLabel ); break; case ET_CheckPersona: nextAction = SetupEventCheckPersona( ConEventCheckPersona(currentEvent), nextLabel ); break; case ET_End: nextAction = SetupEventEnd( ConEventEnd(currentEvent), nextLabel ); break; } // Based on the result of the setup, we either need to jump to another event // or wait for some input from the user. ProcessAction( nextAction, nextLabel ); } Begin: if ( currentEvent == None ) TerminateConversation(); else SetupEvent(); } // ---------------------------------------------------------------------- // State WaitForConWin() // ---------------------------------------------------------------------- state WaitForConWin { function Timer() { if ( (( displayMode == DM_FirstPerson ) && (conWinFirst != None) && ( !conWinFirst.IsVisible())) || (( displayMode == DM_ThirdPerson ) && (conWinThird != None) && ( !conWinThird.IsVisible())) ) { SetTimer(0, False); ConWinFinished(); } else { SetTimer(0.2, True); } } function PlayNextEvent() { SetTimer(0, False); ConWinFinished(); } function CloseConWindow() { if ( displayMode == DM_FirstPerson ) { if (conWinFirst != None ) conWinFirst.Close(); } else { if (conWinThird != None) conWinThird.Close(); } // Wait for the window to finish SetTimer(0.2, True); } function BeginState() { // Allow input if (conWinThird != None) conWinThird.RestrictInput(False); CloseConWindow(); } } // ---------------------------------------------------------------------- // GetCurrentSpeechFont() // ---------------------------------------------------------------------- function Font GetCurrentSpeechFont() { local int resWidth; resWidth = GetCurrentResolutionWidth(); if ((resWidth > 800) && (resWidth < 1280)) return ConversationSpeechFonts[1]; else return ConversationSpeechFonts[0]; } // ---------------------------------------------------------------------- // GetCurrentNameFont() // ---------------------------------------------------------------------- function Font GetCurrentNameFont() { local int resWidth; resWidth = GetCurrentResolutionWidth(); if ((resWidth > 800) && (resWidth < 1280)) return ConversationNameFonts[1]; else return ConversationNameFonts[0]; } // ---------------------------------------------------------------------- // GetCurrentResolutionWidth() // ---------------------------------------------------------------------- function int GetCurrentResolutionWidth() { local int p; local int resX; local int resWidth; local string CurrentRes; CurrentRes = player.ConsoleCommand("GetCurrentRes"); resX = InStr(CurrentRes,"x"); resWidth = int(Left(CurrentRes, resX)); return resWidth; } // ---------------------------------------------------------------------- // ToggleInteractiveCamera() // // Toggles the interactive camera on and off, which allows the user to // screw around the with the camera in Conversation mode // ---------------------------------------------------------------------- function ToggleInteractiveCamera() { if (cameraInfo != None) { interactiveCamera = !interactiveCamera; if ( interactiveCamera ) { conWinThird.CreateCameraWindow(); UpdateCameraInfo(); } else { conWinThird.DestroyCameraWindow(); } cameraInfo.SetInteractiveCamera(interactiveCamera); } } // ---------------------------------------------------------------------- // UpdateCameraInfo() // ---------------------------------------------------------------------- function UpdateCameraInfo() { if (conWinThird != None) conWinThird.UpdateCameraInfo(); } // ---------------------------------------------------------------------- // SetCameraActors() // // If we have a "SpeakingTo" actor, then we'll use it as the actor who's // being spoken to. Otherwise use the last actor that was speaking. // ---------------------------------------------------------------------- function SetCameraActors() { // Totally ignore this if "bForcePlay" is set to true if (bForcePlay) return; if ((currentspeaker != None) && (currentSpeakingTo != None)) { // Update the Actors used by the camera if (cameraInfo != None) { // If we have a pending camera event, then notify the // camera system with the actors if (pendingCameraEvent != None) { cameraInfo.SetActors(currentSpeaker, currentSpeakingTo); cameraInfo.SetupCameraFromEvent(pendingCameraEvent); pendingCameraEvent = None; bSetupInitialCamera = True; } // Otherwise, if we're using a fallback camera and it's a headshot // then we want to make sure the camera is properly trained on // the person talking. else if ((cameraInfo.UsingFallbackCamera()) && (cameraInfo.UsingHeadshot())) { cameraInfo.SetActors(currentSpeaker, currentSpeakingTo); } } // If we haven't setup an initial camera then do so, // because we don't want to play a speech or choice // event without the camera first having been placed if ((cameraInfo != None) && (!bSetupInitialCamera)) { cameraInfo.SetActors(currentSpeaker, currentSpeakingTo); cameraInfo.SetupFallbackCamera(); bSetupInitialCamera = True; } } } // ---------------------------------------------------------------------- // state ConPlayAnim // // Plays an animation and then runs the next event. // Optionally will wait for the animation to finish // ---------------------------------------------------------------------- state ConPlayAnim { Begin: // Check to see if we need to just play this animation once or // loop it. if ( ConEventAnimation(currentEvent).bLoopAnim ) ConEventAnimation(currentEvent).eventOwner.LoopAnim( ConEventAnimation(currentEvent).sequence ); else ConEventAnimation(currentEvent).eventOwner.PlayAnim( ConEventAnimation(currentEvent).sequence ); // If we're not looping the animation and we need to wait for this one to finish, // then do so. if (( !ConEventAnimation(currentEvent).bLoopAnim ) && ( ConEventAnimation(currentEvent).bFinishAnim )) ConEventAnimation(currentEvent).eventOwner.FinishAnim(); currentEvent = currentEvent.nextEvent; GotoState('PlayEvent'); } // ---------------------------------------------------------------------- // state ConTurnActors // // Turns the actors to face each other when speaking // ---------------------------------------------------------------------- state ConTurnActors { Begin: // We used to turn the actors here, but this is now handled by // the pawns themselves... bActorsTurned = True; GotoState('PlayEvent'); } // ---------------------------------------------------------------------- // state WaitForSpeech // // Waiting for a sound to finish playing // ---------------------------------------------------------------------- state WaitForSpeech { // We get here when the timer we set when playing the sound // has finished. We want to play the next event. function Timer() { GotoState( 'WaitForSpeech', 'SpeechFinished' ); } SpeechFinished: // Restrict input if (conWinThird != None) conWinThird.RestrictInput(True); StopSpeakingAnimation(); // Sleep for a second before continuing Sleep(0.5); // Fire the next event PlayNextEvent(); Stop; Idle: // Allow input if (conWinThird != None) conWinThird.RestrictInput(False); Sleep(0.5); Goto('Idle'); Begin: // If this is a first person conversation and A) we don't have speech // or B) we're in "Subtitles Only" mode, then set a timer based on // the length of speech. if ( ConEventSpeech(currentEvent).conSpeech.soundID == -1 ) { SetTimer( FMax(lastSpeechTextLength * perCharDelay, minimumTextPause), False ); } else { // Play the sound, set the timer and go to sleep until the sound // has finished playing. // First Stop any sound that was playing PlaySpeech( ConEventSpeech(currentEvent).conSpeech.soundID, ConEventSpeech(currentEvent).Speaker ); // Add two seconds to the sound since there seems to be a slight lag SetTimer( con.GetSpeechLength(ConEventSpeech(currentEvent).conSpeech.soundID), False ); } Goto('Idle'); } // ---------------------------------------------------------------------- // state WaitForText // // Waiting for a text to finish // ---------------------------------------------------------------------- state WaitForText { // We get here when the timer we set when playing the sound // has finished. We want to play the next event. function Timer() { GotoState( 'WaitForText', 'TextFinished' ); } TextFinished: // Fire the next event // Restrict input if (conWinThird != None) conWinThird.RestrictInput(True); PlayNextEvent(); Stop; Idle: // Allow input if (conWinThird != None) conWinThird.RestrictInput(False); Sleep(0.5); Goto('Idle'); Begin: SetTimer( FMax(lastSpeechTextLength * perCharDelay, minimumTextPause), False ); Goto('Idle'); } // ---------------------------------------------------------------------- // state WaitForInput // // We're waiting to come back from an event that requires User Input (such as // the speech and choice events) // ---------------------------------------------------------------------- state WaitForInput { Begin: // Allow input if (conWinThird != None) conWinThird.RestrictInput(False); Sleep(1); goto('Begin'); } // ---------------------------------------------------------------------------- // All the unique Setup routines for each event type are located here // ---------------------------------------------------------------------------- function EEventAction SetupEventSpeechPre( ConEventSpeech event, out String nextLabel ) { nextLabel = ""; return EA_ConTurnActors; } // ---------------------------------------------------------------------- // SetupEventSpeechPost() // // Display the speech and wait for feedback. // ---------------------------------------------------------------------- function EEventAction SetupEventSpeechPost( ConEventSpeech event, out String nextLabel ) { local EEventAction nextAction; local ConEvent checkEvent; local String speech; local bool bHaveSpeechAudio; bActorsTurned = False; // Restrict input until we've finished setting up this event if (conWinThird != None) conWinThird.RestrictInput(True); // Keep track of the current speaker and speaking to actors if ((currentSpeaker != event.speaker) || (currentSpeakingTo != event.speakingTo)) { // If we're in "Random Camera" mode, then we want to // pick a new camera position. if ((randomCamera) && (cameraInfo != None)) cameraInfo.SetupRandomCameraPosition(); // Update our actor variables currentSpeaker = event.speaker; currentSpeakingTo = event.speakingTo; UpdateCameraInfo(); } // Update the Actors used by the camera SetCameraActors(); // Cause the speaking actor to turn towards the person he is // speaking to. TurnSpeakingActors(event.speaker, event.speakingTo); // Calculate the length of the text string, this is used later speech = event.conSpeech.speech; bHaveSpeechAudio = (event.conSpeech.soundID != -1); lastSpeechTextLength = len(speech); // Display the speech text, if: // // 1. Player has bSubtitles flag on // 2. No speech audio exists for the speech if ((player.bSubtitles) || (!bHaveSpeechAudio)) { if ( displayMode == DM_FirstPerson ) conWinFirst.Show(); // If we're continuing from the last speech, then we want to Append // and not Display the first chunk. if ( event.bContinued == True ) { if ( displayMode == DM_FirstPerson ) conWinFirst.AppendText( speech ); else conWinThird.AppendText( speech ); } else { if ( displayMode == DM_FirstPerson ) { // Clear the window conWinFirst.Clear(); conWinFirst.DisplayName( player.GetDisplayName(event.speaker) ); conWinFirst.DisplayText( speech, currentSpeaker ); } else { // Clear the window conWinThird.Clear(); conWinThird.DisplayName( player.GetDisplayName(event.speaker) ); conWinThird.DisplayText( speech, currentSpeaker ); } } } else if (displayMode == DM_FirstPerson) { conWinFirst.Hide(); } // Save this event in the history AddHistoryEvent(player.GetDisplayName(event.Speaker, True), event.conSpeech); // If we have speech audio, play it! if (bHaveSpeechAudio) { nextAction = EA_WaitForSpeech; } else { // Otherwise, we'll wait for the text to play (either in passive mode, which // means the text will continue on its own, or in ACTIVE mode, in which case // we'll wait for a keypress before continuing. if (( playMode == PM_PASSIVE ) || ( displayMode == DM_FirstPerson )) { nextAction = EA_WaitForText; } else { // If we're here, we either have no speech or we're in a text-only mode // // We want to wait for input unless the next event is a // speech event and has the "Continued" flag set, which // allows for additional speech and choices to // appear immediately after the current speech. // // Choices automatically continue unless they have the "Clear Screen" // flag set. checkEvent = GetNextEvent(); if ( (( ConEventChoice(checkEvent) != None ) && ( !ConEventChoice(checkEvent).bClearScreen )) || (( ConEventSpeech(checkEvent) != None ) && ( ConEventSpeech(checkEvent).bContinued )) ) nextAction = EA_NextEvent; else nextAction = EA_WaitForInput; } } nextLabel = ""; return nextAction; } // ---------------------------------------------------------------------- // SetupEventChoice() // ---------------------------------------------------------------------- function EEventAction SetupEventChoice( ConEventChoice event, out String nextLabel ) { local ConChoice choice; local ButtonWindow newButton; local int choiceCount; local EEventAction nextAction; // Notify the conversation window to ignore input until we're done // creating the choices (this is done to prevent the user from being // able to make a choice while drawing, only a problem on slow machines) if (conWinThird != None) conWinThird.RestrictInput(True); // For choices, the speaker is always the player. The person being // spoken to, well, that's more complicated (unless I force that to be // set in ConEdit). For now we'll assume that the owner of the // conversation is the person being spoken to. currentSpeaker = player; currentSpeakingTo = startActor; // Update the Actors used by the camera SetCameraActors(); // Clear the screen if need be if ( event.bClearScreen ) conWinThird.Clear(); // Okay, we want to create as many buttons as we have choices // and display them. We'll then return and let conPlay get some // user input. choice = event.ChoiceList; choiceCount = 0; while( choice != None ) { // Before we blindly display this choice, we first need to check a // few things. Specifically: // // 1. Check to see if any flags are associated with this choice. // 2. Check to see if this choice is skill-based. // 3. If there are *NO* valid choices, skip to the next event // as a failsafe // // If the above conditions are met, then display the choice. if ( player.CheckFlagRefs( choice.flagRef ) ) { // Now check the skills if ( choice.skillNeeded != None ) { // Does player have it? if ( player.SkillSystem.IsSkilled(choice.skillNeeded, choice.skillLevelNeeded) ) { // Display the choice with some feedback! conWinThird.DisplaySkillChoice( choice ); choiceCount++; } } else { // Plain old vanilla choice conWinThird.DisplayChoice(choice); choiceCount++; } } choice = choice.nextChoice; } nextLabel = ""; if ( choiceCount > 0 ) nextAction = EA_WaitForInput; else nextAction = EA_NextEvent; // Okay to accept user input again if (conWinThird != None) conWinThird.RestrictInput(False); return nextAction; } // ---------------------------------------------------------------------- // SetupEventMoveCamera() // ---------------------------------------------------------------------- function EEventAction SetupEventMoveCamera( ConEventMoveCamera event, out String nextLabel ) { pendingCameraEvent = event; nextLabel = ""; return EA_NextEvent; } // ---------------------------------------------------------------------- // SetupEventEnd() // ---------------------------------------------------------------------- function EEventAction SetupEventEnd( ConEventEnd event, out String nextLabel ) { nextLabel = ""; return EA_End; } // ---------------------------------------------------------------------- // ---------------------------------------------------------------------- defaultproperties { perCharDelay=0.100000 minimumTextPause=3.000000 ConversationSpeechFonts(0)=Font'DeusExUI.FontConversation' ConversationSpeechFonts(1)=Font'DeusExUI.FontConversationLarge' ConversationNameFonts(0)=Font'DeusExUI.FontConversationBold' ConversationNameFonts(1)=Font'DeusExUI.FontConversationLargeBold' bHidden=True } |
Overview | Package | Class | Source | Class tree | Glossary | Deus Ex UnrealScript Documentation |
previous class next class | frames no frames |