Skip to content

Commit

Permalink
* restructured many features behind defines (see: Config.hpp)
Browse files Browse the repository at this point in the history
+ added a layered sound system (see: Config.hpp)
+ added get_hud():UpdateActorMenu() which refreshes the inventory screen
+ added new spawn_loadout features to character descriptions spawn item system (see: alife_object.cpp)
~ made corrections to how ammo_type is drawn on UI (requires static_third_ammo in maingame[_16].xml)
+ engine call to _G.CALifeUpdateManager__on_before_change_level (required!)
+ engine call to inventory_upgrades.effect_upgrade_item (required!)
- removed some unused testing game_object exports (is_explosive, is_script_zone, is_projector, is_missle, is_grenade, is_bottle, is_torch)
+ added game_object:set_bone_visible(string bone_name,bool visibility,bool recursive)
+ added game_object:bone_visible() bool
+ added game_object:get_luminocity() and game_object:get_luminocity_hemi()
- removed game_object:is_actor_indoors() and is_npc_indoors replaced by above
+ added level.get_active_cam() and level.set_active_cam(number)
= fixed game_object:has_upgrade(string)
+ added game_object:install_upgrade(string)
+ m_evaluator_name exposed outside DEBUG for better script logging
+ added FS():rescan_path(string) which toggles the flag to rescan the path when the game reloads which allows you to add new files and see the changes in-game without restarting application
  • Loading branch information
revolucas authored and Xottab-DUTY committed Dec 16, 2017
1 parent f59ae37 commit 6e703b4
Show file tree
Hide file tree
Showing 42 changed files with 769 additions and 386 deletions.
54 changes: 45 additions & 9 deletions src/Common/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,58 @@
// CONFIG_SCRIPT_ENGINE_LOG_EXPORTS
// CONFIG_SCRIPT_ENGINE_LOG_SKIPPED_EXPORTS

/* Callbacks */
#define EXTENDED_ITEM_CALLBACKS // (eItemToBelt, eItemToSlot, eItemToRuck)
#define EXTENDED_WEAPON_CALLBACKS // (eOnWeaponZoomIn, eOnWeaponZoomOut, eOnWeaponJammed)
//#define ACTOR_BEFORE_DEATH_CALLBACK // For extending the life of the actor to fake death or do other tasks that need to happen before actor is dead
#define INPUT_CALLBACKS // (eKeyPress, eKeyRelease, eKeyHold, eMouseMove, eMouseWheel)
#define ENGINE_LUA_ALIFE_STORAGE_MANAGER_CALLBACKS // calls lua functions from engine in a script named alife_storage_manager.script (alife_storage_manager.CALifeStorageManager_save) and (alife_storage_manager.CALifeStorageManager_load)
#define ENGINE_LUA_ALIFE_UPDAGE_MANAGER_CALLBACKS // calls lua function named on_before_change_level and on_after_new_game in _G.script when enabled

/* Scripts */
//#define MOUSE_MOVE_CALLBACK // expose mouse move callback to scripts (configure in bind_stalker)
//#define KEY_RELEASE_CALLBACK // expose key release callback to scripts (configure in bind_stalker)
//#define KEY_HOLD_CALLBACK // expose key hold callback to scripts (configure in bind_stalker)
#define MORE_INVENTORY_SLOTS // Adds 5 more slots CUSTOM_SLOT_1..5
#define GAME_OBJECT_EXTENDED_EXPORTS // see: script_game_object*.cpp/h
#define GAME_OBJECT_TESTING_EXPORTS // see: script_game_object4.cpp functions for object testing (ie. is_stalker(), is_heli())
#define NAMESPACE_LEVEL_EXPORTS // see: level_script.cpp

// VISUAL:
/* Visual */
#define DETAIL_RADIUS // detail draw radius (by K.D.)
#define ECO_RENDER // limit FPS in menu to prevent video card overheat (by alpet)
#define TREE_WIND_EFFECT // configurable tree sway, can be used to have trees sway more during storms or lightly on clear days.
//-VISUAL

