D
Doomknight
[DIALOGUE LINE]
[ADVANCED DIALOGUE CONTROLLER]
[DIALOGUE STATE]
package obj.dialogue
{
import com.adobe.serialization.json.*;
import obj.*;
public class DialogueLine extends Object
{
public var _settings:Object;
public var _style:String;
public var _mood:String;
public var _held:String;
public var _nextLine:String;
public var _phrase:String;
public static var SPEAKING_STYLE:String = "Speak";
public static var THOUGHT_STYLE:String = "Thought";
public static var HIM_STYLE:String = "Him";
public static var advancedController:AdvancedDialogueController;
public function DialogueLine(param1:String, param2:Object = null) : void
{
this._phrase = param1;
if (param2)
{
this._settings = param2;
if (param2["style"])
{
this._style = param2["style"];
}
if (param2["mood"])
{
this._mood = param2["mood"];
}
if (param2["held"])
{
this._held = param2["held"];
}
if (param2["next"])
{
this._nextLine = param2["next"];
}
}
else
{
this._settings = {};
}
return;
}// end function
public function get phrase() : String
{
return this._phrase;
}// end function
public function get settings() : Object
{
return this._settings;
}// end function
public function get style() : String
{
return this._style ? (this._style) : (SPEAKING_STYLE);
}// end function
public function get mood() : String
{
return this._mood ? (this._mood) : ("");
}// end function
public function get held() : String
{
return this._held ? (this._held) : ("");
}// end function
public function get nextLine() : String
{
return this._nextLine;
}// end function
public function get canPlay() : Boolean
{
if (advancedController && !advancedController.canPlay(this))
{
return false;
}
if (g.her.passedOut && this._style == THOUGHT_STYLE)
{
return false;
}
if ((!this._style || this._style == SPEAKING_STYLE) && !g.her.canSpeak())
{
return false;
}
if (this._mood && g.her.mood != this._mood)
{
return false;
}
if (this._held)
{
if (this._held == "true" && Him.armPositions[g.him.currentArmPosition] != "Holding")
{
return false;
}
if (this._held == "false" && Him.armPositions[g.him.currentArmPosition] != "Free")
{
return false;
}
}
return true;
}// end function
public function export() : String
{
var settingsObjectString:String;
var settingsObject:Object;
if (this._style && this._style != SPEAKING_STYLE)
{
settingsObject["style"] = this._style;
}
if (this._mood)
{
settingsObject["mood"] = this._mood;
}
if (this._nextLine)
{
settingsObject["next"] = this._nextLine;
}
if (this._held)
{
settingsObject["held"] = this._held;
}
if (this._settings["set"])
{
settingsObject["set"] = this._settings["set"];
}
if (this._settings["check"])
{
settingsObject["check"] = this._settings["check"];
}
try
{
settingsObjectString = JSON.encode(settingsObject);
}
catch (e:Error)
{
}
if (settingsObjectString == "{}")
{
settingsObjectString;
}
return "\"" + this._phrase + "\"" + settingsObjectString;
}// end function
}
}
{
import com.adobe.serialization.json.*;
import obj.*;
public class DialogueLine extends Object
{
public var _settings:Object;
public var _style:String;
public var _mood:String;
public var _held:String;
public var _nextLine:String;
public var _phrase:String;
public static var SPEAKING_STYLE:String = "Speak";
public static var THOUGHT_STYLE:String = "Thought";
public static var HIM_STYLE:String = "Him";
public static var advancedController:AdvancedDialogueController;
public function DialogueLine(param1:String, param2:Object = null) : void
{
this._phrase = param1;
if (param2)
{
this._settings = param2;
if (param2["style"])
{
this._style = param2["style"];
}
if (param2["mood"])
{
this._mood = param2["mood"];
}
if (param2["held"])
{
this._held = param2["held"];
}
if (param2["next"])
{
this._nextLine = param2["next"];
}
}
else
{
this._settings = {};
}
return;
}// end function
public function get phrase() : String
{
return this._phrase;
}// end function
public function get settings() : Object
{
return this._settings;
}// end function
public function get style() : String
{
return this._style ? (this._style) : (SPEAKING_STYLE);
}// end function
public function get mood() : String
{
return this._mood ? (this._mood) : ("");
}// end function
public function get held() : String
{
return this._held ? (this._held) : ("");
}// end function
public function get nextLine() : String
{
return this._nextLine;
}// end function
public function get canPlay() : Boolean
{
if (advancedController && !advancedController.canPlay(this))
{
return false;
}
if (g.her.passedOut && this._style == THOUGHT_STYLE)
{
return false;
}
if ((!this._style || this._style == SPEAKING_STYLE) && !g.her.canSpeak())
{
return false;
}
if (this._mood && g.her.mood != this._mood)
{
return false;
}
if (this._held)
{
if (this._held == "true" && Him.armPositions[g.him.currentArmPosition] != "Holding")
{
return false;
}
if (this._held == "false" && Him.armPositions[g.him.currentArmPosition] != "Free")
{
return false;
}
}
return true;
}// end function
public function export() : String
{
var settingsObjectString:String;
var settingsObject:Object;
if (this._style && this._style != SPEAKING_STYLE)
{
settingsObject["style"] = this._style;
}
if (this._mood)
{
settingsObject["mood"] = this._mood;
}
if (this._nextLine)
{
settingsObject["next"] = this._nextLine;
}
if (this._held)
{
settingsObject["held"] = this._held;
}
if (this._settings["set"])
{
settingsObject["set"] = this._settings["set"];
}
if (this._settings["check"])
{
settingsObject["check"] = this._settings["check"];
}
try
{
settingsObjectString = JSON.encode(settingsObject);
}
catch (e:Error)
{
}
if (settingsObjectString == "{}")
{
settingsObjectString;
}
return "\"" + this._phrase + "\"" + settingsObjectString;
}// end function
}
}
[ADVANCED DIALOGUE CONTROLLER]
package obj.dialogue
{
import flash.utils.*;
public class AdvancedDialogueController extends Object
{
public var _dialogueDataStore:Dictionary;
public function AdvancedDialogueController() : void
{
this.reset();
return;
}// end function
public function reset() : void
{
this._dialogueDataStore = new Dictionary();
return;
}// end function
public function readAdvancedLineSettings(param1:DialogueLine) : void
{
if (param1.settings["set"])
{
this.setValues(param1.settings["set"]);
}
return;
}// end function
public function setValues(param1:Object) : void
{
var _loc_2:String = null;
var _loc_3:Object = null;
for (_loc_2 in param1)
{
_loc_3 = param1[_loc_2];
if (_loc_3 is String && !isNaN(Number(_loc_3)))
{
if (!this._dialogueDataStore.hasOwnProperty(_loc_2))
{
this._dialogueDataStore[_loc_2] = 0;
}
if ((_loc_3 as String).charAt(0) == "-")
{
this._dialogueDataStore[_loc_2] = this._dialogueDataStore[_loc_2] + Number(_loc_3);
this.outputLog(_loc_2 + ": " + "decrement by " + Number(_loc_3) + " = " + this._dialogueDataStore[_loc_2]);
}
else if ((_loc_3 as String).charAt(0) == "+")
{
this._dialogueDataStore[_loc_2] = this._dialogueDataStore[_loc_2] + Number(_loc_3);
this.outputLog(_loc_2 + ": " + "increment by " + Number(_loc_3) + " = " + this._dialogueDataStore[_loc_2]);
}
continue;
}
this.outputLog("Storing " + _loc_2 + " = " + _loc_3);
this._dialogueDataStore[_loc_2] = _loc_3;
}
return;
}// end function
public function canPlay(param1:DialogueLine) : Boolean
{
var _loc_2:Object = null;
var _loc_3:String = null;
var _loc_4:Object = null;
var _loc_5:Boolean = false;
var _loc_6:Number = NaN;
var _loc_7:Object = null;
var _loc_8:Boolean = false;
if (param1.settings["check"])
{
this.outputLog("Running checks for line: \"" + param1.phrase + "\"");
_loc_2 = param1.settings["check"];
for (_loc_3 in _loc_2)
{
_loc_4 = _loc_2[_loc_3];
_loc_5 = _loc_4 is Number;
_loc_6 = Number(_loc_4.toString().replace(/[>|<|=]""[>|<|=]/g, ""));
if (!_loc_5 && _loc_4 is String)
{
_loc_5 = !isNaN(_loc_6);
}
_loc_7 = this._dialogueDataStore.hasOwnProperty(_loc_3) ? (this._dialogueDataStore[_loc_3]) : (_loc_5 ? (0) : (false));
if (_loc_7 is Number && _loc_4 is String && _loc_5)
{
_loc_8 = true;
if (_loc_4.charAt(0) == ">")
{
if (_loc_4.charAt(1) == "=")
{
_loc_8 = _loc_7 >= _loc_6;
}
else
{
_loc_8 = _loc_7 > _loc_6;
}
}
else if (_loc_4.charAt(0) == "<")
{
if (_loc_4.charAt(1) == "=")
{
_loc_8 = _loc_7 <= _loc_6;
}
else
{
_loc_8 = _loc_7 < _loc_6;
}
}
else
{
_loc_8 = _loc_7 == _loc_6;
}
if (!_loc_8)
{
this.outputLog(" Line will not play: \"" + _loc_3 + "\" needs to be " + _loc_4 + " but is currently set to " + this._dialogueDataStore[_loc_3]);
return false;
}
}
if (_loc_7 is Boolean && (_loc_4 == "true" || _loc_4 == "false"))
{
_loc_4 = _loc_4 == "true";
}
if (!(_loc_5 && _loc_4 is String) && _loc_7 != _loc_4)
{
this.outputLog(" Line will not play: \"" + _loc_3 + "\" needs to be " + _loc_4 + " but is currently set to " + this._dialogueDataStore[_loc_3]);
return false;
}
}
this.outputLog(" Okay.");
}
return true;
}// end function
public function replaceValues(param1:String) : String
{
return param1.replace(/\*(.*?)\*""\*(.*?)\*/gi, this.customValueReplacer);
}// end function
public function customValueReplacer() : String
{
if (arguments.length == 4 && this._dialogueDataStore.hasOwnProperty(arguments[1]))
{
return this._dialogueDataStore[arguments[1]];
}
return "";
}// end function
public function outputLog(param1:String) : void
{
g.dialogueEditor.appendLog(param1);
return;
}// end function
}
}
{
import flash.utils.*;
public class AdvancedDialogueController extends Object
{
public var _dialogueDataStore:Dictionary;
public function AdvancedDialogueController() : void
{
this.reset();
return;
}// end function
public function reset() : void
{
this._dialogueDataStore = new Dictionary();
return;
}// end function
public function readAdvancedLineSettings(param1:DialogueLine) : void
{
if (param1.settings["set"])
{
this.setValues(param1.settings["set"]);
}
return;
}// end function
public function setValues(param1:Object) : void
{
var _loc_2:String = null;
var _loc_3:Object = null;
for (_loc_2 in param1)
{
_loc_3 = param1[_loc_2];
if (_loc_3 is String && !isNaN(Number(_loc_3)))
{
if (!this._dialogueDataStore.hasOwnProperty(_loc_2))
{
this._dialogueDataStore[_loc_2] = 0;
}
if ((_loc_3 as String).charAt(0) == "-")
{
this._dialogueDataStore[_loc_2] = this._dialogueDataStore[_loc_2] + Number(_loc_3);
this.outputLog(_loc_2 + ": " + "decrement by " + Number(_loc_3) + " = " + this._dialogueDataStore[_loc_2]);
}
else if ((_loc_3 as String).charAt(0) == "+")
{
this._dialogueDataStore[_loc_2] = this._dialogueDataStore[_loc_2] + Number(_loc_3);
this.outputLog(_loc_2 + ": " + "increment by " + Number(_loc_3) + " = " + this._dialogueDataStore[_loc_2]);
}
continue;
}
this.outputLog("Storing " + _loc_2 + " = " + _loc_3);
this._dialogueDataStore[_loc_2] = _loc_3;
}
return;
}// end function
public function canPlay(param1:DialogueLine) : Boolean
{
var _loc_2:Object = null;
var _loc_3:String = null;
var _loc_4:Object = null;
var _loc_5:Boolean = false;
var _loc_6:Number = NaN;
var _loc_7:Object = null;
var _loc_8:Boolean = false;
if (param1.settings["check"])
{
this.outputLog("Running checks for line: \"" + param1.phrase + "\"");
_loc_2 = param1.settings["check"];
for (_loc_3 in _loc_2)
{
_loc_4 = _loc_2[_loc_3];
_loc_5 = _loc_4 is Number;
_loc_6 = Number(_loc_4.toString().replace(/[>|<|=]""[>|<|=]/g, ""));
if (!_loc_5 && _loc_4 is String)
{
_loc_5 = !isNaN(_loc_6);
}
_loc_7 = this._dialogueDataStore.hasOwnProperty(_loc_3) ? (this._dialogueDataStore[_loc_3]) : (_loc_5 ? (0) : (false));
if (_loc_7 is Number && _loc_4 is String && _loc_5)
{
_loc_8 = true;
if (_loc_4.charAt(0) == ">")
{
if (_loc_4.charAt(1) == "=")
{
_loc_8 = _loc_7 >= _loc_6;
}
else
{
_loc_8 = _loc_7 > _loc_6;
}
}
else if (_loc_4.charAt(0) == "<")
{
if (_loc_4.charAt(1) == "=")
{
_loc_8 = _loc_7 <= _loc_6;
}
else
{
_loc_8 = _loc_7 < _loc_6;
}
}
else
{
_loc_8 = _loc_7 == _loc_6;
}
if (!_loc_8)
{
this.outputLog(" Line will not play: \"" + _loc_3 + "\" needs to be " + _loc_4 + " but is currently set to " + this._dialogueDataStore[_loc_3]);
return false;
}
}
if (_loc_7 is Boolean && (_loc_4 == "true" || _loc_4 == "false"))
{
_loc_4 = _loc_4 == "true";
}
if (!(_loc_5 && _loc_4 is String) && _loc_7 != _loc_4)
{
this.outputLog(" Line will not play: \"" + _loc_3 + "\" needs to be " + _loc_4 + " but is currently set to " + this._dialogueDataStore[_loc_3]);
return false;
}
}
this.outputLog(" Okay.");
}
return true;
}// end function
public function replaceValues(param1:String) : String
{
return param1.replace(/\*(.*?)\*""\*(.*?)\*/gi, this.customValueReplacer);
}// end function
public function customValueReplacer() : String
{
if (arguments.length == 4 && this._dialogueDataStore.hasOwnProperty(arguments[1]))
{
return this._dialogueDataStore[arguments[1]];
}
return "";
}// end function
public function outputLog(param1:String) : void
{
g.dialogueEditor.appendLog(param1);
return;
}// end function
}
}
[DIALOGUE STATE]
package obj.dialogue
{
import flash.utils.*;
public class DialogueState extends Object
{
public var _buildLevel:Number = 0;
public var _maxBuild:Number = 0;
public var _priority:uint = 0;
public var _prevPhrases:Dictionary;
public var _prevPhrasesLength:uint = 0;
public var _lastUsed:uint = 0;
public var _defaultReduceSpeed:Number = 1;
public var _noBuildDelay:uint = 0;
public function DialogueState(param1:Number, param2:uint, param3:Number = 1) : void
{
this._prevPhrases = new Dictionary();
this._maxBuild = param1;
this._priority = param2;
this._defaultReduceSpeed = param3;
return;
}// end function
public function buildState(param1:Number) : void
{
if (this._noBuildDelay == 0)
{
this._buildLevel = Math.min(this._maxBuild, this._buildLevel + param1);
}
return;
}// end function
public function reduce(param1:Number = -1) : void
{
if (param1 == -1)
{
param1 = this._defaultReduceSpeed;
}
if (this._noBuildDelay > 0)
{
var _loc_2:String = this;
var _loc_3:* = this._noBuildDelay - 1;
_loc_2._noBuildDelay = _loc_3;
}
this._buildLevel = Math.max(0, this._buildLevel - param1);
return;
}// end function
public function clearBuild() : void
{
this._buildLevel = 0;
return;
}// end function
public function delayBuild(param1:uint = 120) : void
{
this._noBuildDelay = param1;
return;
}// end function
public function maxBuild() : void
{
this._buildLevel = this._maxBuild;
return;
}// end function
public function randomPhrase(param1:Array) : uint
{
var _loc_5:uint = 0;
var _loc_6:uint = 0;
var _loc_2:* = param1.length;
if (this._prevPhrasesLength >= _loc_2)
{
this._prevPhrases = new Dictionary();
this._prevPhrases[this._lastUsed] = true;
this._prevPhrasesLength = 1;
}
var _loc_3:* = new Array();
var _loc_4:uint = 0;
while (_loc_4 < _loc_2)
{
if (!this._prevPhrases[_loc_4])
{
_loc_3.push(_loc_4);
}
_loc_4 = _loc_4 + 1;
}
if (_loc_3.length == 0)
{
this.clearPrevPhrases();
return 0;
}
_loc_5 = Math.floor(Math.random() * _loc_3.length);
_loc_6 = _loc_3[_loc_5];
this._prevPhrases[_loc_6] = true;
var _loc_7:String = this;
var _loc_8:* = this._prevPhrasesLength + 1;
_loc_7._prevPhrasesLength = _loc_8;
this._lastUsed = _loc_6;
return _loc_6;
}// end function
public function clearPrevPhrases() : void
{
this._prevPhrases = new Dictionary();
this._prevPhrasesLength = 0;
return;
}// end function
public function get build() : Number
{
return this._buildLevel;
}// end function
public function get max() : Number
{
return this._maxBuild;
}// end function
public function get priority() : uint
{
return this._priority;
}// end function
}
}
{
import flash.utils.*;
public class DialogueState extends Object
{
public var _buildLevel:Number = 0;
public var _maxBuild:Number = 0;
public var _priority:uint = 0;
public var _prevPhrases:Dictionary;
public var _prevPhrasesLength:uint = 0;
public var _lastUsed:uint = 0;
public var _defaultReduceSpeed:Number = 1;
public var _noBuildDelay:uint = 0;
public function DialogueState(param1:Number, param2:uint, param3:Number = 1) : void
{
this._prevPhrases = new Dictionary();
this._maxBuild = param1;
this._priority = param2;
this._defaultReduceSpeed = param3;
return;
}// end function
public function buildState(param1:Number) : void
{
if (this._noBuildDelay == 0)
{
this._buildLevel = Math.min(this._maxBuild, this._buildLevel + param1);
}
return;
}// end function
public function reduce(param1:Number = -1) : void
{
if (param1 == -1)
{
param1 = this._defaultReduceSpeed;
}
if (this._noBuildDelay > 0)
{
var _loc_2:String = this;
var _loc_3:* = this._noBuildDelay - 1;
_loc_2._noBuildDelay = _loc_3;
}
this._buildLevel = Math.max(0, this._buildLevel - param1);
return;
}// end function
public function clearBuild() : void
{
this._buildLevel = 0;
return;
}// end function
public function delayBuild(param1:uint = 120) : void
{
this._noBuildDelay = param1;
return;
}// end function
public function maxBuild() : void
{
this._buildLevel = this._maxBuild;
return;
}// end function
public function randomPhrase(param1:Array) : uint
{
var _loc_5:uint = 0;
var _loc_6:uint = 0;
var _loc_2:* = param1.length;
if (this._prevPhrasesLength >= _loc_2)
{
this._prevPhrases = new Dictionary();
this._prevPhrases[this._lastUsed] = true;
this._prevPhrasesLength = 1;
}
var _loc_3:* = new Array();
var _loc_4:uint = 0;
while (_loc_4 < _loc_2)
{
if (!this._prevPhrases[_loc_4])
{
_loc_3.push(_loc_4);
}
_loc_4 = _loc_4 + 1;
}
if (_loc_3.length == 0)
{
this.clearPrevPhrases();
return 0;
}
_loc_5 = Math.floor(Math.random() * _loc_3.length);
_loc_6 = _loc_3[_loc_5];
this._prevPhrases[_loc_6] = true;
var _loc_7:String = this;
var _loc_8:* = this._prevPhrasesLength + 1;
_loc_7._prevPhrasesLength = _loc_8;
this._lastUsed = _loc_6;
return _loc_6;
}// end function
public function clearPrevPhrases() : void
{
this._prevPhrases = new Dictionary();
this._prevPhrasesLength = 0;
return;
}// end function
public function get build() : Number
{
return this._buildLevel;
}// end function
public function get max() : Number
{
return this._maxBuild;
}// end function
public function get priority() : uint
{
return this._priority;
}// end function
}
}