Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8193.37 API Updates #799

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NWN.Anvil/src/main/API/Constants/PlayerDeviceProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ public sealed class PlayerDeviceProperty
public static readonly PlayerDeviceProperty UiMouseoverFeedback = new PlayerDeviceProperty(NWScript.PLAYER_DEVICE_PROPERTY_UI_MOUSEOVER_FEEDBACK);
public static readonly PlayerDeviceProperty UiTextBubble = new PlayerDeviceProperty(NWScript.PLAYER_DEVICE_PROPERTY_UI_TEXT_BUBBLE);
public static readonly PlayerDeviceProperty UiTargetingFeedback = new PlayerDeviceProperty(NWScript.PLAYER_DEVICE_PROPERTY_UI_TARGETING_FEEDBACK);
public static readonly PlayerDeviceProperty UiCanClickSelfWhileWalking = new PlayerDeviceProperty(NWScript.PLAYER_DEVICE_PROPERTY_UI_CAN_CLICK_SELF_WHILE_WALKING);
public static readonly PlayerDeviceProperty UiFloatingTextFeedback = new PlayerDeviceProperty(NWScript.PLAYER_DEVICE_PROPERTY_UI_FLOATING_TEXT_FEEDBACK);
public static readonly PlayerDeviceProperty UiFloatingTextFeedbackDamageTotalsOnly = new PlayerDeviceProperty(NWScript.PLAYER_DEVICE_PROPERTY_UI_FLOATING_TEXT_FEEDBACK_DAMAGE_TOTALS_ONLY);
public static readonly PlayerDeviceProperty UiHideQuickchatTextInChatWindow = new PlayerDeviceProperty(NWScript.PLAYER_DEVICE_PROPERTY_UI_HIDE_QUICKCHAT_TEXT_IN_CHAT_WINDOW);
public static readonly PlayerDeviceProperty UiConfirmSelfcastSpells = new PlayerDeviceProperty(NWScript.PLAYER_DEVICE_PROPERTY_UI_CONFIRM_SELFCAST_SPELLS);
public static readonly PlayerDeviceProperty UiConfirmSelfcastFeats = new PlayerDeviceProperty(NWScript.PLAYER_DEVICE_PROPERTY_UI_CONFIRM_SELFCAST_FEATS);
public static readonly PlayerDeviceProperty UiConfirmSelfcastItems = new PlayerDeviceProperty(NWScript.PLAYER_DEVICE_PROPERTY_UI_CONFIRM_SELFCAST_ITEMS);
public static readonly PlayerDeviceProperty UiChargenSortClasses = new PlayerDeviceProperty(NWScript.PLAYER_DEVICE_PROPERTY_UI_CHARGEN_SORT_CLASSES);
public static readonly PlayerDeviceProperty UiChatPanePrimaryHeight = new PlayerDeviceProperty(NWScript.PLAYER_DEVICE_PROPERTY_UI_CHAT_PANE_PRIMARY_HEIGHT);
public static readonly PlayerDeviceProperty UiChatPaneSecondaryHeight = new PlayerDeviceProperty(NWScript.PLAYER_DEVICE_PROPERTY_UI_CHAT_PANE_SECONDARY_HEIGHT);
public static readonly PlayerDeviceProperty UiChatSwearFilter = new PlayerDeviceProperty(NWScript.PLAYER_DEVICE_PROPERTY_UI_CHAT_SWEAR_FILTER);
Expand Down
1 change: 1 addition & 0 deletions NWN.Anvil/src/main/API/Constants/PlayerPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum PlayerPlatform
LinuxArm64 = NWScript.PLAYER_DEVICE_PLATFORM_LINUX_ARM64,
MacX86 = NWScript.PLAYER_DEVICE_PLATFORM_MAC_X86,
MacX64 = NWScript.PLAYER_DEVICE_PLATFORM_MAC_X64,
MacArm64 = NWScript.PLAYER_DEVICE_PLATFORM_MAC_ARM64,
Ios = NWScript.PLAYER_DEVICE_PLATFORM_IOS,
AndroidArm32 = NWScript.PLAYER_DEVICE_PLATFORM_ANDROID_ARM32,
AndroidArm64 = NWScript.PLAYER_DEVICE_PLATFORM_ANDROID_ARM64,
Expand Down
1 change: 1 addition & 0 deletions NWN.Anvil/src/main/API/Constants/SavingThrowType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ public enum SavingThrowType
Evil = NWScript.SAVING_THROW_TYPE_EVIL,
Law = NWScript.SAVING_THROW_TYPE_LAW,
Chaos = NWScript.SAVING_THROW_TYPE_CHAOS,
Paralysis = NWScript.SAVING_THROW_TYPE_PARALYSIS,
}
}
10 changes: 10 additions & 0 deletions NWN.Anvil/src/main/API/Constants/SpellFailureType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using NWN.Core;

namespace Anvil.API
{
public enum SpellFailureType
{
All = NWScript.SPELL_FAILURE_TYPE_ALL,
Arcane = NWScript.SPELL_FAILURE_TYPE_ARCANE,
}
}
34 changes: 25 additions & 9 deletions NWN.Anvil/src/main/API/EngineStructures/Effect.Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,12 @@ public static Effect Poison(PoisonType poisonType)
/// </summary>
/// <param name="polymorphType">The polymorph to apply.</param>
/// <param name="locked">If true, players cannot dismiss the polymorph effect.</param>
public static Effect Polymorph(PolymorphTableEntry polymorphType, bool locked = false)
/// <param name="unPolymorphVfx">The visual effect that will play when this polymorph is removed. Set to null to have no effect play.</param>
/// <param name="spellAbilityModifier">Set a custom spell ability modifier for the 3 polymorph spells. Save DC is 10 + Innate spell level + this ability modifier.</param>
/// <param name="spellAbilityCasterLevel">Set a custom caster level for the 3 polymorph spells.</param>
public static Effect Polymorph(PolymorphTableEntry polymorphType, bool locked = false, VfxType? unPolymorphVfx = VfxType.ImpPolymorph, int spellAbilityModifier = -1, int spellAbilityCasterLevel = 0)
{
return NWScript.EffectPolymorph(polymorphType.RowIndex, locked.ToInt())!;
return NWScript.EffectPolymorph(polymorphType.RowIndex, locked.ToInt(), (int?)unPolymorphVfx ?? -1, spellAbilityModifier, spellAbilityCasterLevel)!;
}

/// <summary>
Expand Down Expand Up @@ -733,9 +736,10 @@ public static Effect Slow()
/// </summary>
/// <param name="failPct">A positive number representing the percent chance of spell failing (1-100)</param>
/// <param name="spellSchool">The spell school that is affected.</param>
public static Effect SpellFailure(int failPct, SpellSchool spellSchool = SpellSchool.General)
/// <param name="failureType">Use <see cref="SpellFailureType"/> constants for different spell failure types.</param>
public static Effect SpellFailure(int failPct, SpellSchool spellSchool = SpellSchool.General, SpellFailureType failureType = SpellFailureType.All)
{
return NWScript.EffectSpellFailure(failPct, (int)spellSchool)!;
return NWScript.EffectSpellFailure(failPct, (int)spellSchool, (int)failureType)!;
}

/// <summary>
Expand Down Expand Up @@ -786,20 +790,32 @@ public static Effect Stunned()
}

/// <summary>
/// Creates an effect to summon a creature.<br/>
/// Creates an effect to summon a creature from a resref.<br/>
/// THIS IS OBJECT CONTEXT SENSITIVE! Use <see cref="NwObject.WaitForObjectContext"/> to correctly assign the right owner of the master.
/// </summary>
/// <param name="creatureResRef">The template/ResRef of the creature to summon.</param>
/// <param name="vfxType">A visual effect to display upon summoning.</param>
/// <param name="summonVfx">A visual effect to display upon summoning.</param>
/// <param name="delay">A delay between the visual effect, and the creature actually being added to the area.</param>
/// <param name="appearType">The appear animation to use.</param>
public static Effect SummonCreature(string creatureResRef, VfxType vfxType, TimeSpan delay = default, int appearType = 0)
/// <param name="unsummonVfx">A visual effect to display when this creature is unsummoned.</param>
public static Effect SummonCreature(string creatureResRef, VisualEffectTableEntry summonVfx, TimeSpan delay = default, int appearType = 0, VisualEffectTableEntry? unsummonVfx = default)
{
return NWScript.EffectSummonCreature(creatureResRef, (int)vfxType, (float)delay.TotalSeconds, appearType)!;
return NWScript.EffectSummonCreature(creatureResRef, summonVfx.RowIndex, (float)delay.TotalSeconds, appearType, unsummonVfx?.RowIndex ?? (int)VfxType.ImpUnsummon)!;
}

