コード例 #1
0
        public int OnRunScript(string script, uint oidSelf)
        {
            ObjectSelf = oidSelf;
            ScriptContexts.Push(new ScriptContext {
                OwnerObject = oidSelf, ScriptName = script
            });

            // All NWScript calls require an int return. For most script calls, this can be zero. For a
            // StartingConditional, it can be zero (false) or one (true). A return value of -1 means to pass
            // through DotNET and call the actual .ncs file in the module.
            int retVal = 0;

            // This switch statement illustrates how the template prompts individual script calls. Most
            // implementations will split this logic into a Dictionary or other sensible arrangement. Note that
            // a script does not need to be in the module for its name to be assigned. Many DotNET modules
            // have no .nss or .ncs files at all. Note that script names must always be shorter than 16
            // characters by an internal engine limitation.
            switch (script)
            {
            // An ordinary script. No return value set.
            case "x2_mod_def_load":
                Console.WriteLine("Module loaded.");
                break;

            // A conditional script. Return value set appropriately.
            case "chk_is_male":
                retVal = NWScript.GetGender(NWScript.GetPCSpeaker()) == 0 ? 1 : 0;
                break;

            // Fall through to NWScript. Note that if the script does not exist, this will not cause an error,
            // simply fail silently.
            default:
                retVal = -1;
                break;
            }

            ScriptContexts.Pop();
            ObjectSelf = ScriptContexts.Count == 0 ? NWScript.OBJECT_INVALID : ScriptContexts.Peek().OwnerObject;
            return(retVal);
        }
コード例 #2
0
 public virtual void RemoveFromParty()
 {
     NWScript.RemoveFromParty(this);
 }
コード例 #3
0
 public virtual void Boot(string text)
 {
     NWScript.BootPC(this, text);
 }
コード例 #4
0
 public virtual void AddToParty(NWPlayer partyLeader)
 {
     NWScript.AddToParty(this, partyLeader);
 }
コード例 #5
0
 public virtual void SendMessage(string text)
 {
     NWScript.SendMessageToPC(this, text);
 }