dMZX Forums: Engine Help Please! - dMZX Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Engine Help Please! can You help me?

#1 User is offline   Mr. Apol 

  • medica mechanica
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 3,206
  • Joined: 12-September 01
  • Gender:Male
  • Location:alefgard

Post icon  Posted 09 April 2002 - 07:51 PM

In my game that I'm building, I'd like to use a FF-style save game engine, but I don't understand how to use the file writing capabilities.  Could someone teach me, and put some examples on this here.  I'd also need to know the limitations of that system too.
0

#2 User is offline   Liquid-salt 

  • BUZZ BUZZZZZ BUZZZZZZGGGGRRGRG!!!   BOOM !&
  • PipPipPipPip
  • Group: Members
  • Posts: 520
  • Joined: 04-January 02

Posted 09 April 2002 - 09:30 PM

yeah, could someone setup a tutorial.  I looked at the helpfile but it doesn't seem to make much sense.
0

#3 User is offline   Wervyn 

  • I can see you
  • Group: DigiStaff
  • Posts: 1,855
  • Joined: 24-December 00
  • Gender:Male
  • Location:Caras Galadhon

Posted 09 April 2002 - 10:12 PM

Well, first, you have to find a way to represent every important statistic and piece of data in the game, in text. ?This includes character stats (plus HP/MP), inventory items, key items, and location in both the world and the story arc.
For instance, say a character has six stats, going all the way up to 255 Max. ?He also has HP all the way up to 9999/9999, and MP up to 999/999. Let's convert each of these numbers into Hexadecimal...
255 = 0xFF
999 = 0x03E7
9999 = 0x270F

Now, as we can see, each stat takes up one byte, while HP and MP require 2 (technically, 2 MP stats, Current and MAX, could fit into 3 bytes, but the space that would save is negligiable). ?Thus, each character in the game would be represented by a string like this (bytes represented in Hex, not actual ASCII).

? ? ? ?479A 827B A057 0F3A 0F3A 00A2 0128
Stat: 1 ?2 ? 3 ?4 ?5 ?6 | HP ? MAX ? MP ? MAX

For the sake of example, let's name our stats, picking the standard ones. ?And then you can see what that string equates to:

1. STR ?71
2. INT 154
3. DEX 130
4. VIT 123
5. ATK 160
6. DEF ?87

HP/MAX: 3898/3898
MP/MAX: ?162/ 296

Now, one character specific thing we haven't included is equipment. ?We'll go with the standard Weapon / Armor / Accessory deal. ?The best way to do this is to assign a number to every non-unique item in the game (and when I say that I mean unique as story related). ?It helps if there are only 255 of them (00 is for nothing), as that keeps the tagging down to one byte. ?However, it's not a really important thing. ?Here's one way to do it:

01-05: Health restoring items
? (Low, Mid, High, Full, Revive)
06-09: MP restoring items
? (Low, Mid, High, Full)
0A: Elixir type item
? (Full HP/MP)
0B-0F: Various other restorants
? (Team or area effect, perhaps)
10-1F: P1 Weapons
20-2F: P2 Weapons
30-3F: P3 Weapons
etc...we'll go to 80
80-9F: Armor
A0-BF: Accessories
C0-DF: Status Inflictors
? (Haste, slow, poison, etc.)
E0-FF: Status Removers
? (Maybe less than Inflictors)

Now, just allow three more bytes after the character for these things...Oh, and of course, we need to keep track of Level, and XP, so add another byte for level, and 4 more bytes for XP (may be less depending on how you allot it).
This gives us:

479A 827B A057 0F3A 0F3A 00A2 0128 1588 A114 0005 8A35
? ? ? ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? W A ? X ?L | ?? EXP

Here, Level is 20 and Experience is 363061.

Well, that should be enough to get you started...hopefully. ?Someone else wanna take the stand?

