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

NwCreature - Associates #795

Merged
merged 24 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
76f1a83
Add Custom damage types to DamageData
Oct 2, 2023
4cc591b
Merge remote-tracking branch 'origin/development' into development
Oct 6, 2023
5d19855
Merge remote-tracking branch 'origin/development' into development
Nov 16, 2024
207f788
OnSpellBroadcast - Add Target & position parameters
Jan 3, 2025
39b50cc
NwAreaOfEffect - Add SetRadius
Jan 3, 2025
8f94aa8
NwAreaOfEffect - SetRadius add comments
Jan 3, 2025
c5811bf
NwCreature - Add ForceLevelUp
Jan 3, 2025
5423a82
NwCreature - Add Get/Set for companion and familiars types and names
Jan 3, 2025
67b252f
Merge remote-tracking branch 'origin/development' into development
Jan 3, 2025
aa83cca
NwCreature - Add Setters for familiar and companions types and names
Jan 3, 2025
d34eda1
OnSpellBroadcast - Warning fixes
Jan 3, 2025
99f09ea
OnSpellBroadcast - Typo fixes
Jan 4, 2025
3cf800c
Merge remote-tracking branch 'origin/development' into development
Jan 4, 2025
1c92c65
Merge remote-tracking branch 'origin/development' into development
Jan 4, 2025
a827be6
NwCreature - Add associates methods
Jan 4, 2025
2a21136
DamageData remove old implementation
Jan 4, 2025
e8500b0
Fix typo
Jan 4, 2025
e508c84
Fix declaration of new expression
Jan 4, 2025
ec67e7a
Fixes to fit Anvil design!
Jan 4, 2025
4ff62e4
Parenthesis removal
Jan 4, 2025
7fc1953
Removed Whitespace
Jan 4, 2025
92d0007
Adding a method to force a creature to unsummon itself
Jan 5, 2025
2c02c8a
Update NwCreature.cs
jhett12321 Jan 20, 2025
816e7b3
Update NwCreature.cs
jhett12321 Jan 20, 2025
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
12 changes: 12 additions & 0 deletions NWN.Anvil/src/main/API/Objects/NwAreaOfEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,17 @@ private protected override void AddToArea(CNWSArea area, float x, float y, float
{
AreaOfEffect.AddToArea(area, x, y, z, true.ToInt());
}

/// <summary>
/// Set the radius of this area of effect.
/// </summary>
/// <param name="radius">The new radius of the area of effect.</param>
public void SetRadius(float radius)
{
if (radius > 0 && AreaOfEffect.m_nShape == 0)
{
AreaOfEffect.SetShape(0, radius);
}
}
}
}
110 changes: 102 additions & 8 deletions NWN.Anvil/src/main/API/Objects/NwCreature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,22 @@ public bool AlwaysWalk
}

/// <summary>
/// Gets this creature's animal companion name.
/// Gets or sets this creature's animal companion name.
/// </summary>
public string AnimalCompanionName => NWScript.GetAnimalCompanionName(this);
public string AnimalCompanionName
{
get => NWScript.GetAnimalCompanionName(this);
set => Creature.m_pStats.m_sAnimalCompanionName = value.ToExoString();
}

/// <summary>
/// Gets this creature's animal companion creature type.
/// Gets or sets this creature's animal companion creature type.
/// </summary>
public AnimalCompanionCreatureType AnimalCompanionType => (AnimalCompanionCreatureType)NWScript.GetAnimalCompanionCreatureType(this);
public AnimalCompanionCreatureType AnimalCompanionType
{
get => (AnimalCompanionCreatureType)NWScript.GetAnimalCompanionCreatureType(this);
set => Creature.m_pStats.m_nAnimalCompanionCreatureType = (int)value;
}

/// <summary>
/// Gets or sets the appearance of this creature.
Expand Down Expand Up @@ -355,14 +363,22 @@ public NwFaction Faction
}

/// <summary>
/// Gets this creature's familiar name.
/// Gets or sets this creature's familiar name.
/// </summary>
public string FamiliarName => NWScript.GetFamiliarName(this);
public string FamiliarName
{
get => NWScript.GetFamiliarName(this);
set => Creature.m_pStats.m_sFamiliarName = value.ToExoString();
}

/// <summary>
/// Gets the type of familiar that this creature can summon.
/// Gets or sets the type of familiar that this creature can summon.
/// </summary>
public FamiliarCreatureType FamiliarType => (FamiliarCreatureType)NWScript.GetFamiliarCreatureType(this);
public FamiliarCreatureType FamiliarType
{
get => (FamiliarCreatureType)NWScript.GetFamiliarCreatureType(this);
set => Creature.m_pStats.m_nFamiliarCreatureType = (int)value;
}

