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

Build 8193.36-10 #1731

Merged
merged 2 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
23 changes: 19 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased
https://github.com/nwnxee/unified/compare/build8193.36.9...HEAD
https://github.com/nwnxee/unified/compare/build8193.36.10...HEAD

### Added
- Optimizations: added `NWNX_OPTIMIZATIONS_CACHE_SCRIPTS` to cache scripts after first execution.
- N/A

##### New Plugins
- N/A

##### New NWScript Functions
- Util: CleanResourceDirectory()
- N/A

### Changed
- NWNX_Item_RestoreItemAppearance() will now force an immediate update to the items AC, depending on new appearance.
- N/A

### Deprecated
- N/A
Expand All @@ -28,6 +28,21 @@ https://github.com/nwnxee/unified/compare/build8193.36.9...HEAD
### Fixed
- N/A

## 8193.36.10
https://github.com/nwnxee/unified/compare/build8193.36.9...build8193.36.10

### Added
- Optimizations: added `NWNX_OPTIMIZATIONS_CACHE_SCRIPTS` to cache scripts after first execution.

##### New NWScript Functions
- Util: CleanResourceDirectory()

### Changed
- NWNX_Item_RestoreItemAppearance() will now force an immediate update to the items AC, depending on new appearance.

### Fixed
- Weapon: fixed SetWeaponFinesseSize() clobbering the baseitems.2da values.

## 8193.36.9
https://github.com/nwnxee/unified/compare/build8193.36.8...build8193.36.9

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ find_package(Sanitizers)
execute_process(COMMAND git rev-parse --short HEAD OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE SHORT_HASH)
set(TARGET_NWN_BUILD 8193)
set(TARGET_NWN_BUILD_REVISION 36)
set(TARGET_NWN_BUILD_POSTFIX 9)
set(TARGET_NWN_BUILD_POSTFIX 10)
set(NWNX_BUILD_SHA ${SHORT_HASH})
set(PLUGIN_PREFIX NWNX_)

Expand Down
98 changes: 4 additions & 94 deletions Plugins/Weapon/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ Weapon::Weapon(Services::ProxyServiceList* services)

m_GetWeaponFocusHook = Hooks::HookFunction(&CNWSCreatureStats::GetWeaponFocus, &Weapon::GetWeaponFocus, Hooks::Order::Late);
m_GetEpicWeaponFocusHook = Hooks::HookFunction(&CNWSCreatureStats::GetEpicWeaponFocus, &Weapon::GetEpicWeaponFocus);
static auto s_GetWeaponFinesseHook = Hooks::HookFunction(&CNWSCreatureStats::GetWeaponFinesse, &GetWeaponFinesse, Hooks::Order::Final);

m_GetWeaponImprovedCriticalHook = Hooks::HookFunction(&CNWSCreatureStats::GetWeaponImprovedCritical, &Weapon::GetWeaponImprovedCritical, Hooks::Order::Late);
m_GetWeaponSpecializationHook = Hooks::HookFunction(&CNWSCreatureStats::GetWeaponSpecialization, &Weapon::GetWeaponSpecialization, Hooks::Order::Late);
Expand All @@ -71,8 +70,6 @@ Weapon::Weapon(Services::ProxyServiceList* services)
m_GetMeleeAttackBonusHook = Hooks::HookFunction(&CNWSCreatureStats::GetMeleeAttackBonus, &Weapon::GetMeleeAttackBonus, Hooks::Order::Late);
m_GetRangedAttackBonusHook = Hooks::HookFunction(&CNWSCreatureStats::GetRangedAttackBonus, &Weapon::GetRangedAttackBonus, Hooks::Order::Late);

m_WeaponFinesseSizeMap.insert({Constants::BaseItem::Rapier, (uint8_t) Constants::CreatureSize::Medium});

m_DCScript="";

m_GASling = Config::Get<bool>("GOOD_AIM_SLING", false);
Expand Down Expand Up @@ -184,7 +181,7 @@ ArgumentStack Weapon::SetWeaponFinesseSize(ArgumentStack&& args)
CNWBaseItem *pBaseItem = Globals::Rules()->m_pBaseItemArray->GetBaseItem(w_bitem);
ASSERT_OR_THROW(pBaseItem);

m_WeaponFinesseSizeMap.insert({w_bitem, size});
pBaseItem->m_nWeaponFinesseMinimumCreatureSize = size;
auto baseItemName = pBaseItem->GetNameText();
LOG_INFO("Weapon Finesse Size %d added for Base Item Type %d [%s]", size, w_bitem, baseItemName);

Expand All @@ -193,17 +190,14 @@ ArgumentStack Weapon::SetWeaponFinesseSize(ArgumentStack&& args)

ArgumentStack Weapon::GetWeaponFinesseSize(ArgumentStack&& args)
{
int32_t retVal = -1;

const auto baseItem = ScriptAPI::ExtractArgument<int32_t>(args);
ASSERT_OR_THROW(baseItem >= Constants::BaseItem::MIN);
ASSERT_OR_THROW(baseItem <= Constants::BaseItem::MAX);

auto search = m_WeaponFinesseSizeMap.find(baseItem);
if (search != m_WeaponFinesseSizeMap.end())
retVal = search->second;
CNWBaseItem *pBaseItem = Globals::Rules()->m_pBaseItemArray->GetBaseItem(baseItem);
ASSERT_OR_THROW(pBaseItem);

return ScriptAPI::Arguments(retVal);
return !pBaseItem->m_nWeaponFinesseMinimumCreatureSize ? -1 : pBaseItem->m_nWeaponFinesseMinimumCreatureSize;
}

ArgumentStack Weapon::SetWeaponUnarmed(ArgumentStack&& args)
Expand Down Expand Up @@ -554,16 +548,6 @@ int32_t Weapon::GetEpicWeaponFocus(CNWSCreatureStats* pStats, CNWSItem* pWeapon)
return (bApplicableFeatExists && bHasApplicableFeat ? 1 : plugin.m_GetEpicWeaponFocusHook->CallOriginal<int32_t>(pStats, pWeapon));
}

int32_t Weapon::GetWeaponFinesse(CNWSCreatureStats* pStats, CNWSItem* pWeapon)
{
Weapon& plugin = *g_plugin;

if (!pStats->HasFeat(Constants::Feat::WeaponFinesse))
return 0;

return plugin.GetIsWeaponLight(pStats, pWeapon, true) ? 1 : 0;
}