/// <summary>
/// Creates a swarm effect. This is exactly the same as <see cref="SummonCreature"/>, except, after one dies, another takes its place.
/// Creates an effect that uses summon behaviours on an existing creature.
/// </summary>
/// <param name="summonCreature">The creature to be used as the summoned creature. Must not have a current "master" creature.</param>
/// <param name="summonVfx">A visual effect to display when claiming the summoned creature.</param>
/// <param name="unsummonVfx">A visual effect to play when the summoned creature is unsummoned.</param>
public static Effect SummonCreature(NwCreature summonCreature, VisualEffectTableEntry summonVfx, VisualEffectTableEntry? unsummonVfx = default)
{
return NWScript.EffectSummonCreature("", summonVfx.RowIndex, 0f, 0, unsummonVfx?.RowIndex ?? (int)VfxType.ImpUnsummon, summonCreature)!;
}

/// <summary>
/// Creates a swarm effect. This is exactly the same as <see cref="SummonCreature(string,Anvil.API.VisualEffectTableEntry,System.TimeSpan,int,Anvil.API.VisualEffectTableEntry?)"/>, except, after one dies, another takes its place.
/// </summary>
/// <param name="loop">If true, while the effect is active and the last creature dies, it will loop back to the first template.</param>
/// <param name="creatureTemplate1">The blueprint of the first creature to spawn.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,29 @@ public sealed class OnDisturbed : IEvent
/// <summary>
/// Gets the <see cref="NwCreature"/> that had its inventory disturbed.
/// </summary>
public NwCreature CreatureDisturbed { get; } = NWScript.OBJECT_SELF.ToNwObject<NwCreature>()!;
public NwCreature CreatureDisturbed { get; }

/// <summary>
/// Gets the <see cref="NwItem"/> that was disturbed in the inventory.
/// </summary>
public NwItem DisturbedItem { get; } = NWScript.GetInventoryDisturbItem().ToNwObject<NwItem>()!;
public NwItem DisturbedItem { get; }

/// <summary>
/// Gets the <see cref="NwCreature"/> that disturbed another <see cref="NwCreature"/> inventory.
/// </summary>
public NwCreature Disturber { get; } = NWScript.GetLastDisturbed().ToNwObject<NwCreature>()!;
public NwCreature Disturber { get; }

public InventoryDisturbType DisturbType { get; } = (InventoryDisturbType)NWScript.GetInventoryDisturbType();
public InventoryDisturbType DisturbType { get; }

NwObject IEvent.Context => CreatureDisturbed;

