Skip to content

Commit 6e703b4

Browse files
revolucasXottab-DUTY
authored andcommitted
* restructured many features behind defines (see: Config.hpp)
+ 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
1 parent f59ae37 commit 6e703b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+769
-386
lines changed

src/Common/Config.hpp

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,58 @@
55
// CONFIG_SCRIPT_ENGINE_LOG_EXPORTS
66
// CONFIG_SCRIPT_ENGINE_LOG_SKIPPED_EXPORTS
77

8+
/* Callbacks */
9+
#define EXTENDED_ITEM_CALLBACKS // (eItemToBelt, eItemToSlot, eItemToRuck)
10+
#define EXTENDED_WEAPON_CALLBACKS // (eOnWeaponZoomIn, eOnWeaponZoomOut, eOnWeaponJammed)
11+
//#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
12+
#define INPUT_CALLBACKS // (eKeyPress, eKeyRelease, eKeyHold, eMouseMove, eMouseWheel)
13+
#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)
14+
#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
15+
816
/* Scripts */
9-
//#define MOUSE_MOVE_CALLBACK // expose mouse move callback to scripts (configure in bind_stalker)
10-
//#define KEY_RELEASE_CALLBACK // expose key release callback to scripts (configure in bind_stalker)
11-
//#define KEY_HOLD_CALLBACK // expose key hold callback to scripts (configure in bind_stalker)
17+
#define MORE_INVENTORY_SLOTS // Adds 5 more slots CUSTOM_SLOT_1..5
18+
#define GAME_OBJECT_EXTENDED_EXPORTS // see: script_game_object*.cpp/h
19+
#define GAME_OBJECT_TESTING_EXPORTS // see: script_game_object4.cpp functions for object testing (ie. is_stalker(), is_heli())
20+
#define NAMESPACE_LEVEL_EXPORTS // see: level_script.cpp
1221

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

19-
// TWEAKS:
27+
/* Tweaks: */
2028
//#define FP_DEATH // first person death view
21-
//#define ACTOR_BEFORE_DEATH_CALLBACK
2229
#define DEAD_BODY_COLLISION // restore collision with dead bodies (thanks malandrinus)
23-
#define NEW_ANIMS // use new animations. Please enclose any new animation addions with this define
24-
#define NEW_SOUNDS // use new sounds. Please enclose any new sound addions with this define
30+
#define NEW_ANIMS // use new animations. Please enclose any new animation additions with this define
31+
2532
//#define CONFIG_SUN_MOVEMENT // With this defined sun will move as configured in weather ltx files
33+
34+
/* Sound: */
35+
#define NEW_SOUNDS // use new sounds. Please enclose any new sound additions with this define
36+
#define LAYERED_SND_SHOOT// see comment down below
37+
38+
/* LAYERED_SND_SHOOT by Alundaio
39+
When defined, it will allow you to play a group of sounds from a specified section for snd_shoot.
40+
You can have as many layers as you want, but you must follow naming convention,
41+
snd_1_layer
42+
snd_2_layer
43+
snd_3_layer
44+
...
45+
You can also have different variants for each layer defined,
46+
snd_1_layer
47+
snd_1_layer1
48+
snd_1_layer2
49+
...
50+
The correct line settings are standard, (ie. snd_1_layer = sound_path, volume, delay)
51+
ex.
52+
Here is an example usage:
53+
snd_shoot = new_snd_section
54+
[new_snd_section]
55+
snd_1_layer = weapons\new_sound_shoot1
56+
snd_1_layer1 = weapons\new_sound_shoot2
57+
snd_1_layer2 = weapons\new_sound_shoot3
58+
snd_1_layer3 = weapons\new_sound_shoot4
59+
snd_2_layer = weapons\mechanical_noise, 1.0, 0.1
60+
snd_3_layer = weapons\gunshot_echo, 1.0, 0.8
61+
*/
2662
//-TWEAKS

src/xrGame/Actor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,10 @@ class CActor : public CEntityAlive,
311311
IC CCameraBase* cam_FirstEye() { return cameras[eacFirstEye]; }
312312

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

