// Token: 0x0600001C RID: 28 RVA: 0x000034EC File Offset: 0x000016EC public static void SetupAltarInteraction(ref Trainer altarTrainer, ref SkillSchool templarTreeInstance) { GameObject gameObject = GameObject.Find("DialogueAltar/NPC/InteractionActivatorSettings"); bool flag = gameObject != null; if (flag) { NPCInteraction componentInChildren = gameObject.GetComponentInChildren <NPCInteraction>(); bool flag2 = componentInChildren != null; if (flag2) { bool flag3 = componentInChildren.ActorLocKey == "name_unpc_altar_01"; if (flag3) { DialogueTreeController dialogueController = componentInChildren.NPCDialogue.DialogueController; Graph graph = dialogueController.graph; List <Node> allNodes = graph.allNodes; MultipleChoiceNodeExt multipleChoiceNodeExt = allNodes.FirstOrDefault(delegate(Node n) { bool result; if (n != null && n is MultipleChoiceNodeExt) { result = ((from m in ((MultipleChoiceNodeExt)n).availableChoices where m.statement.text == "(Offer a prayer to Elatt)" select m).ToList <MultipleChoiceNodeExt.Choice>().Count > 0); } else { result = false; } return(result); }) as MultipleChoiceNodeExt; bool flag4 = multipleChoiceNodeExt == null; if (!flag4) { string text = "(Swear an oath to Elatt.)"; MultipleChoiceNodeExt.Choice choice = new MultipleChoiceNodeExt.Choice(); choice.statement = new Statement(); choice.statement.text = text; choice.isUnfolded = true; multipleChoiceNodeExt.availableChoices.Insert(0, choice); ActionNode actionNode = graph.AddNode <ActionNode>(); allNodes.Add(actionNode); altarTrainer = new Trainer(); At.SetValue <UID>(UID.Generate(), typeof(Trainer), altarTrainer, "m_uid"); At.SetValue <UID>(templarTreeInstance.UID, typeof(Trainer), altarTrainer, "m_skillTreeUID"); actionNode.action = new TrainDialogueAction(); ((TrainDialogueAction)actionNode.action).Trainer = new BBParameter <Trainer>(altarTrainer); BBParameter <Character> bbparameter = new BBParameter <Character>(); bbparameter.name = "gInstigator"; ((TrainDialogueAction)actionNode.action).PlayerCharacter = bbparameter; graph.ConnectNodes(multipleChoiceNodeExt, actionNode, 0, -1); FinishNode finishNode = graph.AddNode <FinishNode>(); allNodes.Add(finishNode); graph.ConnectNodes(actionNode, finishNode, -1, -1); } } } } }
// Token: 0x0600001B RID: 27 RVA: 0x000033B0 File Offset: 0x000015B0 public static void SetupRufusInteraction() { GameObject gameObject = GameObject.Find("Dialogue_Rufus/NPC/DialogueTree_1_Initial"); bool flag = gameObject != null; if (flag) { DialogueTreeController component = gameObject.GetComponent <DialogueTreeController>(); bool flag2 = component != null; if (flag2) { Graph graph = component.graph; List <Node> allNodes = graph.allNodes; StatementNodeExt statementNodeExt = allNodes.FirstOrDefault((Node n) => n != null && n is StatementNodeExt && ((StatementNodeExt)n).statement.text.Contains("Elatt however... I’ve had the honor to speak with him. He is very real. Having a god that was once man is comforting.")) as StatementNodeExt; bool flag3 = statementNodeExt != null; if (flag3) { ActionNode actionNode = graph.AddNode <ActionNode>(); GiveReward giveReward = new GiveReward(); actionNode.action = giveReward; giveReward.RewardReceiver = GiveReward.Receiver.Instigator; NodeCanvas.Tasks.Actions.ItemQuantity itemQuantity = new NodeCanvas.Tasks.Actions.ItemQuantity(); itemQuantity.Item = new BBParameter <ItemReference>(new ItemReference { ItemID = Templar.Instance.prayerInstance.ItemID }); itemQuantity.Quantity = 1; giveReward.ItemReward = new List <NodeCanvas.Tasks.Actions.ItemQuantity> { itemQuantity }; statementNodeExt.outConnections[0] = Connection.Create(statementNodeExt, actionNode, -1, -1); FinishNode finishNode = graph.AddNode <FinishNode>(); allNodes.Add(finishNode); graph.ConnectNodes(actionNode, finishNode, -1, -1); } } } }
public static void OnActivate(NPCInteraction __instance) { try { //SoroboreanTravelAgency.Instance.MyLogger.LogDebug(__instance.ActorLocKey); Character character = CharacterManager.Instance.GetCharacter(CharacterManager.Instance.PlayerCharacters.Values[0]); if (character == null) { return; } if (StoreManager.Instance.IsDlcInstalled(OTWStoreAPI.DLCs.Soroboreans)) { return; } AreaEnum areaN = (AreaEnum)AreaManager.Instance.GetAreaIndexFromSceneName(SceneManagerHelper.ActiveSceneName); if (!SoroboreanTravelAgency.StartAreaToTravel.ContainsKey(areaN)) { return; } SoroboreanTravelAgency.TravelDayCost = (int)(float)SoroboreanTravelAgency.Instance.MyConfig.GetValue("Travel Day Cost"); // 80 - 100 - 120 if (areaN == AreaEnum.Levant) // TODO: check quest "Blood under the Sun" { SoroboreanTravelAgency.TravelDayCost = (int)(SoroboreanTravelAgency.TravelDayCost * 1.75); // 140 - 175 - 210 } // TODO: HallowPeaceGuardBlock if (__instance.ActorLocKey == "name_unpc_caravantrader_01") { var graphOwner = __instance.NPCDialogue.DialogueController; var graph = (Graph)graphOwner.GetType().BaseType.GetField("_graph", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(graphOwner as GraphOwner <DialogueTreeExt>); var nodes = typeof(Graph).GetField("_nodes", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(graph as Graph) as List <Node>; var firstNode = (nodes.First(n => n.GetType().Name == "MultipleChoiceNodeExt") as MultipleChoiceNodeExt); if (SoroboreanTravelAgency.DialogIsSet) { foreach (var node in graph.allNodes.Where(n => n.tag == "SoroboreanTravelAgency").ToList()) { graph.RemoveNode(node); } firstNode.availableChoices.RemoveAll(c => c.statement.meta == "TRAVEL"); } int cnt = firstNode.availableChoices.Count - 2; firstNode.availableChoices.Insert(cnt, new MultipleChoiceNodeExt.Choice(new Statement("I want to travel, please.", GlobalAudioManager.Sounds.BGM_Empty, "TRAVEL"))); StatementNodeExt nStart = graph.AddNode <StatementNodeExt>(); nStart.tag = "SoroboreanTravelAgency"; nStart.statement = new Statement($"Where do you want to go?"); nStart.SetActorName(__instance.ActorLocKey); StatementNodeExt nResultMoneyBad = graph.AddNode <StatementNodeExt>(); nResultMoneyBad.tag = "SoroboreanTravelAgency"; nResultMoneyBad.statement = new Statement("Sorry, you don't have enough silver. Come back when you can afford it!"); nResultMoneyBad.SetActorName(__instance.ActorLocKey); StatementNodeExt nResultRationsBad = graph.AddNode <StatementNodeExt>(); nResultRationsBad.tag = "SoroboreanTravelAgency"; nResultRationsBad.statement = new Statement("Sorry, you don't have enough rations to travel this far."); nResultRationsBad.SetActorName(__instance.ActorLocKey); StatementNodeExt nCancel = graph.AddNode <StatementNodeExt>(); nCancel.tag = "SoroboreanTravelAgency"; nCancel.statement = new Statement("See you soon!"); nCancel.SetActorName(__instance.ActorLocKey); FinishNode nFinish = graph.AddNode <FinishNode>(); nFinish.tag = "SoroboreanTravelAgency"; StatementNodeExt nNoDestination = graph.AddNode <StatementNodeExt>(); nNoDestination.tag = "SoroboreanTravelAgency"; nNoDestination.statement = new Statement("Sorry, you have not discovered any other town... You can only travel to places you visited at least once!"); nNoDestination.SetActorName(__instance.ActorLocKey); bool hasEntry = false; MultipleChoiceNodeExt nChoose = graph.AddNode <MultipleChoiceNodeExt>(); nChoose.tag = "SoroboreanTravelAgency"; foreach (StrTravel travel in SoroboreanTravelAgency.StartAreaToTravel[areaN]) { //if (!QuestEventManager.Instance.HasQuestEvent(SoroboreanTravelAgency.AreaToQuestEvent[travel.TargetArea])) if (!(bool)SoroboreanTravelAgency.Instance.MyConfig.GetValue(travel.TargetArea + "Visited")) { continue; // This town has not been visited yet } hasEntry = true; string areaLabel = travel.TargetArea.ToString(); if (travel.TargetArea == AreaEnum.CierzoVillage) { areaLabel = "Cierzo"; } int rationsCost = travel.DurationDays; int moneyCost = travel.DurationDays * SoroboreanTravelAgency.TravelDayCost; string msgCost = $"{areaLabel} ({moneyCost} silver and {rationsCost} rations)."; if (travel.DurationDays == 0) { rationsCost = 0; moneyCost = SoroboreanTravelAgency.TravelDayCost; msgCost = $"{areaLabel} ({moneyCost} silver)."; } nChoose.availableChoices.Add(new MultipleChoiceNodeExt.Choice(new Statement(msgCost))); ConditionNode nCheckMoney = graph.AddNode <ConditionNode>(); nCheckMoney.tag = "SoroboreanTravelAgency"; nCheckMoney.condition = new Condition_OwnsItem() { character = character, item = new ItemReference { ItemID = 9000010 }, minAmount = moneyCost }; ConditionNode nCheckRations = graph.AddNode <ConditionNode>(); nCheckRations.tag = "SoroboreanTravelAgency"; nCheckRations.condition = new Condition_OwnsItem() { character = character, item = new ItemReference { ItemID = 4100550 }, // Travel Ration minAmount = rationsCost }; graph.ConnectNodes(nChoose, nCheckMoney); ActionNode nWishRent = graph.AddNode <ActionNode>(); nWishRent.tag = "SoroboreanTravelAgency"; ActionList actions = new ActionList(); actions.AddAction(new NodeCanvas.Tasks.Actions.PlaySound() { Sound = GlobalAudioManager.Sounds.UI_MERCHANT_CompleteTransaction }); actions.AddAction(new NodeCanvas.Tasks.Actions.FadeOut() { fadeTime = 1.0f }); actions.AddAction(new SetTravelArea() { Script = SoroboreanTravelAgency.Instance, TargetArea = travel.TargetArea }); actions.AddAction(new AreaSwitchPlayersTime() { Character = new BBParameter <Character>(character), Area = travel.TargetArea, IncreaseTime = travel.DurationDays * 24 }); actions.AddAction(new NodeCanvas.Tasks.Actions.RemoveItem() { fromCharacter = new BBParameter <Character>(character), Items = new List <BBParameter <ItemReference> >() { new ItemReference { ItemID = 9000010 }, new ItemReference { ItemID = 4100550 } }, Amount = new List <BBParameter <int> >() { new BBParameter <int>(moneyCost), new BBParameter <int>(rationsCost) }, }); nWishRent.action = actions; graph.ConnectNodes(nCheckMoney, nCheckRations); graph.ConnectNodes(nCheckMoney, nResultMoneyBad); graph.ConnectNodes(nCheckRations, nWishRent); graph.ConnectNodes(nCheckRations, nResultRationsBad); graph.ConnectNodes(nWishRent, nFinish); } if (hasEntry) { graph.ConnectNodes(firstNode, nStart, cnt); nChoose.availableChoices.Add(new MultipleChoiceNodeExt.Choice(new Statement("Changed my mind."))); graph.ConnectNodes(nStart, nChoose); graph.ConnectNodes(nChoose, nCancel); } else { graph.ConnectNodes(firstNode, nNoDestination, cnt); } graph.ConnectNodes(nResultMoneyBad, nFinish); graph.ConnectNodes(nResultRationsBad, nFinish); graph.ConnectNodes(nNoDestination, nFinish); graph.ConnectNodes(nCancel, nFinish);//*/ SoroboreanTravelAgency.DialogIsSet = true; } } catch (Exception ex) { SoroboreanTravelAgency.Instance.MyLogger.LogError(ex.Message); } }
protected void OnFinishNode(NodeType node) { FinishNode?.Invoke(node); }
public static void DebugDialogue(Node p_node, int p_level, NodeCanvas.Status p_status = NodeCanvas.Status.Running) { string strTab = ""; for (int i = 0; i < p_level; i++) { strTab += " |-"; } strTab += " "; if (p_node.GetType().Name == "StatementNodeExt") { StatementNodeExt n = p_node as StatementNodeExt; string msg = n.statement.text; if (msg.Length > 60) { msg = msg.Substring(0, 60) + "..."; } OLogger.Log($"{strTab}{n.ID}: SAY \"{msg}\""); //OLogger.Log($"{strTab} outConnectionType={n.outConnectionType.GetType().Name}"); //OLogger.Log($"{strTab} isBreakpoint={n.isBreakpoint}"); //OLogger.Log($"{strTab} allowAsPrime={n.allowAsPrime}"); } else if (p_node.GetType().Name == "MultipleChoiceNodeExt") { MultipleChoiceNodeExt n = p_node as MultipleChoiceNodeExt; OLogger.Log($"{strTab}{n.ID}: MCH"); foreach (var choice in n.availableChoices) { int targetNodeId = n.availableChoices.IndexOf(choice); if (targetNodeId >= 0 && n.outConnections.Count > targetNodeId) { targetNodeId = n.outConnections[targetNodeId].targetNode.ID; } OLogger.Log($"{strTab}> {choice.condition?.name}\"{choice.condition?.GetType().Name} {choice.statement.text}\" --> {targetNodeId}"); } } else if (p_node.GetType().Name == "ConditionNode") { ConditionNode n = p_node as ConditionNode; string msg = $"{strTab}{n.ID}: CND"; if (n.condition != null) { /*switch (n.condition.GetType().Name) * { * default: * break; * }*/ msg += $" {n.condition.GetType().Name}"; } OLogger.Log(msg); } // TODO : MultipleConditionNode else if (p_node.GetType().Name == "ActionNode") { ActionNode n = p_node as ActionNode; OLogger.Log($"{strTab}{n.ID}: ACT {n.action?.GetType().Name} "); if (n.action.GetType().Name == "BranchDialogue") { OLogger.Log($"{(n.action as BranchDialogue).dialogueStarter.ToString()}"); } } else if (p_node.GetType().Name == "FinishNode") { FinishNode n = p_node as FinishNode; OLogger.Log($"{strTab}{n.ID}: END"); } else { OLogger.Log($"{strTab}{p_node.ID}: [{p_node.GetType().Name}]"); } foreach (var conn in p_node.outConnections) { DebugDialogue(conn.targetNode, p_level + 1, conn.status); } }
public static void OnActivate(NPCInteraction __instance) { try { AreaEnum areaN = (AreaEnum)AreaManager.Instance.GetAreaIndexFromSceneName(SceneManagerHelper.ActiveSceneName); if (!InnRentStash.StashAreaToQuestEvent.ContainsKey(areaN) || CharacterManager.Instance.PlayerCharacters.Count == 0) { return; } Character character = CharacterManager.Instance.GetCharacter(CharacterManager.Instance.PlayerCharacters.Values[0]); if (character == null) { return; } if (__instance.ActorLocKey != InnRentStash.StashAreaToQuestEvent[areaN].NpcName) { return; } var graphOwner = __instance.NPCDialogue.DialogueController; var graph = (Graph)graphOwner.GetType().BaseType.GetField("_graph", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(graphOwner as GraphOwner <DialogueTreeExt>); var nodes = typeof(Graph).GetField("_nodes", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(graph as Graph) as List <Node>; var firstNode = nodes.First(n => n.GetType().Name == "MultipleChoiceNodeExt") as MultipleChoiceNodeExt; foreach (var node in graph.allNodes.Where(n => n.tag == "InnRentStash").ToList()) { graph.RemoveNode(node); } firstNode.availableChoices.RemoveAll(c => c.statement.meta == "RENT"); //TreeNode<Node>.DebugDialogue(nodes[0], 0); /* Un dialogue c'est: afficher un texte + action(optionnel) + choix(optionnel) * * Outil de conversion Graph --> ma structure */ firstNode.availableChoices.Insert(1, new MultipleChoiceNodeExt.Choice(new Statement("I want to rent a stash, please.", GlobalAudioManager.Sounds.BGM_Empty, "RENT"))); StatementNodeExt nStart = graph.AddNode <StatementNodeExt>(); nStart.tag = "InnRentStash"; nStart.statement = new Statement($"Of course! Renting a stash costs only {InnRentStash.Instance.ConfigRentPrice.Value} silver for one week."); nStart.SetActorName(__instance.ActorLocKey); MultipleChoiceNodeExt nChoose = graph.AddNode <MultipleChoiceNodeExt>(); nChoose.tag = "InnRentStash"; nChoose.availableChoices.Add(new MultipleChoiceNodeExt.Choice(new Statement("Sh*t up and take my money!"))); nChoose.availableChoices.Add(new MultipleChoiceNodeExt.Choice(new Statement("I will be back."))); ConditionNode nCheckMoney = graph.AddNode <ConditionNode>(); nCheckMoney.tag = "InnRentStash"; nCheckMoney.condition = new Condition_OwnsItem() { character = character, item = new ItemReference { ItemID = 9000010 }, minAmount = InnRentStash.Instance.ConfigRentPrice.Value }; ConditionNode nCheckHouse = graph.AddNode <ConditionNode>(); nCheckHouse.tag = "InnRentStash"; nCheckHouse.condition = new Condition_QuestEventOccured() { QuestEventRef = new QuestEventReference { EventUID = InnRentStash.StashAreaToQuestEvent[areaN].PlayerHouseQuestEventUID } }; StatementNodeExt nCheckHouseBad = graph.AddNode <StatementNodeExt>(); nCheckHouseBad.tag = "InnRentStash"; nCheckHouseBad.statement = new Statement("You have a house, no need to rent a stash anymore."); nCheckHouseBad.SetActorName(__instance.ActorLocKey); ConditionNode nCheckAlready = graph.AddNode <ConditionNode>(); nCheckAlready.tag = "InnRentStash"; nCheckAlready.condition = new Condition_QuestEventOccured() { QuestEventRef = new QuestEventReference { EventUID = InnRentStash.StashAreaToQuestEvent[areaN].QuestEvent.EventUID } }; StatementNodeExt nCheckAlreadyBad = graph.AddNode <StatementNodeExt>(); nCheckAlreadyBad.tag = "InnRentStash"; nCheckAlreadyBad.statement = new Statement("You've already rented a stash for the week! Just use it."); nCheckAlreadyBad.SetActorName(__instance.ActorLocKey); ActionNode nWishRent = graph.AddNode <ActionNode>(); nWishRent.tag = "InnRentStash"; ActionList action = new ActionList(); action.AddAction(new NodeCanvas.Tasks.Actions.RemoveItem() { fromCharacter = new BBParameter <Character>(character), Items = new List <BBParameter <ItemReference> >() { new ItemReference { ItemID = 9000010 } }, Amount = new List <BBParameter <int> >() { new BBParameter <int>(InnRentStash.Instance.ConfigRentPrice.Value) }, }); action.AddAction(new NodeCanvas.Tasks.Actions.SendQuestEvent() { QuestEventRef = new QuestEventReference { EventUID = InnRentStash.StashAreaToQuestEvent[areaN].QuestEvent.EventUID } }); action.AddAction(new NodeCanvas.Tasks.Actions.PlaySound() { Sound = GlobalAudioManager.Sounds.UI_MERCHANT_CompleteTransaction }); nWishRent.action = action; StatementNodeExt nResultOk = graph.AddNode <StatementNodeExt>(); nResultOk.tag = "InnRentStash"; nResultOk.statement = new Statement("Thanks, I've unlocked the stash for you."); nResultOk.SetActorName(__instance.ActorLocKey); StatementNodeExt nResultBad = graph.AddNode <StatementNodeExt>(); nResultBad.tag = "InnRentStash"; nResultBad.statement = new Statement("Sorry, you don't have enough silver. Come back when you can afford it!"); nResultBad.SetActorName(__instance.ActorLocKey); StatementNodeExt nCancel = graph.AddNode <StatementNodeExt>(); nCancel.tag = "InnRentStash"; nCancel.statement = new Statement("See you soon!"); nCancel.SetActorName(__instance.ActorLocKey); FinishNode nFinish = graph.AddNode <FinishNode>(); nFinish.tag = "InnRentStash"; graph.ConnectNodes(firstNode, nCheckHouse, 1); // Check if the player owns the house of the town graph.ConnectNodes(nCheckHouse, nCheckHouseBad); // The player owns it --> exit graph.ConnectNodes(nCheckHouse, nCheckAlready); // Check if the player has already a rent ongoing in the town graph.ConnectNodes(nCheckAlready, nCheckAlreadyBad); // The player already has the rent --> exit graph.ConnectNodes(nCheckAlready, nStart); // All checks successfull, we can show the pricefor the rent graph.ConnectNodes(nStart, nChoose); // Show the choices for the player (to rent or not) graph.ConnectNodes(nChoose, nCheckMoney); // Check if the player has enough money graph.ConnectNodes(nChoose, nCancel); // The player doesn't want to rent --> exit graph.ConnectNodes(nCheckMoney, nWishRent); // The player has enough money, go activate the rent graph.ConnectNodes(nCheckMoney, nResultBad); // The player doesn't have enough money --> exit graph.ConnectNodes(nWishRent, nResultOk); // Activate the rent! graph.ConnectNodes(nCheckHouseBad, nFinish); graph.ConnectNodes(nCheckAlreadyBad, nFinish); graph.ConnectNodes(nResultBad, nFinish); graph.ConnectNodes(nResultOk, nFinish); graph.ConnectNodes(nCancel, nFinish);//*/ } catch (Exception ex) { InnRentStash.MyLogger.LogError("OnActivate: " + ex.Message); } }