public OnDisturbed()
{
CreatureDisturbed = NWScript.OBJECT_SELF.ToNwObject<NwCreature>()!;
DisturbedItem = NWScript.GetInventoryDisturbItem(CreatureDisturbed).ToNwObject<NwItem>()!;
Disturber = NWScript.GetLastDisturbed(CreatureDisturbed).ToNwObject<NwCreature>()!;
DisturbType = (InventoryDisturbType)NWScript.GetInventoryDisturbType(CreatureDisturbed);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ public sealed class OnClose : IEvent
/// <summary>
/// Gets the <see cref="NwCreature"/> that closed the <see cref="NwDoor"/>.
/// </summary>
public NwGameObject ClosedBy { get; } = NWScript.GetLastClosedBy().ToNwObject<NwGameObject>()!;
public NwGameObject ClosedBy { get; }

/// <summary>
/// Gets the <see cref="NwDoor"/> that was closed.
/// </summary>
public NwDoor Door { get; } = NWScript.OBJECT_SELF.ToNwObject<NwDoor>()!;
public NwDoor Door { get; }

NwObject IEvent.Context => Door;

public OnClose()
{
Door = NWScript.OBJECT_SELF.ToNwObject<NwDoor>()!;
ClosedBy = NWScript.GetLastClosedBy(Door).ToNwObject<NwGameObject>()!;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ public sealed class OnLock : IEvent
/// <summary>
/// Gets the <see cref="NwDoor"/> that was locked.
/// </summary>
public NwDoor Door { get; } = NWScript.OBJECT_SELF.ToNwObject<NwDoor>()!;
public NwDoor Door { get; }

/// <summary>
/// Gets the <see cref="NwCreature"/> that locked this <see cref="NwDoor"/>.
/// </summary>
public NwCreature LockedBy { get; } = NWScript.GetLastLocked().ToNwObject<NwCreature>()!;
public NwCreature LockedBy { get; }

NwObject IEvent.Context => Door;

public OnLock()
{
Door = NWScript.OBJECT_SELF.ToNwObject<NwDoor>()!;
LockedBy = NWScript.GetLastLocked(Door).ToNwObject<NwCreature>()!;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ public sealed class OnOpen : IEvent
/// <summary>
/// Gets the <see cref="NwDoor"/> that was opened.
/// </summary>
public NwDoor Door { get; } = NWScript.OBJECT_SELF.ToNwObject<NwDoor>()!;
public NwDoor Door { get; }

/// <summary>
/// Gets the <see cref="NwCreature"/> that opened the <see cref="NwDoor"/>.
/// </summary>
public NwGameObject OpenedBy { get; } = NWScript.GetLastOpenedBy().ToNwObject<NwGameObject>()!;
public NwGameObject OpenedBy { get; }

NwObject IEvent.Context => Door;

public OnOpen()
{
Door = NWScript.OBJECT_SELF.ToNwObject<NwDoor>()!;
OpenedBy = NWScript.GetLastOpenedBy(Door).ToNwObject<NwGameObject>()!;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ public sealed class OnUnlock : IEvent
/// <summary>
/// Gets the <see cref="NwDoor"/> that was unlocked.
/// </summary>
public NwDoor Door { get; } = NWScript.OBJECT_SELF.ToNwObject<NwDoor>()!;
public NwDoor Door { get; }

/// <summary>
/// Gets the <see cref="NwCreature"/> that unlocked <see cref="NwDoor"/>.
/// </summary>
public NwCreature UnlockedBy { get; } = NWScript.GetLastUnlocked().ToNwObject<NwCreature>()!;
public NwCreature UnlockedBy { get; }

NwObject IEvent.Context => Door;

public OnUnlock()
{
Door = NWScript.OBJECT_SELF.ToNwObject<NwDoor>()!;
UnlockedBy = NWScript.GetLastUnlocked(Door).ToNwObject<NwCreature>()!;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ public sealed class OnClose : IEvent
/// <summary>
/// Gets the <see cref="NwCreature"/> that closed the <see cref="NwPlaceable"/>.
/// </summary>
public NwCreature? ClosedBy { get; } = NWScript.GetLastClosedBy().ToNwObject<NwCreature>();
public NwCreature? ClosedBy { get; }

/// <summary>
/// Gets the <see cref="NwPlaceable"/> that was closed.
/// </summary>
public NwPlaceable Placeable { get; } = NWScript.OBJECT_SELF.ToNwObject<NwPlaceable>()!;
public NwPlaceable Placeable { get; }

NwObject IEvent.Context => Placeable;

public OnClose()
{
Placeable = NWScript.OBJECT_SELF.ToNwObject<NwPlaceable>()!;
ClosedBy = NWScript.GetLastClosedBy(Placeable).ToNwObject<NwCreature>();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,32 @@ public sealed class OnDisturbed : IEvent
/// <summary>
/// Gets the <see cref="NwItem"/> that triggered the disturb event on <see cref="NwPlaceable"/>.
/// </summary>
public NwItem? DisturbedItem { get; } = NWScript.GetInventoryDisturbItem().ToNwObject<NwItem>();
public NwItem? DisturbedItem { get; }

/// <summary>
/// Gets the object that disturbed <see cref="NwPlaceable"/>.
/// </summary>
public NwGameObject? Disturber { get; } = NWScript.GetLastDisturbed().ToNwObject<NwGameObject>();
public NwGameObject? Disturber { get; }

/// <summary>
/// Gets the <see cref="InventoryDisturbType"/>.
/// </summary>
public InventoryDisturbType DisturbType { get; } = (InventoryDisturbType)NWScript.GetInventoryDisturbType();
public InventoryDisturbType DisturbType { get; }

/// <summary>
/// Gets the <see cref="NwPlaceable"/> that was disturbed.
/// </summary>
public NwPlaceable Placeable { get; } = NWScript.OBJECT_SELF.ToNwObject<NwPlaceable>()!;
public NwPlaceable Placeable { get; }

NwObject IEvent.Context => Placeable;

public OnDisturbed()
{
Placeable = NWScript.OBJECT_SELF.ToNwObject<NwPlaceable>()!;
Disturber = NWScript.GetLastDisturbed(Placeable).ToNwObject<NwGameObject>();
DisturbType = (InventoryDisturbType)NWScript.GetInventoryDisturbType(Placeable);
DisturbedItem = NWScript.GetInventoryDisturbItem(Placeable).ToNwObject<NwItem>();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ public sealed class OnLock : IEvent
/// <summary>
/// Gets the <see cref="NwCreature"/> that locked this <see cref="NwPlaceable"/>.
/// </summary>
public NwCreature? LockedBy { get; } = NWScript.GetLastLocked().ToNwObject<NwCreature>();
public NwCreature? LockedBy { get; }

/// <summary>
/// Gets the <see cref="NwPlaceable"/> that was locked.
/// </summary>
public NwPlaceable LockedPlaceable { get; } = NWScript.OBJECT_SELF.ToNwObject<NwPlaceable>()!;
public NwPlaceable LockedPlaceable { get; }

NwObject IEvent.Context => LockedPlaceable;

public OnLock()
{
LockedPlaceable = NWScript.OBJECT_SELF.ToNwObject<NwPlaceable>()!;
LockedBy = NWScript.GetLastLocked(LockedPlaceable).ToNwObject<NwCreature>();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ public sealed class OnOpen : IEvent
/// <summary>
/// Gets the <see cref="NwCreature"/> that opened the <see cref="NwPlaceable"/>.
/// </summary>
public NwCreature? OpenedBy { get; } = NWScript.GetLastOpenedBy().ToNwObject<NwCreature>();
public NwCreature? OpenedBy { get; }

/// <summary>
/// Gets the <see cref="NwPlaceable"/> that was opened.
/// </summary>
public NwPlaceable Placeable { get; } = NWScript.OBJECT_SELF.ToNwObject<NwPlaceable>()!;
public NwPlaceable Placeable { get; }

NwObject IEvent.Context => Placeable;

public OnOpen()
{
Placeable = NWScript.OBJECT_SELF.ToNwObject<NwPlaceable>()!;
OpenedBy = NWScript.GetLastOpenedBy(Placeable).ToNwObject<NwCreature>();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ public sealed class OnUnlock : IEvent
/// <summary>
/// Gets the <see cref="NwPlaceable"/> that was unlocked.
/// </summary>
public NwPlaceable Placeable { get; } = NWScript.OBJECT_SELF.ToNwObject<NwPlaceable>()!;
public NwPlaceable Placeable { get; }

/// <summary>
/// Gets the <see cref="NwCreature"/> that unlocked <see cref="NwPlaceable"/>.
/// </summary>
public NwCreature? UnlockedBy { get; } = NWScript.GetLastUnlocked().ToNwObject<NwCreature>();
public NwCreature? UnlockedBy { get; }

NwObject IEvent.Context => Placeable;

public OnUnlock()
{
Placeable = NWScript.OBJECT_SELF.ToNwObject<NwPlaceable>()!;
UnlockedBy = NWScript.GetLastUnlocked(Placeable).ToNwObject<NwCreature>();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ public sealed class OnClose : IEvent
/// <summary>
/// Gets the <see cref="NwCreature"/> that last closed this <see cref="NwStore"/>.
/// </summary>
public NwCreature Creature { get; } = NWScript.GetLastClosedBy().ToNwObject<NwCreature>()!;
public NwCreature Creature { get; }

/// <summary>
/// Gets the <see cref="NwStore"/> being closed.
/// </summary>
public NwStore Store { get; } = NWScript.OBJECT_SELF.ToNwObject<NwStore>()!;
public NwStore Store { get; }

NwObject IEvent.Context => Store;

public OnClose()
{
Store = NWScript.OBJECT_SELF.ToNwObject<NwStore>()!;
Creature = NWScript.GetLastClosedBy(Store).ToNwObject<NwCreature>()!;
}
}
}
}
Expand Down
Loading
Loading