Programming Project 1287194683

Addtional Information in .docx file, Project is also attached

Change the project settings in VisualStudio to provide for the Common and Lua include and library paths. In VisualStudio select Tools | Options from the menu. In the left pane, navigate to the Projects folder and select VisualC++ Directories.
In the upper right hand corner change the Show directories for list box to Include files and add paths to the lua-5.0\include and luabind folders.
Also, add a path to the Common folder included in the raven.zip archive that you just downloaded and extracted. This folder is similar to the Buckland source code Common folder but includes some important source code changes.

In the upper right hand corner change the Show directories for list box to Library files and add the path to your lua-5.0\lib folder:

Rebuild the project using the menu option Build | Rebuild Solution. This may take several minutes.
If you get a linker error about an “unresolved external symbol”, this is likely due to a source file (.cpp) not being included in the Source Files folder.
If you get a compiler error about “cannot include file”, this is likely due to a header file being in a different path/folder. To fix this either change the include statement or change the location/folder structure where these files are located.

Run the program and examine the output. It should look like:

Also, put an include statement at the top of Goal_GetItem.cpp: #include “Goal_DodgeSideToSide.h

Modification

It will be useful for us to be able to output and view some debug statements in our modified application. There is a debug console window that we need to enable.
In main.cpp, in the WinMain function, just after the timer is created and started, add a simple macro statement to turn on the debug console:
// turn on the debug console
debug_on;
In DebugConsole.h, make sure the statement:
#define DEBUG
is NOT commented out.
Now the other changes we will make can have diagnostic statements that will display in a separate window using something like:
debug_con << “debug output message” << “”;

Modification

Currently the DodgeSideToSide goal is set up to run specifically while the agent is in attack mode. We want to be able to use this goal in an evasive manner. Add a boolean flag to the Goal_DodgeSideToSide class that will store whether the agent is evading or not:
// flag to determine if bot is evading or attacking
bool m_bEvadeFlag;
Add a setter method (if you made this data member private):
// setter for evade flag
void SetEvadeFlag(bool newValue) {
m_bEvadeFlag = newValue;
}
Currently the Goal_DodgeSideToSide::Process method is written to specifically work in attack mode. Modify this method so its code is:
//if status is inactive, call Activate()
ActivateIfInactive();
// check if attacking or evading
if (m_bEvadeFlag) {
debug_con << m_pOwner->ID() << ” dodging” << “”;
if (m_pOwner->isAtPosition(m_vStrafeTarget))
{
m_iStatus = completed;
}
}
else {
// put the rest of the existing Process method code here
}
return m_iStatus;

Modification

Since the Dodge goal now has an evade flag, we have to modify the code where the Dodge goal is added. Fortunately this only occurs in two places.
In the Goal_AttackTarget::Activate method, modify the code that adds the Goal_DodgeSideToSide as a SubGoal to:

// have to modify how we add the Goal_DodgeSideToSide
// since we added the evade flag mod
Goal_DodgeSideToSide* pGS2S = new Goal_DodgeSideToSide(m_pOwner);
pGS2S->SetEvadeFlag(false);
AddSubgoal(pGS2S);

In the Goal_GetItem::HandleMessage method, in the code for the Msg_PathReady message, add the following just prior to the return statement:
// check if health is low add a goal to dodge side to side
if (m_pOwner->Health() < m_pOwner->MaxHealth() / 2) {
Vector2D dummy;
if (m_pOwner->canStepLeft(dummy) || m_pOwner->canStepRight(dummy))
{
// dodge side to side
debug_con << “adding dodge to healthpath ” << m_pOwner->ID() << “”;
Goal_DodgeSideToSide* pGS2S = new Goal_DodgeSideToSide(m_pOwner);
pGS2S->SetEvadeFlag(true);
AddSubgoal(pGS2S);
}
}

Rebuild and Run the modified application. The output may look something like:

Notice in the output that Bot 401 has successfully dodged the exploding missile fired from Bot 402 and is still dodging. Bot 403 is dodging as well since its health is also below MaxHealth/2 ( < 50).

Leave a Reply

Your email address will not be published. Required fields are marked *