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 - Add ForceLevelUp #792

Closed

Conversation

Chimerik
Copy link
Contributor

@Chimerik Chimerik commented Jan 3, 2025

Forces a PC to level up without the level up GUI

using System.Runtime.InteropServices;
using Anvil.API.Events;
using Anvil.Native;
using Anvil.Services;
using NWN.Core;

Check warning

Code scanning / InspectCode

Redundant using directive Warning

Using directive is not required by the code and can be safely removed
OnSpellBroadcast eventData = ProcessEvent(EventCallbackType.Before, new OnSpellBroadcast
{
Caster = creature.ToNwObject<NwCreature>()!,
Spell = NwSpell.FromSpellId((int)nSpellId)!,
ClassIndex = nMultiClass,
Feat = NwFeat.FromFeatId(nFeat)!,
TargetObject = oTarget,
TargetPosition = oTarget is not null ? oTarget.Position : new Vector3(BitConverter.Int32BitsToSingle((int)creature.m_pExecutingAIAction.m_pParameter[6]), BitConverter.Int32BitsToSingle((int)creature.m_pExecutingAIAction.m_pParameter[7]), BitConverter.Int32BitsToSingle((int)creature.m_pExecutingAIAction.m_pParameter[8])),

Check warning

Code scanning / InspectCode

Expression is always true according to nullable reference types' annotations Warning

Expression is always true according to nullable reference types' annotations
OnSpellBroadcast eventData = ProcessEvent(EventCallbackType.Before, new OnSpellBroadcast
{
Caster = creature.ToNwObject<NwCreature>()!,
Spell = NwSpell.FromSpellId((int)nSpellId)!,
ClassIndex = nMultiClass,
Feat = NwFeat.FromFeatId(nFeat)!,
TargetObject = oTarget,
TargetPosition = oTarget is not null ? oTarget.Position : new Vector3(BitConverter.Int32BitsToSingle((int)creature.m_pExecutingAIAction.m_pParameter[6]), BitConverter.Int32BitsToSingle((int)creature.m_pExecutingAIAction.m_pParameter[7]), BitConverter.Int32BitsToSingle((int)creature.m_pExecutingAIAction.m_pParameter[8])),

Check notice

Code scanning / InspectCode

Merge conditional ?: expression into conditional access Note

Merge conditional expression
@@ -104,5 +104,17 @@
{
AreaOfEffect.AddToArea(area, x, y, z, true.ToInt());
}
/// <summary>

Check warning

Code scanning / InspectCode

Incorrect blank lines: Blank lines are missing elsewhere Warning

Blank lines are missing, expected minimum 1 instead of 0
@@ -992,6 +992,33 @@
await WaitForObjectContext();
NWScript.ActionCounterSpell(counterSpellTarget);
}
/// <summary>

Check warning

Code scanning / InspectCode

Incorrect blank lines: Blank lines are missing elsewhere Warning

Blank lines are missing, expected minimum 1 instead of 0
/// <param name="addStatsToList">Adds the new stats to the character sheet</param>
public void ForceLevelUp(byte nClass, byte nHitDie, byte nAbilityGain = 6, int bEpic = 0, ushort nSkillPointsRemaining = 0, byte nDomain1 = 255, byte nDomain2 = 255, byte nSchool = 255, int addStatsToList = 1)
{
CNWLevelStats stats = new()

Check notice

Code scanning / InspectCode

Use preferred style of 'new' expression when created type is evident Note

Missing type specification
Copy link

github-actions bot commented Jan 3, 2025

Test Results

       1 files  ±0     219 suites  ±0   1m 25s ⏱️ ±0s
1 416 tests ±0  1 416 ✔️ ±0  0 💤 ±0  0 ±0 
2 224 runs  ±0  2 224 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit c5811bf. ± Comparison against base commit f9e27f5.

♻️ This comment has been updated with latest results.

get => NWScript.GetAnimalCompanionName(this);
set => Creature.m_pStats.m_sAnimalCompanionName = value.ToExoString();
}

Check notice

Code scanning / InspectCode

Unnecessary whitespace at the end of line

Unnecessary whitespace
get => (AnimalCompanionCreatureType)NWScript.GetAnimalCompanionCreatureType(this);
set => Creature.m_pStats.m_nAnimalCompanionCreatureType = (int)value;
}

Check notice

Code scanning / InspectCode

Unnecessary whitespace at the end of line

Unnecessary whitespace
{
get => NWScript.GetFamiliarName(this);
set => Creature.m_pStats.m_sFamiliarName = value.ToExoString();
}

Check warning

Code scanning / InspectCode

Incorrect indent: Around declaration braces

Line indent is not restored to the previous level around declaration braces
get => NWScript.GetFamiliarName(this);
set => Creature.m_pStats.m_sFamiliarName = value.ToExoString();
}

Check notice

Code scanning / InspectCode

Unnecessary whitespace at the end of line

Unnecessary whitespace
public FamiliarCreatureType FamiliarType => (FamiliarCreatureType)NWScript.GetFamiliarCreatureType(this);

public FamiliarCreatureType FamiliarType
{

Check notice

Code scanning / InspectCode

Unnecessary whitespace at the end of line

Unnecessary whitespace
@Chimerik Chimerik force-pushed the NwCreatureForceLevelUp branch from 7355749 to c5811bf Compare January 3, 2025 10:04
@Chimerik Chimerik requested a review from jhett12321 January 3, 2025 10:23
@Chimerik Chimerik closed this Jan 4, 2025
@Chimerik Chimerik deleted the NwCreatureForceLevelUp branch January 4, 2025 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant