@ -47,6 +47,9 @@ All rights reserved.
# include "SoundEffect.h"
# include "SoundEffect.h"
# include "ClassInfo.h"
# include "ClassInfo.h"
# include "RowInventoryScrollableWindowComponent.h"
# include "RowInventoryScrollableWindowComponent.h"
# ifndef __EMSCRIPTEN__
# include <isteamuserstats.h>
# endif
INCLUDE_game
INCLUDE_game
INCLUDE_DATA
INCLUDE_DATA
@ -840,8 +843,10 @@ void Inventory::EquipItem(const std::weak_ptr<Item>it,EquipSlot slot){
if ( equippedSlot ! = EquipSlot : : NONE ) UnequipItem ( equippedSlot ) ;
if ( equippedSlot ! = EquipSlot : : NONE ) UnequipItem ( equippedSlot ) ;
if ( ! GetEquip ( slot ) . expired ( ) ) UnequipItem ( slot ) ;
if ( ! GetEquip ( slot ) . expired ( ) ) UnequipItem ( slot ) ;
Inventory : : equipment [ slot ] = it ;
Inventory : : equipment [ slot ] = it ;
game - > GetPlayer ( ) - > RecalculateEquipStats ( ) ;
game - > GetPlayer ( ) - > RecalculateEquipStats ( ) ;
} ;
} ;
void Inventory : : UnequipItem ( EquipSlot slot ) {
void Inventory : : UnequipItem ( EquipSlot slot ) {
Inventory : : equipment [ slot ] = Item : : BLANK ;
Inventory : : equipment [ slot ] = Item : : BLANK ;
game - > GetPlayer ( ) - > RecalculateEquipStats ( ) ;
game - > GetPlayer ( ) - > RecalculateEquipStats ( ) ;
@ -923,6 +928,33 @@ void Item::EnhanceItem(uint8_t qty){
if ( enhancementLevel + 1 > " Item.Item Max Enhancement Level " _I ) ERR ( " WARNING! Attempted to enhance " < < DisplayName ( ) < < " beyond the cap of " < < " Item.Item Max Enhancement Level " _I ) ;
if ( enhancementLevel + 1 > " Item.Item Max Enhancement Level " _I ) ERR ( " WARNING! Attempted to enhance " < < DisplayName ( ) < < " beyond the cap of " < < " Item.Item Max Enhancement Level " _I ) ;
enhancementLevel + + ;
enhancementLevel + + ;
if ( SteamUserStats ( ) ) {
# pragma region Fully Decked Out Achievement
datafile & unlock = DATA . GetProperty ( " Achievement.Equip Unlocks.Fully Decked Out " ) ;
if ( Inventory : : EquipsFullyMaxedOut ( unlock [ " Weapon Max Level " ] . GetInt ( ) , unlock [ " Armor Max Level " ] . GetInt ( ) ) ) {
SteamUserStats ( ) - > SetAchievement ( unlock [ " API Name " ] . GetString ( ) . c_str ( ) ) ;
SteamUserStats ( ) - > StoreStats ( ) ;
}
# pragma endregion
# pragma region Equipment achievement unlocks
for ( auto & [ key , size ] : DATA . GetProperty ( " Achievement.Equip Unlocks " ) ) {
datafile & unlock = DATA . GetProperty ( std : : format ( " Achievement.Equip Unlocks.{} " , key ) ) ;
if ( ! ( unlock . HasProperty ( " Upgrade Requirement " ) & & unlock . HasProperty ( " Equip Slot " ) ) ) continue ; //Ignore any achievements that don't have an upgrade requirement/equipment slot defined.
if ( EnhancementLevel ( ) > = unlock [ " Upgrade Requirement " ] . GetInt ( ) ) {
EquipSlot validSlots = EquipSlot : : NONE ;
for ( const std : : string & slot : unlock [ " Equip Slot " ] . GetValues ( ) ) {
validSlots | = ItemInfo : : StringToEquipSlot ( slot ) ; //Collect all the bits that this equipment can fall under.
}
if ( GetEquipSlot ( ) & validSlots ) {
//This piece of gear matches one of the provided slots.
SteamUserStats ( ) - > SetAchievement ( unlock [ " API Name " ] . GetString ( ) . c_str ( ) ) ;
SteamUserStats ( ) - > StoreStats ( ) ;
}
}
}
# pragma endregion
}
const CraftingRequirement & consumedResources = GetEnhancementInfo ( ) [ EnhancementLevel ( ) ] . craftingRequirement ;
const CraftingRequirement & consumedResources = GetEnhancementInfo ( ) [ EnhancementLevel ( ) ] . craftingRequirement ;
@ -1284,4 +1316,25 @@ void Item::Lock(){
}
}
void Item : : Unlock ( ) {
void Item : : Unlock ( ) {
locked = false ;
locked = false ;
}
//Specifically for the "Fully Decked Out" achievement.
const bool Inventory : : EquipsFullyMaxedOut ( int maxWeaponLevel , int maxArmorLevel ) {
for ( int i = int ( EquipSlot : : HELMET ) ; i < = int ( EquipSlot : : RING2 ) ; i < < = 1 ) {
EquipSlot slot = EquipSlot ( i ) ;
if ( ! ISBLANK ( Inventory : : GetEquip ( slot ) ) ) {
std : : shared_ptr < Item > equip = Inventory : : GetEquip ( slot ) . lock ( ) ;
if ( ! ( equip - > IsAccessory ( ) | |
( equip - > IsWeapon ( ) & & equip - > EnhancementLevel ( ) > = maxWeaponLevel ) | |
( equip - > IsArmor ( ) & & equip - > EnhancementLevel ( ) > = maxArmorLevel ) )
) {
return false ;
}
} else return false ;
}
return true ;
}
const EquipSlot ItemInfo : : StringToEquipSlot ( std : : string_view slotName ) {
return nameToEquipSlot [ std : : string ( slotName ) ] ;
}
}