linking attributes/points from one game to another

Started by gypsysnail, Tue 02/03/2010 17:40:11

Previous topic - Next topic

gypsysnail

This might be interesting and probably very complicated, but an idea I came up with, is if imagine a game is a series. Say you gain skill points/items, etc from the first game that could be transferred to the next game. Could this be possible in an AGS game, would there be any scripting for this or would it be too complicated? Can we throw around some ideas and advice if this is possible? Looking forward to hearing everyones opinions and advice.
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

monkey0506

It's possible using RunAGSGame to pass a single integer value to the next game. However, seeing as you asked about a "series" of games I imagine you were thinking more along the lines of persisting a set of variables across several stand-alone games, right?

For that you could use the File functions which create files in the save game directory. That would mean that every game in the series would have to share save games though..which unless the games were all extracted to the same folder could present problems trying to load a save from a different game..and could be confusing for the player.

So yes, it's possible but it becomes somewhat of a logistical nightmare if the games are stand-alone. If you want the games to automatically advance to the next then you could release each new game as a sort of "patch" to the previous game with the new game's EXE and a CRM file. The CRM would be the last room from the previous game (make sure this room has a totally unique room ID from the other games). At the end of each "episode" you could have that room be a "Next episode coming on.." sort of notification or something and then in the patch the CRM would instead call RunAGSGame and load up the next game.

If you want to go for that route you may also want to check out RickJ's MiniGame module which would help with persisting the data and calling up the games and such.

Khris

It's also possible to store more than one value in an integer. Whether that's gonna be sufficient depends on the amount and max values of the values you want to pass on.

A simple example would be level (1-20) and max HP (100-999).
Pass on level * 1000 + max_HP (e.g. 13750 means level 13 and max HP 750) and in the second game, use
Code: ags
  level = p / 1000;  // level gets rounded down, e.g. 13750 / 1000 -> 13
  max_HP = p - level * 1000;  //   13750 - (13*1000) -> 13750 - 13000 -> 750

gypsysnail

Hey guys thanks for the tips! It does sound complicated. I have been thinking about this. I did wonder if it could be a save file that can be transferred to the next game (I am making a series) and it wouldn't be compulsory, it would be a choice by the player and I would give them the option at the start of each game in the series, to click a button that says "transfer achievements file from the previous game - yes or no." It will be a file that has achievements from first game on to the 6th in the series

Quote from: monkey_05_06 on Tue 02/03/2010 17:53:22
However, seeing as you asked about a "series" of games I imagine you were thinking more along the lines of persisting a set of variables across several stand-alone games, right?

Yep thats the one :) So it could be a logistical nightmare hmmm, I wonder if there is a way to make it simpler for the player? Possibly I could explain to them how to transfer the file from prev game to that game etc.

Quote from: monkey_05_06 on Tue 02/03/2010 17:53:22
For that you could use the File functions which create files in the save game directory. That would mean that every game in the series would have to share save games though..which unless the games were all extracted to the same folder could present problems trying to load a save from a different game..and could be confusing for the player.

Now thats a good question, could the be possible to have the games extracted to the same folder? Or an explanation for the player on how to do this. Or how to transfer the file from prev game to the next game - I wonder if it is possible for them to copy that file from the prev game's folder to the next game's folder?

Let me know if these are possibilities.

Khris you have posted a good possibility with a level type scripting. Could this be attributed to an achievements file? The character that has achieved some missions purely by her/his choice. Thank you again guys, u are great as usual! ;)
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

GarageGothic

You could do what tolworthy is doing with his Enter the Story games and install the .exe's for all the episodes in the same folder (this way you can also check if the end game code whether the next episode is available or not, and if so, proceed to it using RunAGSGame - this does require that you stay with the same engine version all the way though, or update any previous games to the latest version when releasing a new episode).

And yeah, if you have lots of variables to keep track of it would make most sense to write the info to a file. You can always use the encryption module to make it more difficult to cheat or mess things up by editing it.

