Skip to content

Commit 422b48c

Browse files
revolucasXottab-DUTY
authored andcommitted
+ added decay_rate for detectors when use_condition = true. on animation end this value will be subtracted from the items condition
= fixed issue with non-slot equipment mechanic and stacks ~ added PDA_SLOT and TORCH_SLOT to list
1 parent 835f476 commit 422b48c

File tree

7 files changed

+56
-27
lines changed

7 files changed

+56
-27
lines changed

src/xrGame/CustomDetector.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ void CCustomDetector::OnAnimationEnd(u32 state)
155155
inherited::OnAnimationEnd(state);
156156
switch (state)
157157
{
158-
case eShowing: { SwitchState(eIdle);
158+
case eShowing:
159+
{
160+
SwitchState(eIdle);
161+
if (IsUsingCondition() && m_fDecayRate > 0.f)
162+
this->SetCondition(-m_fDecayRate);
159163
}
160164
break;
161165
case eHiding:
@@ -197,6 +201,7 @@ void CCustomDetector::Load(LPCSTR section)
197201

198202
m_fAfDetectRadius = pSettings->r_float(section, "af_radius");
199203
m_fAfVisRadius = pSettings->r_float(section, "af_vis_radius");
204+
m_fDecayRate = READ_IF_EXISTS(pSettings, r_float, section, "decay_rate", 0.f); //Alundaio
200205
m_artefacts.load(section, "af");
201206

202207
m_sounds.LoadSound(section, "snd_draw", "sndShow");
@@ -214,6 +219,10 @@ void CCustomDetector::shedule_Update(u32 dt)
214219

215220
Fvector P;
216221
P.set(H_Parent()->Position());
222+
223+
if (IsUsingCondition() && GetCondition() <= 0.01f)
224+
return;
225+
217226
m_artefacts.feel_touch_update(P, m_fAfDetectRadius);
218227
}
219228

src/xrGame/CustomDetector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class CCustomDetector : public CHudItemObject
166166

167167
bool m_bWorking;
168168
float m_fAfVisRadius;
169-
169+
float m_fDecayRate; //Alundaio
170170
CAfList m_artefacts;
171171
};
172172

src/xrGame/console_commands.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ extern int g_upgrades_log;
9696
extern float g_smart_cover_animation_speed_factor;
9797

9898
extern BOOL g_ai_use_old_vision;
99-
float g_aim_predict_time = 0.44f;
99+
float g_aim_predict_time = 0.40f;
100100
int g_keypress_on_start = 1;
101101

102102
ENGINE_API extern float g_console_sensitive;
@@ -2161,10 +2161,11 @@ void CCC_RegisterCommands()
21612161
#ifdef DEBUG
21622162
extern BOOL g_ai_dbg_sight;
21632163
CMD4(CCC_Integer, "ai_dbg_sight", &g_ai_dbg_sight, 0, 1);
2164+
#endif // #ifdef DEBUG
21642165

2166+
//Alundaio: Scoped outside DEBUG
21652167
extern BOOL g_ai_aim_use_smooth_aim;
21662168
CMD4(CCC_Integer, "ai_aim_use_smooth_aim", &g_ai_aim_use_smooth_aim, 0, 1);
2167-
#endif // #ifdef DEBUG
21682169

21692170
extern float g_ai_aim_min_speed;
21702171
CMD4(CCC_Float, "ai_aim_min_speed", &g_ai_aim_min_speed, 0.f, 10.f * PI);

src/xrGame/ui/UIActorMenuInventory.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ void CUIActorMenu::InitInventoryContents(CUIDragDropListEx* pBagList)
421421
InitCellForSlot(BINOCULAR_SLOT);
422422
if (!m_pActorInvOwner->inventory().SlotIsPersistent(ARTEFACT_SLOT))
423423
InitCellForSlot(ARTEFACT_SLOT);
424+
if (!m_pActorInvOwner->inventory().SlotIsPersistent(PDA_SLOT))
425+
InitCellForSlot(PDA_SLOT);
424426
if (!m_pActorInvOwner->inventory().SlotIsPersistent(TORCH_SLOT))
425427
InitCellForSlot(TORCH_SLOT); //Alundaio: TODO find out why this crash when you unequip
426428
//-Alundaio
@@ -586,8 +588,24 @@ bool CUIActorMenu::ToSlot(CUICellItem* itm, bool force_place, u16 slot_id)
586588
}
587589
else
588590
{
589-
SendEvent_Item2Slot(iitem, m_pActorInvOwner->object_id(), slot_id);
590-
SendEvent_ActivateSlot(slot_id, m_pActorInvOwner->object_id());
591+
//Alundaio: Since the player's inventory is being used as a slot we need to search for cell with matching m_pData
592+
CUICellContainer* c = slot_list->GetContainer();
593+
WINDOW_LIST child_list = c->GetChildWndList();
594+
// XXX: try to replace with range-based for
595+
for (WINDOW_LIST::iterator it = child_list.begin(); child_list.end() != it; ++it)
596+
{
597+
CUICellItem* i = static_cast<CUICellItem*>(*it);
598+
const PIItem pitm = static_cast<PIItem>(i->m_pData);
599+
if (pitm == _iitem)
600+
{
601+
if (ToBag(i, false))
602+
break;
603+
604+
return false;
605+
}
606+
}
607+
608+
return ToSlot(itm, false, slot_id);
591609
}
592610

