Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation
previous class next class | frames no frames

# Tyrion.AI_Talk

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

    //=====================================================================
    // AI_Talk
    //=====================================================================

    class AI_Talk extends AI_CharacterAction
    	editinlinenew;

    //=====================================================================
    // Variables

    var(Parameters) Name lipsyncAnimName "Name of the lipsync animation to play";
    var(Parameters) Name subtitleTag "The localization tag for the subtitle text of the dialogue";
    var(Parameters) Name targetName "The pawn to talk to";
    var(Parameters) Rotator facing "Where the AI turns to before talking if targetName is none";
    var(Parameters) bool bNeedsToTurn "If true the targetName and facing values will be used";
    var(Parameters) bool bPositional "Whether the sound is to be positional or 2D";
    var(Parameters) bool bWaitForSpeech "Whether the action should wait till the sound has finished playing before continuing";

    var(InternalParameters) editconst Pawn target;

    // totally internal
    var float speechDuration;

    //=====================================================================
    // Functions

    //---------------------------------------------------------------------
    // Make sure the speech stops

    function cleanup()
    {
    	super.cleanup();

    	if(! achievingGoal.wasAchieved())
    		character().Level.speechManager.CancelSpeech(character());
    }

    //=====================================================================
    // State code

    state Running
    {
    Begin:
    	if ( pawn.logTyrion )
    		log( name @ "(" @ pawn.name @ ") is starting to talk." );

    	// block all the character's resources
    	if ( target == None && targetName != 'None')
    	{
    		target = Pawn(pawn.findByLabel( class'Engine.Pawn', targetName ));

    		if ( target == None )
    		{
    			log( "AI WARNING:" @ name @ "can't find specified pawn" );
    			fail( ACT_INVALID_PARAMETERS, true );
    		}
    	}

    	if ( target != None )
    		facing = Rotator(target.Location - pawn.Location);

    	if ( bNeedsToTurn && resource.requiredResourcesAvailable( achievingGoal.priority, 0, 0 ) )
    	{
    		waitForGoal( (new class'AI_TurnGoal'( movementResource(), achievingGoal.priority, facing )).postGoal( self ), true );
    	}

    	useResources( class'AI_Resource'.const.RU_HEAD );
    	speechDuration = pawn.Level.speechManager.PlayScriptedSpeech( pawn, lipsyncAnimName, bPositional );

    	if ( bWaitForSpeech )
    		sleep( speechDuration );

    	// catch this here just in case
    	while ( class'Pawn'.static.checkAlive( pawn ) && pawn.IsPlayingLIPSincAnim() )
    		yield();

    	if ( pawn.logTyrion )
    		log( name @ "(" @ pawn.name @ ") stopped." );
    	succeed();
    }

    //=====================================================================

    defaultproperties
    {
    	satisfiesGoal = class'AI_TalkGoal'
    }

Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation
previous class next class | frames no frames

Class file time: ne 5.9.2004 15:54:06.000 - Creation time: st 23.5.2018 00:10:41.818 - Created with UnCodeX