"The reason you don't understand it is that there's nothing to understand."
To lie is to change the truth.
..Ignorance is to be unaware of the truth.
....Incompetence is to be unable to grasp the truth.
......And escape is to run away from the truth.
It is useless to run, since the truth is right next to you.

-Wervyn
0

#4 User is offline   astral 

  • 6 pc chicken mcnobody
  • PipPipPip
  • Group: Members
  • Posts: 475
  • Joined: 20-October 01
  • Gender:Male
  • Location:South Carolina

Posted 10 April 2002 - 01:47 AM

I think he wants how to use the actual counters, not the method for saving the game. I'd try to explain it, but I'm not even sure *I* get it.. so I'd only end up confusing him.
i thought you said weast
0

#5 User is offline   Mr. Apol 

  • medica mechanica
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 3,206
  • Joined: 12-September 01
  • Gender:Male
  • Location:alefgard

Posted 10 April 2002 - 06:34 PM

.... uhh...yeah!

I'm just hoping that the 2.62b encyclopedia comes out, so I can take a peek at the actual code....

I'll try to make sense of it though.  Thanks Wervyn.  Anyone else wanna try to explain some?  If so, go for it.  Or, if anyone is decides to be ultra-cool they can make an actual engine and give it to all the feeble-minded people who don't understand it.
0

#6 User is offline   Revvy 

  • Jeez guys, there's no need to be narky.
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 3,520
  • Joined: 05-March 01
  • Gender:Male
  • Location:Ontario, Canada

Posted 11 April 2002 - 05:33 PM

Okay, I've got reading/writing down pat I think, so I'll have a go at it.

Let's say we want to write what someone inputs (input string "string") in the file "foobar.txt"
------

set "foobar.txt" to "fread_open"
input string "Input a string"
set "fwrite" "input"

------
This writes what someone typed into the Input box to the file foobar.txt, which you can then make a call to.
------

set "foobar.txt" to "fread_open"
* &fread&

------
This reads from "foobar.txt" the first 14 characters, or up to the first asterisk *, which stops the reading. ?Now we'll read and write to the mzx2.62b counter "$string0" which can hold actual strings with letters and ascii-characters.
------

set "foobar.txt" to "fwrite_open"
input string "Input a string"
set "fwrite" to "input"
set "foobar.txt" to "fread_open"
set "$string0" to "fread"
* "&$string0"

------

Assuming that the user typed "Foobar" in the input box, the word "Foobar" would appear at the bottom of the screen in flashing colours. ?You can also use the "write overlay" command with $string0, and any other commands that allow counters between ampersands. ?Any time you make a call to the "fread" counter, it reads the first 14 bytes unless it encounters an asterisk as I mentioned earlier. ?Anyways, hope this helps.

EDIT: Yay!  500 Posts!  I'm a four-star Fontmaster!
<+AFK> Bringing whisky to my mother is like irrigating a lake.

<+AFK> dormando's apathy is palpable.
* AFK palpates
<dormando> stop that

<Malwyn> undressing with revvy a little over a metre away. new definition of awkward.
0

#7 User is offline   Exophase 

  • Laughing on the inside.
  • Group: DigiStaff
  • Posts: 7,155
  • Joined: 23-October 00
  • Gender:Male
  • Location:Cleveland, OH

Posted 11 April 2002 - 06:20 PM

Revolution, you can't use Input (or mod_name, or board_name, or any built in string) in a normal string operation. You must first copy it to a string, then you can use the string. It will use the value of the counter, which could be something fruity, or just 0.

That aside, the fwriting for strings goes like this:

set "$string0" "fwrite"

