public static void SetFloat(NWN2ScriptVarTable variables, string name, float value) { try { variables.GetVariable(name).ValueFloat = value; variables.GetVariable(name).VariableType = NWN2ScriptVariableType.Float; } catch { NWN2ScriptVariable var = new NWN2ScriptVariable(name, value); var.VariableType = NWN2ScriptVariableType.Float; variables.Add(var); } }
private void condAdvance(Actor trigger, NWN2ScriptVarTable varTable, string questName, int questId, int xp, string script, string message) { LinkedList<String> toRemove = new LinkedList<string>(); toRemove.AddLast("negate"); toRemove.AddLast("condition"); toRemove.AddLast("script"); toRemove.AddLast("message"); varTable = getAdvanceJournalVar(varTable, questName, questId, xp, toRemove); string value = ""; if (preReq == EnumTypes.prereq.SimplePrereq || preReq == EnumTypes.prereq.CastSpecificPrereq) { int questValue = preReqNode.questId; if (questValue == 0) questValue = 1; value = questValue.ToString(); } NWN2GameScript sayString = module.Scripts["gtr_conditional_run_script"]; if (sayString == null) { sayString = new NWN2GameScript("gtr_conditional_run_script", module.Repository.DirectoryName, module.Repository); sayString.Data = Properties.Resources.gtr_conditional_run_script; sayString.OEISerialize(); module.Scripts.Add(sayString); } if (preReq == EnumTypes.prereq.SimplePrereq) { value = "<" + value; NWN2ScriptVariable negate = new NWN2ScriptVariable("negate", 1); varTable.Add(negate); } NWN2ScriptVariable compare1 = new NWN2ScriptVariable("condition", value); NWN2ScriptVariable scriptVar = new NWN2ScriptVariable("script", script); if (message != "") { NWN2ScriptVariable messageVar = new NWN2ScriptVariable("message", message); varTable.Add(messageVar); } varTable.Add(compare1); varTable.Add(scriptVar); trigger.Var = varTable; if (trigger.boolInstance) { ((NWN2TriggerInstance)trigger.instance).OnEnter = sayString.Resource; } else { ((NWN2TriggerBlueprint)trigger.blueprint).OnEnter = sayString.Resource; } }
private static NWN2ScriptVarTable getAdvanceJournalVar(NWN2ScriptVarTable varTable, string questName, int questId, int xp, LinkedList<string> toRemove) { toRemove.AddLast("XP"); toRemove.AddLast("JournalUpdate"); toRemove.AddLast("nextState"); removeDuplicates(varTable, toRemove); var XP = new NWN2ScriptVariable("XP", xp); var journalCategory = new NWN2ScriptVariable("JournalUpdate", "Q_" + questName); int state = (questId == 0) ? 1 : questId; var journalEntry = new NWN2ScriptVariable("nextState", state); varTable.Add(XP); varTable.Add(journalCategory); varTable.Add(journalEntry); return varTable; }
public static void SetInteger(NWN2ScriptVarTable variables, string name, int value) { try { variables.GetVariable(name).ValueInt = value; variables.GetVariable(name).VariableType = NWN2ScriptVariableType.Int; } catch { NWN2ScriptVariable var = new NWN2ScriptVariable(name, value); var.VariableType = NWN2ScriptVariableType.Int; variables.Add(var); } }
public static void SetString(NWN2ScriptVarTable variables, string name, string value) { try { variables.GetVariable(name).ValueString = value; variables.GetVariable(name).VariableType = NWN2ScriptVariableType.String; } catch { NWN2ScriptVariable var = new NWN2ScriptVariable(name, value); var.VariableType = NWN2ScriptVariableType.String; variables.Add(var); } }