/// <summary> /// Sets the parameters of a conditional functor - with a String value /// </summary> /// <param name="fun">The conditional functor</param> /// <param name="paramNumber">The parameter number</param> /// <param name="value">The value of the parameter</param> private static void setParam(ref NWN2ConditionalFunctor fun, int paramNumber, string value) { fun.Parameters.Add(new NWN2ScriptParameter()); fun.Parameters[paramNumber].ParameterType = NWN2ScriptParameterType.String; fun.Parameters[paramNumber].ValueString = value; }
/// <summary> /// Sets the conditional values to ensure that a conversation will only fire when needed /// </summary> /// <param name="questName">The name of the quest</param> /// <returns>The functor</returns> private NWN2ConditionalFunctor conditional(string questName) { //I set the parameters of the condition NWN2ConditionalFunctor conditionalFunctor = null; if (preReqNode != null) { /* If we have the simple prerequisite, then the variable must be greater-or-equal to fire. * So, since there is no built in greater-or-equal, I just apply the fact that greater-or-equal * is the same as the negatation of less-than */ String condValue = preReqNode.questId.ToString(); if (preReq == EnumTypes.prereq.SimplePrereq) { condValue = "<" + condValue; } conditionalFunctor = makeJournalCheck(questName, condValue); conditionalFunctor.Not = preReq == EnumTypes.prereq.SimplePrereq; } else if (happensEnum == EnumTypes.happens.Trigger && triggerHappens != convType.None) { // If we have either an escort mission or an explore mission, I need to check if the value is correct conditionalFunctor = new NWN2ConditionalFunctor(); String tempStringName = ""; String tempStringValue = ""; if (triggerHappens == convType.Escort) { tempStringName = "sCreatureToEscort"; tempStringValue = actor.Tag; } else if (triggerHappens == convType.Explore) { tempStringName = "sTriggerToFind"; tempStringValue = trigger.Tag; } if (tempStringName != "") { conditionalFunctor.Script = makeScript("gc_global_string"); setParam(ref conditionalFunctor, 0, tempStringName); setParam(ref conditionalFunctor, 1, tempStringValue); } } return conditionalFunctor; }
/// <summary> /// Creates a functor which will check whether it is the 0 node /// </summary> /// <returns>The functor</returns> private static NWN2ConditionalFunctor node() { NWN2ConditionalFunctor node = new NWN2ConditionalFunctor(); node.Script = makeScript("gc_node"); // I add the parameters setParam(ref node, 0, 1); return node; }
private static NWN2ConditionalFunctor makeJournalCheck(string questName, string condValue) { NWN2ConditionalFunctor conditionalFunctor = new NWN2ConditionalFunctor(); // I make the journal check conditionalFunctor.Script = makeScript("gc_journal_entry"); questName = "Q_" + questNamePrep(questName); // I add the name of the quest setParam(ref conditionalFunctor, 0, questName); setParam(ref conditionalFunctor, 1, condValue); return conditionalFunctor; }
/// <summary> /// Creates a functor which will check the progression of a quest /// </summary> /// <param name="questName">The name of the quest</param> /// <param name="questId">The id of the quest</param> /// <returns>The functor</returns> private static NWN2ConditionalFunctor intCheck(String questName, int questId) { NWN2ConditionalFunctor globalIntCheck = new NWN2ConditionalFunctor(); globalIntCheck.Script = makeScript("gc_global_int"); int letValue = questId; if (letValue == 0) letValue = 1; questName = questNamePrep(questName); setParam(ref globalIntCheck, 0, questName); setParam(ref globalIntCheck, 1, "<" + letValue); return globalIntCheck; }
/// <summary> /// Creates a node that checks whether the player has a certain item /// </summary> /// <param name="tag">The tag of the item to check for</param> /// <returns>The functor</returns> private static NWN2ConditionalFunctor checkItem(String tag) { NWN2ConditionalFunctor itemCond = new NWN2ConditionalFunctor(); itemCond.Script = makeScript("gc_check_item"); setParam(ref itemCond, 0, tag); setParam(ref itemCond, 1, 0); return itemCond; }
/// <summary> /// Creates a functor to check whether the player has a certian amount of gold /// </summary> /// <param name="amount">The amount of gold to remove</param> /// <returns>The functor</returns> private static NWN2ConditionalFunctor checkGold(int amount) { NWN2ConditionalFunctor goldCond = new NWN2ConditionalFunctor(); goldCond.Script = makeScript("gc_check_gold"); setParam(ref goldCond, 0, amount); setParam(ref goldCond, 1, 0); return goldCond; }