Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

ConSys.Conversation


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
//=============================================================================
// Conversation
//=============================================================================
class Conversation extends ConObject
    native
    noexport;

var Name         conName;               // Conversation Name
var String       Description;           // Description
var String       CreatedBy;             // Who created event
var String       conOwnerName;          // Name of Actor owner
var Bool         bDataLinkCon;          // True if this is a DataLink conversation

var Bool         bDisplayOnce;          // Flag to display conversation only once
var Bool         bFirstPerson;          // Remain in First-Person mode
var Bool         bNonInteractive;       // True if non-interactive conversation
var Bool         bRandomCamera;         // True if random camera placement
var Bool         bCanBeInterrupted;     // True if this conversation can be interrupted by another
var Bool         bCannotBeInterrupted;  // True if this conversation CANNOT be interrupted by another
var Bool         bGenerateAudioNames;   // True if we're to auto-generate filenames for the audio

var Bool         bInvokeBump;           // Invoke by Bumping
var Bool         bInvokeFrob;           // Invoke by Frobbing
var Bool         bInvokeSight;          // Invoke by Sight
var Bool         bInvokeRadius;         // Invoke by Radius
var Int          radiusDistance;        // Distance from PC needed to invoke conversation, 0 = Frob

var ConEvent     eventList;             // First Event
var ConFlagRef   flagRefList;           // Flag List

var int          conversationID;        // Internal Conversation ID

// Unique identifier of audio package.  This is used to generate
// audio names so we can demand load audio from a package
var String       audioPackageName;

var Float        lastPlayedTime;        // Time when conversation last played (ended).
var Int          ownerRefCount;         // Number of owners this conversation has

intrinsic(2050) final function ConFlagRef CreateFlagRef( Name flagName, bool flagValue );
intrinsic(2051) final function ConCamera CreateConCamera();
intrinsic(2052) final function BindEvents(Actor conBoundActors[10], Actor invokeActor);
intrinsic(2053) final function BindActorEvents(Actor actorToBind);
intrinsic(2054) final function ClearBindEvents();
intrinsic(2055) final function Sound GetSpeechAudio(int soundID);
intrinsic(2056) final function Float GetSpeechLength(int soundID);

// ----------------------------------------------------------------------
// GetEventFromLabel()
//
// Searches this conversation for a label and returns it.  If it can't
// find a matching label then it returns None.
// ----------------------------------------------------------------------

function ConEvent GetEventFromLabel( String searchLabel )
{
    local ConEvent currentEvent;

    currentEvent = eventList;

    while( currentEvent != None )
    {
        if ( Caps(searchLabel) == Caps(currentEvent.Label) )
            break;

        currentEvent = currentEvent.nextEvent;
    }   

    return currentEvent;
}

// ----------------------------------------------------------------------
// AddFlagRef()
//
// Adds a flag reference, using the given flag name and value passed in
// ----------------------------------------------------------------------

function AddFlagRef( Name flagName, Bool value )
{
    local ConFlagRef newFlagRef;
    local ConFlagRef refChain;
    local ConFlagRef refMatch;
    
    newFlagRef = CreateFlagRef( flagName, value );
    
    // Now search through our flag refs to see if we already have a 
    // flag ref by this name

    refChain = flagRefList;
    refMatch = None;

    while( refChain != None )
    {
        if ( refChain.flagName == flagName )
        {
            refMatch = refChain;
            break;
        } 
        refChain = refChain.nextFlagRef;
    }

    // If we found a match, then update the value.  Otherwise 
    // insert this flag ref at the top of the food chain

    if ( refMatch != None )
    {
        refMatch.value = value;
    }
    else
    {
        newFlagRef.nextFlagRef = flagRefList;
        flagRefList = newFlagRef;
    }   
}

// ----------------------------------------------------------------------
// CheckActors()
//
// Checks to see if all the actors doing speaking in the conversation
// actually exist.
// ----------------------------------------------------------------------

function bool CheckActors(optional bool bLogActors)
{
    local ConEvent event;
    local ConEventSpeech eventSpeech;
    local bool bActorsValid;

    bActorsValid = True;
    event = eventList;

    while(event != None)
    {
        eventSpeech = ConEventSpeech(event);
        if (eventSpeech != None)
        {
            if ((eventSpeech.speaker == None) || (eventSpeech.speakingTo == None))
            {
                bActorsValid = False;

                if (bLogActors)
                {
                    if (eventSpeech.speaker == None)
                        log("  SpeakingActor   =" @ eventSpeech.speakerName);
                    if (eventSpeech.speakingTo == None)
                        log("  SpeakingToActor =" @ eventSpeech.speakingToName);
                }
                else
                {
                    break;
                }           
            }
        }

        event = event.nextEvent;
    }

    return bActorsValid;
}

