Skip to content

Commit

Permalink
Restore AI dodging behaviour
Browse files Browse the repository at this point in the history
Apply transformation scaling in SetRobotLocationInfo and changes
GameLoop to run ReadControls after rendering to preserve
bPlayerFiredLaserThisFrame.
  • Loading branch information
arbruijn committed Jun 17, 2022
1 parent 65d6220 commit 4ed0b95
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion main/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1148,14 +1148,14 @@ else {
//playerSynchronizer.Start ();
CalcFrameTime (fps);
//playerSynchronizer.Stop ();
HandleControls (bControls);
gameStates.render.EnableCartoonStyle (1, 1, 1);
m_nResult = Preprocess ();
gameStates.render.DisableCartoonStyle ();
if (0 > m_nResult)
RETVAL (m_nResult)
if (bRender)
Render ();
HandleControls (bControls);
gameStates.render.EnableCartoonStyle (1, 1, 1);
m_nResult = Postprocess ();
gameStates.render.DisableCartoonStyle ();
Expand Down
15 changes: 14 additions & 1 deletion render/objrender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,27 @@ RETURN
void SetRobotLocationInfo (CObject *pObj)
{
if (pObj && (gameStates.app.bPlayerFiredLaserThisFrame != -1)) {
CFixVector vPos;
#if 0
CRenderPoint temp;

temp.TransformAndEncode (pObj->info.position.vPos);
if (temp.Behind ()) //robot behind the screen
return;

vPos = temp.ViewPos ();
#else
CFixMatrix m = transformation.m_info.view [1];
m.Scale (transformation.m_info.scale);
vPos = m * (pObj->info.position.vPos - transformation.m_info.pos);

if (vPos.v.coord.z <= 0) //robot behind the screen
return;
#endif

//the code below to check for CObject near the center of the screen
//completely ignores z, which may not be good
if ((abs (temp.ViewPos ().v.coord.x) < I2X (4)) && (abs (temp.ViewPos ().v.coord.y) < I2X (4))) {
if ((abs (vPos.v.coord.x) < I2X (4)) && (abs (vPos.v.coord.y) < I2X (4))) {
pObj->cType.aiInfo.nDangerLaser = gameStates.app.bPlayerFiredLaserThisFrame;
pObj->cType.aiInfo.nDangerLaserSig = OBJECT (gameStates.app.bPlayerFiredLaserThisFrame)->info.nSignature;
}
Expand Down

0 comments on commit 4ed0b95

Please sign in to comment.