593611
bool result = ToSlot(itm, false, slot_id);
@@ -721,6 +739,8 @@ CUIDragDropListEx* CUIActorMenu::GetSlotList(u16 slot_idx)
721739

722740
case DETECTOR_SLOT: return m_pInventoryDetectorList; break;
723741

742+
case PDA_SLOT:
743+
case TORCH_SLOT:
724744
case ARTEFACT_SLOT:
725745
case BINOCULAR_SLOT:
726746
case KNIFE_SLOT:

src/xrGame/ui/UIActorMenu_action.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,15 @@ bool CUIActorMenu::OnItemDbClick(CUICellItem* itm)
192192
{
193193
break;
194194
}
195-
PIItem iitem_to_place = (PIItem)itm->m_pData;
196-
if (!ToSlot(itm, false, iitem_to_place->BaseSlot()))
195+
PIItem iitem_to_place = static_cast<PIItem>(itm->m_pData);
196+
if (!m_pActorInvOwner->inventory().SlotIsPersistent(iitem_to_place->BaseSlot())
197+
&& m_pActorInvOwner->inventory().ItemFromSlot(iitem_to_place->BaseSlot()) == iitem_to_place)
197198
{
199+
ToBag(itm, false);
200+
}
201+
else if (!ToSlot(itm, false, iitem_to_place->BaseSlot()))
198202
if (!ToBelt(itm, false))
199-
{
200203
ToSlot(itm, true, iitem_to_place->BaseSlot());
201-
}
202-
}
203204
break;
204205
}
205206
case iActorBelt:

src/xrGame/ui/UIDragDropListEx.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -481,19 +481,20 @@ bool CUICellContainer::AddSimilar(CUICellItem* itm)
481481
if (!m_pParentDragDropList->IsGrouping())
482482
return false;
483483

484+
//Alundaio: Don't stack equipped items
485+
const PIItem iitem = static_cast<PIItem>(itm->m_pData);
486+
if (iitem && iitem->m_pInventory && iitem->m_pInventory->ItemFromSlot(iitem->BaseSlot()) == iitem)
487+
return false;
488+
//-Alundaio
489+
484490
CUICellItem* i = FindSimilar(itm);
485-
if (i == nullptr)
491+
if (i == nullptr || i == itm || itm->ChildsCount() > 0)
486492
return false;
487493

488-
R_ASSERT(i != itm);
489-
R_ASSERT(0 == itm->ChildsCount());
490-
if (i)
491-
{
492-
i->PushChild(itm);
493-
itm->SetOwnerList(m_pParentDragDropList);
494-
}
494+
i->PushChild(itm);
495+
itm->SetOwnerList(m_pParentDragDropList);
495496

496-
return (i != NULL);
497+
return true;
497498
}
498499

499500
CUICellItem* CUICellContainer::FindSimilar(CUICellItem* itm)
@@ -510,11 +511,11 @@ CUICellItem* CUICellContainer::FindSimilar(CUICellItem* itm)
510511
PIItem iitem = static_cast<PIItem>(i->m_pData);
511512
if (iitem && iitem->m_pInventory && iitem->m_pInventory->ItemFromSlot(iitem->BaseSlot()) == iitem)
512513
continue;
514+
//-Alundaio
513515

514516
if (i == itm)
515517
continue;
516518

517-
//R_ASSERT(i != itm);
518519
if (i->EqualTo(itm))
519520
return i;
520521
}
@@ -869,12 +870,8 @@ void CUICellContainer::Draw()
869870
{
870871
//Alundaio: Highlight equipped items
871872
PIItem iitem = static_cast<PIItem>(ui_cell.m_item->m_pData);
872-
if (iitem)
873-
{
874-
u16 slot = iitem->BaseSlot();
875-
if (iitem->m_pInventory && iitem->m_pInventory->ItemFromSlot(slot) == iitem)
876-
select_mode = 3;
877-
}
873+
if (iitem && iitem->m_pInventory && iitem->m_pInventory->ItemFromSlot(iitem->BaseSlot()) == iitem)
874+
select_mode = 3;
878875
//-Alundaio
879876
}
880877
}

src/xrGame/ui/UIDragDropListEx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class CUIDragDropListEx : public CUIWindow, public CUIWndCallback
150150
void clear_select_armament();
151151
Ivector2 PickCell(const Fvector2& abs_pos);
152152
CUICell& GetCellAt(const Ivector2& pos);
153+
CUICellContainer* GetContainer() { return m_container; }; //Alundaio
153154

154155
public:
155156
// UIWindow overriding

0 commit comments

Comments
 (0)