Skip to content
This repository has been archived by the owner on Nov 10, 2021. It is now read-only.

Commit

Permalink
Added PlaySound function
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed May 18, 2020
1 parent 2b283e9 commit ee8b44b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
16 changes: 2 additions & 14 deletions UtilityLibrary.Test/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NetScriptFramework;
using NetScriptFramework.SkyrimSE;
using Main = NetScriptFramework.Main;

namespace UtilityLibrary.Example
{
Expand Down Expand Up @@ -49,23 +50,10 @@ protected override bool Initialize(bool loadedAny)
}
});

/*var ptr = NetScriptFramework.Main.GameInfo.GetAddressOf(39406, 0x89, 0, "E8 ? ? ? ? 48 85 C0");
Memory.WriteHook(new HookParameters
{
Address = ptr,
IncludeLength = 0,
ReplaceLength = 0x13,
Before = ctx =>
{
var item = MemoryObject.FromAddress<ExtraContainerChanges.ItemEntry>(ctx.CX);
if(item != null)
Utils.Log($"Item: {item.Template?.Name}");
}
});*/

Events.OnApplyPoison.Register(e =>
{
Utils.Log($"Item: {e.ItemEntry.Template?.Name}");
UtilityLibrary.PlaySound(Main.GameInfo.GetAddressOf(269252));
});

/*Events.OnCrafting.Register(e =>
Expand Down
24 changes: 24 additions & 0 deletions UtilityLibrary/AddressLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace UtilityLibrary
{
public static class AddressLibrary
{
#region Functions

/// <summary>
/// <para>Use <see cref="Memory.InvokeCdecl"/></para>
///
Expand Down Expand Up @@ -63,6 +65,23 @@ public static class AddressLibrary
/// </summary>
public static IntPtr GetSoulTypeFunc { get; internal set; }

/// <summary>
/// <para>Use <see cref="Memory.InvokeCdecl"/></para>
///
/// <para>
/// This function will play a sound.
/// </para>
///
/// <para>
/// Input is a pointer to the sound to be played.
/// </para>
/// </summary>
public static IntPtr PlaySoundFunc { get; internal set; }

#endregion

#region Events

/// <summary>
/// Address for <see cref="Events.OnTempering"/>
/// </summary>
Expand Down Expand Up @@ -108,6 +127,11 @@ public static class AddressLibrary
/// </summary>
internal static IntPtr AlchemyFunc2 { get; set; }

/// <summary>
/// Address fro <see cref="Events.OnApplyPoison"/>
/// </summary>
internal static IntPtr ApplyPoison { get; set; }

#endregion
}
}
1 change: 1 addition & 0 deletions UtilityLibrary/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ protected override bool Initialize(bool loadedAny)
AddressLibrary.GetDisenchantmentValue = Main.GameInfo.GetAddressOf(11213);
AddressLibrary.AlchemyFunc1 = Main.GameInfo.GetAddressOf(50424);
AddressLibrary.AlchemyFunc2 = Main.GameInfo.GetAddressOf(50463);
AddressLibrary.PlaySoundFunc = Main.GameInfo.GetAddressOf(52054);

//events addresses
AddressLibrary.SmithingTempering = Main.GameInfo.GetAddressOf(50477, 0x115, 6);
Expand Down
12 changes: 11 additions & 1 deletion UtilityLibrary/UtilityLibrary.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NetScriptFramework;
using System;
using NetScriptFramework;
using NetScriptFramework.SkyrimSE;
using Main = NetScriptFramework.SkyrimSE.Main;

Expand Down Expand Up @@ -60,5 +61,14 @@ public static long ToGameTime(long ms)
return true;

}

/// <summary>
/// Plays the given sound
/// </summary>
/// <param name="sound">Pointer to the sound</param>
public static void PlaySound(IntPtr sound)
{
Memory.InvokeCdecl(AddressLibrary.PlaySoundFunc, sound);
}
}
}

0 comments on commit ee8b44b

Please sign in to comment.