Kingdom of the Lyre: Forces of the Underworld
Saturday, 16th November 2019
This is the final post in Damian's blog series on how the game works.
While the player is wandering around the Kingdom of the Lyre, they are relentlessly pursued by the forces of the underworld. If those forces catch the player, the game is over. If they catch the lyre as well, the game is very over. Let's see the subroutine that controls them.
REM --- Subroutine to move the forces of the underworld 270 IF P=U THEN RETURN IF J=2 THEN RETURN REM --- See where the forces are in relation to the player LET X=U GOSUB 600 LET B=10-B REM --- See if the forces can travel towards the player GOSUB 310 IF B=2 THEN IF E/2-E/4*2>0 THEN GOTO 271 IF B=4 THEN IF E/4-E/8*2>0 THEN GOTO 271 IF B=6 THEN IF E-E/2*2>0 THEN GOTO 271 IF B=8 THEN IF E/8>0 THEN GOTO 271 IF A>2 THEN GOTO 271 REM --- If not, pick a random direction and see if they can go there LET Z=G GOSUB 990 LET G=Z LET B=2*(1+Z-Z/4*4) IF B=2 THEN IF E/2-E/4*2>0 THEN GOTO 271 IF B=4 THEN IF E/4-E/8*2>0 THEN GOTO 271 IF B=6 THEN IF E-E/2*2>0 THEN GOTO 271 IF B=8 THEN IF E/8>0 THEN GOTO 271 RETURN 271 IF B=2 THEN LET U=U-80 IF B=4 THEN LET U=U-1 IF B=6 THEN LET U=U+1 IF B=8 THEN LET U=U+80 RETURN
This is no artificial intelligence. It heads relentlessly towards the player. Initially I made an attempt to make the forces follow valid paths, as I thought that luring them into dead-ends might be a valid tactic. But this led to them getting caught up in a maze, and removed any urgency from the game, so I finally decided to let the forces crash through any obstacle if they were far enough from the player that this wouldn't be noticeable. If the armies are close to the player, and if paths do not lie in a convenient direction, then the forces will choose a random direction in order to try and get past the obstacle.
Two conditions at the top of the routine halt the armies. Firstly, if they have already found the player - this will have happened if the player blunders into them. Secondly, if the player has a just (J) drunk a speed (2) potion. Speed potions are probably the easiest way for the player to shake off an army in close pursuit.
That more or less covers the mechanics of the game. One other thing I wanted to point out about the code is the use of line numbers. Unlike Intergalactic Space Rescue, I kept them in order this time. But I wasn't able to leave room in the numbering for all lines to be numbered. If you want to convert this to other BASICs, then some quite extensive renumbering of the routines will be needed. I'd suggest multiplying all line numbers by 10, and then manually adjusting those that still don't leave enough room for all the lines between. Remember that the computed GOTOs will need careful adjustment. Then you can use the --output=lst option to output a program with full line numbers.
Another thing I wanted to mention is that the game was developed in haste, so it lacks some polish. If I find any bugs then I'll correct them and will upload. But additional features, like those terrain-related variations I mentioned in previous posts, will be left to a different game. Or maybe you'd like to try to introduce some improvements yourself!
Comments