First we initialize MN
(the monster being attacked) and DAM
(the damage being done) to 0. Then we ask what weapon the player wants to use:
1650 MN = 0:DAM = 0: PRINT "ATTACK": PRINT "WHICH WEAPON ";: GET Q$
Then, depending on what they select, we set the appropriate damage DAM
. But if the player does not own the item, say so and go back to asking which weapon:
1651 IF Q$ = "R" THEN DAM = 10: PRINT "RAPIER": IF PW(1) < 1 THEN PRINT "NOT OWNED": GOTO 1650
1652 IF Q$ = "A" THEN DAM = 5: PRINT "AXE": IF PW(2) < 1 THEN PRINT "NOT OWNED": GOTO 1650
1653 IF Q$ = "S" THEN DAM = 1: PRINT "SHIELD": IF PW(3) < 1 THEN PRINT "NOT OWNED": GOTO 1650
1654 IF Q$ = "B" THEN DAM = 4: PRINT "BOW": IF PW(4) < 1 THEN PRINT "NOT OWNED": GOTO 1650
If MAGIC AMULET has been selected, skip down to line 1680:
1655 IF Q$ = "M" THEN PRINT "MAGIC AMULET": GOTO 1680
Check player class ($PT
) and, if player is a mage and they picked a BOW or RAPIER, tell them they can't use it and go back to asking which weapon again:
1656 IF Q$ = "B" AND PT$ = "M" THEN PRINT "MAGES CAN'T USE BOWS!": GOTO 1650
1657 IF Q$ = "R" AND PT$ = "M" THEN PRINT "MAGES CAN'T USE RAPIERS!": GOTO 1650
If none of the weapons matched, DAM
will still be 0 and we'll assume HANDS.
1659 IF DAM = 0 THEN PRINT "HANDS"
If it's an AXE or BOW, we skip ahead to line 1670:
1660 IF DAM = 5 OR DAM = 4 THEN 1670
This next line is unique to Melee Weapons. We work out which monster type is in the direction the player is facing. (Looks like DN%()
might contain 10 x the monster level/type at that location).
1661 MN = DN%(PX + DX,PY + DY) / 10:MN = INT (MN)
But from this point on, the code is shared with Ranged weapons too...
If there are no monsters, MN
will be < 1 (not sure if it will ever be negative). The hit chance is based on DEXTERITY, the monster level and the dungeon level.
1662 IF MN < 1 OR C(2) - RND (1) * 25 < MN + INOUT THEN PRINT "YOU MISSED": GOTO 1668
If we hit, we work out actual damage (based on DAM
and STRENGTH) and put it back in DAM
and reduce the HIT POINTS accordingly. MZ%(MN,1)
must contain the HIT POINTS of the monster of type MN
.
1663 PRINT "HIT!!! ":DAM = ( RND (1) * DAM + C(1) / 5):MZ%(MN,1) = MZ%(MN,1) - DAM
We display the monster's new HIT POINTS:
1664 PRINT M$(MN);"'S HIT POINTS=";MZ%(MN,1)
If that has dropped to 0 or less, it's a kill. The reward is an amount of gold equal to the monster level + dungeon level.
1665 IF MZ%(MN,1) < 1 THEN PRINT "THOU HAST KILLED A ";M$(MN): PRINT "THOU SHALT RECEIVE":DA = INT (MN + IN): PRINT DA;" PIECES OF EIGHT"
We add the gold to the player inventory. We then remove the monster from the DNG%
map and set MZ%(MN,0)
to 0. ML%(MN,0)
must contain the X-cordinate of the monster and ML%(MN,1)
the Y-coordinate.
1666 IF MZ%(MN,1) < 1 THEN C(5) = INT (C(5) + DA):DNG%(ML%(MN,0),ML%(MN,1)) = DNG%(ML%(MN,0),ML%(MN,1)) - 10 * MN:MZ%(MN,0) = 0
LK
is the number of HIT POINTS the player will gain when they leave the dungeon. We increment LK
by half the monster level MN
times the dungeon level IN
. If the monster was the quest monster, we mark the quest done (by negating TASK
).
1667 LK = LK + INT (MN * IN / 2): IF MN = TASK THEN TASK = - TASK
Regardless of hit or miss, we end up here...
If PAUSE is ON, we wait for a CR to continue:
1668 IF PA = 1 THEN PRINT "-CR- TO CONT. ";: INPUT Q$
And we're done.
1669 GOTO 1090
If it's an AXE, we give the player the option to THROW (ranged) or SWING (melee). If they SWING, we just go back to the Melee Weapon section above.
1670 IF DAM = 5 THEN PRINT "TO THROW OR SWING:";: GET Q$: IF Q$ < > "T" THEN PRINT "SWING": GOTO 1661
If it's an AXE (and we've already established at this point we're throwing it) we reduce the count by one:
1671 IF DAM = 5 THEN PRINT "THROW":PW(2) = PW(2) - 1
We iterate over the 5 squares in the direction the player is facing. If we go off the map (a coordinate hit 0 or 10), we go back to Common Attack Code with MN
still 0.
If DNG%(x, y)
has a monster, it will contain monster level * 10
.
1672 FOR Y = 1 TO 5: IF PX + DX * Y < 1 OR PX + DX * Y > 9 OR PY + DY * Y > 9 OR PY + DY * Y < 0 THEN 1662
1673 MN = DNG%(PX + DX * Y,PY + DY * Y):MN = INT (MN / 10): IF MN > 0 THEN 1662
1674 NEXT : GOTO 1662
If there's no magic amulet in the player's possession, we go back to asking them which weapon to use.
1680 IF PW(5) < 1 THEN PRINT "NONE OWNED": GOTO 1650
If the player is a fighter, the amulet's action is random:
1681 IF PT$ = "F" THEN Q = INT ( RND (1) * 4 + 1): GOTO 1685
If the player is a mage, they get to pick the amulet's action:
1682 PRINT "1-LADDER-UP","2-LADDER-DN": PRINT "3-KILL","4-BAD??": PRINT "CHOICE ";: GET Q$:Q = VAL (Q$): PRINT Q: IF Q < 1 OR Q > 4 THEN 1682
But in that case, there's a 25% chance the amulet will be on its last charge (and will be removed from the inventory).
1683 IF RND (1) > .75 THEN PRINT "LAST CHARGE ON THIS AMULET!":PW(5) = PW(5) - 1
Regardless of fighter or mage, we end up here.
1685 ON Q GOTO 1686,1690,1691,1692
Q = 1. Make an up-ladder:
1686 PRINT "LADDER UP":DNG%(PX,PY) = 8: GOTO 1090
Q = 2. Make a down-ladder:
1690 PRINT "LADDER DOWN":DNG%(PX,PY) = 7: GOTO 1090
Q = 3. A magic attack. Set the damage to 10 + dungeon level and go to Ranged Attack.
1691 PRINT "MAGIC ATTACK":DAM = 10 + INOUT: GOTO 1672
Q = 4. Random badness.
1692 ON INT ( RND (1) * 3 + 1) GOTO 1693,1695,1697
a) get turned into a TOAD and have STRENGTH, DEXTERITY, STAMINA and WISDOM all turned to 3.
1693 PRINT "YOU HAVE BEEN TURNED": PRINT "INTO A TOAD!"
1694 FOR Z2 = 1 TO 4:C(Z2) = 3: NEXT Z2: GOTO 1090
b) get turned into a LIZARD MAN and have HIT POINTS, STRENGTH, DEXTERITY, STAMINA and WISDOM all multiplied by 2.5:
1695 PRINT "YOU HAVE BEEN TURNED": PRINT "INTO A LIZARD MAN": FOR Y = 0 TO 4:C(Y) = INT (C(Y) * 2.5): NEXT : GOTO 1090
c) backfire and halve HIT POINTS
1697 PRINT "BACKFIRE":C(0) = C(0) / 2: GOTO 1090