Skip to content

Commit

Permalink
xrGame/inventory_item_upgrade.cpp: support helmet_avaliable for outfi…
Browse files Browse the repository at this point in the history
…t's upgrades
  • Loading branch information
ChugunovRoman committed Dec 8, 2024
1 parent ba97ca2 commit 069a701
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/xrGame/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ void CActor::UpdateVisor()
if (!pVisor)
{
auto pOutfit = smart_cast<CCustomOutfit*>(inventory().ItemFromSlot(OUTFIT_SLOT));
if (pOutfit && !pOutfit->bIsHelmetAvaliable) // if our outfit blocks the helmet, it probably includes it's own helmet
if (pOutfit && !pOutfit->IsHelmetAllowed()) // if our outfit blocks the helmet, it probably includes it's own helmet
pVisor = pOutfit->cast_inventory_item();
}

Expand Down
6 changes: 3 additions & 3 deletions src/xrGame/CustomOutfit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@ void CCustomOutfit::OnMoveToSlot(const SInvItemPlace& prev)
if (pActor)
{
ApplySkinModel(pActor, true, false);
if (prev.type == eItemPlaceSlot && !bIsHelmetAvaliable)
if (prev.type == eItemPlaceSlot && !IsHelmetAllowed())
{
CTorch* pTorch = smart_cast<CTorch*>(pActor->inventory().ItemFromSlot(TORCH_SLOT));
if (pTorch && pTorch->GetNightVisionStatus())
pTorch->SwitchNightVision(true, false);
}
PIItem pHelmet = pActor->inventory().ItemFromSlot(HELMET_SLOT);
if (pHelmet && !bIsHelmetAvaliable)
if (pHelmet && !IsHelmetAllowed())
pActor->inventory().Ruck(pHelmet, false);

if (g_outfit_faction)
Expand Down Expand Up @@ -306,7 +306,7 @@ void CCustomOutfit::OnMoveToRuck(const SInvItemPlace& prev)
{
ApplySkinModel(pActor, false, false);
CTorch* pTorch = smart_cast<CTorch*>(pActor->inventory().ItemFromSlot(TORCH_SLOT));
if (pTorch && !bIsHelmetAvaliable)
if (pTorch && !IsHelmetAllowed())
pTorch->SwitchNightVision(false);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/xrGame/CustomOutfit.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class CCustomOutfit : public CInventoryItemObject
void ReloadBonesProtection();
void AddBonesProtection(LPCSTR bones_section);

virtual bool IsHelmetAllowed() const { return bIsHelmetAvaliable || !!m_flags.test(FAllowHelmet); };

protected:
virtual bool install_upgrade_impl(LPCSTR section, bool test);
};
2 changes: 1 addition & 1 deletion src/xrGame/Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ bool CInventory::CanPutInSlot(PIItem pIItem, u16 slot_id) const
if (slot_id == HELMET_SLOT)
{
CCustomOutfit* pOutfit = m_pOwner->GetOutfit();
if (pOutfit && !pOutfit->bIsHelmetAvaliable)
if (pOutfit && !pOutfit->IsHelmetAllowed())
return false;
}

Expand Down
1 change: 1 addition & 0 deletions src/xrGame/PhysicObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class CPhysicObject : public CPhysicsShellHolder, public CPHSkeleton
FInInterpolation = (1 << 9),
FInInterpolate = (1 << 10),
FIsQuestItem = (1 << 11),
FAllowHelmet = (1 << 12),
};
Flags16 m_flags;
bool m_just_after_spawn;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/inventory_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void CInventoryItem::ReloadNames()
if (artefact_count == 0)
artefact_count = pSettings->read_if_exists<u32>(section, "artefact_count", 0);

bool IsHelmetAvaliable = outfit->bIsHelmetAvaliable;
bool IsHelmetAvaliable = outfit->IsHelmetAllowed();
if (!IsHelmetAvaliable)
IsHelmetAvaliable = pSettings->read_if_exists<bool>(section, "helmet_avaliable", true);

Expand Down
2 changes: 2 additions & 0 deletions src/xrGame/inventory_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class CInventoryItem : public CAttachableItem,
FInInterpolate = (1 << 10),
FIsQuestItem = (1 << 11),
FIsHelperItem = (1 << 12),
FAllowHelmet = (1 << 13),
};

