Paul's 4k Adventure - coder's help needed (again)
Moderator: Alastair
Paul's 4k Adventure - coder's help needed (again)
So, it seems that my affection for trashy games has led me to this game author...
The game in question (Paul's 4k Adventure, to be downloaded at the GB 64) features battles with a kind of random system. There is a battle against a knight, which is, to all my knowledge, impossible to win. And I suspect that is a bug. The reason why I suspect this: when the game tells me "you hit knight very hard" (or a related expression), it actually subtracts a fundamental amount of hit points from me instead of from the knight.
Maybe one of you guys with coding knowledge could have a look at the battle system and check if all's right there, or if I missed something vital (a specific combination of items or so). Thanks a lot!
The game in question (Paul's 4k Adventure, to be downloaded at the GB 64) features battles with a kind of random system. There is a battle against a knight, which is, to all my knowledge, impossible to win. And I suspect that is a bug. The reason why I suspect this: when the game tells me "you hit knight very hard" (or a related expression), it actually subtracts a fundamental amount of hit points from me instead of from the knight.
Maybe one of you guys with coding knowledge could have a look at the battle system and check if all's right there, or if I missed something vital (a specific combination of items or so). Thanks a lot!
-
Mr Creosote
- Posts: 1121
- Joined: Tue Sep 22, 2009 9:23 am
- Contact:
Re: Paul's 4k Adventure - coder's help needed (again)
There's also a C16 version of the game. Have you tried whether the same thing occurs there, too?
Re: Paul's 4k Adventure - coder's help needed (again)
Not yet, and frankly, I don't think I want to. I have tried to play quite a few C16 adventures by now, and for some reason my VICE C16 emulator always shuts itself down when I try to save a snapshot image (practically the only real way to save a game). The whole C16 business is way too annoying for my level of patienceMr Creosote wrote:There's also a C16 version of the game. Have you tried whether the same thing occurs there, too?
Also, from what I know about Commodore basic, I reckon the code is identical between the C16 and C64.
Re: Paul's 4k Adventure - coder's help needed (again)
The code looks to be fine:
The code is basically:
Your hit points (HM and HP) start at 294; so it seems combat is unfair and you may just have to save (in game, not as an image) and retry it a lot to shift the random numbers around. If you want I can try and edit the code so you always win the fight.
Edit: the C16 code from a quick look is exactly the same as the C64 code - so it may be an unofficial port as they shared the same flavour of BASIC.
Code: Select all
211 MH=INT(RND(1)*350)+1:YY$="WITH A BONE-CRUSHING SOUND."
212 PRINT">":I=INT(RND(1)*25)+1:FORX=1TO500:NEXT:YS$="YOU SMASHED "
213 WD=1:FORX=1TO21:IFLO(X)=105THENPRINT"YOU ARE WIELDING ";NO$(X);"’.":WD=X:X=21
214 NEXT
215 PRINT"YOU ARE FIGHTING ";NO$(N);"."
216 PRINT">":IFI<=5THENPRINT"YOU MISSED."
217 IFI>=6ANDI<=10THENPRINT"YOU STRUCK A SOLID BLOW.":MH=MH-I
218 IFI>=11ANDI<=15THENPRINT"YOU HIT ";NO$(N):PRINT"VERY HARD.":MH=MH-WD:MH=MH-I
219 IFI>=16ANDI<=20THENPRINTYS$;NO$(N):PRINT YY$:MH=MH-(WD*2):MH=MH-I
220 IFI>=21THENPRINT"IT DODGED YOUR BLOW."
221 PRINT"YOUR HP’:";HP;"/";HM
222 PRINT"THEIRS ’:";MH
223 PRINT">":FORX=1TO300:NEXT
225 P=INT(RND(1)*25)+1:IFP<=5THENPRINT"THEY MISSED YOU."
226 IFP>=6ANDP<=10THENPRINT"YOU WERE HIT HARD.":HP=HP-P
227 IFP>=11ANDP<=15THENPRINT"YOU WERE SMASHED INTO FRAGMENTS.":HP=HP-P*8:HP=HP+AC
228 IFP>=16THENPRINT"YOU DODGED THE ATTACK."
229 PRINT">":FORX=1TO100:NEXT
230 IFMH<1THENPRINT"THE ";NO$(N);" DIED.":PRINT"YOU KILLED ";NO$(N);".":GOTO 240
231 IFHP<1THENPRINT"YOU DIED.":FORX=1TO1000:NEXT:PRINT:PRINT"GAME OVER’":CLR:END
232 GOTO212- Choose a random amount of HP for the enemy (between 1 and 350)
- Your strike - damage depends on whether you're wielding the sword
- Choose a random number between 1 and 25
- 1-5 = miss, no damage to enemy
- 6-10 = normal hit, do between 6-10 points of damage
- 11-15 = hit very hard, do 11-15 points of damage and add the damage of the sword or your hands (1 or 10)
- 16-20 = smash, do 16-20 points of damage and add the damage of the sword or your hands * 2 (2 or 10)
- 21-25 = dodged, no damage
- Print your hp and the enemies
- Enemies strike:
- Choose a random number between 1 and 25
- 1-5 = miss, no damage
- 6-10 = hit hard, take 6-10 points of damage
- 11-15 = smashed, take 11-15 * 8 points of damage reduce by your armour (which can be worn)
- 16-25 = dodged, no damage
- Check if any HP are below 1 - if so act accordingly
- Repeat
Your hit points (HM and HP) start at 294; so it seems combat is unfair and you may just have to save (in game, not as an image) and retry it a lot to shift the random numbers around. If you want I can try and edit the code so you always win the fight.
Edit: the C16 code from a quick look is exactly the same as the C64 code - so it may be an unofficial port as they shared the same flavour of BASIC.
Re: Paul's 4k Adventure - coder's help needed (again)
Thanks a lot for looking into the code
.
Maybe the armor would help... I didn't find it in the places accessible before the bottleneck guarded by the knight. Could it be that I missed it? If yes, then the game is slightly richer than I thought. I never suspected any hidden items, from what I saw in Paul's games so far. Could it be that there is an actual puzzle in the game...? Any pointer there maybe..?
Hmm... there's something that struck me as odd. I did try that battle like 25 times, and as far as I saw, the battles went in exactly identical ways, enemy hit points included. The knight always started with 294 or so. the damage the knight did was always exactly the same, in the exact same order. For shits and giggles, I attacked a villager in a nearby room. Course of battle: exactly the same as well. Could it be that the random number generator can't be properly emulated by VICE..?dave wrote:Choose a random amount of HP for the enemy (between 1 and 350)
Well, that's one ultra hard blow... If the battle were truly random, and perchance the knight would NOT always land one of those, it could just be possible to win.dave wrote:11-15 = smashed, take 11-15 * 8 points of damage reduce by your armour (which can be worn)
Maybe the armor would help... I didn't find it in the places accessible before the bottleneck guarded by the knight. Could it be that I missed it? If yes, then the game is slightly richer than I thought. I never suspected any hidden items, from what I saw in Paul's games so far. Could it be that there is an actual puzzle in the game...? Any pointer there maybe..?
- Gunness
- Site Admin
- Posts: 1939
- Joined: Tue Dec 07, 2004 7:04 pm
- Location: Copenhagen, Denmark
- Contact:
Re: Paul's 4k Adventure - coder's help needed (again)
Well, I hacked the game to turn the odds a bit in my favour after dying countless timesMark wrote:Maybe the armor would help... I didn't find it in the places accessible before the bottleneck guarded by the knight. Could it be that I missed it? If yes, then the game is slightly richer than I thought. I never suspected any hidden items, from what I saw in Paul's games so far. Could it be that there is an actual puzzle in the game...? Any pointer there maybe..?
So with some additional code tweaks, I won that battle as well as the final one with the evil guy himself. I haven't found any use for the ring, but otherwise there doesn't seem to be a lot of stones left to turn, and the game is very brief. Oddly, given the very strict memory restrictions there are quite a lot of empty locations. I think those bytes could have been filled up with something more useful
Re: Paul's 4k Adventure - coder's help needed (again)
Well, yes... the game is trash. It downright sucks. But you know me, Jacob. I seldom hesitate to play even the dumbest games around, hehe.
Also, this specific author seems to have had a reputation as a sort of "Ed Wood of adventure games". Maybe it's sentimental, but I'd really like to play a few of his games (if only to pay heed to the memory of a slightly weird personality within the scene). Would it be very time-wasting to fix this particular game and put it up here, so I can solve it by fair means? It would be best to fix battles in a way that forces the player to at least find out that he has to "wear" stuff, and "wield" the sword to win.
P.S. is "classics" the appropriate place for this thread anyway? They were made for the C64, but they're quite recent.
Also, this specific author seems to have had a reputation as a sort of "Ed Wood of adventure games". Maybe it's sentimental, but I'd really like to play a few of his games (if only to pay heed to the memory of a slightly weird personality within the scene). Would it be very time-wasting to fix this particular game and put it up here, so I can solve it by fair means? It would be best to fix battles in a way that forces the player to at least find out that he has to "wear" stuff, and "wield" the sword to win.
P.S. is "classics" the appropriate place for this thread anyway? They were made for the C64, but they're quite recent.
Re: Paul's 4k Adventure - coder's help needed (again)
The odds of you winning a fight seem a bit poor: you have a 3 in 5 chance of scoring a hit, for either 6-11, 12-25 or 18-30 points of damage, which with 294 enemy hits will take a while. The enemy, on the other hand has a 2 in 5 chance of scoring a hit for either 6-11 or 88 - 120 points of damage, which'll kill you very quickly.
When you mention trying several times, did you restore from a save game, or use a save state? The way most random numbers are generated depends on most 8-bit machines depend on a mathematical formula to get a number from a sequence, usually the seed is stored in memory and will be the same when the machine boots, or is restored from a state; leading to the same random numbers. (this messed up another Spectrum game, which I fixed by manipulating the random number seed.)
[edit] Gunness, if you used my C64 detokeniser to decode this, I realised I got the tokens for ">" and "<" the wrong way around, so the program may look a bit strange.
[edit 2] I found this page on how the random number generator works on the C64; it looks like it wouldn't have been so bad if he'd just used RND(0) instead of RND(1).
When you mention trying several times, did you restore from a save game, or use a save state? The way most random numbers are generated depends on most 8-bit machines depend on a mathematical formula to get a number from a sequence, usually the seed is stored in memory and will be the same when the machine boots, or is restored from a state; leading to the same random numbers. (this messed up another Spectrum game, which I fixed by manipulating the random number seed.)
[edit] Gunness, if you used my C64 detokeniser to decode this, I realised I got the tokens for ">" and "<" the wrong way around, so the program may look a bit strange.
[edit 2] I found this page on how the random number generator works on the C64; it looks like it wouldn't have been so bad if he'd just used RND(0) instead of RND(1).
Re: Paul's 4k Adventure - coder's help needed (again)
88-120... Yes, that looks quite bleak for our poor hero... Would it be possible to manipulate the numbers in a way that the battle without a sword is almost impossible to win, but with the sword pretty easy? So at least the wield sword "puzzle" has some sense, AND the author's attempt at bringing in a rpg element is still there.dave wrote:The odds of you winning a fight seem a bit poor: you have a 3 in 5 chance of scoring a hit, for either 6-11, 12-25 or 18-30 points of damage, which with 294 enemy hits will take a while. The enemy, on the other hand has a 2 in 5 chance of scoring a hit for either 6-11 or 88 - 120 points of damage, which'll kill you very quickly.
Sounds like you put your finger on it. I save via the snapshot image function. Got used to doing that, since too many games either have no save command at all, or can only save one slot, or are buggy with saving games in the first place...dave wrote:When you mention trying several times, did you restore from a save game, or use a save state?
Re: Paul's 4k Adventure - coder's help needed (again)
The C64 random seed is stored in memory locations $8b - $ 8f; so you can probably edit it directly from the VICE monitor - though this looks to be a standard BASIC float variable, which is a sod to convert to.
I'll have a look at hacking the source code - I'll probably reduce the enemy's hit points and make the damages more sensible (and have the sword make more differences).
I'll have a look at hacking the source code - I'll probably reduce the enemy's hit points and make the damages more sensible (and have the sword make more differences).
Re: Paul's 4k Adventure - coder's help needed (again)
Not that I understand one whit what you folks are referring to, I recall playing some games, where the outcome was the same if you "saved" just previous to starting that sequence, but with others it truly was random.
Does it matter "when" the randomness is set to start?
Does it matter "when" the randomness is set to start?
Re: Paul's 4k Adventure - coder's help needed (again)
It really does depend on the program. Most random numbers on old 8-bit computers were just generated by an algorithm, which took a starting number (the seed) and produced a "random" number, which meant that every time you reset the machine, you'd get the same random numbers afterwards.terri wrote:Not that I understand one whit what you folks are referring to, I recall playing some games, where the outcome was the same if you "saved" just previous to starting that sequence, but with others it truly was random.
Does it matter "when" the randomness is set to start?
Most versions of BASIC had a way to reset the seed. Depending on the programmer, this may have been done in a sensible place, following something more random (e.g. reading from the system clock or from hardware) or not at all.
So, in conclusion, it really does depend on the program. This one is evil as the odds of winning combat are skewed vastly away from the player!
Re: Paul's 4k Adventure - coder's help needed (again)
Thanks, Dave. I learned something today. Some things are not truly "random". If random depends on something, then is it truly random?
One of those philosphical, rhetorical questions, that, as they be wont to be, will be laid to rest, without further ado, by me. Such imponderables are best done in college, or when one is young, and thinks it is important...
One of those philosphical, rhetorical questions, that, as they be wont to be, will be laid to rest, without further ado, by me. Such imponderables are best done in college, or when one is young, and thinks it is important...
Re: Paul's 4k Adventure - coder's help needed (again)
No, it's pseudo-random. Yes, really. That really is the technical term. Just about every old BASIC manual used to have a note in the section on random numbers, explaining that they were only pseudo-random not really random. (Of course, back then there was no difference in practice since you couldn't save and reload a snapshot of the whole machine's state. It's only modern emulators that have exposed the weakness in the system.)terri wrote:Thanks, Dave. I learned something today. Some things are not truly "random". If random depends on something, then is it truly random?
[b]~~[i] Pippa [/i]~~[/b]
- Gunness
- Site Admin
- Posts: 1939
- Joined: Tue Dec 07, 2004 7:04 pm
- Location: Copenhagen, Denmark
- Contact:
Re: Paul's 4k Adventure - coder's help needed (again)
@Dave: No, I didn't use the detokenizer, I just looked at the listing from within the game. I guess the other method would be easier
(the LIST command in C64 BASIC is pretty sucky. As is the rest of the BASIC, actually!)
But I agree completely, and I've enjoyed (in a weird, masochistic way) playing this particular game. Somehow I don't think Paul ever anticipated that anyone would try to reverse engineer his program so enthusiastically 
Unless Dave does it, I can also "fix" the program a bit. You can't say that the player has to wear the armour of wield the sword to win, as it all comes down to semi-random numbers, but you can improve the odds a lot.
The "classics" refers to the platforms, here meaning the various 8-bit and 16-bit computers as opposed to Inform and the other modern interpreters.
Hehe, Paul Panks had quite a reputation in the IF communityMark wrote:Also, this specific author seems to have had a reputation as a sort of "Ed Wood of adventure games". Maybe it's sentimental, but I'd really like to play a few of his games (if only to pay heed to the memory of a slightly weird personality within the scene). Would it be very time-wasting to fix this particular game and put it up here, so I can solve it by fair means? It would be best to fix battles in a way that forces the player to at least find out that he has to "wear" stuff, and "wield" the sword to win.
Unless Dave does it, I can also "fix" the program a bit. You can't say that the player has to wear the armour of wield the sword to win, as it all comes down to semi-random numbers, but you can improve the odds a lot.
Could "Paul's 4K Adventure" ever have been considered a classic, no matter what decade it was written in??P.S. is "classics" the appropriate place for this thread anyway? They were made for the C64, but they're quite recent.