Previous Blog Next Blog
Prev/Next Blog
by date

AFX Selected Objects, AutoAttack AI and Jerkiness.

AFX Selected Objects, AutoAttack AI and Jerkiness.
Name:Danni 
Date Posted:Jul 17, 2008
Rating:4.0 out of 5
Public:YES
Comments:YES
RSS Feed:GarageGames Blog feedor Subscribe with .
Profile Page:View profile page for Danni

Blog post
I made the leap and bought AFX to checkout the coolness of this wonderful resource. Immediately i thought what cool this would be to use AFX to create weapon effects or even summoned weapons (www.youtube.com/watch?v=zLpLoLGdack&hl=en). That's when I found the cool AFXWeapon resource from Michael Perry, a good starting point and even has a stats class with it, shouldn't take long to mold this the way i want it. But first! How to go about actually handling the battles. Well spells are simple, just cast from a distance, but what about normal attacks.

I decided on implementing an AI method to control the player and target and bring them together to hash out the damage. Lets cheat here and use AFX's selectobj system and a spinoff from getAIMove. Strange, AFX's getSelectedObj() is NULL, how can that be?! I clearly have a player selected, there is netcode here to transfer the selected object, whats up?! Oh wait.. that's sending it server to client but the selection is client side. Weird!? Not a problem... (Hack, hack, hack).

Under mMoveList.serverReadMovePacket(bstream);

      mMoveList.serverReadMovePacket(bstream);

// [Danni] Retreive and resolve selected client object.
if(bstream->readFlag())
{
if(bstream->readFlag())
{
S32 gIndex = bstream->readInt(NetConnection::GhostIdBitSize);
setSelectedObj(static_cast<SceneObject*>(resolveObjectFromGhostIndex(gIndex)));
}
else
{
setSelectedObj(NULL);
}
}


mCameraPos = bstream->readFlag() ? 1.0f : 0.0f;


Then under mMoveList.clientWriteMovePacket(bstream);

		mMoveList.clientWriteMovePacket(bstream);

// [Danni] Send selected object to server
if (bstream->writeFlag(mChangedClientSelectedObj))
{
mChangedClientSelectedObj = false;
S32 gidx;
if (mSelectedObj && !mSelectedObj.isNull() && (gidx = getGhostIndex(mSelectedObj)) != -1)
{
bstream->writeFlag(true);
bstream->writeInt(gidx, NetConnection::GhostIdBitSize);
}
else
{
bstream->writeFlag(false);
}
}


bstream->writeFlag(mCameraPos == 0);


Problem solved! Here is a nice video of the result antihax.net/movies/AFXAutomoves.wmv Now to interpolate out that nasty jerkiness and free the camera's rotation. May not notice but I already freed the camera height.

Recent Blog Posts
List:07/17/08 - AFX Selected Objects, AutoAttack AI and Jerkiness.
06/01/08 - Async (non-blocking) Postgres Database Handler
05/18/08 - Postgres as a database solution?
05/04/08 - Step sounds, recoil and hit scans.
01/27/08 - Torque prediction hack for hitscans

Submit ResourceSubmit your own resources!

Brian Wilson   (Jul 17, 2008 at 07:13 GMT)
Quote:

even summoned weapons (www.youtube.com/watch?v=zLpLoLGdack&hl=en).


Now THAT'S a big F**kin' sword!

Keep us updated on your AFX experiences. It always seems someone buys it, makes a bunch of "OH WOW!" posts for the first weeks, then disappears... I'd like to hear from long-term users of AFX and get an idea of the shiny new toy is still shiny several months later...

Dave Young   (Jul 17, 2008 at 15:40 GMT)
Never seen a better use of Lina Inverse on a blog post!

Erik Madison   (Jul 17, 2008 at 20:43 GMT)
Very nice. I've been struggling myself getting a 'mountVehicle' command to accept the afx client selected object as the serverID'd input. No form of ghostID, etc commands would produce the value I required. This really looks like what I needed!

Danni   (Jul 17, 2008 at 22:14 GMT)   Resource Rating: 5
Erik: I hope it helps, don't forget to add bool mChangedClientSelectedObj to the Player class and set it false in the constructor.

Dave: Oldie but a goodie. :)

Brian: I doubt I will get anything complete worth great celebration, I am mostly learning more about the engine and systems in general. Since most of the time I find someone else who is after similar things I try to share anything I find. :)

You must be a member and be logged in to either append comments or rate this resource.