Skip to content

Commit

Permalink
+ new game object exports
Browse files Browse the repository at this point in the history
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
  • Loading branch information
revolucas authored and Xottab-DUTY committed Dec 17, 2017
1 parent eba6916 commit 9b6a6db
Show file tree
Hide file tree
Showing 22 changed files with 703 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/xrEngine/xr_ioc_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ void CCC_Register()
CMD3(CCC_Mask, "snd_acceleration", &psSoundFlags, ss_Hardware);
CMD3(CCC_Mask, "snd_efx", &psSoundFlags, ss_EAX);
CMD4(CCC_Integer, "snd_targets", &psSoundTargets, 4, 32);
CMD4(CCC_Integer, "snd_cache_size", &psSoundCacheSizeMB, 4, 32);
CMD4(CCC_Integer, "snd_cache_size", &psSoundCacheSizeMB, 4, 64);

#ifdef DEBUG
CMD3(CCC_Mask, "snd_stats", &g_stats_flags, st_sound);
Expand Down
10 changes: 10 additions & 0 deletions src/xrGame/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,16 @@ void CActor::SetShotRndSeed(s32 Seed)
m_ShotRndSeed = s32(Level().timeServer_Async());
};

Fvector CActor::GetMissileOffset() const
{
return m_vMissileOffset;
}

void CActor::SetMissileOffset(const Fvector& vNewOffset)
{
m_vMissileOffset.set(vNewOffset);
}

void CActor::spawn_supplies()
{
inherited::spawn_supplies();
Expand Down
28 changes: 28 additions & 0 deletions src/xrGame/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ class CActor : public CEntityAlive,

BOOL m_bJumpKeyPressed;

public:
float m_fWalkAccel;
float m_fJumpSpeed;
float m_fRunFactor;
Expand Down Expand Up @@ -465,6 +466,13 @@ class CActor : public CEntityAlive,
// crouch+no acceleration
float m_fDispCrouchNoAccelFactor;

Fvector m_vMissileOffset;

public:
// Получение, и запись смещения для гранат
Fvector GetMissileOffset() const;
void SetMissileOffset(const Fvector& vNewOffset);

protected:
//косточки используемые при стрельбе
int m_r_hand;
Expand Down Expand Up @@ -743,6 +751,26 @@ class CActor : public CEntityAlive,
bool m_disabled_hitmarks;
bool m_inventory_disabled;
// static CPhysicsShell *actor_camera_shell;

IC u32 get_state() const
{
return this->mstate_real;
}

IC void set_state(u32 state)
{
mstate_real = state;
}

IC u32 get_state_wishful() const
{
return this->mstate_wishful;
}

IC void set_state_wishful(u32 state)
{
mstate_wishful = state;
}
};

extern bool isActorAccelerated(u32 mstate, bool ZoomMode);
Expand Down
3 changes: 3 additions & 0 deletions src/xrGame/ActorCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ class CActorCondition : public CEntityCondition
float m_fAccelK;
float m_fSprintK;

public:
float m_MaxWalkWeight;

protected:
float m_zone_max_power[ALife::infl_max_count];
float m_zone_danger[ALife::infl_max_count];
float m_f_time_affected;
Expand Down
9 changes: 7 additions & 2 deletions src/xrGame/TeleWhirlwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ void CTeleWhirlwind::draw_out_impact(Fvector& dir, float& val)
{
VERIFY2(m_saved_impacts.size(), "NO IMPACTS ADDED!");

if (m_saved_impacts.empty())
return;

dir.set(m_saved_impacts[0].force);
val = dir.magnitude();
if (!fis_zero(val))
dir.mul(1.f / val);

// Swartz
//if (!fis_zero(val))
// dir.mul(1.f / val);
m_saved_impacts.erase(m_saved_impacts.begin());
}