315316
protected:
316-
virtual void cam_Set(EActorCameras style);
317+
//virtual void cam_Set(EActorCameras style);
317318
void cam_Update(float dt, float fFOV);
318319
void cam_Lookout(const Fmatrix& xform, float camera_height);
319320
void camUpdateLadder(float dt);

src/xrGame/Actor_Feel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void CActor::PickupModeUpdate()
146146
}
147147

148148
#include "xrEngine/CameraBase.h"
149-
BOOL g_b_COD_PickUpMode = TRUE;
149+
BOOL g_b_COD_PickUpMode = TRUE; // XXX: allow to change this via console
150150
void CActor::PickupModeUpdate_COD()
151151
{
152152
if (Level().CurrentViewEntity() != this || !g_b_COD_PickUpMode)

src/xrGame/GameObject.cpp

Lines changed: 54 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,13 @@ BOOL CGameObject::net_Spawn(CSE_Abstract* DC)
453453
}
454454
else
455455
{
456-
R_ASSERT(Level().Objects.net_Find(E->ID) == NULL);
456+
//Alundaio:
457+
//R_ASSERT(Level().Objects.net_Find(E->ID) == nullptr);
458+
if (Level().Objects.net_Find(E->ID) != nullptr)
459+
{
460+
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);
461+
return false;
462+
}
457463
}
458464

459465
setID(E->ID);
@@ -701,54 +707,59 @@ void CGameObject::spawn_supplies()
701707
for (u32 k = 0, j; spawn_ini()->r_line("spawn", k, &N, &V); k++)
702708
{
703709
VERIFY(xr_strlen(N));
704-
j = 1;
705-
p = 1.f;
706-
707-
float f_cond = 1.0f;
708-
if (V && xr_strlen(V))
710+
if (pSettings->section_exist(N)) //Alundaio: Validate section exists
709711
{
710-
int n = _GetItemCount(V);
711-
string16 temp;
712-
if (n > 0)
713-
j = atoi(_GetItem(V, 0, temp)); // count
714-
715-
if (NULL != strstr(V, "prob="))
716-
p = (float)atof(strstr(V, "prob=") + 5);
717-
if (fis_zero(p))
718-
p = 1.f;
719-
if (!j)
720-
j = 1;
721-
if (NULL != strstr(V, "cond="))
722-
f_cond = (float)atof(strstr(V, "cond=") + 5);
723-
bScope = (NULL != strstr(V, "scope"));
724-
bSilencer = (NULL != strstr(V, "silencer"));
725-
bLauncher = (NULL != strstr(V, "launcher"));
726-
}
727-
for (u32 i = 0; i < j; ++i)
728-
if (::Random.randF(1.f) < p)
712+
j = 1;
713+
p = 1.f;
714+
715+
float f_cond = 1.0f;
716+
if (V && xr_strlen(V))
717+
{
718+
int n = _GetItemCount(V);
719+
string16 temp;
720+
if (n > 0)
721+
j = atoi(_GetItem(V, 0, temp)); // count
722+
723+
if (NULL != strstr(V, "prob="))
724+
p = (float)atof(strstr(V, "prob=") + 5);
725+
if (fis_zero(p))
726+
p = 1.f;
727+
if (!j)
728+
j = 1;
729+
if (NULL != strstr(V, "cond="))
730+
f_cond = (float)atof(strstr(V, "cond=") + 5);
731+
bScope = (NULL != strstr(V, "scope"));
732+
bSilencer = (NULL != strstr(V, "silencer"));
733+
bLauncher = (NULL != strstr(V, "launcher"));
734+
}
735+
for (u32 i = 0; i < j; ++i)
729736
{
730-
CSE_Abstract* A = Level().spawn_item(N, Position(), ai_location().level_vertex_id(), ID(), true);
737+
if (::Random.randF(1.f) < p)
738+
{
739+
CSE_Abstract* A = Level().spawn_item(N, Position(), ai_location().level_vertex_id(), ID(), true);
731740

732-
CSE_ALifeInventoryItem* pSE_InventoryItem = smart_cast<CSE_ALifeInventoryItem*>(A);
733-
if (pSE_InventoryItem)
734-
pSE_InventoryItem->m_fCondition = f_cond;
741+
CSE_ALifeInventoryItem* pSE_InventoryItem = smart_cast<CSE_ALifeInventoryItem*>(A);
742+
if (pSE_InventoryItem)
743+
pSE_InventoryItem->m_fCondition = f_cond;
735744

736-
CSE_ALifeItemWeapon* W = smart_cast<CSE_ALifeItemWeapon*>(A);
737-
if (W)
738-
{
739-
if (W->m_scope_status == ALife::eAddonAttachable)
740-
W->m_addon_flags.set(CSE_ALifeItemWeapon::eWeaponAddonScope, bScope);
741-
if (W->m_silencer_status == ALife::eAddonAttachable)
742-
W->m_addon_flags.set(CSE_ALifeItemWeapon::eWeaponAddonSilencer, bSilencer);
743-
if (W->m_grenade_launcher_status == ALife::eAddonAttachable)
744-
W->m_addon_flags.set(CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher, bLauncher);
745-
}
745+
CSE_ALifeItemWeapon* W = smart_cast<CSE_ALifeItemWeapon*>(A);
746+
if (W)
747+
{
748+
if (W->m_scope_status == ALife::eAddonAttachable)
749+
W->m_addon_flags.set(CSE_ALifeItemWeapon::eWeaponAddonScope, bScope);
750+
if (W->m_silencer_status == ALife::eAddonAttachable)
751+
W->m_addon_flags.set(CSE_ALifeItemWeapon::eWeaponAddonSilencer, bSilencer);
752+
if (W->m_grenade_launcher_status == ALife::eAddonAttachable)
753+
W->m_addon_flags.set(CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher, bLauncher);
754+
}
746755

747-
NET_Packet P;
748-
A->Spawn_Write(P, TRUE);
749-
Level().Send(P, net_flags(TRUE));
750-
F_entity_Destroy(A);
756+
NET_Packet P;
757+
A->Spawn_Write(P, TRUE);
758+
Level().Send(P, net_flags(TRUE));
759+
F_entity_Destroy(A);
760+
}
751761
}
762+
}
752763
}
753764
}
754765

