Skip to content

Commit

Permalink
Add xrGameLA files
Browse files Browse the repository at this point in the history
  • Loading branch information
St4lker0k765 committed Dec 7, 2024
1 parent 3a1dda7 commit d3ed9e2
Show file tree
Hide file tree
Showing 2,594 changed files with 373,812 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ if(NOT IXRAY_COMPRESSOR_ONLY)
if(IXR_TEST_CI)
add_subdirectory("Layers/xrRenderPC_R4")
add_subdirectory("xrGame")
add_subdirectory("xrGameLA")
endif()
endif()

Expand Down Expand Up @@ -57,6 +58,7 @@ if(NOT IXRAY_COMPRESSOR_ONLY)

if(IXR_TEST_CI)
set_target_properties(xrGame PROPERTIES ${IXRAY_FOLDER_GAME})
set_target_properties(xrGameLA PROPERTIES ${IXRAY_FOLDER_GAME})
endif()
endif()

Expand Down
108 changes: 108 additions & 0 deletions src/xrGameLA/AI_PhraseDialogManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
///////////////////////////////////////////////////////////////
// AI_PhraseDialogManager.cpp
// Êëàññ, îò êîòîðîãî íàñëåäóþòñÿ NPC ïåðñîíàæè, âåäóùèå äèàëîã
// ñ àêòåðîì
//
///////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "AI_PhraseDialogManager.h"
#include "PhraseDialog.h"
#include "inventoryowner.h"
#include "character_info.h"
#include "gameobject.h"
#include "relation_registry.h"

CAI_PhraseDialogManager::CAI_PhraseDialogManager (void)
{
m_sStartDialog = m_sDefaultStartDialog = NULL;
}

CAI_PhraseDialogManager::~CAI_PhraseDialogManager (void)
{}

//PhraseDialogManager
void CAI_PhraseDialogManager::ReceivePhrase (DIALOG_SHARED_PTR& phrase_dialog)
{
AnswerPhrase(phrase_dialog);
CPhraseDialogManager::ReceivePhrase(phrase_dialog);
}
#include "uigamesp.h"
#include "hudmanager.h"
#include "level.h"
#include "ui/UItalkWnd.h"

void CAI_PhraseDialogManager::AnswerPhrase (DIALOG_SHARED_PTR& phrase_dialog)
{
CInventoryOwner* pInvOwner = smart_cast<CInventoryOwner*>(this);
THROW (pInvOwner);
CGameObject* pOthersGO = smart_cast<CGameObject*>(phrase_dialog->OurPartner(this));
THROW (pOthersGO);
CInventoryOwner* pOthersIO = smart_cast<CInventoryOwner*>(pOthersGO);
THROW (pOthersIO);

if(!phrase_dialog->IsFinished())
{
CHARACTER_GOODWILL attitude = RELATION_REGISTRY().GetAttitude(pOthersIO, pInvOwner);

xr_vector<int> phrases;
CHARACTER_GOODWILL phrase_goodwill = NO_GOODWILL;
//åñëè íå íàéäåì áîëåå ïîäõîäÿåùåé âûâîäèì ôðàçó
//ïîñëåäíþþ èç ñïèñêà (ñàìóþ ãðóáóþ)
int phrase_num = phrase_dialog->PhraseList().size()-1;
for(u32 i=0; i<phrase_dialog->PhraseList().size(); ++i)
{
phrase_goodwill = phrase_dialog->PhraseList()[phrase_num]->GoodwillLevel();
if(attitude >= phrase_goodwill)
{
phrase_num = i;
break;
}
}

for(i=0; i<phrase_dialog->PhraseList().size(); i++)
{
if(phrase_goodwill == phrase_dialog->PhraseList()[phrase_num]->GoodwillLevel())
phrases.push_back(i);
}

phrase_num = phrases[Random.randI(0, phrases.size())];

shared_str phrase_id = phrase_dialog->PhraseList()[phrase_num]->GetID();

CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(CurrentGameUI());
pGameSP->TalkMenu->AddAnswer (phrase_dialog->GetPhraseText(phrase_id), pInvOwner->Name());

CPhraseDialogManager::SayPhrase(phrase_dialog, phrase_id);
}
}



