Skip to content

Commit c1775dc

Browse files
Merge pull request #322 from ProfLander/shotgun-launchers
Launchers: Cartridge Ammo + Trajectory and Reload Options
2 parents 62922b9 + 9a23392 commit c1775dc

17 files changed

+378
-280
lines changed

gamedata/configs/text/eng/ui_mm_modded_exes.xml

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,23 @@
600600
<text>Gameplay</text>
601601
</string>
602602

603+
<!-- Gameplay General -->
604+
<string id="ui_mm_menu_gameplay_general">
605+
<text>General</text>
606+
</string>
607+
<string id="ui_mm_gameplay_general_modded_exes">
608+
<text>General</text>
609+
</string>
610+
<string id="ui_mm_modded_exes_gameplay_gameplay_general_g_progressive_stamina_cost">
611+
<text>Progressive stamina cost (g_progressive_stamina_cost)</text>
612+
</string>
613+
<string id="ui_mm_modded_exes_gameplay_gameplay_general_g_progressive_stamina_cost_desc">
614+
<text>Stamina will drain linearly with current weight instead of cutoff point</text>
615+
</string>
616+
<string id="ui_mm_modded_exes_gameplay_gameplay_general_g_auto_reload">
617+
<text>Automatically reload weapon when ammo is depleted (g_auto_reload)</text>
618+
</string>
619+
603620
<!-- Aim -->
604621
<string id="ui_mm_menu_aim">
605622
<text>Aim</text>
@@ -670,6 +687,30 @@
670687
<text>Item</text>
671688
</string>
672689

690+
<!-- Launchers -->
691+
<string id="ui_mm_menu_launchers">
692+
<text>Launchers</text>
693+
</string>
694+
<string id="ui_mm_launchers_modded_exes">
695+
<text>Launchers</text>
696+
</string>
697+
698+
<string id="ui_mm_modded_exes_gameplay_launchers_g_fire_reloads_ubgl">
699+
<text>Reload under-barrel launchers with fire input (g_fire_reloads_ubgl)</text>
700+
</string>
701+
<string id="ui_mm_modded_exes_gameplay_launchers_g_launcher_dynamic_range">
702+
<text>Apply launcher assist while unaimed (g_launcher_dynamic_range)</text>
703+
</string>
704+
<string id="ui_mm_modded_exes_gameplay_launchers_g_launcher_dynamic_range_zoom">
705+
<text>Apply launcher assist while aimed (g_launcher_dynamic_range_zoom)</text>
706+
</string>
707+
<string id="ui_mm_modded_exes_gameplay_launchers_g_launcher_dynamic_range_mode">
708+
<text>Target dynamic objects with launcher assist (g_launcher_dynamic_range_mode)</text>
709+
</string>
710+
<string id="ui_mm_modded_exes_gameplay_launchers_g_launcher_dynamic_range_max">
711+
<text>Maximum launcher assist range (g_launcher_dynamic_range_max)</text>
712+
</string>
713+
673714
<!-- First Person Death -->
674715
<string id="ui_mm_menu_first_person_death">
675716
<text>First Person Death</text>
@@ -688,20 +729,6 @@
688729
<text>FPD Camera Direction Change Smoothing (first_person_death_direction_smoothing)</text>
689730
</string>
690731

691-
<!-- Gameplay General -->
692-
<string id="ui_mm_menu_gameplay_general">
693-
<text>General</text>
694-
</string>
695-
<string id="ui_mm_gameplay_general_modded_exes">
696-
<text>General</text>
697-
</string>
698-
<string id="ui_mm_modded_exes_gameplay_gameplay_general_g_progressive_stamina_cost">
699-
<text>Progressive stamina cost (g_progressive_stamina_cost)</text>
700-
</string>
701-
<string id="ui_mm_modded_exes_gameplay_gameplay_general_g_progressive_stamina_cost_desc">
702-
<text>Stamina will drain linearly with current weight instead of cutoff point</text>
703-
</string>
704-
705732
<!-- Stalkers -->
706733
<string id="ui_mm_menu_stalkers">
707734
<text>Stalkers</text>

gamedata/configs/text/rus/ui_mm_modded_exes.xml

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,23 @@
578578
<text>Ãåéìïëåé</text>
579579
</string>
580580