src/xrGame/HudItem.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ void CHudItem::PlaySound(LPCSTR alias, const Fvector& position)
4848
m_sounds.PlaySound(alias, position, object().H_Root(), !!GetHUDmode());
4949
}
5050

51+
//Alundaio: Play at index
52+
void CHudItem::PlaySound(pcstr alias, const Fvector& position, u8 index)
53+
{
54+
m_sounds.PlaySound(alias, position, object().H_Root(), !!GetHUDmode(), false, index);
55+
}
56+
//-Alundaio
57+
5158
void CHudItem::renderable_Render()
5259
{
5360
UpdateXForm();

src/xrGame/HudItem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class CHudItem : public CHUDState
9191
virtual void OnH_A_Independent();
9292

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

src/xrGame/HudSound.cpp

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ void HUD_SOUND_ITEM::PlaySound(
8484
u32 flags = b_hud_mode ? sm_2D : 0;
8585
if (looped)
8686
flags |= sm_Looped;
87-
87+
//Alundaio: Sanity, don't allow PlaySound of index greater then the size, just play last index
8888
if (index == u8(-1))
8989
index = (u8)Random.randI(hud_snd.sounds.size());
90+
else if (index >= (u8)hud_snd.sounds.size())
91+
index = (u8)hud_snd.sounds.size()-1;
9092

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

@@ -180,3 +182,120 @@ void HUD_SOUND_COLLECTION::LoadSound(LPCSTR section, LPCSTR line, LPCSTR alias,
180182
snd_item.m_alias = alias;
181183
snd_item.m_b_exclusive = exclusive;
182184
}
185+
//Alundaio:
186+
/*
187+
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
188+
wrapping the class around HUD_SOUND_COLLECTION and tagging them with the same alias. This way, when one for example
189+
sndShot is played, it will play all the sound items with the same alias.
190+
*/
191+
//----------------------------------------------------------
192+
#ifdef LAYERED_SND_SHOOT
193+
HUD_SOUND_COLLECTION_LAYERED::~HUD_SOUND_COLLECTION_LAYERED()
194+
{
195+
xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin();
196+
xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end();
197+
198+
for (; it != it_e; ++it)
199+
{
200+
it->~HUD_SOUND_COLLECTION();
201+
}
202+
203+
m_sound_items.clear();
204+
}
205+
206+
void HUD_SOUND_COLLECTION_LAYERED::StopAllSounds()
207+
{
208+
xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin();
209+
xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end();
210+
211+
for (; it != it_e; ++it)
212+
{
213+
it->StopAllSounds();
214+
}
215+
}
216+
217+
void HUD_SOUND_COLLECTION_LAYERED::StopSound(pcstr alias)
218+
{
219+
xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin();
220+
xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end();
221+
222+
for (; it != it_e; ++it)
223+
{
224+
if (it->m_alias == alias)
225+
it->StopSound(alias);
226+
}
227+
}
228+
229+
void HUD_SOUND_COLLECTION_LAYERED::SetPosition(pcstr alias, const Fvector& pos)
230+
{
231+
xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin();
232+
xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end();
233+
234+
for (; it != it_e; ++it)
235+
{
236+
if (it->m_alias == alias)
237+
it->SetPosition(alias, pos);
238+
}
239+
}
240+
241+
void HUD_SOUND_COLLECTION_LAYERED::PlaySound(pcstr alias, const Fvector& position, const IGameObject* parent,
242+
bool hud_mode, bool looped, u8 index)
243+
{
244+
xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin();
245+
xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end();
246+
247+
for (; it != it_e; ++it)
248+
{
249+
if (it->m_alias == alias)
250+
it->PlaySound(alias, position, parent, hud_mode, looped, index);
251+
}
252+
}
253+
254+
255+
HUD_SOUND_ITEM* HUD_SOUND_COLLECTION_LAYERED::FindSoundItem(pcstr alias, bool b_assert)
256+
{
257+
xr_vector<HUD_SOUND_COLLECTION>::iterator it = m_sound_items.begin();
258+
xr_vector<HUD_SOUND_COLLECTION>::iterator it_e = m_sound_items.end();
259+
260+
for (; it != it_e; ++it)
261+
{
262+
if (it->m_alias == alias)
263+
return it->FindSoundItem(alias, b_assert);
264+
}
265+
return nullptr;
266+
}
267+
268+
void HUD_SOUND_COLLECTION_LAYERED::LoadSound(pcstr section, pcstr line, pcstr alias, bool exclusive, int type)
269+
{
270+
pcstr str = pSettings->r_string(section, line);
271+
string256 buf_str;
272+
273+
int count = _GetItemCount(str);
274+
R_ASSERT(count);
275+
276+
_GetItem(str, 0, buf_str);
277+
278+
if (pSettings->section_exist(buf_str))
279+
{
280+
string256 sound_line;
281+
xr_strcpy(sound_line, "snd_1_layer");
282+
int k = 1;
283+
while (pSettings->line_exist(buf_str, sound_line))
284+
{
285+
m_sound_items.resize(m_sound_items.size() + 1);
286+
HUD_SOUND_COLLECTION& snd_item = m_sound_items.back();
287+
snd_item.LoadSound(buf_str, sound_line, alias, exclusive, type);
288+
snd_item.m_alias = alias;
289+
xr_sprintf(sound_line, "snd_%d_layer", ++k);
290+
}
291+
}
292+
else //For compatibility with normal HUD_SOUND_COLLECTION sounds
293+
{
294+
m_sound_items.resize(m_sound_items.size() + 1);
295+
HUD_SOUND_COLLECTION& snd_item = m_sound_items.back();
296+
snd_item.LoadSound(section, line, alias, exclusive, type);
297+
snd_item.m_alias = alias;
298+
}
299+
}
300+
#endif
301+
//-Alundaio

0 commit comments

Comments
 (0)