// TWEAKS:
/* Tweaks: */
//#define FP_DEATH // first person death view
//#define ACTOR_BEFORE_DEATH_CALLBACK
#define DEAD_BODY_COLLISION // restore collision with dead bodies (thanks malandrinus)
#define NEW_ANIMS // use new animations. Please enclose any new animation addions with this define
#define NEW_SOUNDS // use new sounds. Please enclose any new sound addions with this define
#define NEW_ANIMS // use new animations. Please enclose any new animation additions with this define

//#define CONFIG_SUN_MOVEMENT // With this defined sun will move as configured in weather ltx files

/* Sound: */
#define NEW_SOUNDS // use new sounds. Please enclose any new sound additions with this define
#define LAYERED_SND_SHOOT// see comment down below

/* LAYERED_SND_SHOOT by Alundaio
When defined, it will allow you to play a group of sounds from a specified section for snd_shoot.
You can have as many layers as you want, but you must follow naming convention,
snd_1_layer
snd_2_layer
snd_3_layer
...
You can also have different variants for each layer defined,
snd_1_layer
snd_1_layer1
snd_1_layer2
...
The correct line settings are standard, (ie. snd_1_layer = sound_path, volume, delay)
ex.
Here is an example usage:
snd_shoot = new_snd_section
[new_snd_section]
snd_1_layer = weapons\new_sound_shoot1
snd_1_layer1 = weapons\new_sound_shoot2
snd_1_layer2 = weapons\new_sound_shoot3
snd_1_layer3 = weapons\new_sound_shoot4
snd_2_layer = weapons\mechanical_noise, 1.0, 0.1
snd_3_layer = weapons\gunshot_echo, 1.0, 0.8
*/
//-TWEAKS
3 changes: 2 additions & 1 deletion src/xrGame/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,10 @@ class CActor : public CEntityAlive,
IC CCameraBase* cam_FirstEye() { return cameras[eacFirstEye]; }

EActorCameras active_cam() const { return cam_active; } // KD: we need to know which cam is active outside actor methods
virtual void cam_Set(EActorCameras style); //Alundaio: made public

protected:
virtual void cam_Set(EActorCameras style);
//virtual void cam_Set(EActorCameras style);
void cam_Update(float dt, float fFOV);
void cam_Lookout(const Fmatrix& xform, float camera_height);
void camUpdateLadder(float dt);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Actor_Feel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void CActor::PickupModeUpdate()
}

#include "xrEngine/CameraBase.h"
BOOL g_b_COD_PickUpMode = TRUE;
BOOL g_b_COD_PickUpMode = TRUE; // XXX: allow to change this via console
void CActor::PickupModeUpdate_COD()
{
if (Level().CurrentViewEntity() != this || !g_b_COD_PickUpMode)
Expand Down
97 changes: 54 additions & 43 deletions src/xrGame/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,13 @@ BOOL CGameObject::net_Spawn(CSE_Abstract* DC)
}
else
{
R_ASSERT(Level().Objects.net_Find(E->ID) == NULL);
//Alundaio:
//R_ASSERT(Level().Objects.net_Find(E->ID) == nullptr);
if (Level().Objects.net_Find(E->ID) != nullptr)
{
ai().script_engine().script_log(LuaMessageType::Error, "CGameObject:net_Spawn() | Level().Objects.net_Find(E->ID) != nullptr (This mean object already exist on level by this ID) ID=%s s_name=%s", E->ID, E->s_name);
return false;
}
}