/// <summary>
/// Gets the number of feats known by this creature.
Expand Down Expand Up @@ -993,6 +1009,35 @@ public async Task ActionCounterspell(NwGameObject counterSpellTarget)
NWScript.ActionCounterSpell(counterSpellTarget);
}

/// <summary>
/// Forces a PC to level up without the level up GUI.
/// </summary>
/// <param name="classType">The class to level up.</param>
/// <param name="hitDie">The hit points gained during this level up.</param>
/// <param name="abilityGain">The abilty to increase : 6 = no increase.</param>
/// <param name="epic">Is this an epic level.</param>
/// <param name="skillPointsRemaining">Number of skill points to give</param>
/// <param name="domain1">Sets a cleric domain for the class (255 = no domain)</param>
/// <param name="domain2">Sets the second cleric domain for the class (255 = no domain)</param>
/// <param name="school">Sets the wizard school for the class (255 = no school)</param>
/// <param name="addStatsToList">Adds the new stats to the character sheet</param>
public void ForceLevelUp(NwClass classType, byte hitDie, Ability? abilityGain = default, bool epic = false, ushort skillPointsRemaining = 0, NwDomain? domain1 = default, NwDomain? domain2 = default, SpellSchool school = SpellSchool.Unknown, bool addStatsToList = true)
{
abilityGain ??= (Ability)6;

CNWLevelStats stats = new CNWLevelStats()
{
m_nClass = classType.Id,
m_nHitDie = hitDie,
m_nAbilityGain = (byte)abilityGain,
m_bEpic = epic.ToInt(),
m_nSkillPointsRemaining = skillPointsRemaining,
};

Creature.m_pStats.LevelUp(stats, domain1?.Id ?? 255, domain2?.Id ?? 255, unchecked((byte)school), addStatsToList.ToInt());
GC.SuppressFinalize(stats);
}

/// <summary>
/// Instructs this creature to equip the specified item into the given inventory slot.<br/>
/// Note: If the creature already has an item equipped in the slot specified, it will be unequipped automatically
Expand Down Expand Up @@ -2574,6 +2619,26 @@ public void SummonAnimalCompanion()
NWScript.SummonAnimalCompanion(this);
}

/// <summary>
/// Forces this creature to summon a familiar event if it does not meet the base game requirements
/// </summary>
/// <param name="resRef">The blueprint resource reference of the creature.</param>
public void SummonAnimalCompanion(string resRef)
{
Creature.SummonAssociate(new CResRef(resRef), Creature.m_pStats.m_sAnimalCompanionName, (ushort)AssociateType.AnimalCompanion);
Creature.m_bSummonedAnimalCompanion = 1;
}

/// <summary>
/// Forces this creature to unsummon their animal companion.<br/>
/// Does nothing if this creature has no animal companion summoned.
/// </summary>
public void UnsummonAnimalCompanion()
{
GetAssociate(AssociateType.AnimalCompanion)?.Creature.UnsummonMyself();
Creature.m_bSummonedAnimalCompanion = 0;
}

/// <summary>
/// Instructs this creature to summon their familiar (wizard/sorcerer).<br/>
/// Does nothing if this creature has no familiar available.
Expand All @@ -2583,6 +2648,35 @@ public void SummonFamiliar()
NWScript.SummonFamiliar(this);
}

/// <summary>
/// Forces this creature to summon a familiar event if it does not meet the base game requirements
/// </summary>
/// <param name="resRef">The blueprint resource reference of the creature.</param>
public void SummonFamiliar(string resRef)
{
Creature.SummonAssociate(new CResRef(resRef), Creature.m_pStats.m_sFamiliarName, (ushort)AssociateType.Familiar);
Creature.m_bSummonedFamiliar = 1;
}

/// <summary>
/// Forces this creature to unsummon their familiar.<br/>
/// Does nothing if this creature has no familiar summoned.
/// </summary>
public void UnsummonFamiliar()
{
GetAssociate(AssociateType.Familiar)?.Creature.UnsummonMyself();
Creature.m_bSummonedFamiliar = 0;
}

/// <summary>
/// Forces this creature to unsummon itself.<br/>
/// Does nothing if this creature is not a summon.
/// </summary>
public void Unsummon()
{
Creature.UnsummonMyself();
}

/// <summary>
/// Takes gold away from this creature.
/// </summary>
Expand Down
Loading