Flags16 m_flags;
Expand Down Expand Up @@ -222,6 +223,7 @@ class CInventoryItem : public CAttachableItem,
virtual ALife::_TIME_ID TimePassedAfterIndependant() const;

virtual bool IsSprintAllowed() const { return !!m_flags.test(FAllowSprint); };
virtual bool IsHelmetAllowed() const { return !!m_flags.test(FAllowHelmet); };
virtual float GetControlInertionFactor() const { return m_fControlInertionFactor; };
virtual void UpdateXForm();

Expand Down
7 changes: 7 additions & 0 deletions src/xrGame/inventory_item_upgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ bool CInventoryItem::install_upgrade_impl(LPCSTR section, bool test)
}
result |= result2;

result2 = process_if_exists_set(section, "helmet_avaliable", &CInifile::r_bool, value, test);
if (result2 && !test)
{
m_flags.set(FAllowHelmet, value);
}
result |= result2;

if (!g_normalize_upgrade_mouse_sens)
{
result |= process_if_exists(section, "control_inertion_factor", &CInifile::r_float, m_fControlInertionFactor, test);
Expand Down
8 changes: 4 additions & 4 deletions src/xrGame/ui/UIActorMenuInventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ bool CUIActorMenu::ToSlot(CUICellItem* itm, bool force_place, u16 slot_id)
if (slot_id == HELMET_SLOT)
{
CCustomOutfit* pOutfit = m_pActorInvOwner->GetOutfit();
if (pOutfit && !pOutfit->bIsHelmetAvaliable)
if (pOutfit && !pOutfit->IsHelmetAllowed())
return false;
}

Expand All @@ -561,7 +561,7 @@ bool CUIActorMenu::ToSlot(CUICellItem* itm, bool force_place, u16 slot_id)
else*/ if (slot_id == OUTFIT_SLOT)
{
CCustomOutfit* pOutfit = smart_cast<CCustomOutfit*>(iitem);
if (pOutfit && !pOutfit->bIsHelmetAvaliable)
if (pOutfit && !pOutfit->IsHelmetAllowed())
{
CUIDragDropListEx* helmet_list = GetSlotList(HELMET_SLOT);
if (helmet_list && helmet_list->ItemsCount() == 1)
Expand Down Expand Up @@ -1057,7 +1057,7 @@ void CUIActorMenu::PropertiesBoxForSlots(PIItem item, bool& b_show)
}

CCustomOutfit* outfit_in_slot = m_pActorInvOwner->GetOutfit();
if (pHelmet && !bAlreadyDressed && (!outfit_in_slot || outfit_in_slot->bIsHelmetAvaliable))
if (pHelmet && !bAlreadyDressed && (!outfit_in_slot || outfit_in_slot->IsHelmetAllowed()))
{
m_UIPropertiesBox->AddItem("st_dress_helmet", NULL, INVENTORY_TO_SLOT_ACTION);
b_show = true;
Expand Down Expand Up @@ -1613,7 +1613,7 @@ void CUIActorMenu::UpdateOutfit()
CCustomOutfit* outfit = m_pActorInvOwner->GetOutfit();
if (m_pLists[eInventoryHelmetList])
{
if (outfit && !outfit->bIsHelmetAvaliable)
if (outfit && !outfit->IsHelmetAllowed())
m_pLists[eInventoryHelmetList]->SetCellsCapacity({ 0, 0 });
else
m_pLists[eInventoryHelmetList]->SetCellsCapacity(m_pLists[eInventoryHelmetList]->MaxCellsCapacity());
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ui/UIActorStateInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void ui_actor_state_wnd::UpdateActorInfo(CInventoryOwner* owner)
m_state[stt_armor]->set_text(value);

fwou_value += value * outfit->GetCondition();
if (!outfit->bIsHelmetAvaliable)
if (!outfit->IsHelmetAllowed())
{
const auto head_bone = ikv->LL_BoneID("bip01_head");
fwou_value += outfit->GetBoneArmor(head_bone) * outfit->GetCondition();
Expand Down

0 comments on commit 069a701

Please sign in to comment.