581+
<!-- Gameplay General -->
582+
<string id="ui_mm_menu_gameplay_general">
583+
<text>Îáùèå</text>
584+
</string>
585+
<string id="ui_mm_gameplay_general_modded_exes">
586+
<text>Îáùèå</text>
587+
</string>
588+
<string id="ui_mm_modded_exes_gameplay_gameplay_general_g_progressive_stamina_cost">
589+
<text>Ïðîãðåññèâíàÿ çàòðàòà âûíîñëèâîñòè (g_progressive_stamina_cost)</text>
590+
</string>
591+
<string id="ui_mm_modded_exes_gameplay_gameplay_general_g_progressive_stamina_cost_desc">
592+
<text>Âûíîñëèâîñòü áóäåò óìåíüøàòüñÿ ëèíåéíî â çàâèñèìîñòè îò òåêóùåãî âåñà, à íå ïî ïîðîãîâîìó çíà÷åíèþ</text>
593+
</string>
594+
<string id="ui_mm_modded_exes_gameplay_gameplay_general_g_auto_reload">
595+
<text>Àâòîìàòè÷åñêè ïåðåçàðÿæàòü îðóæèå ïðè èñ÷åðïàíèè áîåïðèïàñîâ (g_auto_reload)</text>
596+
</string>
597+
581598
<!-- Aim -->
582599
<string id="ui_mm_menu_aim">
583600
<text>Aim</text>
@@ -648,6 +665,30 @@
648665
<text>Ïðåäìåò</text>
649666
</string>
650667

668+
<!-- Launchers -->
669+
<string id="ui_mm_menu_launchers">
670+
<text>Ãðàíàòîìåòû</text>
671+
</string>
672+
<string id="ui_mm_launchers_modded_exes">
673+
<text>Ãðàíàòîìåòû</text>
674+
</string>
675+
676+
<string id="ui_mm_modded_exes_gameplay_launchers_g_fire_reloads_ubgl">
677+
<text>Ïåðåçàðÿæàòü ïîäñòâîëüíûå ãðàíàòîìåòû ñ ïîìîùüþ îãíÿ (g_fire_reloads_ubgl)</text>
678+
</string>
679+
<string id="ui_mm_modded_exes_gameplay_launchers_g_launcher_dynamic_range">
680+
<text>Ïðèìåíÿòü ïîìîùü ïðè çàïóñêå, êîãäà íå íàöåëèâàåøüñÿ (g_launcher_dynamic_range)</text>
681+
</string>
682+
<string id="ui_mm_modded_exes_gameplay_launchers_g_launcher_dynamic_range_zoom">
683+
<text>Ïðèìåíÿéòå ïîìîùü ïðèöåëèâàíèÿ ïðè íàâåäåíèè (g_launcher_dynamic_range_zoom)</text>
684+
</string>
685+
<string id="ui_mm_modded_exes_gameplay_launchers_g_launcher_dynamic_range_mode">
686+
<text>Íàöåëèâàéòåñü íà äèíàìè÷åñêèå îáúåêòû ñ ïîìîùüþ ñèñòåìû ïîìîùè ïðè çàïóñêå (g_launcher_dynamic_range_mode)</text>
687+
</string>
688+
<string id="ui_mm_modded_exes_gameplay_launchers_g_launcher_dynamic_range_max">
689+
<text>Ìàêñèìàëüíàÿ äàëüíîñòü äåéñòâèÿ ïóñêîâîé óñòàíîâêè (g_launcher_dynamic_range_max)</text>
690+
</string>
691+
651692
<!-- First Person Death -->
652693
<string id="ui_mm_menu_first_person_death">
653694
<text>Ñìåðòü îò ïåðâîãî ëèöà</text>
@@ -666,20 +707,6 @@
666707
<text>Ãëàäêîñòü ñìåíû íàïðàâëåíèÿ êàìåðû (first_person_death_direction_smoothing)</text>
667708
</string>
668709

669-
<!-- Gameplay General -->
670-
<string id="ui_mm_menu_gameplay_general">
671-
<text>Îáùèå</text>
672-
</string>
673-
<string id="ui_mm_gameplay_general_modded_exes">
674-
<text>Îáùèå</text>
675-
</string>
676-
<string id="ui_mm_modded_exes_gameplay_gameplay_general_g_progressive_stamina_cost">
677-
<text>Ïðîãðåññèâíàÿ çàòðàòà âûíîñëèâîñòè (g_progressive_stamina_cost)</text>
678-
</string>
679-
<string id="ui_mm_modded_exes_gameplay_gameplay_general_g_progressive_stamina_cost_desc">
680-
<text>Âûíîñëèâîñòü áóäåò óìåíüøàòüñÿ ëèíåéíî â çàâèñèìîñòè îò òåêóùåãî âåñà, à íå ïî ïîðîãîâîìó çíà÷åíèþ</text>
681-
</string>
682-
683710
<!-- Stalkers -->
684711
<string id="ui_mm_menu_stalkers">
685712
<text>Ñòàëêåðû</text>