int32_t Weapon::GetWeaponImprovedCritical(CNWSCreatureStats* pStats, CNWSItem* pWeapon)
{
int32_t bApplicableFeatExists = 0;
Expand Down Expand Up @@ -1129,80 +1113,6 @@ int32_t Weapon::GetRangedAttackBonus(CNWSCreatureStats* pStats, int32_t bInclude
return nBonus;
}


bool Weapon::GetIsWeaponLight(CNWSCreatureStats* pStats, CNWSItem* pWeapon, bool bFinesse)
{
Weapon& plugin = *g_plugin;

if (GetIsUnarmedWeapon(pWeapon))
{
return true;
}

if (pStats->m_pBaseCreature == nullptr ||
pStats->m_pBaseCreature->m_nCreatureSize < (int32_t) Constants::CreatureSize::Tiny ||
pStats->m_pBaseCreature->m_nCreatureSize > (int32_t) Constants::CreatureSize::Huge)
{
return false;
}

if (bFinesse)
{
auto w = plugin.m_WeaponFinesseSizeMap.find(pWeapon->m_nBaseItem);
int iSize = (w == plugin.m_WeaponFinesseSizeMap.end()) ? Constants::CreatureSize::Huge + 1 : w->second;

if (pStats->m_pBaseCreature->m_nCreatureSize >= iSize)
{
return true;
}
}

int rel = pStats->m_pBaseCreature->GetRelativeWeaponSize(pWeapon);

// Ensure small creatures can finesse small weapons
if (bFinesse &&
(uint32_t) (pStats->m_pBaseCreature->m_nCreatureSize) <= Constants::CreatureSize::Small)
{
return (rel <= 0);
}

return (rel < 0);
}

bool Weapon::GetIsUnarmedWeapon(CNWSItem* pWeapon)
{
Weapon& plugin = *g_plugin;

if (pWeapon == nullptr)
return true;

// In case of standard unarmed weapon return true
if (pWeapon->m_nBaseItem == Constants::BaseItem::Gloves ||
pWeapon->m_nBaseItem == Constants::BaseItem::Bracer ||
pWeapon->m_nBaseItem == Constants::BaseItem::CreatureSlashWeapon ||
pWeapon->m_nBaseItem == Constants::BaseItem::CreaturePierceWeapon ||
pWeapon->m_nBaseItem == Constants::BaseItem::CreatureBludgeWeapon ||
pWeapon->m_nBaseItem == Constants::BaseItem::CreatureSlashPierceWeapon)
{
return true;
}

// Check if weapon should be considered unarmed
auto w = plugin.m_WeaponUnarmedSet.find(pWeapon->m_nBaseItem);
return (w == plugin.m_WeaponUnarmedSet.end()) ? false : true;
}

int Weapon::GetLevelByClass(CNWSCreatureStats *pStats, uint32_t nClassType)
{
for (int i = 0; i < pStats->m_nNumMultiClasses; i++)
{
if (pStats->m_ClassInfo[i].m_nClass == nClassType)
return pStats->m_ClassInfo[i].m_nLevel;
}

return 0;
}

ArgumentStack Weapon::SetOneHalfStrength(ArgumentStack&& args)
{
auto objectId = ScriptAPI::ExtractArgument<ObjectID>(args);
Expand Down
6 changes: 0 additions & 6 deletions Plugins/Weapon/Weapon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class Weapon : public NWNXLib::Plugin

static int32_t GetWeaponFocus (CNWSCreatureStats *pStats, CNWSItem* pItem);
static int32_t GetEpicWeaponFocus (CNWSCreatureStats *pStats, CNWSItem *pItem);
static int32_t GetWeaponFinesse (CNWSCreatureStats *pStats, CNWSItem *pItem);
static int32_t GetWeaponImprovedCritical (CNWSCreatureStats *pStats, CNWSItem *pItem);
static int32_t GetWeaponSpecialization (CNWSCreatureStats *pStats, CNWSItem *pItem);
static int32_t GetEpicWeaponSpecialization (CNWSCreatureStats *pStats, CNWSItem *pItem);
Expand All @@ -94,7 +93,6 @@ class Weapon : public NWNXLib::Plugin

std::map<std::uint32_t, std::set<std::uint32_t>> m_WeaponFocusMap;
std::map<std::uint32_t, std::set<std::uint32_t>> m_EpicWeaponFocusMap;
std::map<std::uint32_t, std::uint8_t> m_WeaponFinesseSizeMap;
std::map<std::uint32_t, std::set<std::uint32_t>> m_WeaponImprovedCriticalMap;
std::map<std::uint32_t, std::set<std::uint32_t>> m_WeaponSpecializationMap;
std::map<std::uint32_t, std::set<std::uint32_t>> m_EpicWeaponSpecializationMap;
Expand All @@ -106,10 +104,6 @@ class Weapon : public NWNXLib::Plugin

std::set<std::uint32_t> m_WeaponUnarmedSet;

bool GetIsWeaponLight (CNWSCreatureStats* pInfo, CNWSItem* pWeapon, bool bFinesse);
bool GetIsUnarmedWeapon(CNWSItem* pWeapon);
int GetLevelByClass (CNWSCreatureStats* pStats, uint32_t nClassType);

// Devastating Critical data
DevastatingCriticalDataStr m_DCData;
std::string m_DCScript;
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[![Discord](https://img.shields.io/discord/382306806866771978.svg?colorB=7289DA&label=Discord&logo=Discord&logoColor=7289DA&style=flat-square)](https://discord.gg/hxTt8Fr)

# NWNX:EE (build 8193.36.9 - v88 - DEVELOPMENT)
# NWNX:EE (build 8193.36.10 - v88 - DEVELOPMENT)

- Latest release: [build8193.36.9-HEAD](https://github.com/nwnxee/unified/releases/latest) - [Changelog](https://github.com/nwnxee/unified/blob/master/CHANGELOG.md#Unreleased)
- Latest release: [build8193.36.10-HEAD](https://github.com/nwnxee/unified/releases/latest) - [Changelog](https://github.com/nwnxee/unified/blob/master/CHANGELOG.md#Unreleased)
- Docker tag: `nwnxee/unified:latest`
- nwserver-linux md5: `2c14f05dc968ab3ae3ed690ac06a9618`
- nwserver-linux md5: `bb78316696fff8df0d82f76e073b2f78`

@mainpage
@tableofcontents
Expand Down
Loading