// ----------------------------------------------------------------------
// CheckActorDistances()
//
// Checks to see how far all the actors are away from each other 
// to make sure it's reasonable to start a conversation.
// Ignore the player in these checks.
// ----------------------------------------------------------------------

function bool CheckActorDistances(Actor player)
{
    local ConEvent event;
    local ConEventSpeech eventSpeech;
    local int  actorIndex;
    local Int  dist;
    local bool bDistanceValid;

    bDistanceValid = True;

    event = eventList;

    // First fill up our array of actors
    while(event != None)
    {
        eventSpeech = ConEventSpeech(event);
        if (eventSpeech != None)
        {
            // Check the distance between the two actors
            if ((eventSpeech.speaker != None) && (eventSpeech.speaker != player) && 
                (eventSpeech.speakingTo != None) && (eventSpeech.speakingTo != player))
            {
                dist = VSize(eventSpeech.speaker.Location - eventSpeech.speakingTo.Location);

                if (dist > 300)
                {
                    bDistanceValid = False;
                    break;
                }
            }
        }
        event = event.nextEvent;
    }

    return bDistanceValid;
}

// ----------------------------------------------------------------------
// GetFirstSpeechActors()
//
// Looks for the first Speech event in this conversation and returns
// the speaker and speakingTo actors.  This is used to setup the first
// camera event
// ----------------------------------------------------------------------

function GetFirstSpeechActors( out Actor firstSpeaker, out Actor firstSpeakingTo )
{
    local ConEvent conEvent;

    conEvent = eventList;

    firstSpeaker    = None;
    firstSpeakingTo = None;

    while( conEvent != None )
    {   
        if ( ConEventSpeech( conEvent ) != None )
        {   
            firstSpeaker    = ConEventSpeech( conEvent ).speaker;
            firstSpeakingTo = ConEventSpeech( conEvent ).speakingTo;
            break;
        }
        conEvent = conEvent.nextEvent;
    }
}

// ----------------------------------------------------------------------
// GetFirstSpeakerDisplayName()
// ----------------------------------------------------------------------

function String GetFirstSpeakerDisplayName(optional String startLabel)
{
    local ConEvent conEvent;
    local Conversation con;
    local String   speakerName;

    if (startLabel != "")
        conEvent = GetEventFromLabel(startLabel);
    else
        conEvent = eventList;

    while(conEvent != None)
    {   
        // Follow any jump events
        if (ConEventJump(conEvent) != None)
        {
            if (ConEventJump(conEvent).jumpCon != None)
            {
                con = ConEventJump(conEvent).jumpCon;
                speakerName = con.GetFirstSpeakerDisplayName(ConEventJump(conEvent).jumpLabel);
                break;
            }
        }

        // If this is a speech event, grab the name and quit.
        if (ConEventSpeech(conEvent) != None)
        {   
            speakerName = ConEventSpeech(conEvent).speakerName;
            break;
        }
        conEvent = conEvent.nextEvent;
    }

    return speakerName;
}

// ----------------------------------------------------------------------
// IsSpeakingActor()
//
// Looks to see if the actor passed in is even involved in this
// conversation.  Returns True if the actor has a speaking part.
// ----------------------------------------------------------------------

function Bool IsSpeakingActor(Actor speakingActor)
{
    local bool bSpeaking;
    local ConEventSpeech eventSpeech;
    local ConEvent event;

    event = eventList;

    while(event != None)
    {
        eventSpeech = ConEventSpeech(event);
        if (eventSpeech != None)
        {
            if ((eventSpeech.speakerName == speakingActor.BindName) || (eventSpeech.speakingToName == speakingActor.BindName))
            {
                bSpeaking = True;
                break;
            }
        }
        event = event.nextEvent;
    }

    return bSpeaking;
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

defaultproperties
{
     bGenerateAudioNames=True
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mon 8/11/2021 16:22:50.000 - Creation time: Mon 8/11/2021 16:31:24.840 - Created with UnCodeX