Skip to content

Commit 9b6a6db

Browse files
revolucasXottab-DUTY
authored andcommitted
+ new game object exports
phantom_set_enemy is_on_belt item_on_belt belt_count get_actor_max_weight set_actor_max_weight get_actor_max_walk_weight set_actor_max_walk_weight get_additional_max_weight set_additional_max_weight get_additional_max_walk_weight set_additional_max_walk_weight get_total_weight weight get_actor_jump_speed set_actor_jump_speed get_actor_sprint_koef set_actor_sprint_koef get_actor_run_coef set_actor_run_coef get_actor_runback_coef set_actor_runback_coef + ray_pick class export * console command snd_cache_size upper limit increased to 64
1 parent eba6916 commit 9b6a6db

22 files changed

+703
-20
lines changed

src/xrEngine/xr_ioc_cmd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ void CCC_Register()
754754
CMD3(CCC_Mask, "snd_acceleration", &psSoundFlags, ss_Hardware);
755755
CMD3(CCC_Mask, "snd_efx", &psSoundFlags, ss_EAX);
756756
CMD4(CCC_Integer, "snd_targets", &psSoundTargets, 4, 32);
757-
CMD4(CCC_Integer, "snd_cache_size", &psSoundCacheSizeMB, 4, 32);
757+
CMD4(CCC_Integer, "snd_cache_size", &psSoundCacheSizeMB, 4, 64);
758758

759759
#ifdef DEBUG
760760
CMD3(CCC_Mask, "snd_stats", &g_stats_flags, st_sound);

src/xrGame/Actor.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,6 +1833,16 @@ void CActor::SetShotRndSeed(s32 Seed)
18331833
m_ShotRndSeed = s32(Level().timeServer_Async());
18341834
};
18351835

1836+
Fvector CActor::GetMissileOffset() const
1837+
{
1838+
return m_vMissileOffset;
1839+
}
1840+
1841+
void CActor::SetMissileOffset(const Fvector& vNewOffset)
1842+
{
1843+
m_vMissileOffset.set(vNewOffset);
1844+
}
1845+
18361846
void CActor::spawn_supplies()
18371847
{
18381848
inherited::spawn_supplies();

src/xrGame/Actor.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ class CActor : public CEntityAlive,
408408

409409
BOOL m_bJumpKeyPressed;
410410

411+
public:
411412
float m_fWalkAccel;
412413
float m_fJumpSpeed;
413414
float m_fRunFactor;
@@ -465,6 +466,13 @@ class CActor : public CEntityAlive,
465466
// crouch+no acceleration
466467
float m_fDispCrouchNoAccelFactor;
467468

469+
Fvector m_vMissileOffset;
470+
471+
public:
472+
// Получение, и запись смещения для гранат
473+
Fvector GetMissileOffset() const;
474+
void SetMissileOffset(const Fvector& vNewOffset);
475+
468476
protected:
469477
//косточки используемые при стрельбе
470478
int m_r_hand;
@@ -743,6 +751,26 @@ class CActor : public CEntityAlive,
743751
bool m_disabled_hitmarks;
744752
bool m_inventory_disabled;
745753
// static CPhysicsShell *actor_camera_shell;
754+
755+
IC u32 get_state() const
756+
{
757+
return this->mstate_real;
758+
}
759+
760+
IC void set_state(u32 state)
761+
{
762+
mstate_real = state;
763+
}
764+
765+
IC u32 get_state_wishful() const
766+
{
767+
return this->mstate_wishful;
768+
}
769+
770+
IC void set_state_wishful(u32 state)
771+
{
772+
mstate_wishful = state;
773+
}
746774
};
747775

748776
extern bool isActorAccelerated(u32 mstate, bool ZoomMode);

src/xrGame/ActorCondition.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ class CActorCondition : public CEntityCondition
139139
float m_fAccelK;
140140
float m_fSprintK;
141141

142+
public:
142143
float m_MaxWalkWeight;
144+
145+
protected:
143146
float m_zone_max_power[ALife::infl_max_count];
144147
float m_zone_danger[ALife::infl_max_count];
145148
float m_f_time_affected;