setID(E->ID);
Expand Down Expand Up @@ -701,54 +707,59 @@ void CGameObject::spawn_supplies()
for (u32 k = 0, j; spawn_ini()->r_line("spawn", k, &N, &V); k++)
{
VERIFY(xr_strlen(N));
j = 1;
p = 1.f;

float f_cond = 1.0f;
if (V && xr_strlen(V))
if (pSettings->section_exist(N)) //Alundaio: Validate section exists
{
int n = _GetItemCount(V);
string16 temp;
if (n > 0)
j = atoi(_GetItem(V, 0, temp)); // count

if (NULL != strstr(V, "prob="))
p = (float)atof(strstr(V, "prob=") + 5);
if (fis_zero(p))
p = 1.f;
if (!j)
j = 1;
if (NULL != strstr(V, "cond="))
f_cond = (float)atof(strstr(V, "cond=") + 5);
bScope = (NULL != strstr(V, "scope"));
bSilencer = (NULL != strstr(V, "silencer"));
bLauncher = (NULL != strstr(V, "launcher"));
}
for (u32 i = 0; i < j; ++i)
if (::Random.randF(1.f) < p)
j = 1;
p = 1.f;

float f_cond = 1.0f;
if (V && xr_strlen(V))
{
int n = _GetItemCount(V);
string16 temp;
if (n > 0)
j = atoi(_GetItem(V, 0, temp)); // count

if (NULL != strstr(V, "prob="))
p = (float)atof(strstr(V, "prob=") + 5);
if (fis_zero(p))
p = 1.f;
if (!j)
j = 1;
if (NULL != strstr(V, "cond="))
f_cond = (float)atof(strstr(V, "cond=") + 5);
bScope = (NULL != strstr(V, "scope"));
bSilencer = (NULL != strstr(V, "silencer"));
bLauncher = (NULL != strstr(V, "launcher"));
}
for (u32 i = 0; i < j; ++i)
{
CSE_Abstract* A = Level().spawn_item(N, Position(), ai_location().level_vertex_id(), ID(), true);
if (::Random.randF(1.f) < p)
{
CSE_Abstract* A = Level().spawn_item(N, Position(), ai_location().level_vertex_id(), ID(), true);

CSE_ALifeInventoryItem* pSE_InventoryItem = smart_cast<CSE_ALifeInventoryItem*>(A);
if (pSE_InventoryItem)
pSE_InventoryItem->m_fCondition = f_cond;
CSE_ALifeInventoryItem* pSE_InventoryItem = smart_cast<CSE_ALifeInventoryItem*>(A);
if (pSE_InventoryItem)
pSE_InventoryItem->m_fCondition = f_cond;

CSE_ALifeItemWeapon* W = smart_cast<CSE_ALifeItemWeapon*>(A);
if (W)
{
if (W->m_scope_status == ALife::eAddonAttachable)
W->m_addon_flags.set(CSE_ALifeItemWeapon::eWeaponAddonScope, bScope);
if (W->m_silencer_status == ALife::eAddonAttachable)
W->m_addon_flags.set(CSE_ALifeItemWeapon::eWeaponAddonSilencer, bSilencer);
if (W->m_grenade_launcher_status == ALife::eAddonAttachable)
W->m_addon_flags.set(CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher, bLauncher);
}
CSE_ALifeItemWeapon* W = smart_cast<CSE_ALifeItemWeapon*>(A);
if (W)
{
if (W->m_scope_status == ALife::eAddonAttachable)
W->m_addon_flags.set(CSE_ALifeItemWeapon::eWeaponAddonScope, bScope);
if (W->m_silencer_status == ALife::eAddonAttachable)
W->m_addon_flags.set(CSE_ALifeItemWeapon::eWeaponAddonSilencer, bSilencer);
if (W->m_grenade_launcher_status == ALife::eAddonAttachable)
W->m_addon_flags.set(CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher, bLauncher);
}

NET_Packet P;
A->Spawn_Write(P, TRUE);
Level().Send(P, net_flags(TRUE));
F_entity_Destroy(A);
NET_Packet P;
A->Spawn_Write(P, TRUE);
Level().Send(P, net_flags(TRUE));
F_entity_Destroy(A);
}
}
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/xrGame/HudItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ void CHudItem::PlaySound(LPCSTR alias, const Fvector& position)
m_sounds.PlaySound(alias, position, object().H_Root(), !!GetHUDmode());
}

//Alundaio: Play at index
void CHudItem::PlaySound(pcstr alias, const Fvector& position, u8 index)
{
m_sounds.PlaySound(alias, position, object().H_Root(), !!GetHUDmode(), false, index);
}
//-Alundaio