Khris

Writing the data to a file isn't that complicated. I'd devise some sort of simply encryption, e.g. storing whether the player achieved several goals can be done like this:

Code: ags
  File*TransferFile = File.Open("data.dat", eFileWrite);
  TransferFile.WriteInt(1);  // first game in the series
  int a = g1*16 + g2*8 + g3*4 + g4*2 + g5;   // "encrypt" goal flags
  TransferFile.WriteInt(a);
  TransferFile.Close();


g1 - g5 are either 1 (goal x achieved) or 0 (not). They can be interpreted as a binary number which is converted to decimal and stored in the file.

In the sequel, look if the file is present. If it is, open it and read the first int. If it indicates the data file is from the predecessor, read the achievement flags:

Code: ags
// first room after fadein

  if (!File.Exists("data.dat")) return;   // file not found, exit

  File*TransferFile = File.Open("data.dat", eFileRead);
  if (TransferFile.ReadInt() != 1) return;  // data is there but not from previous game

  // read achievement flags
  int a = TransferFile.ReadInt();
  g1 = a/16; a = a - g1*16;
  g2 = a/8; a = a - g2*8;
  g3 = a/4; a = a - g3*4;
  g4 = a/2; a = a - g4*2;
  g5 = a;
  TransferFile.Close();

gypsysnail

Thanks guys!!!! It sounds easier now that you have explained the best ways to do it :). I will keep this thread for future reference for when I come to the point of the 2nd game. I am working on my 1st game at the moment :).
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Khris

Btw, you can't save one game via the usual AGS mechanism, then restore that save game in another game.

gypsysnail

Ah ok, I'm not sure what you mean by that? Which sounds silly, but I'm not yet that experienced with programming so it's a bit confusing. Save one game and restore in another game?
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Khris

I thought that's what you meant by this:
Quote from: gypsysnail on Wed 03/03/2010 10:36:08I did wonder if it could be a save file that can be transferred to the next game

But I guess you did mean a separate file :)

monkey0506

#10
Uh Khris, if you have both game EXEs in the same folder with the same save game directory, AGS will automatically load the correct game if the save game belongs to a different EXE..

Somebody needs to take a dose of their own medicine and RTFM on RunAGSGame. :=

gypsysnail

Yesss :D thats what I meant. Pheww I'm relieved we understand each other now ;). Yep a separate file that can be copied into the folder of the new game if that is possible, or the game is installed automatically to the same folder of the previous game. When the time comes I will probably call on you guys for help on how to make the file a save file using the scriping you showed me earlier in this thread.

Oh Monkey, thats an interesting point.... so it will be ok won't it?
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

monkey0506

When you are ready to release the second chapter/episode/whateveryouwanttocallit, you will need to advise users that they need to install to the same directory as the first. When you are making the game you need to make sure you set the save game directory to the same as the first game. You should let the users know that all the save slots will be shared between the two games, but if they load a save slot belonging to the other game it will automatically load that game.

Khris

... someone needs to chill I guess.
I said it's not possible to save game A, then restore game B using the same save game.
If I'm mistaken I'll gladly stand corrected though.

monkey0506

Well the save slots are shared so if game A saves slot 1 then game B saves slot 1 then slot 1 of game A will be overwritten. If that's what you meant then it was unclear (to me anyways).

And I have been perfectly "chill" the whole time. :P Just coz I misunderstood you I made the (apparently incorrect) assumption that you weren't taking your own medicine. :=

GarageGothic

Couldn't you have different save game file extensions for each episode? Or do the extensions have to be identical when using RunAGSGame?

suicidal pencil

Using the save games might be easier, but coding it sounds fun ;D

Only one question, though: If someone skipped the first installment of the series, and went straight to the second, would it start a new game, or would it just ask them to go play the first?

SMF spam blocked by CleanTalk