@@ -436,21 +436,22 @@ void CStalkerActionKillEnemy::execute()
436436 inherited::execute ();
437437 // Alundaio: Prevent Stalkers from shooting at walls for prolonged periods due to kill if not visible
438438 const CEntityAlive* enemy = object ().memory ().enemy ().selected ();
439- if (!enemy || !enemy->g_Alive ())
440- return ;
441-
442- CMemoryInfo mem_object = object ().memory ().memory (enemy);
443- if (!mem_object.m_object )
444- return ;
445-
446- object ().best_cover (mem_object.m_object_params .m_position );
447-
448- u32 last_time_seen = object ().memory ().visual ().visible_object_time_last_seen (enemy);
449- if (last_time_seen != u32 (-1 ) && Device.dwTimeGlobal - last_time_seen <= 2000 )
439+ if (enemy && enemy->g_Alive ())
450440 {
451- object ().sight ().setup (CSightAction (enemy, true , true ));
452- fire ();
441+ CMemoryInfo mem_object = object ().memory ().memory (enemy);
442+ if (mem_object.m_object )
443+ object ().best_cover (mem_object.m_object_params .m_position );
444+ u32 last_time_seen = object ().memory ().visual ().visible_object_time_last_seen (enemy);
445+
446+ // Here NPC will only fire at not visible enemy for no more than 3 seconds instead of shooting at walls like morons
447+ if (last_time_seen != u32 (-1 ) && Device.dwTimeGlobal - last_time_seen <= 3000 )
448+ {
449+ object ().sight ().setup (CSightAction (enemy, true , true ));
450+ fire ();
451+ }
453452 }
453+ else
454+ object ().sight ().setup (CSightAction (SightManager::eSightTypePathDirection, true , true ));
454455 // Alundaio: END
455456}
456457
@@ -502,6 +503,7 @@ void CStalkerActionTakeCover::execute()
502503
503504 inherited::execute ();
504505
506+ // Alundaio:
505507 const CEntityAlive* enemy = object ().memory ().enemy ().selected ();
506508 if (!enemy)
507509 return ;
@@ -536,9 +538,15 @@ void CStalkerActionTakeCover::execute()
536538 // if (object().memory().visual().visible_now(object().memory().enemy().selected()) && object().can_kill_enemy())
537539 // if (object().memory().visual().visible_now(object().memory().enemy().selected()))
538540
539- // Alundaio: Fix shooting at walls or aiming at ceiling or floor during this action
541+ if (object ().movement ().path_completed ()) // && (object().memory().enemy().selected()->Position().distance_to_sqr(object().Position()) >= 10.f))
542+ {
543+ object ().best_cover_can_try_advance ();
544+ m_storage->set_property (eWorldPropertyInCover, true );
545+ }
546+
547+ // Don't shoot if enemy not visible for longer than 3 seconds
540548 u32 last_time_seen = object ().memory ().visual ().visible_object_time_last_seen (enemy);
541- if (last_time_seen != u32 (-1 ) && Device.dwTimeGlobal - last_time_seen <= 2000 && fire_make_sense ())
549+ if (last_time_seen != u32 (-1 ) && Device.dwTimeGlobal - last_time_seen <= 3000 && fire_make_sense ())
542550 {
543551 fire ();
544552 }
@@ -643,6 +651,8 @@ void CStalkerActionLookOut::execute()
643651 }
644652 else
645653 object ().sight ().setup (CSightAction (SightManager::eSightTypePosition, mem_object.m_object_params .m_position , true ));
654+
655+ object ().best_cover (mem_object.m_object_params .m_position );
646656 // -Alundaio
647657
648658 if (current_cover (m_object) >= 3 .f )
@@ -675,8 +685,6 @@ void CStalkerActionLookOut::execute()
675685 // m_storage->set_property (eWorldPropertyLookedOut,true);
676686 // object().movement().set_nearest_accessible_position ();
677687 // }
678-
679- object ().best_cover (mem_object.m_object_params .m_position );
680688}
681689
682690// ////////////////////////////////////////////////////////////////////////
@@ -715,6 +723,14 @@ void CStalkerActionHoldPosition::execute()
715723
716724 inherited::execute ();
717725
726+ // Alundaio: Cleaned up
727+ /*
728+ Possible TODO : This action is a good place to prevent stalkers staring at walls.
729+ A simple ray query each execute can do the trick by rotating the stalker until
730+ the differences between the last query and new query are larger than some defined threshold.
731+ This way you can detect edges of walls and would give the illusion of stalkers looking at corridors or chokepoints instead of through a wall.
732+ */
733+
718734 const CEntityAlive* enemy = object ().memory ().enemy ().selected ();
719735 if (!enemy)
720736 return ;
@@ -723,6 +739,8 @@ void CStalkerActionHoldPosition::execute()
723739 if (!mem_object.m_object )
724740 return ;
725741
742+ object ().best_cover (mem_object.m_object_params .m_position );
743+
726744 if (current_cover (m_object) < 3 .f )
727745 m_storage->set_property (eWorldPropertyLookedOut, false );
728746
@@ -756,16 +774,7 @@ void CStalkerActionHoldPosition::execute()
756774 {
757775 aim_ready ();
758776 }
759-
760- if (object ().memory ().enemy ().selected ())
761- {
762- CMemoryInfo mem_object = object ().memory ().memory (object ().memory ().enemy ().selected ());
763-
764- if (mem_object.m_object )
765- {
766- object ().best_cover (mem_object.m_object_params .m_position );
767- }
768- }
777+ // -Alundaio
769778}
770779
771780// ////////////////////////////////////////////////////////////////////////
@@ -799,13 +808,13 @@ void CStalkerActionDetourEnemy::initialize()
799808
800809 object ().agent_manager ().member ().member (m_object).cover (0 );
801810
802- // #ifndef SILENT_COMBAT
803- // Alundaio: Sanity
811+ // #ifndef SILENT_COMBAT
812+ // Alundaio: Added sanity to make sure enemy exists
804813 if (object ().memory ().enemy ().selected () && object ().memory ().enemy ().selected ()->human_being () && object ().agent_manager ().member ().group_behaviour ())
805814 // Alundaio: END
806815 // object().sound().play(eStalkerSoundNeedBackup);
807816 object ().sound ().play (eStalkerSoundDetour);
808- // #endif
817+ // #endif
809818}
810819
811820void CStalkerActionDetourEnemy::finalize ()
@@ -887,7 +896,7 @@ void CStalkerActionPostCombatWait::initialize()
887896 if (object ().movement ().current_params ().cover ())
888897 return ;
889898
890- object ().movement ().set_movement_type (eMovementTypeRun); // Alundaio. Was eMovementTypeStand
899+ object ().movement ().set_movement_type (eMovementTypeRun); // Alundaio: Changed from walk to run. ( eMovementTypeStand)
891900 EObjectAction action = eObjectActionAimReady1;
892901 if (m_storage->property (eWorldPropertyKilledWounded))
893902 action = eObjectActionIdle;
0 commit comments