void CHudItem::renderable_Render()
{
UpdateXForm();
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/HudItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class CHudItem : public CHUDState
virtual void OnH_A_Independent();

virtual void PlaySound(LPCSTR alias, const Fvector& position);

virtual void PlaySound(pcstr alias, const Fvector& position, u8 index); //Alundaio: Play at index
virtual bool Action(u16 cmd, u32 flags) { return false; }
void OnMovementChanged(ACTOR_DEFS::EMoveCommand cmd);

Expand Down
121 changes: 120 additions & 1 deletion src/xrGame/HudSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ void HUD_SOUND_ITEM::PlaySound(
u32 flags = b_hud_mode ? sm_2D : 0;
if (looped)
flags |= sm_Looped;

//Alundaio: Sanity, don't allow PlaySound of index greater then the size, just play last index
if (index == u8(-1))
index = (u8)Random.randI(hud_snd.sounds.size());
else if (index >= (u8)hud_snd.sounds.size())
index = (u8)hud_snd.sounds.size()-1;

hud_snd.m_activeSnd = &hud_snd.sounds[index];

Expand Down Expand Up @@ -180,3 +182,120 @@ void HUD_SOUND_COLLECTION::LoadSound(LPCSTR section, LPCSTR line, LPCSTR alias,
snd_item.m_alias = alias;
snd_item.m_b_exclusive = exclusive;
}
//Alundaio:
/*
It's usage is to play a group of sounds HUD_SOUND_ITEMs as if they were a single layered entity. This is a achieved by
wrapping the class around HUD_SOUND_COLLECTION and tagging them with the same alias. This way, when one for example
sndShot is played, it will play all the sound items with the same alias.
*/
//----------------------------------------------------------
#ifdef LAYERED_SND_SHOOT
HUD_SOUND_COLLECTION_LAYERED::~HUD_SOUND_COLLECTION_LAYERED()
{
xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin();
xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end();

for (; it != it_e; ++it)
{
it->~HUD_SOUND_COLLECTION();
}

m_sound_items.clear();
}

void HUD_SOUND_COLLECTION_LAYERED::StopAllSounds()
{
xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin();
xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end();

for (; it != it_e; ++it)
{
it->StopAllSounds();
}
}

void HUD_SOUND_COLLECTION_LAYERED::StopSound(pcstr alias)
{
xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin();
xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end();

for (; it != it_e; ++it)
{
if (it->m_alias == alias)
it->StopSound(alias);
}
}

void HUD_SOUND_COLLECTION_LAYERED::SetPosition(pcstr alias, const Fvector& pos)
{
xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin();
xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end();

for (; it != it_e; ++it)
{
if (it->m_alias == alias)
it->SetPosition(alias, pos);
}
}

void HUD_SOUND_COLLECTION_LAYERED::PlaySound(pcstr alias, const Fvector& position, const IGameObject* parent,
bool hud_mode, bool looped, u8 index)
{
xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin();
xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end();

for (; it != it_e; ++it)
{
if (it->m_alias == alias)
it->PlaySound(alias, position, parent, hud_mode, looped, index);
}
}


HUD_SOUND_ITEM* HUD_SOUND_COLLECTION_LAYERED::FindSoundItem(pcstr alias, bool b_assert)
{
xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin();
xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end();

for (; it != it_e; ++it)
{
if (it->m_alias == alias)
return it->FindSoundItem(alias, b_assert);
}
return nullptr;
}

void HUD_SOUND_COLLECTION_LAYERED::LoadSound(pcstr section, pcstr line, pcstr alias, bool exclusive, int type)
{
pcstr str = pSettings->r_string(section, line);
string256 buf_str;

int count = _GetItemCount(str);
R_ASSERT(count);

_GetItem(str, 0, buf_str);

if (pSettings->section_exist(buf_str))
{
string256 sound_line;
xr_strcpy(sound_line, "snd_1_layer");
int k = 1;
while (pSettings->line_exist(buf_str, sound_line))
{
m_sound_items.resize(m_sound_items.size() + 1);
HUD_SOUND_COLLECTION& snd_item = m_sound_items.back();
snd_item.LoadSound(buf_str, sound_line, alias, exclusive, type);
snd_item.m_alias = alias;
xr_sprintf(sound_line, "snd_%d_layer", ++k);
}
}
else //For compatibility with normal HUD_SOUND_COLLECTION sounds
{
m_sound_items.resize(m_sound_items.size() + 1);
HUD_SOUND_COLLECTION& snd_item = m_sound_items.back();
snd_item.LoadSound(section, line, alias, exclusive, type);
snd_item.m_alias = alias;
}
}
#endif
//-Alundaio
Loading

0 comments on commit 6e703b4

Please sign in to comment.