// // CPT operator / SondeerGame // This source file is (c) by Deltares. // - October 2014 // /// jln - 12-09-2008 One line in a conversation (but can contain multiple synonyms) class ConversationNode extends Object; /// The answers or replies for this message: var array messages; /// The event name to trigger when the message is displayed var string eventname; /// Is this the end of the conversation? var bool conversationend; function AddString(string str) { /// Split string using string separator: messages = Split(str, "#"); } function SetConversationEnd(int end) { Log("end: " @ end); conversationend = (end == 1); } function bool GetConversationEnd() { return conversationend; } function SetEventName(string str) { eventname = str; } function string GetEventName() { return eventname; } function string GetString() { local int rnd; rnd = Rand( Messages.Length ); //Log("Random: " @ rnd @ " - message length: " @ Messages.Length); return messages[rnd]; } /** str = input string div = divider **/ function array Split(string str, string div) { local array temp; local bool bEOL; local string tempChar; local int precount, curcount, wordcount, strLength; strLength = len(str); bEOL = false; precount = 0; curcount = 0; wordcount = 0; if (strLength == 0) return temp; while(!bEOL) { tempChar = Mid(str, curcount, 1); //go up by 1 count if(tempChar != div) curcount++; else if(tempChar == div) { temp[wordcount] = Mid(str, precount, curcount-precount); wordcount++; precount = curcount + 1; //removes the divider. curcount++; } if(curcount == strLength)//end of string, flush out the final word. { temp[wordcount] = Mid(str, precount, curcount); bEOL = true; } } return temp; }