First
This commit is contained in:
commit
de059ef1c5
5334
NWScriptActions.cs
Normal file
5334
NWScriptActions.cs
Normal file
File diff suppressed because it is too large
Load Diff
7537
NWScriptConstants.cs
Normal file
7537
NWScriptConstants.cs
Normal file
File diff suppressed because it is too large
Load Diff
1343
NWScriptSupport.cs
Normal file
1343
NWScriptSupport.cs
Normal file
File diff suppressed because it is too large
Load Diff
BIN
NativeScriptUtil.exe
Normal file
BIN
NativeScriptUtil.exe
Normal file
Binary file not shown.
5
PackageScript.cmd
Normal file
5
PackageScript.cmd
Normal file
@ -0,0 +1,5 @@
|
||||
@echo off
|
||||
|
||||
echo Packaging %1 into %2...
|
||||
|
||||
%~dp0\NativeScriptUtil.exe -i %1 -o %2 -q
|
2
nwn2_ai_onmoduleload/.gitignore
vendored
Normal file
2
nwn2_ai_onmoduleload/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
bin/
|
||||
obj/
|
36
nwn2_ai_onmoduleload/Properties/AssemblyInfo.cs
Normal file
36
nwn2_ai_onmoduleload/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("nwn2_ai_onmoduleload")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("nwn2_ai_onmoduleload")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2011")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("39b94a55-b8d7-4a59-846e-fabeeb3bc3cc")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
150
nwn2_ai_onmoduleload/StandardEntrypoints.cs
Normal file
150
nwn2_ai_onmoduleload/StandardEntrypoints.cs
Normal file
@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using CLRScriptFramework;
|
||||
using NWScript;
|
||||
using NWScript.ManagedInterfaceLayer.NWScriptManagedInterface;
|
||||
|
||||
using NWEffect = NWScript.NWScriptEngineStructure0;
|
||||
using NWEvent = NWScript.NWScriptEngineStructure1;
|
||||
using NWLocation = NWScript.NWScriptEngineStructure2;
|
||||
using NWTalent = NWScript.NWScriptEngineStructure3;
|
||||
using NWItemProperty = NWScript.NWScriptEngineStructure4;
|
||||
|
||||
namespace CLRScript
|
||||
{
|
||||
public partial class nwn2_ai_onmoduleload : CLRScriptBase, ICLRScriptImplementation
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// This helper function saves the value of all 'globals' to an object
|
||||
/// array for use with storing a saved state (e.g. a script situation).
|
||||
/// </summary>
|
||||
/// <returns>A list of global variables, to be restored by a future
|
||||
/// call to LoadScriptGlobals.</returns>
|
||||
public object[] SaveScriptGlobals()
|
||||
{
|
||||
object[] Globals = new object[GlobalFields.Count];
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (FieldInfo Field in GlobalFields)
|
||||
{
|
||||
Globals[i] = Field.GetValue(this);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return Globals;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This routine is the main entry point symbol for the script. It is
|
||||
/// invoked when the packaged script is executed.
|
||||
/// </summary>
|
||||
/// <param name="ObjectSelf">Supplies the "OBJECT_SELF" object id of
|
||||
/// the object that the script is being executed over. This may be the
|
||||
/// invalid object id (Script.OBJECT_INVALID) if no object is
|
||||
/// associated with the execute script request.</param>
|
||||
/// <param name="ScriptParameters">Supplies the parameter values for
|
||||
/// the script. If the type deriving from IGeneratedScriptProgram
|
||||
/// declares a ScriptParameterTypes public field, then parameters may
|
||||
/// be passed in via this array (in which case the parameter types
|
||||
/// have already been converted and validated). Otherwise, no
|
||||
/// arguments are provided.</param>
|
||||
/// <param name="DefaultReturnCode">Supplies the requested default
|
||||
/// return code to use if the script is a "main"-style script that
|
||||
/// would not conventionally return a value.</param>
|
||||
/// <returns></returns>
|
||||
public Int32 ExecuteScript([In] UInt32 ObjectSelf, [In] object[] ScriptParameters, [In] Int32 DefaultReturnCode)
|
||||
{
|
||||
UInt32 OldOBJECT_SELF = ObjectSelf;
|
||||
int ReturnCode;
|
||||
|
||||
try
|
||||
{
|
||||
OBJECT_SELF = ObjectSelf;
|
||||
ReturnCode = ScriptMain(ScriptParameters, DefaultReturnCode);
|
||||
}
|
||||
finally
|
||||
{
|
||||
OBJECT_SELF = OldOBJECT_SELF;
|
||||
}
|
||||
|
||||
return ReturnCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This routine is invoked when a script situation created by the
|
||||
/// script is resumed for execution (for example, a DelayCommand
|
||||
/// continuation). Its purpose is to perform the appropriate resume
|
||||
/// action for this continuation.
|
||||
///
|
||||
/// Note that a script situation may be resumed after the original
|
||||
/// script object has been deleted, or even after the host process has
|
||||
/// been exited and restarted (in the save of a saved game that has
|
||||
/// been loaded).
|
||||
/// </summary>
|
||||
/// <param name="ScriptSituationId">Supplies the ScriptSituationId that
|
||||
/// was provided to the initial StoreState request, which is intended
|
||||
/// to uniquely identify the site within which the script situation was
|
||||
/// created.</param>
|
||||
/// <param name="Locals">Supplies an array of local variables that were
|
||||
/// provided to the initial StoreState request. The locals may only
|
||||
/// include standard NWScript types (Int32, UInt32, Single, and engine
|
||||
/// structures).</param>
|
||||
/// <param name="ObjectSelf">Supplies the "OBJECT_SELF" object id of
|
||||
/// the object that the script is being executed over. This may be the
|
||||
/// invalid object id (Script.OBJECT_INVALID) if no object is
|
||||
/// associated with the execute script request.</param>
|
||||
public void ExecuteScriptSituation([In] UInt32 ScriptSituationId, [In] object[] Locals, [In] UInt32 ObjectSelf)
|
||||
{
|
||||
//
|
||||
// Call the helper function.
|
||||
//
|
||||
|
||||
DispatchExecuteScriptSituation(ScriptSituationId, Locals, ObjectSelf);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This routine is invoked when the script context is being cloned for
|
||||
/// the creation of a script situation. Its purpose is to create a new
|
||||
/// SampleManagedNWScript object and transfer any state desired to the
|
||||
/// new script object.
|
||||
/// </summary>
|
||||
/// <returns>The cloned script object is returned.</returns>
|
||||
public IGeneratedScriptProgram CloneScriptProgram()
|
||||
{
|
||||
return (IGeneratedScriptProgram)(new nwn2_ai_onmoduleload(this));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This routine is invoked when the script context was restored from
|
||||
/// the interopability script stack for a script situation. Its
|
||||
/// purpose is to restore any 'global' (i.e. member variable) state
|
||||
/// that was passed to the initial StoreState request. The globals may
|
||||
/// only include standard NWScript types (Int32, UInt32, Single, and
|
||||
/// engine structures).
|
||||
/// </summary>
|
||||
/// <param name="Globals">Supplies an array of global variables that
|
||||
/// were provided to the initial StoreState request.</param>
|
||||
public void LoadScriptGlobals([In] object[] Globals)
|
||||
{
|
||||
//
|
||||
// Restore all [NWScriptGlobal] attributed globals from the global
|
||||
// list.
|
||||
//
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (FieldInfo Field in GlobalFields)
|
||||
{
|
||||
Field.SetValue(this, Globals[i]);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
62
nwn2_ai_onmoduleload/nwn2_ai_onmoduleload.cs
Normal file
62
nwn2_ai_onmoduleload/nwn2_ai_onmoduleload.cs
Normal file
@ -0,0 +1,62 @@
|
||||
//
|
||||
// This script serves as a basis for new scripts. New scripts can copy this
|
||||
// source file to start out.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using CLRScriptFramework;
|
||||
using NWScript;
|
||||
using NWScript.ManagedInterfaceLayer.NWScriptManagedInterface;
|
||||
|
||||
using NWEffect = NWScript.NWScriptEngineStructure0;
|
||||
using NWEvent = NWScript.NWScriptEngineStructure1;
|
||||
using NWLocation = NWScript.NWScriptEngineStructure2;
|
||||
using NWTalent = NWScript.NWScriptEngineStructure3;
|
||||
using NWItemProperty = NWScript.NWScriptEngineStructure4;
|
||||
|
||||
namespace CLRScript
|
||||
{
|
||||
public partial class nwn2_ai_onmoduleload : CLRScriptBase, ICLRScriptImplementation, IGeneratedScriptProgram
|
||||
{
|
||||
|
||||
public nwn2_ai_onmoduleload([In] NWScriptJITIntrinsics Intrinsics, [In] INWScriptProgram Host)
|
||||
{
|
||||
InitScript(Intrinsics, Host);
|
||||
}
|
||||
|
||||
private nwn2_ai_onmoduleload([In] nwn2_ai_onmoduleload Other)
|
||||
{
|
||||
InitScript(Other);
|
||||
|
||||
LoadScriptGlobals(Other.SaveScriptGlobals());
|
||||
}
|
||||
|
||||
//
|
||||
// Include the list of types for parameters to the main function here.
|
||||
// An empty list means no parameters.
|
||||
//
|
||||
public static Type[] ScriptParameterTypes = { };
|
||||
|
||||
public Int32 ScriptMain([In] object[] ScriptParameters, [In] Int32 DefaultReturnCode)
|
||||
{
|
||||
int Volume;
|
||||
|
||||
MessageToSpeak = "Hello, world";
|
||||
Volume = TALKVOLUME_TALK;
|
||||
|
||||
AssignCommand(OBJECT_SELF, delegate() { ActionSpeakString(MessageToSpeak, Volume); });
|
||||
|
||||
return DefaultReturnCode;
|
||||
}
|
||||
|
||||
[NWScriptGlobal]
|
||||
private string MessageToSpeak;
|
||||
}
|
||||
}
|
68
nwn2_ai_onmoduleload/nwn2_ai_onmoduleload.csproj
Normal file
68
nwn2_ai_onmoduleload/nwn2_ai_onmoduleload.csproj
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{D2787600-DE01-4E09-9F74-1A13F1ADB4E8}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>nwn2_ai_onmoduleload</RootNamespace>
|
||||
<AssemblyName>nwn2_ai_onmoduleload</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NWNScriptJITIntrinsics, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\CLRv4.0.30319\NWNScriptJITIntrinsics.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NWScriptManagedInterface, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\CLRv4.0.30319\NWScriptManagedInterface.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="nwn2_ai_onmoduleload.cs" />
|
||||
<Compile Include="..\NWScriptActions.cs" />
|
||||
<Compile Include="..\NWScriptConstants.cs" />
|
||||
<Compile Include="..\NWScriptSupport.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="StandardEntrypoints.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>..\..\..\PackageScript.cmd "$(TargetPath)" "$(TargetName).ncs"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user