Expand Down
4 changes: 4 additions & 0 deletions src/xrGame/UIStaticItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class CUIStaticItem
IC float GetPosY() { return vPos.y; }
IC void SetTextureColor(u32 clr) { dwColor = clr; }
IC u32 GetTextureColor() const { return dwColor; }
void SetColor(u32 clr) { dwColor = clr; }
void SetColor(Fcolor clr) { dwColor = clr.get(); }
u32 GetColor() const { return dwColor; }
u32& GetColorRef() { return dwColor; }
ui_shader& GetShader() { return hShader; }
public:
CUIStaticItem();
Expand Down
8 changes: 8 additions & 0 deletions src/xrGame/ai/phantom/phantom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ BOOL CPhantom::net_Spawn(CSE_Abstract* DC)
if (!inherited::net_Spawn(DC))
return FALSE;

OBJ->set_killer_id(u16(-1)); // Alundaio: Hack to prevent strange crash with dynamic phantoms

m_enemy = Level().CurrentEntity();
VERIFY(m_enemy);

Expand Down Expand Up @@ -137,6 +139,9 @@ void CPhantom::animation_end_callback(CBlend* B)
//---------------------------------------------------------------------
void CPhantom::SwitchToState_internal(EState new_state)
{
if (!m_enemy)
m_enemy = Level().CurrentEntity();

if (new_state != m_CurState)
{
IKinematicsAnimated* K = smart_cast<IKinematicsAnimated*>(Visual());
Expand Down Expand Up @@ -242,6 +247,9 @@ void CPhantom::OnFlyState()
void CPhantom::OnDeadState() { UpdateFlyMedia(); }
void CPhantom::UpdateFlyMedia()
{
if (!m_enemy)
m_enemy = Level().CurrentEntity();

UpdatePosition(m_enemy->Position());
Fmatrix xform = XFORM_center();
// update particles
Expand Down
2 changes: 2 additions & 0 deletions src/xrGame/ai/phantom/phantom.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,6 @@ class CPhantom : public CEntity
virtual bool IsVisibleForZones() { return false; }
virtual BOOL UsedAI_Locations() { return false; }
virtual CEntity* cast_entity() { return this; }

void SetEnemy(IGameObject* enemy) { m_enemy = enemy; } //Alundaio
};
59 changes: 58 additions & 1 deletion src/xrGame/level_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#include "xrServer_Objects_ALife_Monsters.h"
#include "xrScriptEngine/ScriptExporter.hpp"
#include "HUDManager.h"
#include "raypick.h"
#include "xrCDB/xr_collide_defs.h"

using namespace luabind;
using namespace luabind::policy;
Expand Down Expand Up @@ -649,6 +651,27 @@ void set_active_cam(u8 mode)
#endif
//-Alundaio

// KD: raypick
bool ray_pick(const Fvector& start, const Fvector& dir, float range,
collide::rq_target tgt, script_rq_result& script_R,
CScriptGameObject* ignore_object)
{
collide::rq_result R;
IGameObject* ignore = nullptr;
if (ignore_object)
ignore = smart_cast<IGameObject*>(&(ignore_object->object()));
if (Level().ObjectSpace.RayPick(start, dir, range, tgt, R, ignore))
{
script_R.set(R);
return true;
}
return false;
}

// XXX nitrocaster: one can export enum like class, without defining dummy type
template<typename T>
struct EnumCallbackType {};

IC static void CLevel_Export(lua_State* luaState)
{
class_<CEnvDescriptor>("CEnvDescriptor")
Expand Down Expand Up @@ -731,11 +754,45 @@ IC static void CLevel_Export(lua_State* luaState)

def("vertex_id", &vertex_id),

def("game_id", &GameID)],
def("game_id", &GameID),
def("ray_pick", &ray_pick)],

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

module(luaState)
[
class_<CRayPick>("ray_pick")
.def(constructor<>())
.def(constructor<Fvector&, Fvector&, float, collide::rq_target, CScriptGameObject*>())
.def("set_position", &CRayPick::set_position)
.def("set_direction", &CRayPick::set_direction)
.def("set_range", &CRayPick::set_range)
.def("set_flags", &CRayPick::set_flags)
.def("set_ignore_object", &CRayPick::set_ignore_object)
.def("query", &CRayPick::query)
.def("get_result", &CRayPick::get_result)
.def("get_object", &CRayPick::get_object)
.def("get_distance", &CRayPick::get_distance)
.def("get_element", &CRayPick::get_element),
class_<script_rq_result>("rq_result")
.def_readonly("object", &script_rq_result::O)
.def_readonly("range", &script_rq_result::range)
.def_readonly("element", &script_rq_result::element)
.def(constructor<>()),
class_<EnumCallbackType<collide::rq_target>>("rq_target")
.enum_("targets")
[
value("rqtNone", int(collide::rqtNone)),
value("rqtObject", int(collide::rqtObject)),
value("rqtStatic", int(collide::rqtStatic)),
value("rqtShape", int(collide::rqtShape)),
value("rqtObstacle", int(collide::rqtObstacle)),
value("rqtBoth", int(collide::rqtBoth)),
value("rqtDyn", int(collide::rqtDyn))
]
];

module(luaState)[def("command_line", &command_line), def("IsGameTypeSingle", &IsGameTypeSingle),
def("IsDynamicMusic", &IsDynamicMusic), def("render_get_dx_level", &render_get_dx_level),
def("IsImportantSave", &IsImportantSave)];
Expand Down
35 changes: 35 additions & 0 deletions src/xrGame/raypick.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "stdafx.h"
#include "raypick.h"
#include "level.h"

CRayPick::CRayPick()
{
start_position.set(0, 0, 0);
direction.set(0, 0, 0);
range = 0;
flags = collide::rq_target::rqtNone;
ignore = nullptr;
};

CRayPick::CRayPick(const Fvector& P, const Fvector& D, const float R, const collide::rq_target F, CScriptGameObject* I)
{
start_position.set(P);
direction.set(D);
range = R;
flags = F;
ignore = nullptr;
if (I)
ignore = smart_cast<IGameObject*>(&(I->object()));
};

bool CRayPick::query()
{
collide::rq_result R;
if (Level().ObjectSpace.RayPick(start_position, direction, range, flags, R, ignore))
{
result.set(R);
return true;
}

return false;
}
60 changes: 60 additions & 0 deletions src/xrGame/raypick.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#pragma once

#include "script_game_object.h"
#include "xrCDB/xr_collide_defs.h"

struct script_rq_result
{
CScriptGameObject* O;
float range;
int element;

script_rq_result()
{
O = nullptr;
range = 0;
element = 0;
};

void set(collide::rq_result& R)
{
if (R.O)
{
IGameObject* go = smart_cast<IGameObject*>(R.O);
if (go)
O = go->lua_game_object();
}
range = R.range;
element = R.element;
};
};

// class for performing ray pick
struct CRayPick
{
Fvector start_position;
Fvector direction;
float range;
collide::rq_target flags;
script_rq_result result;
IGameObject* ignore;

CRayPick();
CRayPick(const Fvector& P, const Fvector& D, const float R, const collide::rq_target F, CScriptGameObject* I);

void set_position(Fvector& P) { start_position = P; };
void set_direction(Fvector& D) { direction = D; };
void set_range(float R) { range = R; };
void set_flags(collide::rq_target F) { flags = F; };
void set_ignore_object(CScriptGameObject* I)
{
if (I) ignore = smart_cast<IGameObject*>(&(I->object()));
}

bool query();

script_rq_result get_result() { return result; };
CScriptGameObject* get_object() { return result.O; };
float get_distance() { return result.range; };
int get_element() { return result.element; };
};
14 changes: 14 additions & 0 deletions src/xrGame/script_game_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "physics_shell_scripted.h"
#include "CharacterPhysicsSupport.h" //Alundaio: For set_visual
#include "damage_manager.h" //Alundaio: For set_visual
#include "ai/phantom/phantom.h"

class CScriptBinderObject;

Expand Down Expand Up @@ -595,3 +596,16 @@ pcstr CScriptGameObject::get_smart_cover_description() const

void CScriptGameObject::set_visual_name(LPCSTR visual) { object().cNameVisual_set(visual); }
LPCSTR CScriptGameObject::get_visual_name() const { return object().cNameVisual().c_str(); }

void CScriptGameObject::PhantomSetEnemy(CScriptGameObject* enemy)
{
CPhantom* phant = smart_cast<CPhantom*>(&object());
if (!phant)
return;

IGameObject* obj = smart_cast<IGameObject*>(enemy);
if (!obj)
return;

phant->SetEnemy(obj);
}
Loading

0 comments on commit 9b6a6db

Please sign in to comment.