Skip to content

Commit

Permalink
+ added alife().jump_to_level
Browse files Browse the repository at this point in the history
+ added alife().teleport_object
+ added level.get_target_obj
+ added level.get_target_dist
+ added level.send
+ added several condition checks to stalker_combat_actions.cpp to further the validity of the performed action.
  • Loading branch information
revolucas authored and Xottab-DUTY committed Aug 14, 2017
1 parent 9eb0a68 commit c826696
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 33 deletions.
7 changes: 3 additions & 4 deletions src/xrGame/alife_online_offline_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,12 @@ void CSE_ALifeOnlineOfflineGroup::force_change_position(Fvector position)

//Alundaio: force new graph location
/*
void CSE_ALifeOnlineOfflineGroup::force_change_game_vertex_id(u32 game_vertex_id)
void CSE_ALifeOnlineOfflineGroup::force_change_game_vertex_id(GameGraph::_GRAPH_ID game_vertex_id)
{
if (game_vertex_id && ai().game_graph().valid_vertex_id(game_vertex_id))
{
const CGameGraph::CVertex vertex = *ai().game_graph().vertex(game_vertex_id);
m_tNodeID = vertex.level_vertex_id;
o_Position = vertex.level_point;
m_tNodeID = ai().game_graph().vertex(game_vertex_id)->level_vertex_id();
o_Position = ai().game_graph().vertex(game_vertex_id)->level_point();
if (m_tGraphID != game_vertex_id)
{
Expand Down
4 changes: 4 additions & 0 deletions src/xrGame/alife_simulator_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ SCRIPT_EXPORT(CALifeSimulator, (), {
.def("dont_has_info", &dont_has_info)
.def("switch_distance", &CALifeSimulator::switch_distance)
.def("switch_distance", &CALifeSimulator::set_switch_distance)
//Alundaio: extend alife simulator exports
.def("jump_to_level", (void (CALifeSimulator::*) (LPCSTR))(&CALifeSimulator::jump_to_level))
.def("teleport_object", (void (CALifeSimulator::*) (ALife::_OBJECT_ID, GameGraph::_GRAPH_ID, u32, Fvector))(&CALifeSimulator::teleport_object))
//Alundaio: END

,
def("alife", &alife)];
Expand Down
35 changes: 35 additions & 0 deletions src/xrGame/level_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "alife_object_registry.h"
#include "xrServer_Objects_ALife_Monsters.h"
#include "xrScriptEngine/ScriptExporter.hpp"
#include "HUDManager.h"

using namespace luabind;
using namespace luabind::policy;
Expand Down Expand Up @@ -585,6 +586,34 @@ void stop_tutorial()

LPCSTR translate_string(LPCSTR str) { return *CStringTable().translate(str); }
bool has_active_tutotial() { return (g_tutorial != NULL); }

//Alundaio: namespace level exports extension

//ability to update level netpacket
void g_send(NET_Packet& P, bool bReliable = false, bool bSequential = true, bool bHighPriority = false, bool bSendImmediately = false)
{
Level().Send(P, net_flags(bReliable, bSequential, bHighPriority, bSendImmediately));
}

//ability to get the target game_object at crosshair
CGameObject* g_get_target_obj()
{
collide::rq_result& RQ = HUD().GetCurrentRayQuery();
CGameObject* object = smart_cast<CGameObject*>(RQ.O);
if (object)
return object;
}

float g_get_target_dist()
{
collide::rq_result& RQ = HUD().GetCurrentRayQuery();
CGameObject* object = smart_cast<CGameObject*>(RQ.O);
if (object)
return RQ.range;
}

//Alundaio: END

IC static void CLevel_Export(lua_State* luaState)
{
class_<CEnvDescriptor>("CEnvDescriptor")
Expand All @@ -594,6 +623,12 @@ IC static void CLevel_Export(lua_State* luaState)
class_<CEnvironment>("CEnvironment").def("current", current_environment);

module(luaState, "level")[
//Alundaio: Extend level namespace exports
def("send", g_send) , //allow the ability to send netpacket to level
//def("ray_pick",g_ray_pick),
def("get_target_obj", g_get_target_obj) , //intentionally named to what is in xray extensions
def("get_target_dist", g_get_target_dist) ,
//Alundaio: END
// obsolete\deprecated
def("object_by_id", get_object_by_id),
#ifdef DEBUG
Expand Down
64 changes: 36 additions & 28 deletions src/xrGame/stalker_combat_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,6 @@ void CStalkerActionRetreatFromEnemy::execute()
{
inherited::execute();

if (!object().memory().enemy().selected())
return;

if (!object().memory().enemy().selected())
return;

Expand Down Expand Up @@ -437,27 +434,26 @@ void CStalkerActionKillEnemy::execute()
#endif // TEST_MENTAL_STATE

inherited::execute();
//Alundaio
if (object().memory().enemy().selected() && object().memory().enemy().selected()->g_Alive())
{
object().sight().setup(CSightAction(object().memory().enemy().selected(), true, true));

object().sight().setup(CSightAction(object().memory().enemy().selected(), true, true));

// u32 min_queue_size, max_queue_size, min_queue_interval, max_queue_interval;
// float distance =
// object().memory().enemy().selected()->Position().distance_to(object().Position());
// select_queue_params (distance,min_queue_size, max_queue_size, min_queue_interval,
// max_queue_interval);
// object().CObjectHandler::set_goal (eObjectActionFire1,object().best_weapon(),min_queue_size, max_queue_size,
// min_queue_interval, max_queue_interval);
fire();
// u32 min_queue_size, max_queue_size, min_queue_interval, max_queue_interval;
// float distance = object().memory().enemy().selected()->Position().distance_to(object().Position());
// select_queue_params(distance,min_queue_size, max_queue_size, min_queue_interval, max_queue_interval);
// object().CObjectHandler::set_goal (eObjectActionFire1,object().best_weapon(),min_queue_size, max_queue_size, min_queue_interval, max_queue_interval);
fire();

if (object().memory().enemy().selected())
{
CMemoryInfo mem_object = object().memory().memory(object().memory().enemy().selected());

if (mem_object.m_object)
{
object().best_cover(mem_object.m_object_params.m_position);
}
}
else
object().sight().setup(CSightAction(SightManager::eSightTypePathDirection, true, true));

//Alundaio: END
}

//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -488,7 +484,7 @@ void CStalkerActionTakeCover::initialize()
m_storage->set_property(eWorldPropertyEnemyDetoured, false);

#ifndef SILENT_COMBAT
if (object().memory().enemy().selected()->human_being())
if (object().memory().enemy().selected() && object().memory().enemy().selected()->human_being())
{
if (object().agent_manager().member().can_cry_noninfo_phrase())
if (object().Position().distance_to_sqr(object().memory().enemy().selected()->Position()) < _sqr(10.f))
Expand All @@ -508,6 +504,9 @@ void CStalkerActionTakeCover::execute()

inherited::execute();

if (!object().memory().enemy().selected())
return;

CMemoryInfo mem_object = object().memory().memory(object().memory().enemy().selected());

if (!mem_object.m_object)
Expand Down Expand Up @@ -625,6 +624,9 @@ void CStalkerActionLookOut::execute()

inherited::execute();

if (!object().memory().enemy().selected())
return;

CMemoryInfo mem_object = object().memory().memory(object().memory().enemy().selected());

if (!mem_object.m_object)
Expand Down Expand Up @@ -710,6 +712,9 @@ void CStalkerActionHoldPosition::execute()

inherited::execute();

if (!object().memory().enemy().selected())
return;

CMemoryInfo mem_object = object().memory().memory(object().memory().enemy().selected());

if (!mem_object.m_object)
Expand Down Expand Up @@ -1016,7 +1021,7 @@ void CStalkerActionSuddenAttack::execute()

inherited::execute();

//Alundaio: Removed check to allow stalkers to sneak up on enemy even if they are in a squad; most likely removed because of friendly fire but not an issue with rx_ff scheme
//Alundaio: Removed check to allow stalkers to sneak up on enemy even if they are in a group.
//if (object().agent_manager().member().combat_members().size() > 1)
// m_storage->set_property(eWorldPropertyUseSuddenness, false);
//Alundaio: END
Expand Down Expand Up @@ -1093,7 +1098,7 @@ void CStalkerActionSuddenAttack::execute()

CVisualMemoryManager* visual_memory_manager = object().memory().enemy().selected()->visual_memory();
VERIFY(visual_memory_manager);
if (!visual_memory_manager->visible_now(&object()))
if (object().memory().enemy().selected()->g_Alive() && !visual_memory_manager->visible_now(&object()))
return;

m_storage->set_property(eWorldPropertyUseSuddenness, false);
Expand Down Expand Up @@ -1179,16 +1184,19 @@ void CStalkerActionCriticalHit::initialize()
object().brain().affect_cover(false);
object().movement().set_movement_type(eMovementTypeStand);

if (object().memory().enemy().selected())
if (object().inventory().ActiveItem() && object().best_weapon() && (object().inventory().ActiveItem()->object().ID() == object().best_weapon()->object().ID()))
{
u32 min_queue_size, max_queue_size, min_queue_interval, max_queue_interval;
float distance = object().memory().enemy().selected()->Position().distance_to(object().Position());
select_queue_params(distance, min_queue_size, max_queue_size, min_queue_interval, max_queue_interval);
object().CObjectHandler::set_goal(eObjectActionIdle, object().best_weapon(), min_queue_size, max_queue_size,
min_queue_interval, max_queue_interval);
if (object().memory().enemy().selected())
{
u32 min_queue_size, max_queue_size, min_queue_interval, max_queue_interval;
float distance = object().memory().enemy().selected()->Position().distance_to(object().Position());
select_queue_params(distance, min_queue_size, max_queue_size, min_queue_interval, max_queue_interval);
object().set_goal(eObjectActionIdle, object().best_weapon(), min_queue_size, max_queue_size,
min_queue_interval, max_queue_interval);
}
else
object().set_goal(eObjectActionIdle, object().best_weapon());
}
else
object().CObjectHandler::set_goal(eObjectActionIdle, object().best_weapon());

object().sight().setup(CSightAction(SightManager::eSightTypeCurrentDirection, true, true));
object().sound().play(eStalkerSoundInjuring);
Expand Down
2 changes: 1 addition & 1 deletion src/xrServerEntities/xrServer_Objects_ALife_Monsters.h
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ class CSE_ALifeOnlineOfflineGroup : public CSE_ALifeDynamicObject,
void clear_location_types();
void add_location_type(LPCSTR mask);
void force_change_position(Fvector position);
//void force_change_game_vertex_id(u32 game_vertex_id);
//void force_change_game_vertex_id(GameGraph::_GRAPH_ID game_vertex_id);
virtual void on_failed_switch_online();
#else
public:
Expand Down

0 comments on commit c826696

Please sign in to comment.