src/xrGame/TeleWhirlwind.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,15 @@ void CTeleWhirlwind::draw_out_impact(Fvector& dir, float& val)
4545
{
4646
VERIFY2(m_saved_impacts.size(), "NO IMPACTS ADDED!");
4747

48+
if (m_saved_impacts.empty())
49+
return;
50+
4851
dir.set(m_saved_impacts[0].force);
4952
val = dir.magnitude();
50-
if (!fis_zero(val))
51-
dir.mul(1.f / val);
53+
54+
// Swartz
55+
//if (!fis_zero(val))
56+
// dir.mul(1.f / val);
5257
m_saved_impacts.erase(m_saved_impacts.begin());
5358
}
5459

src/xrGame/UIStaticItem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ class CUIStaticItem
3737
IC float GetPosY() { return vPos.y; }
3838
IC void SetTextureColor(u32 clr) { dwColor = clr; }
3939
IC u32 GetTextureColor() const { return dwColor; }
40+
void SetColor(u32 clr) { dwColor = clr; }
41+
void SetColor(Fcolor clr) { dwColor = clr.get(); }
42+
u32 GetColor() const { return dwColor; }
43+
u32& GetColorRef() { return dwColor; }
4044
ui_shader& GetShader() { return hShader; }
4145
public:
4246
CUIStaticItem();

src/xrGame/ai/phantom/phantom.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ BOOL CPhantom::net_Spawn(CSE_Abstract* DC)
8080
if (!inherited::net_Spawn(DC))
8181
return FALSE;
8282

83+
OBJ->set_killer_id(u16(-1)); // Alundaio: Hack to prevent strange crash with dynamic phantoms
84+
8385
m_enemy = Level().CurrentEntity();
8486
VERIFY(m_enemy);
8587