void CAI_PhraseDialogManager::SetStartDialog(shared_str phrase_dialog)
{
m_sStartDialog = phrase_dialog;
}

void CAI_PhraseDialogManager::SetDefaultStartDialog(shared_str phrase_dialog)
{
m_sDefaultStartDialog = phrase_dialog;
}

void CAI_PhraseDialogManager::RestoreDefaultStartDialog()
{
m_sStartDialog = m_sDefaultStartDialog;
}


void CAI_PhraseDialogManager::UpdateAvailableDialogs (CPhraseDialogManager* partner)
{
m_AvailableDialogs.clear();
m_CheckedDialogs.clear();

if(*m_sStartDialog)
inherited::AddAvailableDialog(*m_sStartDialog, partner);
inherited::AddAvailableDialog("hello_dialog", partner);

inherited::UpdateAvailableDialogs(partner);
}
39 changes: 39 additions & 0 deletions src/xrGameLA/AI_PhraseDialogManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////
// AI_PhraseDialogManager.h
// Êëàññ, îò êîòîðîãî íàñëåäóþòñÿ NPC ïåðñîíàæè, âåäóùèå äèàëîã
// ñ àêòåðîì
//
///////////////////////////////////////////////////////////////

#pragma once

#include "PhraseDialogManager.h"


class CAI_PhraseDialogManager: public CPhraseDialogManager
{
private:
typedef CPhraseDialogManager inherited;
public:
CAI_PhraseDialogManager ();
virtual ~CAI_PhraseDialogManager ();

virtual void ReceivePhrase (DIALOG_SHARED_PTR& phrase_dialog);
virtual void UpdateAvailableDialogs (CPhraseDialogManager* partner);
virtual void AnswerPhrase (DIALOG_SHARED_PTR& phrase_dialog);


virtual void SetStartDialog (shared_str phrase_dialog);
virtual void SetDefaultStartDialog (shared_str phrase_dialog);
virtual shared_str GetStartDialog () {return m_sStartDialog;}
virtual void RestoreDefaultStartDialog ();
protected:
//äèàëîã, åñëè íå NULL, òî åãî ïåðñîíàæ çàïóñòèò
//ïðè âñòðå÷å ñ àêòåðîì
shared_str m_sStartDialog;
shared_str m_sDefaultStartDialog;

DEFINE_VECTOR(DIALOG_SHARED_PTR, DIALOG_SHARED_VECTOR, DIALOG_SHARED_IT);
//ñïèñîê äèàëîãîâ, íà êîòîðûå íóæíî îòâåòèòü
DIALOG_SHARED_VECTOR m_PendingDialogs;
};
120 changes: 120 additions & 0 deletions src/xrGameLA/AcidFog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/////////////////////////////////////
// file name: AcidFog.cpp
// author: lost alpha
// created: 18/08/2011
// edited: 18/08/2011
// purpose: rusty fog anomaly
//////////////////////////////////////
#include "stdafx.h"
#include "AcidFog.h"
#include "hudmanager.h"
#include "ParticlesObject.h"
#include "level.h"
#include "actor.h"
#include "inventory.h"
#include "physicsshellholder.h"
#include "../xr_collide_form.h"

#define DEFAULT_RUST_DAMAGE 0.15f

CRustyFog::CRustyFog(void)
{
m_dwDeltaTime = 0;
m_fHitImpulseScale = 1.f;

m_bLastBlowoutUpdate = false;
}

CRustyFog::~CRustyFog(void)
{
}

