Archived

This topic is now archived and is closed to further replies.

saeZ

Action Replay

Recommended Posts

Hey people, I''m not sure if this is the right forum for this, but please direct me to the correct one if you get pissed. First, some general info: I''m working on a turn-based "strategy" game. It''s not going to be innovative and it''s not going to be very complex. It''s my first real game-project and I want to make it right.. sort of a test project. Okay, well here''s what I''ve been thinking: Action Replay. I''m wondering how to do it. I have two squads, each one contains 2-16 units. The turn-based mode is not individual turn-based, but squad-based. I though I would do the replay thing like this: I will record all the actions of every unit; walk->destination, shoot->target, etc. BUT what troubles me is that the done damage can differ. It has to be exactly the same it was in the combat. Also, units don''t always hit their actual target if anything. My other problem is that everything in the game can be blown to pieces. There''s just so massive amount of data there to be recorded during every combat to be shown as Action-Replay... I don''t know how to organize it efficiently. Any ideas, people? Thank you. saezee

Share this post


Link to post
Share on other sites
The simplest way to do this is simply create a log of everything that happens (kinda like those play by play logs in basketball games). Keep track of how much damage each attack did, how and when each unit takes an action, etc. Then write some function in your game that reads that log and recreate everything that happens. Just keep in mind, some things aren''t really necessary to keep track of, like keeping track of every piece of shrapnel in an explosion. Unless each piece of shrapnel actually does something, keeping track of each piece is just too much to do for no real gain.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
if you save off your initial states, all you need to record is the controller or keyboard inputs and the very important timestamp. when you do the replay you setup the initial state and run your game as normal and instead of reading the keyboard or controller each frame you just grab your recorded data.

a couple of things to consider when doing replays..

-you shouldnt have random events. they wont happen the same way when you play back your replay. if you do have random stuff happening you need to save off the seed at the beginning, even this may not be enough. if you do have random stuff taking place, and your having unknown bugs during your replay, turn off all the random stuff and see if that fixes your problems.

-framerate. very big one here. we had ghost races in my last racing game, since we were recording the controller inputs (during gameplay the ghost car would just read the recorded inputs instead of reading the controller). any little hiccup in framerate completely hosed the replay, especially any physics routines. things need to happen _exactly_ as you recorded them..hence saving off the timestamp during recording, so you can munge your games frametime if anything gets out of sync.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Regarding the previous AP''s comment about random stuff, you might be able to get around that requirement by using a separate pseudo-random number generator other than the built-in rand() function for each entity. With a good PRNG correctly setup, you can actually replay even stochastic events.

Another problem with recording only inputs though is that it''s really hard to avoid chaos. As you get further away from the intitial conditions, your game can get really out of synch with what actually happened.

I suggest using a hybrid scheme which primarily records inputs, but also ocassionally records the actual states as well (sort of like networking).


TLC

Share this post


Link to post
Share on other sites
Well, you could use the random events as long as you record the seed that you use for generating the event.

Ie. in your game

save initial player and game state
savedseed = RandomNumberGenerator.GetSeed();
do sequence of battle events
read user input
save user input
do user event
generate random enemy events
end sequence

..and in the replay you would do this...

restore initial player and game state
RandomNumberGenerator.SetSeed(savedseed)
do sequence of battle events
load users next saved input
do user event
generate random enemy events
end sequence

That way, all you need to do is save your initial state (ie. the players health, enemies state etc) as well as the random number generators seed before you start your battle sequence.

Since you restore the same seed for your generator when doing the action replay you are guaranteed to have the same events occurring just by storing a single number.

I think this is what TLC was trying to say.

Hope this helped,
FReY

PS. The key is to get hold of a random generator whose seed you can read.

Share this post


Link to post
Share on other sites
Thanks for the ideas people.

Yea I know random events are tricky, even impossible to implement. Myth 1&2&3 are great examples on how well a replay should work. Everything in them works just the way it happened in the game, eg. a dwarf throws a molotov cocktail but it hits a tree and bounces back and blows up the dwarf. Everything seems to work exactly the way they happened in the gameplay, which is very cool in my opinion.

I decided not to save random seeds or anything like that because my game really isn''t very complex. I''m thinking of going the log way, logging EVERYTHING that happens and has meaning.
I added a log thingy which logs the movements of each unit. That works perfectly because all I need to log for each turn is the starting coordinates of each unit and their destination. Pathfinder does the rest because it certainly doesn''t have any random elements!

I''m thinking I just need to log everything that counts. I have to log actions of every unit. Shooting is a bit tricky, but I can log the done damage (if hit the target) so that should work. Explosions might work the same way.

Oh well, will be seen if I get things to work.
Once again, thanks for the ideas and help!

saezee

Share this post


Link to post
Share on other sites
Do you need to keep track of how much damage is done? It might be simpler just to record who shoots who and when things die.

If you want an example of what not to do, check out Rogue Spear. I''m not sure what those replays kept track of, but I remember confusedly watching my sniper stand in the corner of a room and shoot the wall, while the bad guys he was supposed to have killed simply ignored everything going on around them. It''d be harder to mess a turn-based game up this badly, though, and it sounds like you have a good system going.

Share this post


Link to post
Share on other sites
Here''s a direct link to the article I mentioned before. It basically uses the method the original AP suggested, which IMO is the easiest. Logging every possible action that happens would probably be much more difficult unless your game isn''t that complex.

Share this post


Link to post
Share on other sites
T Bag,

Yes I want to keep track of every shot done because if a firing unit misses its target/enemy unit, the shot can hit something else like a wall for example. This isn''t very difficult actually. I simplified things a bit; I record who shoots and where the bullet/beam/missile/what-ever hits and how much damage it inflicts to where it hit.

Every object (eg. a wall) and unit has set amount of hitpoints. If the hitpoints drop to 0 or below, then it dies/explodes/gets destroyed,...

SilentCoder,

Thanks for the link! I will check it out and see if it helps.

I came to the conclusion that I can make the Action Replay by logging _almost_ all events because there really aren''t very many different events in my game. Things are quite simple, nothing complex. That seems to be an advantage when coding AR.

saezee

Share this post


Link to post
Share on other sites