gamedata/scripts/options_modded_exes_gameplay.script

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
local page_gameplay_general = options_modded_exes_gameplay_general.PAGE
44
local page_aim = options_modded_exes_aim.PAGE
55
local page_3d_ballistics = options_modded_exes_3d_ballistics.PAGE
6+
local page_launchers = options_modded_exes_launchers.PAGE
67
local page_first_person_death = options_modded_exes_first_person_death.PAGE
78
local page_stalkers = options_modded_exes_stalkers.PAGE
89
local page_monsters = options_modded_exes_monsters.PAGE
@@ -16,6 +17,7 @@ GROUP = group {
1617
page_gameplay_general,
1718
page_aim,
1819
page_3d_ballistics,
20+
page_launchers,
1921
page_first_person_death,
2022
page_stalkers,
2123
page_monsters,

gamedata/scripts/options_modded_exes_gameplay_general.script

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ options_builder.import_into(this)
66
PAGE = page {
77
{ id = "gameplay_general" },
88
list_bool { id = "g_progressive_stamina_cost" },
9+
list_bool { id = "g_auto_reload" },
910
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--- Launchers options tree
2+
3+
-- Import smart constructors
4+
options_builder.import_into(this)
5+
6+
PAGE = page {
7+
{ id = "launchers" },
8+
list_bool { id = "g_fire_reloads_ubgl" },
9+
list_bool { id = "g_launcher_dynamic_range" },
10+
list_bool { id = "g_launcher_dynamic_range_zoom" },
11+
list_bool { id = "g_launcher_dynamic_range_mode" },
12+
track {
13+
id = "g_launcher_dynamic_range_max",
14+
def = 300,
15+
step = 1,
16+
},
17+
}

src/xrGame/RocketLauncher.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class CGameObject;
1010

1111
class CRocketLauncher
1212
{
13+
friend class CWeaponGrenadeLauncher;
14+
1315
public:
1416
CRocketLauncher();
1517
~CRocketLauncher();

src/xrGame/Weapon.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ struct SafemodeAnm
4949
class CWeapon : public CHudItemObject,
5050
public CShootingObject
5151
{
52+
friend class CWeaponGrenadeLauncher;
53+
5254
private:
5355
typedef CHudItemObject inherited;
5456

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
#include "StdAfx.h"
2+
#include <utility>
3+
4+
#include "WeaponGrenadeLauncher.h"
5+
#include "../xrPhysics/MathUtils.h"
6+
#include "Actor.h"
7+
#include "Level.h"
8+
#include "Entity.h"
9+
#include "Inventory.h"
10+
#include "InventoryOwner.h"
11+
#include "Weapon.h"
12+
#include "WeaponMagazined.h"
13+
#include "RocketLauncher.h"
14+
#include "ExplosiveRocket.h"
15+
#include "xrDebug.h"
16+
17+
BOOL g_launcher_dynamic_range = FALSE;
18+
BOOL g_launcher_dynamic_range_zoom = TRUE;
19+
BOOL g_launcher_dynamic_range_mode = FALSE;
20+
float g_launcher_dynamic_range_max = 300.0f;
21+
22+
BOOL CWeaponGrenadeLauncher::use_dynamic_range(CWeapon* wpn)
23+
{
24+
if (wpn->IsZoomed())
25+
{
26+
return g_launcher_dynamic_range_zoom;
27+
}
28+
29+
return g_launcher_dynamic_range;
30+
}
31+
32+
collide::rq_target CWeaponGrenadeLauncher::get_rq_target()
33+
{
34+
if(g_launcher_dynamic_range_mode)
35+
return collide::rqtBoth;
36+
37+
return collide::rqtStatic;
38+
}
39+
40+
void CWeaponGrenadeLauncher::LaunchGrenade(CWeapon* wpn)
41+
{
42+
CWeaponMagazined* wm = smart_cast<CWeaponMagazined*>(wpn);
43+
VERIFY(wm);
44+
45+
CRocketLauncher* rl = smart_cast<CRocketLauncher*>(wpn);
46+
VERIFY(rl);
47+
48+
#ifdef CROCKETLAUNCHER_CHANGE
49+
LPCSTR ammo_name = wm->m_ammoTypes[wm->m_ammoType].c_str();
50+
float launch_speed = READ_IF_EXISTS(pSettings, r_float, ammo_name, "ammo_grenade_vel", rl->m_fLaunchSpeed);
51+
#endif
52+
Fvector p1, d;
53+
p1.set(wpn->get_LastFP2());
54+
d.set(wpn->get_LastFD());
55+
CEntity* E = smart_cast<CEntity*>(wpn->H_Parent());
56+
57+
if (E)
58+
{
59+
CInventoryOwner* io = smart_cast<CInventoryOwner*>(wpn->H_Parent());
60+
if (NULL == io->inventory().ActiveItem())
61+
{
62+
Log("current_state", wpn->GetState());
63+
Log("next_state", wpn->GetNextState());
64+
Log("item_sect", wpn->cNameSect().c_str());
65+
Log("H_Parent", wpn->H_Parent()->cNameSect().c_str());
66+
}
67+
E->g_fireParams(wpn, p1, d);
68+
}
69+
if (IsGameTypeSingle())
70+
p1.set(wpn->get_LastFP2());
71+
72+
Fmatrix launch_matrix;
73+
launch_matrix.identity();
74+
launch_matrix.k.set(d);
75+
Fvector::generate_orthonormal_basis(launch_matrix.k,
76+
launch_matrix.j,
77+
launch_matrix.i);
78+
79+
launch_matrix.c.set(p1);
80+
81+
if (IsGameTypeSingle() && use_dynamic_range(wpn) && smart_cast<CActor*>(wpn->H_Parent()))
82+
{
83+
wpn->H_Parent()->setEnabled(FALSE);
84+
wpn->setEnabled(FALSE);
85+
86+
collide::rq_result RQ;
87+
BOOL HasPick = Level().ObjectSpace.RayPick(p1, d, g_launcher_dynamic_range_max, get_rq_target(), RQ, wpn);
88+
89+
wpn->setEnabled(TRUE);
90+
wpn->H_Parent()->setEnabled(TRUE);
91+
92+
if (HasPick)
93+
{
94+
Fvector Transference;
95+
Transference.mul(d, RQ.range);
96+
Fvector res[2];
97+
#ifdef DEBUG
98+
//. DBG_OpenCashedDraw();
99+
//. DBG_DrawLine(p1,Fvector().add(p1,d),D3DCOLOR_XRGB(255,0,0));
100+
#endif
101+
#ifdef CROCKETLAUNCHER_CHANGE
102+
u8 canfire0 = TransferenceAndThrowVelToThrowDir(Transference, launch_speed, wpn->EffectiveGravity(), res);
103+
#else
104+
u8 canfire0 = TransferenceAndThrowVelToThrowDir(Transference,
105+
rl->m_fLaunchSpeed,
106+
rl->EffectiveGravity(),
107+
res);
108+
#endif
109+
#ifdef DEBUG
110+
//. if(canfire0>0)DBG_DrawLine(p1,Fvector().add(p1,res[0]),D3DCOLOR_XRGB(0,255,0));
111+
//. if(canfire0>1)DBG_DrawLine(p1,Fvector().add(p1,res[1]),D3DCOLOR_XRGB(0,0,255));
112+
//. DBG_ClosedCashedDraw(30000);
113+
#endif
114+
115+
if (canfire0 != 0)
116+
{
117+
d = res[0];
118+
};
119+
}
120+
};
121+
122+
d.normalize();
123+
#ifdef CROCKETLAUNCHER_CHANGE
124+
d.mul(launch_speed);
125+
#else
126+
d.mul(rl->m_fLaunchSpeed);
127+
#endif
128+
VERIFY2(_valid(launch_matrix), "CWeaponMagazinedWGrenade::SwitchState. Invalid launch_matrix!");
129+
rl->LaunchRocket(launch_matrix, d, zero_vel);
130+
131+
CExplosiveRocket* pGrenade = smart_cast<CExplosiveRocket*>(rl->getCurrentRocket());
132+
VERIFY(pGrenade);
133+
pGrenade->SetInitiator(wpn->H_Parent()->ID());
134+
135+
if (wpn->Local() && OnServer())
136+
{
137+
VERIFY(wm->m_magazine.size());
138+
wm->m_magazine.pop_back();
139+
--wm->iAmmoElapsed;
140+
VERIFY((u32) wpn->iAmmoElapsed == wm->m_magazine.size());
141+
142+
NET_Packet P;
143+
wpn->u_EventGen(P, GE_LAUNCH_ROCKET, wpn->ID());
144+
P.w_u16(rl->getCurrentRocket()->ID());
145+
wpn->u_EventSend(P);
146+
};
147+
}

src/xrGame/WeaponGrenadeLauncher.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef _WEAPON_GRENADE_LAUNCHER_
2+
#define _WEAPON_GRENADE_LAUNCHER_
3+
4+
#include "../xrCDB/xr_collide_defs.h"
5+
6+
class CWeaponGrenadeLauncher
7+
{
8+
private:
9+
static BOOL use_dynamic_range(CWeapon* wpn);
10+
static collide::rq_target get_rq_target();
11+
public:
12+
static void LaunchGrenade(CWeapon* wpn);
13+
};
14+
15+
#endif //_WEAPON_GRENADE_LAUNCHER

0 commit comments

Comments
 (0)