void CRustyFog::Load(LPCSTR section)
{
inherited::Load(section);
m_rust_damage = READ_IF_EXISTS(pSettings, r_float, section, "rusty_damage", DEFAULT_RUST_DAMAGE);
}


void CRustyFog::Postprocess(f32 /**val/**/)
{
}

bool CRustyFog::BlowoutState()
{
bool result = inherited::BlowoutState();
if(!result)
{
m_bLastBlowoutUpdate = false;
UpdateBlowout();
}
else if(!m_bLastBlowoutUpdate)
{
m_bLastBlowoutUpdate = true;
UpdateBlowout();
}

return result;
}

void CRustyFog::Affect(SZoneObjectInfo* O)
{
CPhysicsShellHolder *pGameObject = smart_cast<CPhysicsShellHolder*>(O->object);
if(!pGameObject) return;

if(O->zone_ignore) return;

Fvector P;
XFORM().transform_tiny(P,CFORM()->getSphere().P);

#ifdef DEBUG
char l_pow[255];
xr_sprintf(l_pow, "zone hit. %.1f", Power(pGameObject->Position().distance_to(P)));
if(bDebug) Msg("%s %s",*pGameObject->cName(), l_pow);
#endif

Fvector hit_dir;
hit_dir.set(::Random.randF(-.5f,.5f),
::Random.randF(.0f,1.f),
::Random.randF(-.5f,.5f));
hit_dir.normalize();


Fvector position_in_bone_space;

VERIFY(!pGameObject->getDestroy());

float dist = pGameObject->Position().distance_to(P) - pGameObject->Radius();
float power = Power(dist>0.f?dist:0.f);
float impulse = m_fHitImpulseScale*power*pGameObject->GetMass();

//ñòàòèñòèêà ïî îáúåêòó
O->total_damage += power;
O->hit_num++;

if(power > 0.01f)
{
m_dwDeltaTime = 0;
position_in_bone_space.set(0.f,0.f,0.f);

CreateHit(pGameObject->ID(),ID(),hit_dir,power,0,position_in_bone_space,impulse,m_eHitTypeBlowout);

PlayHitParticles(pGameObject);
}
if (pGameObject->ID() == Actor()->ID())
RustyItems();
}

#define RUSTY_ITEM(item, val) \
if (item) \
item->ChangeCondition(item->GetCondition() - val); \


void CRustyFog::RustyItems()
{
auto& slots = Actor()->inventory().m_slots;
RUSTY_ITEM(slots[PISTOL_SLOT].m_pIItem, m_rust_damage);
RUSTY_ITEM(slots[RIFLE_SLOT].m_pIItem, m_rust_damage);
RUSTY_ITEM(slots[RIFLE_2_SLOT].m_pIItem, m_rust_damage);
RUSTY_ITEM(slots[OUTFIT_SLOT].m_pIItem, m_rust_damage);
}
39 changes: 39 additions & 0 deletions src/xrGameLA/AcidFog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/////////////////////////////////////
// file name: AcidFog.h
// author: lost alpha
// created: 18/08/2011
// edited: 18/08/2011
// purpose: rusty fog anomaly
//////////////////////////////////////
#pragma once

#include "customzone.h"
#include "script_export_space.h"

class CRustyFog : public CCustomZone
{
private:
typedef CCustomZone inherited;
public:
CRustyFog(void);
virtual ~CRustyFog(void);

virtual void Load(LPCSTR section);
virtual void Postprocess(f32 val);
virtual bool EnableEffector() {return true;}


virtual void Affect(SZoneObjectInfo* O);

protected:
virtual bool BlowoutState();
bool m_bLastBlowoutUpdate;
private:
void RustyItems();
float m_rust_damage;
public:
DECLARE_SCRIPT_REGISTER_FUNCTION
};
add_to_type_list(CRustyFog)
#undef script_type_list
#define script_type_list save_type_list(CRustyFog)
Loading

0 comments on commit d3ed9e2

Please sign in to comment.