@@ -137,6 +139,9 @@ void CPhantom::animation_end_callback(CBlend* B)
137139
//---------------------------------------------------------------------
138140
void CPhantom::SwitchToState_internal(EState new_state)
139141
{
142+
if (!m_enemy)
143+
m_enemy = Level().CurrentEntity();
144+
140145
if (new_state != m_CurState)
141146
{
142147
IKinematicsAnimated* K = smart_cast<IKinematicsAnimated*>(Visual());
@@ -242,6 +247,9 @@ void CPhantom::OnFlyState()
242247
void CPhantom::OnDeadState() { UpdateFlyMedia(); }
243248
void CPhantom::UpdateFlyMedia()
244249
{
250+
if (!m_enemy)
251+
m_enemy = Level().CurrentEntity();
252+
245253
UpdatePosition(m_enemy->Position());
246254
Fmatrix xform = XFORM_center();
247255
// update particles

src/xrGame/ai/phantom/phantom.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,6 @@ class CPhantom : public CEntity
8787
virtual bool IsVisibleForZones() { return false; }
8888
virtual BOOL UsedAI_Locations() { return false; }
8989
virtual CEntity* cast_entity() { return this; }
90+
91+
void SetEnemy(IGameObject* enemy) { m_enemy = enemy; } //Alundaio
9092
};

src/xrGame/level_script.cpp

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#include "xrServer_Objects_ALife_Monsters.h"
3939
#include "xrScriptEngine/ScriptExporter.hpp"
4040
#include "HUDManager.h"
41+
#include "raypick.h"
42+
#include "xrCDB/xr_collide_defs.h"
4143

4244
using namespace luabind;
4345
using namespace luabind::policy;
@@ -649,6 +651,27 @@ void set_active_cam(u8 mode)
649651
#endif
650652
//-Alundaio
651653

654+
// KD: raypick
655+
bool ray_pick(const Fvector& start, const Fvector& dir, float range,
656+
collide::rq_target tgt, script_rq_result& script_R,
657+
CScriptGameObject* ignore_object)
658+
{
659+
collide::rq_result R;
660+
IGameObject* ignore = nullptr;
661+
if (ignore_object)
662+
ignore = smart_cast<IGameObject*>(&(ignore_object->object()));
663+
if (Level().ObjectSpace.RayPick(start, dir, range, tgt, R, ignore))
664+
{
665+
script_R.set(R);
666+
return true;
667+
}
668+
return false;
669+
}
670+
671+
// XXX nitrocaster: one can export enum like class, without defining dummy type
672+
template<typename T>
673+
struct EnumCallbackType {};
674+
652675
IC static void CLevel_Export(lua_State* luaState)
653676
{
654677
class_<CEnvDescriptor>("CEnvDescriptor")
@@ -731,11 +754,45 @@ IC static void CLevel_Export(lua_State* luaState)
731754

732755
def("vertex_id", &vertex_id),
733756

734-
def("game_id", &GameID)],
757+
def("game_id", &GameID),
758+
def("ray_pick", &ray_pick)],
735759

736760
module(luaState, "actor_stats")[def("add_points", &add_actor_points),
737761
def("add_points_str", &add_actor_points_str), def("get_points", &get_actor_points)];
738762

763+
module(luaState)
764+
[
765+
class_<CRayPick>("ray_pick")
766+
.def(constructor<>())
767+
.def(constructor<Fvector&, Fvector&, float, collide::rq_target, CScriptGameObject*>())
768+
.def("set_position", &CRayPick::set_position)
769+
.def("set_direction", &CRayPick::set_direction)
770+
.def("set_range", &CRayPick::set_range)
771+
.def("set_flags", &CRayPick::set_flags)
772+
.def("set_ignore_object", &CRayPick::set_ignore_object)
773+
.def("query", &CRayPick::query)
774+
.def("get_result", &CRayPick::get_result)
775+
.def("get_object", &CRayPick::get_object)
776+
.def("get_distance", &CRayPick::get_distance)
777+
.def("get_element", &CRayPick::get_element),
778+
class_<script_rq_result>("rq_result")
779+
.def_readonly("object", &script_rq_result::O)
780+
.def_readonly("range", &script_rq_result::range)
781+
.def_readonly("element", &script_rq_result::element)
782+
.def(constructor<>()),
783+
class_<EnumCallbackType<collide::rq_target>>("rq_target")
784+
.enum_("targets")
785+
[
786+
value("rqtNone", int(collide::rqtNone)),
787+
value("rqtObject", int(collide::rqtObject)),
788+
value("rqtStatic", int(collide::rqtStatic)),
789+
value("rqtShape", int(collide::rqtShape)),
790+
value("rqtObstacle", int(collide::rqtObstacle)),
791+
value("rqtBoth", int(collide::rqtBoth)),
792+
value("rqtDyn", int(collide::rqtDyn))
793+
]
794+
];
795+
739796
module(luaState)[def("command_line", &command_line), def("IsGameTypeSingle", &IsGameTypeSingle),
740797
def("IsDynamicMusic", &IsDynamicMusic), def("render_get_dx_level", &render_get_dx_level),
741798
def("IsImportantSave", &IsImportantSave)];

src/xrGame/raypick.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include "stdafx.h"
2+
#include "raypick.h"
3+
#include "level.h"
4+
5+
CRayPick::CRayPick()
6+
{
7+
start_position.set(0, 0, 0);
8+
direction.set(0, 0, 0);
9+
range = 0;
10+
flags = collide::rq_target::rqtNone;
11+
ignore = nullptr;
12+
};
13+
14+
CRayPick::CRayPick(const Fvector& P, const Fvector& D, const float R, const collide::rq_target F, CScriptGameObject* I)
15+
{
16+
start_position.set(P);
17+
direction.set(D);
18+
range = R;
19+
flags = F;
20+
ignore = nullptr;
21+
if (I)
22+
ignore = smart_cast<IGameObject*>(&(I->object()));
23+
};
24+
25+
bool CRayPick::query()
26+
{
27+
collide::rq_result R;
28+
if (Level().ObjectSpace.RayPick(start_position, direction, range, flags, R, ignore))
29+
{
30+
result.set(R);
31+
return true;
32+
}
33+
34+
return false;
35+
}

0 commit comments

Comments
 (0)