Skip to content

Commit

Permalink
+ Added sanity checks to a couple actions that should verify if enemy…
Browse files Browse the repository at this point in the history
…/danger object actually exists before executing since it's possible these can become NULL between the time the evaluator is ran and the action is executed

+ Added a condition check to see if member is visible_now before transfering enemy through CAI_Stalker::process_enemies to prevent omniscient detection
* Changed ERROR to WARNING when an object is transfered to a new inventory owner when it doesn't have a parent
  • Loading branch information
revolucas authored and Xottab-DUTY committed Aug 14, 2017
1 parent 599df0e commit 9eb0a68
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/xrGame/ai/stalker/ai_stalker_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ void CAI_Stalker::process_enemies()
continue;
}

//Alundaio: Only transfer enemy if I can see member at this very moment!
if (!memory().visual().visible_now(member))
continue;
//Alundaio: END

memory().make_object_visible_somewhen(member->memory().enemy().selected());
found = true;
break;
Expand Down
19 changes: 19 additions & 0 deletions src/xrGame/alife_online_offline_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,25 @@ void CSE_ALifeOnlineOfflineGroup::force_change_position(Fvector position)
// m_tGraphID = new_graph_vertex;
}

//Alundaio: force new graph location
/*
void CSE_ALifeOnlineOfflineGroup::force_change_game_vertex_id(u32 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;
if (m_tGraphID != game_vertex_id)
{
alife().graph().change(this, m_tGraphID, game_vertex_id);
}
}
}
*/
//Alundaio: END

void CSE_ALifeOnlineOfflineGroup::on_failed_switch_online()
{
MEMBERS::const_iterator I = m_members.begin();
Expand Down
22 changes: 18 additions & 4 deletions src/xrGame/stalker_combat_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,10 @@ void CStalkerActionDetourEnemy::initialize()
object().agent_manager().member().member(m_object).cover(0);

//#ifndef SILENT_COMBAT
if (object().memory().enemy().selected()->human_being() && object().agent_manager().member().group_behaviour())
// object().sound().play (eStalkerSoundNeedBackup);
//Alundaio: Sanity
if (object().memory().enemy().selected() && object().memory().enemy().selected()->human_being() && object().agent_manager().member().group_behaviour())
//Alundaio: END
//object().sound().play(eStalkerSoundNeedBackup);
object().sound().play(eStalkerSoundDetour);
//#endif
}
Expand All @@ -806,6 +808,11 @@ void CStalkerActionDetourEnemy::execute()

inherited::execute();

//Alundaio: Sanity
if (!object().memory().enemy().selected())
return;
//Alundaio: END

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

if (!mem_object.m_object)
Expand Down Expand Up @@ -1009,8 +1016,10 @@ void CStalkerActionSuddenAttack::execute()

inherited::execute();

if (object().agent_manager().member().combat_members().size() > 1)
m_storage->set_property(eWorldPropertyUseSuddenness, false);
//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
//if (object().agent_manager().member().combat_members().size() > 1)
// m_storage->set_property(eWorldPropertyUseSuddenness, false);
//Alundaio: END

if (!object().memory().enemy().selected())
return;
Expand Down Expand Up @@ -1133,6 +1142,11 @@ void CStalkerActionKillEnemyIfPlayerOnThePath::execute()

inherited::execute();

//Alundaio: Sanity
if (!object().memory().enemy().selected())
return;
//Alundaio: END

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

fire();
Expand Down
5 changes: 5 additions & 0 deletions src/xrGame/stalker_danger_in_direction_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ void CStalkerActionDangerInDirectionLookOut::execute()
{
inherited::execute();

//Alundaio: This action should verify the danger object exists; sanity
if (!object().memory().danger().selected())
return;
//Alundaio: END

// CMemoryInfo mem_object =
// object().memory().memory(object().memory().danger().selected()->object());
//
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/xrServer_process_event_reject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bool xrServer::Process_event_reject(
xr_vector<u16>::iterator c = std::find(C.begin(), C.end(), id_entity);
if (c == C.end())
{
Msg("! ERROR: SV: can't find children [%d] of parent [%d]", id_entity, e_parent);
Msg("! WARNING: SV: can't find children [%d] of parent [%d]", id_entity, e_parent);
return false;
}

Expand Down
1 change: 1 addition & 0 deletions src/xrServerEntities/xrServer_Objects_ALife_Monsters.h
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +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);
virtual void on_failed_switch_online();
#else
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ static void CSE_ALifeOnlineOfflineGroup_Export(lua_State* luaState)
.def("add_location_type", &CSE_ALifeOnlineOfflineGroup::add_location_type)
.def("clear_location_types", &CSE_ALifeOnlineOfflineGroup::clear_location_types)
.def("force_change_position", &CSE_ALifeOnlineOfflineGroup::force_change_position)
//.def("force_change_game_vertex_id", &CSE_ALifeOnlineOfflineGroup::force_change_game_vertex_id)
#endif
];
}
Expand Down

0 comments on commit 9eb0a68

Please sign in to comment.