Same goes with fread, if you use fwrite or fread as normal counters it returns the word (that's two bytes, not a string) at the file position, not a string.

That will write $string0 to the file, terminated by an asterisk. When you read it it reads until the asterisk. The asterisk is important (for some reason with TC++ I had problems using the null character, and it's difficult for users to enter a null character on a board, so I thought I'd be consistant with the board routines)

Understand that you can have two files open, a read file and a write file. Also understand that the current position of the file is incremented to after wherever you last read/wrote to it (so you can do so incrementially).. however you can manually go to any position using the fread/write_pos and fread/write_page counters. Check out the help file, pretty much everything you need to know about ANY MZX additions post s3.1 are in the built-in counters section.

Uh... to avoid confusion, lemme fix your code.

set "foobar.txt" to "fwrite_open"
. "You need to set it to fwrite_open to write to it..."
input string "Input a string"
set "$string0" "input"
set "$string0" "fwrite"

------
This writes what someone typed into the Input box to the file foobar.txt, which you can then make a call to.
------

set "" "fwrite_open"
. "If you opened it previously you need to close it, the above code will do that."
set "foobar.txt" to "fread_open"
set "$string0" "fread"
* "&$string0&"

------
This reads from "foobar.txt" the first 14 characters, or up to the first asterisk *, which stops the reading. ?Now we'll read and write to the mzx2.62b counter "$string0" which can hold actual strings with letters and ascii-characters.
------

set "foobar.txt" to "fwrite_open"
input string "Input a string"
set "$string0" "input"
set "$string0" "fwrite"
set "" "fwrite_open"
set "foobar.txt" to "fread_open"
set "$string0" to "fread"
* "&$string0&"

- Exo
~ ex0 has a kickass battle engine, without it you sux0rz! without it you sux0rz! ~

"The fact that I say I've one of the best, is called honesty." -Akwende
"Megazeux is not ment to be just ASCII, it is ANSI!" - T-bone6
"I hate it when you get all exo on me." - emalkay

Exophase can what Rubi-cant.
exoware is ware ur ware is exoware
ps. not loking 4 new membrs kthx
0

#8 User is offline   Revvy 

  • Jeez guys, there's no need to be narky.
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 3,520
  • Joined: 05-March 01
  • Gender:Male
  • Location:Ontario, Canada

Posted 11 April 2002 - 06:43 PM

Oops.  :asthanos:
<+AFK> Bringing whisky to my mother is like irrigating a lake.

<+AFK> dormando's apathy is palpable.
* AFK palpates
<dormando> stop that

<Malwyn> undressing with revvy a little over a metre away. new definition of awkward.
0

#9 User is offline   Thunderdog 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 622
  • Joined: 18-December 01

Posted 11 April 2002 - 07:23 PM

This is possible with mzx?!??!!!?
0

#10 User is offline   Nanobot 

  • It's in your blood
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,623
  • Joined: 11-October 00
  • Gender:Male
  • Location:Chico, CA (USA)

Posted 11 April 2002 - 07:35 PM

Thunderdog: Get MZX 2.62b. It supports full file access (in the same directory).
The Nanobox, where wings take dreams...
0

#11 User is offline   weasel 

  • bleh
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 7,915
  • Joined: 23-December 00
  • Gender:Male
  • Location:Hillsboro, Oregon

Posted 12 April 2002 - 01:08 AM

Dude, why bother with this? Just make it so you can only save on the status screens. Something like this is only a gimmick, and it leaves the game open to VERY easy savegame hacking. People could get through effortlessly, without even editing the game itself.
Blaugh!
Serious damage to important body parts pretty much ruins any plans you had for living. Bummer.
0

#12 User is offline   Wervyn 

  • I can see you
  • Group: DigiStaff
  • Posts: 1,855
  • Joined: 24-December 00
  • Gender:Male
  • Location:Caras Galadhon

Posted 12 April 2002 - 01:58 AM

Quote

Dude, why bother with this? Just make it so you can only save on the status screens. Something like this is only a gimmick, and it leaves the game open to VERY easy savegame hacking. People could get through effortlessly, without even editing the game itself.


Well, not necessarily.  It is entirely possible to encrypt the file, or rather, the strings going into the file.  Also, how would you know exactly how he had it arranged?  There are also plenty of ways to thwart file hacking, even the creation of test files, by using checksums, garbage characters, encryptions, and the like.  Now, this doesn't mean the game CAN'T be hacked, but it does make sure that whoever DOES hack it is taking extreme measures; that is, they really need to cheat.

"If you damage these hands, how can you expect to realize my dreams of yours!"
To lie is to change the truth.
..Ignorance is to be unaware of the truth.
....Incompetence is to be unable to grasp the truth.
......And escape is to run away from the truth.
It is useless to run, since the truth is right next to you.

-Wervyn
0

#13 User is offline   Exophase 

  • Laughing on the inside.
  • Group: DigiStaff
  • Posts: 7,155
  • Joined: 23-October 00
  • Gender:Male
  • Location:Cleveland, OH

Posted 12 April 2002 - 03:07 AM

The real question is why bother protecting people from cheating.. if they really want to cheat who cares? They're only ruining an experience for themselves.

Anyway, save files can be much more flexible than plain MZX saves, and can be much much much smaller too. They're not just a gimmick.

BTW, something to keep in mind, you might want to try doing something like this:

set "$string0" "board_name"
set "$string0" "fwrite"
set "fwrite" "playerx"
set "fwrite" "playery"

.. later..

set "$string0" "fread"
set "fread" "local"
set "fread" "loopcount"
teleport player "&$string0&" "local" "loopcount"

Just be sure to keep your board names under 14 chars.

BTW, I wasn't going to make this public, but Koji never bothered limitting MZX's file directory access to the current directory. Don't abuse this. If you don't know how to access files at a specific directory then I'm not going to tell you, figure it out.

- Exo
~ ex0 has a kickass battle engine, without it you sux0rz! without it you sux0rz! ~

"The fact that I say I've one of the best, is called honesty." -Akwende
"Megazeux is not ment to be just ASCII, it is ANSI!" - T-bone6
"I hate it when you get all exo on me." - emalkay

Exophase can what Rubi-cant.
exoware is ware ur ware is exoware
ps. not loking 4 new membrs kthx
0

#14 User is offline   Revvy 

  • Jeez guys, there's no need to be narky.
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 3,520
  • Joined: 05-March 01
  • Gender:Male
  • Location:Ontario, Canada

Posted 12 April 2002 - 12:12 PM

Hey Exo, are you able to set the $strings to the current mod name?
<+AFK> Bringing whisky to my mother is like irrigating a lake.

<+AFK> dormando's apathy is palpable.
* AFK palpates
<dormando> stop that

<Malwyn> undressing with revvy a little over a metre away. new definition of awkward.
0

#15 User is offline   Galladin 

  • Threadkiller
  • PipPipPipPipPip
  • Group: Members
  • Posts: 2,266
  • Joined: 08-January 02
  • Gender:Male
  • Location:Finland

Posted 12 April 2002 - 12:19 PM

huh?????
Interactive (F) Fantasies

<Beige> In Finland, they defecate on each other's sleeping areas.
<Beige> It's a cultural sign of respect.
0

#16 User is offline   Revvy 

  • Jeez guys, there's no need to be narky.
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 3,520
  • Joined: 05-March 01
  • Gender:Male
  • Location:Ontario, Canada

Posted 12 April 2002 - 12:35 PM

Okay.  Recapping the mzx2.62b help file.

There are new strings (ten of them, labelled $string0 - $string9) that can hold text (set "$string0"to "bob") and other useful things such as the "mod_order" counter, the "board_name" counter, the "board_scan" counter etc.  These $strings are very useful.  You can use commands like:

set "$string0" to "Bob"
write overlay c07 "&$string0" 0 0

and the word "Bob" will be written at 0 0.  There's many useful things to do with these $strings.
<+AFK> Bringing whisky to my mother is like irrigating a lake.

<+AFK> dormando's apathy is palpable.
* AFK palpates
<dormando> stop that

<Malwyn> undressing with revvy a little over a metre away. new definition of awkward.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

4 User(s) are reading this topic
0 members, 4 guests, 0 anonymous users