HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Saving/Loading Character

05-30-2006, 04:55 PM#1
ixmike88
This is possible for most RPGs, and games like Human vs Orc, could anyone give me any idea on how to do this code?
05-30-2006, 05:03 PM#2
iNfraNe
How about you look around to find one someone made? its not that hard to find. We cant just "tell" you the triggers since they're rather big and rely on what you want saved.
05-30-2006, 05:05 PM#3
ixmike88
Thanks for your advice, because I've never tried to open any RPG before.

As your professional comprehension skills has it, I didn't ask for triggers, I asked for a general idea on how to do this.
05-30-2006, 05:29 PM#4
Vexorian
Well in this case there is no such a thing as a general idea.

But well you need to:
- Select the data you wish to save (in case of a hero you'd need to be able to get and set things like unit type, level, experience, intelligence, strength, agility, his items and his skills.

- Be able to convert that data into a string
- Be able to convert a string into that data.


We would call those operations encoding and decoding.

Thing is that there are plenty of ways to encode the data.

In mine I have an array that holds all the values and binary sizes of the values. Then I convert the values to a chain of binary data. Then I take groups of 6 / 5 or 4 (depending on some charmap) and convert each of the groups to a character depending on the charmap

For example:

0000 A
0001 B
0010 C
0011 D
...

Then I just show the character that represent the binary chain.

And when I decode I take the string and convert it to binary

ABCD would be 0000000100100011
then I convert the binary chain to values in the array-

And done.

Of course that there are much easier methods. But Since I don't know how to make them I can't mention how to do so
05-30-2006, 05:38 PM#5
The)TideHunter(
Quote:
Originally Posted by Vexorian
Well in this case there is no such a thing as a general idea.

But well you need to:
- Select the data you wish to save (in case of a hero you'd need to be able to get and set things like unit type, level, experience, intelligence, strength, agility, his items and his skills.

- Be able to convert that data into a string
- Be able to convert a string into that data.


We would call those operations encoding and decoding.

Thing is that there are plenty of ways to encode the data.

In mine I have an array that holds all the values and binary sizes of the values. Then I convert the values to a chain of binary data. Then I take groups of 6 / 5 or 4 (depending on some charmap) and convert each of the groups to a character depending on the charmap

For example:

0000 A
0001 B
0010 C
0011 D
...

Then I just show the character that represent the binary chain.

And when I decode I take the string and convert it to binary

ABCD would be 0000000100100011
then I convert the binary chain to values in the array-

And done.

Of course that there are much easier methods. But Since I don't know how to make them I can't mention how to do so

When you say it like that, it actually makes sense, i never really knew how encryption methods worked before.

Seems slightly complicated but i understand
05-30-2006, 06:58 PM#6
ixmike88
I was figuring something like this, was hoping there was an easier way though.
05-30-2006, 08:38 PM#7
wyrmlord
Actually, saving a hero is quite simple. It just gets a little harder when making the code not so easily recognizable. For a start, try saving a hero-type and the hero's level. First step is to "get" the hero and set some values for him/her.

Trigger:
Save
Collapse Events
Player - Player 1 (Red) types a chat message containing -save as An exact match
Collapse Conditions
(Number of units in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))) Equal to 1
Collapse Actions
Set Hero = (Random unit from (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)))
If ((Unit-type of Hero) Equal to Blood Mage) then do (Set Class = 1) else do (Do nothing)
If ((Unit-type of Hero) Equal to Mountain King) then do (Set Class = 2) else do (Do nothing)
If ((Unit-type of Hero) Equal to Archmage) then do (Set Class = 3) else do (Do nothing)
If ((Unit-type of Hero) Equal to Paladin) then do (Set Class = 4) else do (Do nothing)
Set Level = (Hero level of Hero)
Game - Display to (Player group((Triggering player))) for 30.00 seconds the text: (Your code is: + ((String(Class)) + (String(Level))))
Set Hero = No unit

This trigger first checks to make sure that the player owns only 1 hero. (This is ideal for RPGs with only 1 hero). Next, it will get a random unit from the units owned by the player, that is a hero. With only 1 possible outcome, it gets the hero and sets it to a variable. After that, I use a series of If/Then/Else functions to check the unit-type of the hero, and then set a variable to a different amount for each class. If you have more than 9 classes, I suggest making each class code 2 digets long. Now, set another variable to the level of the hero. Once again, if the levels can get to a very high number, you might have to add an amount to the level integer.

The next step is to show the message, first, show some text so that the player knows that the text is a code, then after, add a space and show the integers. At the end, we set the hero variable to no unit so it won't get mixed up (you will find out why in the load trigger).

Next, we will need to make another trigger to create a unit based on a password.

Trigger:
Load
Collapse Events
Player - Player 1 (Red) types a chat message containing -load as A substring
Collapse Conditions
(Substring((Entered chat string), 1, 6)) Equal to -load
Collapse Actions
Set Class = (Integer((Substring((Entered chat string), 7, 7))))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Class Equal to 1
Collapse Then - Actions
Unit - Create 1 Blood Mage for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
Set Hero = (Last created unit)
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Class Equal to 2
Collapse Then - Actions
Unit - Create 1 Mountain King for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
Set Hero = (Last created unit)
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Class Equal to 3
Collapse Then - Actions
Unit - Create 1 Archmage for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
Set Hero = (Last created unit)
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Class Equal to 4
Collapse Then - Actions
Unit - Create 1 Paladin for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
Set Hero = (Last created unit)
Else - Actions
Set Level = (Integer((Substring((Entered chat string), 8, (Length of (Entered chat string))))))
Hero - Set Hero Hero-level to Level, Show level-up graphics
Set Hero = No unit

Now I will break this apart. First, when a player types "-load" as a substring, it will check to make sure the first 6 entered characters are "-load ". The next step sets substring(7,7) (the 7th character entered) to the class variable (as an integer). It then goes through more If/Then/Else actions to check the variable to make sure it is one of many values. If there is a match on one number, then it creates a unit and sets the Hero variable to that unit, so if no unit is created, a random unit won't be messed up later on. Next, we set the level integer to substring(8,length of string). Since the level is the last thing in the code, it will take up the remainder of the code. And finally, it will set the level of (Hero) to that integer and then set the Hero unit to no unit, so it won't get mixed up later on.

This is just how a basic save trigger works, you could do items the same way as you would do classes, but this is just the easiest way to understand how save/load triggers work. To make the codes harder to recognize, you could add/multiply/do whatever to the codes to make it harder to see a pattern. Just make sure the load trigger can undo that.
05-30-2006, 08:41 PM#8
Captain Griffen
It is much much easier to use an array set at init, and then loop throug them, rather than if/then/else, which is time consuming, and makes triggers very long.
05-30-2006, 08:50 PM#9
Blade.dk
The problem with your method, wyrmlord, is that because it is so easy to make, it is also very easy to abuse. You can easily steal other players' heroes with that, or find out how to change the values yourself to make your hero ridicously overpowered.
05-30-2006, 09:13 PM#10
Freakazoid
Quote:
Originally Posted by Blade.dk
The problem with your method, wyrmlord, is that because it is so easy to make, it is also very easy to abuse. You can easily steal other players' heroes with that, or find out how to change the values yourself to make your hero ridicously overpowered.

Therefore you need to add 2 or 3 security strings(letters).
05-30-2006, 11:43 PM#11
wyrmlord
I know Blade, I was just trying to explain basicly how a save/load system works with a simple demonstration. I myself would not use something so simple in my maps, and would advise others not to either.