Engine Help Please! can You help me?
#1
Posted 09 April 2002 - 07:51 PM
#2
Posted 09 April 2002 - 09:30 PM
#3
Posted 09 April 2002 - 10:12 PM
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."
..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
#4
Posted 10 April 2002 - 01:47 AM
#5
Posted 10 April 2002 - 06:34 PM
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.
#6
Posted 11 April 2002 - 05:33 PM
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> dormando's apathy is palpable.
* AFK palpates
<dormando> stop that
<Malwyn> undressing with revvy a little over a metre away. new definition of awkward.
#7
Posted 11 April 2002 - 06:20 PM
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
"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
#8
Posted 11 April 2002 - 06:43 PM
<+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.
#10
Posted 11 April 2002 - 07:35 PM
#11
Posted 12 April 2002 - 01:08 AM
Serious damage to important body parts pretty much ruins any plans you had for living. Bummer.
#12
Posted 12 April 2002 - 01:58 AM
Quote
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!"
..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
#13
Posted 12 April 2002 - 03:07 AM
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
"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
#14
Posted 12 April 2002 - 12:12 PM
<+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.
#15
Posted 12 April 2002 - 12:19 PM
<Beige> In Finland, they defecate on each other's sleeping areas.
<Beige> It's a cultural sign of respect.
#16
Posted 12 April 2002 - 12:35 PM
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> dormando's apathy is palpable.
* AFK palpates
<dormando> stop that
<Malwyn> undressing with revvy a little over a metre away. new definition of awkward.

Help













