IF playerTile$ = "Wall" THEN playerNewGridX = playerGridX playerNewGridY = playerGridY END IF IF playerTile$ = "Empty" THEN playerGridX = playerNewGridX playerGridY = playerNewGridY REPEAT 2 '--- Position background sprite. IF keydown$ = "UPARROW" THEN roomSpriteY = roomSpriteY + 22 IF keydown$ = "DOWNARROW" THEN roomSpriteY = roomSpriteY - 22 IF keydown$ = "LEFTARROW" THEN roomSpriteX = roomSpriteX + 22 IF keydown$ = "RIGHTARROW" THEN roomSpriteX = roomSpriteX - 22 '--- Position NPC1sprite. npc1spriteY = npc1gridY * 44 npc1spriteY = npc1spriteY - 44 npc1spriteY = npc1spriteY + roomSpriteY npc1spriteX = npc1gridX * 44 npc1spriteX = npc1spriteX - 44 npc1spriteX = npc1spriteX + roomSpriteX '--- Position NPC2sprite. npc2spriteY = npc2gridY * 44 npc2spriteY = npc2spriteY - 44 npc2spriteY = npc2spriteY + roomSpriteY npc2spriteX = npc2gridX * 44 npc2spriteX = npc2spriteX - 44 npc2spriteX = npc2spriteX + roomSpriteX '--- Position NPC3sprite. npc3spriteY = npc3gridY * 44 npc3spriteY = npc3spriteY - 44 npc3spriteY = npc3spriteY + roomSpriteY npc3spriteX = npc3gridX * 44 npc3spriteX = npc3spriteX - 44 npc3spriteX = npc3spriteX + roomSpriteX '--- Check which NPCs are alive and draw the sprites of the living ones. IF npc1alive = 1 THEN SPRITE -npc1SpriteNumber npc1spriteX npc1spriteY $npc1sprite$$ IF npc2alive = 1 THEN SPRITE -npc2SpriteNumber npc2spriteX npc2spriteY $npc2sprite$$ IF npc3alive = 1 THEN SPRITE -npc3SpriteNumber npc3spriteX npc3spriteY $npc3sprite$$ SPRITE roomSpriteNumber roomSpriteX roomSpriteY END REPEAT END IF '---Battle Engine------------------------------------------------------------------------------- '--- Enter battle routine. IF enterBattle = 1 THEN enterBattle = 0 results$ = "" SOUND $playerAttackSound$$ IF npc0GridY < playerGridY THEN playerAttackIcon$ = "attackIconUp.gif" IF npc0GridY > playerGridY THEN playerAttackIcon$ = "attackIconDown.gif" IF npc0GridX < playerGridX THEN playerAttackIcon$ = "attackIconLeft.gif" IF npc0GridX > playerGridX THEN playerAttackIcon$ = "attackIconRight.gif" SPRITE actionEffectSpriteNumber playerSpriteX playerSpriteY $playerAttackIcon$$ SPRITEPATH actionEffectSpriteNumber npc0SpriteX npc0SpriteY attackIconMoveSpeed '--- Determine the chance of the attack hitting. hitWindow = baseHitChance hitWindow = hitWindow + playerAccuracy hitWindow = hitWindow - npc0Evasion IF hitWindow > maxHitChance THEN hitWindow = maxHitChance IF hitWindow < minHitChance THEN hitWindow = minHitChance hitRoll = RANDOM 100 '--- If the attack hits, deal damage. IF hitRoll =< hitWindow THEN results$ = results$ + "AttackHit " damageRoll = RANDOM baseRandomDamage damageRoll = damageRoll + baseDamage damageRoll = damageRoll + playerAttack damageRoll = damageRoll - npc0Defense IF damageRoll < minDamage THEN damageRoll = minDamage IF damageRoll > maxDamage THEN damageRoll = maxDamage npc0HP = npc0HP - damageRoll ELSE results$ = results$ + "AttackMiss " END IF IF npc0HP < 1 THEN results$ = results$ + "EnemyDied " '--- Calculate HP status. tenPercent = npc0MaxHP / 10 entityHPSprite$ = "HP-90%.gif" percentCheck = tenPercent * 9 IF npc0HP < percentCheck THEN entityHPSprite$ = "HP-80%.gif" percentCheck = tenPercent * 8 IF npc0HP < percentCheck THEN entityHPSprite$ = "HP-70%.gif" percentCheck = tenPercent * 7 IF npc0HP < percentCheck THEN entityHPSprite$ = "HP-60%.gif" percentCheck = tenPercent * 6 IF npc0HP < percentCheck THEN entityHPSprite$ = "HP-50%.gif" percentCheck = tenPercent * 5 IF npc0HP < percentCheck THEN entityHPSprite$ = "HP-40%.gif" percentCheck = tenPercent * 4 IF npc0HP < percentCheck THEN entityHPSprite$ = "HP-30%.gif" percentCheck = tenPercent * 3 IF npc0HP < percentCheck THEN entityHPSprite$ = "HP-20%.gif" percentCheck = tenPercent * 2 IF npc0HP < percentCheck THEN entityHPSprite$ = "HP-10%.gif" percentCheck = tenPercent * 1 IF npc0HP < percentCheck THEN entityHPSprite$ = "HP-0%.gif" IF npc0HP => npc0MaxHP THEN entityHPSprite$ = "HP-100%.gif" IF npc0HP =< 0 THEN entityHPSprite$ = "HP-None.gif"
IF results$ CONTAINS "AttackHit" THEN SOUND $playerAttackHitSound$$ SPRITE actionEffectSpriteNumber npc0SpriteX npc0SpriteY Attack-Hit-Icon.gif SPRITE entityHpSpriteNumber npc0SpriteX npc0SpriteY $entityHPSprite$$ DELAY attackHitDisplayTime SPRITE -actionEffectSpriteNumber -1000 -1000 SPRITE entityHpSpriteNumber -1000 -1000 END IF IF results$ CONTAINS "AttackMiss" THEN SOUND $playerAttackMissSound$$ SPRITE actionEffectSpriteNumber npc0SpriteX npc0SpriteY Attack-Miss-Icon.gif DELAY attackMissDisplayTime SPRITE actionEffectSpriteNumber -1000 -1000 END IF IF results$ CONTAINS "EnemyDied" THEN SOUND Enemy Death npc0Alive = 0 npc0GridX = 0 npc0GridY = 0 IF activeNpc = 1 THEN SPRITE -npc1SpriteNumber IF activeNpc = 2 THEN SPRITE -npc2SpriteNumber IF activeNpc = 3 THEN SPRITE -npc3SpriteNumber '--- Calculate the enemy's EXP. enemyLvlDifference = npc0Lvl - playerLvl enemyExpAdjustment = 50 * enemyLvlDifference enemyExp = 100 IF enemyLvlDifference <> 0 THEN enemyExp = enemyExp + enemyExpAdjustment IF enemyExp < 5 THEN enemyExp = 5 '--- Award EXP. playerExp = playerExp - enemyExp IF playerExp < 0 THEN playerExp = 0 CLEAR TEXT PRINT You slay the $npc0Name$$ PRINT + $enemyExp$ EXP '--- Check if the player has enough EXP to LVL up. IF playerExp =< 0 THEN IF playerLvl < playerMaxLvl THEN playerExp = expNeededToLvlUp playerLvl = playerLvl + 1 playerAttributePoints = playerAttributePoints + 20 IF playerAttributePoints > playerMaxAttributePoints THEN playerAttributePoints = playerMaxAttributePoints END IF END IF END IF '--- Write the updated stats of the active NPC into the appropriate vars. IF activeNpc = 1 THEN npc1Alive = npc0Alive npc1GridX = npc0GridX npc1GridY = npc0GridY npc1SpriteX = npc0SpriteX npc1SpriteY = npc0SpriteY npc1HP = npc0HP END IF IF activeNpc = 2 THEN npc2Alive = npc0Alive npc2GridX = npc0GridX npc2GridY = npc0GridY npc2SpriteX = npc0SpriteX npc2SpriteY = npc0SpriteY npc2HP = npc0HP END IF IF activeNpc = 3 THEN npc3Alive = npc0Alive npc3GridX = npc0GridX npc3GridY = npc0GridY npc3SpriteX = npc0SpriteX npc3SpriteY = npc0SpriteY npc3HP = npc0HP END IF END IF '---------------------------------------------------------------------------------------------- IF keydown$ CONTAINS "ARROW" THEN gameState$ = "NPC's Turn" END IFEND KEYDOWN
ON TIMER -10  IF gameState$ = "NPC's Turn" THEN   gameState$ = "Player's Turn"   npc1Turn$ = "Available"   npc2Turn$ = "Available"   npc3Turn$ = "Available"   REPEAT   '--- Check which NPCs have taken their turn.   activeNpc = 0   IF npc3Alive = 1 THEN    IF npc3Turn$ = "Available" THEN     activeNpc = 3     npc0Alive = npc3Alive     npc0Type$ = npc3Type$     npc0Name$ = npc3Name$     npc0Sprite$ = npc3Sprite$     npc0SpriteNumber = npc3SpriteNumber     npc0GridX = npc3GridX     npc0GridY = npc3GridY     npc0SpriteX = npc3SpriteX     npc0SpriteY = npc3SpriteY     npc0Lvl = npc3Lvl     npc0HP = npc3HP     npc0MaxHP = npc3MaxHP     npc0Attack = npc3Attack     npc0Defence = npc3Defence     npc0Accuracy = npc3Accuracy     npc0Evasion = npc3Evasion    END IF   END IF   IF npc2Alive = 1 THEN    IF npc2Turn$ = "Available" THEN     activeNpc = 2     npc0Alive = npc2Alive     npc0Type$ = npc2Type$     npc0Name$ = npc2Name$     npc0Sprite$ = npc2Sprite$     npc0SpriteNumber = npc2SpriteNumber     npc0GridX = npc2GridX     npc0GridY = npc2GridY     npc0SpriteX = npc2SpriteX     npc0SpriteY = npc2SpriteY     npc0Lvl = npc2Lvl     npc0HP = npc2HP     npc0MaxHP = npc2MaxHP     npc0Attack = npc2Attack     npc0Defence = npc2Defence     npc0Accuracy = npc2Accuracy     npc0Evasion = npc2Evasion    END IF   END IF   IF npc1Alive = 1 THEN    IF npc1Turn$ = "Available" THEN     activeNpc = 1     npc0Alive = npc1Alive     npc0Type$ = npc1Type$     npc0Name$ = npc1Name$     npc0Sprite$ = npc1Sprite$     npc0SpriteNumber = npc1SpriteNumber     npc0GridX = npc1GridX     npc0GridY = npc1GridY     npc0SpriteX = npc1SpriteX     npc0SpriteY = npc1SpriteY     npc0Lvl = npc1Lvl     npc0HP = npc1HP     npc0MaxHP = npc1MaxHP     npc0Attack = npc1Attack     npc0Defence = npc1Defence     npc0Accuracy = npc1Accuracy     npc0Evasion = npc1Evasion    END IF   END IF   '--- If an NPC is due a turn, enter the Active NPC routine.   IF activeNpc > 0 THEN    IF activeNpc = 1 THEN npc1Turn$ = "Passed"    IF activeNpc = 2 THEN npc2Turn$ = "Passed"    IF activeNpc = 3 THEN npc3Turn$ = "Passed"    npc0NewGridX = npc0GridX    npc0NewGridY = npc0GridY    '--- NPC AI.    npc0AI$ = "Roam"    IF npc0Type$ = "Enemy" THEN     npc0Action = random 10     IF npc0Action > 1 THEN npc0AI$ = "Follow Player"    END IF    IF npc0AI$ = "Roam" THEN     npc0Action = RANDOM 4     IF npc0Action = 1 THEN npc0Action$ = "moveup"     IF npc0Action = 2 THEN npc0Action$ = "movedown"     IF npc0Action = 3 THEN npc0Action$ = "moveleft"     IF npc0Action = 4 THEN npc0Action$ = "moveright"    END IF IF npc0AI$ = "Follow Player" THEN npc0ActionList$ = "" npc0ActionChoices = 0 IF playerGridY < npc0GridY THEN npc0ActionList$ = npc0ActionList$ + "moveUp " npc0ActionChoices = npc0ActionChoices + 1 END IF IF playerGridY > npc0GridY THEN npc0ActionList$ = npc0ActionList$ + "moveDown " npc0ActionChoices = npc0ActionChoices + 1 END IF IF playerGridX < npc0GridX THEN npc0ActionList$ = npc0ActionList$ + "moveLeft " npc0ActionChoices = npc0ActionChoices + 1 END IF IF playerGridX > npc0GridX THEN npc0ActionList$ = npc0ActionList$ + "moveRight " npc0ActionChoices = npc0ActionChoices + 1 END IF chosenItemFromList = RANDOM npc0ActionChoices npc0Action$ = WORD$ npc0ActionList$ chosenItemFromList END IF
'--- Check which direction the NPC wants to move in. IF npc0Action$ = "moveUp" THEN npc0NewGridY = npc0GridY - 1 IF npc0Action$ = "moveDown" THEN npc0NewGridY = npc0GridY + 1 IF npc0Action$ = "moveLeft" THEN npc0NewGridX = npc0GridX - 1 IF npc0Action$ = "moveRight" THEN npc0NewGridX = npc0GridX + 1 '--- Check what kind of tile the NPC is trying to move onto. (check if it's traversable or not) IF npc0NewGridY = 1 THEN gridRow$ = gridRow1$ IF npc0NewGridY = 2 THEN gridRow$ = gridRow2$ IF npc0NewGridY = 3 THEN gridRow$ = gridRow3$ IF npc0NewGridY = 4 THEN gridRow$ = gridRow4$ IF npc0NewGridY = 5 THEN gridRow$ = gridRow5$ IF npc0NewGridY = 6 THEN gridRow$ = gridRow6$ IF npc0NewGridY = 7 THEN gridRow$ = gridRow7$ IF npc0NewGridY = 8 THEN gridRow$ = gridRow8$ IF npc0NewGridY = 9 THEN gridRow$ = gridRow9$ IF npc0NewGridY = 10 THEN gridRow$ = gridRow10$ IF npc0NewGridY = 11 THEN gridRow$ = gridRow11$ IF npc0NewGridY = 12 THEN gridRow$ = gridRow12$ IF npc0NewGridY = 13 THEN gridRow$ = gridRow13$ IF npc0NewGridY = 14 THEN gridRow$ = gridRow14$ IF npc0NewGridY = 15 THEN gridRow$ = gridRow15$ IF npc0NewGridY = 16 THEN gridRow$ = gridRow16$ IF npc0NewGridY = 17 THEN gridRow$ = gridRow17$ IF npc0NewGridY = 18 THEN gridRow$ = gridRow18$ IF npc0NewGridY = 19 THEN gridRow$ = gridRow19$ IF npc0NewGridY = 20 THEN gridRow$ = gridRow20$ IF npc0NewGridY = 21 THEN gridRow$ = gridRow21$ IF npc0NewGridY = 22 THEN gridRow$ = gridRow22$ IF npc0NewGridY = 23 THEN gridRow$ = gridRow23$ IF npc0NewGridY = 24 THEN gridRow$ = gridRow24$ IF npc0NewGridY = 25 THEN gridRow$ = gridRow25$ npc0Tile$ = MID$ gridRow$ npc0NewGridX 1 IF npc0Tile$ = "0" THEN npc0Tile$ = "Empty" IF npc0Tile$ = "1" THEN npc0Tile$ = "Wall " IF npc0NewGridX < 1 THEN npc0Tile$ = "Wall" IF npc0NewGridX > roomSize THEN npc0Tile$ = "Wall" IF npc0NewGridY < 1 THEN npc0Tile$ = "Wall" IF npc0NewGridY > roomSize THEN npc0Tile$ = "Wall" '--- This prevents the NPC from walking over other entities. IF npc0NewGridX = playerGridX THEN IF npc0NewGridY = playerGridY THEN npc0Tile$ = "Wall" enterBattle = 1 END IF END IF IF npc0NewGridX = npc1GridX THEN IF npc0NewGridY = npc1GridY THEN npc0Tile$ = "Wall" END IF IF npc0NewGridX = npc2GridX THEN IF npc0NewGridY = npc2GridY THEN npc0Tile$ = "Wall" END IF IF npc0NewGridX = npc3GridX THEN IF npc0NewGridY = npc3GridY THEN npc0Tile$ = "Wall" END IF IF npc0Tile$ = "Empty" THEN npc0GridX = npc0NewGridX npc0GridY = npc0NewGridY IF npc0Action$ = "moveUp" THEN npc0SpriteY = npc0SpriteY - 44 IF npc0Action$ = "moveDown" THEN npc0SpriteY = npc0SpriteY + 44 IF npc0Action$ = "moveLeft" THEN npc0SpriteX = npc0SpriteX - 44 IF npc0Action$ = "moveRight" THEN npc0SpriteX = npc0SpriteX + 44 SPRITEPATH npc0SpriteNumber npc0SpriteX npc0SpriteY 2 END IF '---Battle Engine------------------------------------------------------------------------------ '--- Enter battle routine. IF enterBattle = 1 THEN enterBattle = 0 results$ = "" SOUND $npc0AttackSound$$ IF playerGridY < npc0GridY THEN npc0AttackIcon$ = "attackIconUp.gif" IF playerGridY > npc0GridY THEN npc0AttackIcon$ = "attackIconDown.gif" IF playerGridX < npc0GridX THEN npc0AttackIcon$ = "attackIconLeft.gif" IF playerGridX > npc0GridX THEN npc0AttackIcon$ = "attackIconRight.gif" SPRITE actionEffectSpriteNumber npc0SpriteX npc0SpriteY $npc0AttackIcon$$ SPRITEPATH actionEffectSpriteNumber playerSpriteX playerSpriteY attackIconMoveSpeed
    '--- Determine the chance of the attack hitting.     hitWindow = baseHitChance     hitWindow = hitWindow + npc0Accuracy     hitWindow = hitWindow - playerEvasion     IF hitWindow > maxHitChance THEN hitWindow = maxHitChance     IF hitWindow < minHitChance THEN hitWindow = minHitChance     hitRoll = RANDOM 100     '--- If the attack hits, deal damage.     IF hitRoll =< hitWindow THEN      results$ = results$ + "AttackHit "      damageRoll = RANDOM baseRandomDamage      damageRoll = damageRoll + baseDamage      damageRoll = damageRoll + npc0Attack      damageRoll = damageRoll - playerDefense      IF damageRoll < minDamage THEN damageRoll = minDamage      IF damageRoll > maxDamage THEN damageRoll = maxDamage      playerHP = playerHP - damageRoll     ELSE      results$ = results$ + "AttackMiss "     END IF     IF playerHP < 1 THEN results$ = results$ + "PlayerDied "     '--- Calculate HP status.     tenPercent = playerMaxHP / 10     entityHPSprite$ = "HP-90%.gif"     percentCheck = tenPercent * 9     IF playerHP < percentCheck THEN entityHPSprite$ = "HP-80%.gif"     percentCheck = tenPercent * 8     IF playerHP < percentCheck THEN entityHPSprite$ = "HP-70%.gif"     percentCheck = tenPercent * 7     IF playerHP < percentCheck THEN entityHPSprite$ = "HP-60%.gif"     percentCheck = tenPercent * 6     IF playerHP < percentCheck THEN entityHPSprite$ = "HP-50%.gif"     percentCheck = tenPercent * 5     IF playerHP < percentCheck THEN entityHPSprite$ = "HP-40%.gif"     percentCheck = tenPercent * 4     IF playerHP < percentCheck THEN entityHPSprite$ = "HP-30%.gif"     percentCheck = tenPercent * 3     IF playerHP < percentCheck THEN entityHPSprite$ = "HP-20%.gif"     percentCheck = tenPercent * 2     IF playerHP < percentCheck THEN entityHPSprite$ = "HP-10%.gif"     percentCheck = tenPercent * 1     IF playerHP < percentCheck THEN entityHPSprite$ = "HP-0%.gif"     IF playerHP => playerMaxHP THEN entityHPSprite$ = "HP-100%.gif"     IF playerHP =< 0 THEN entityHPSprite$ = "HP-None.gif"     IF results$ CONTAINS "AttackHit" THEN      SOUND $npc0AttackHitSound$$      SPRITE actionEffectSpriteNumber playerSpriteX playerSpriteY Attack-Hit-Icon.gif      SPRITE entityHpSpriteNumber playerSpriteX playerSpriteY $entityHPSprite$$      DELAY attackHitDisplayTime      SPRITE -actionEffectSpriteNumber -1000 -1000      SPRITE entityHpSpriteNumber -1000 -1000     END IF     IF results$ CONTAINS "AttackMiss" THEN      SOUND $npc0AttackMissSound$$      SPRITE actionEffectSpriteNumber playerSpriteX playerSpriteY Attack-Miss-Icon.gif      DELAY attackMissDisplayTime      SPRITE actionEffectSpriteNumber -1000 -1000     END IF     IF results$ CONTAINS "PlayerDied" THEN      DELAY 1      SOUND Player Death      ALERT You have been defeated...      GOTOCARD 246     END IF'---Check for event triggers-----------------------------------------------------------------------IF roomNumber = 1 THEN  IF room1Event2 = 0 THEN   triggerRoomEvent = 2   GETPICTURE   GOTOCARD 5  END IFEND IF'------------------------------------------------------------------------------------------------    END IF '--- Check whether or not the NPC is far enough away from the player to despawn. despawn = 0 target = playerGridX + 7 IF npc0GridX => target THEN despawn = 1 target = playerGridX - 7 IF npc0GridX =< target THEN despawn = 1 target = playerGridY + 7 IF npc0GridY => target THEN despawn = 1 target = playerGridY - 7 IF npc0GridY =< target THEN despawn = 1 IF despawn = 1 THEN npc0Alive = 0 SPRITE -npc0SpriteNumber -1000 -1000 END IF
'--- Write the updated stats of the active NPC into the appropriate vars. IF activeNpc = 1 THEN npc1Alive = npc0Alive npc1GridX = npc0GridX npc1GridY = npc0GridY npc1SpriteX = npc0SpriteX npc1SpriteY = npc0SpriteY npc1HP = npc0HP END IF IF activeNpc = 2 THEN npc2Alive = npc0Alive npc2GridX = npc0GridX npc2GridY = npc0GridY npc2SpriteX = npc0SpriteX npc2SpriteY = npc0SpriteY npc2HP = npc0HP END IF IF activeNpc = 3 THEN npc3Alive = npc0Alive npc3GridX = npc0GridX npc3GridY = npc0GridY npc3SpriteX = npc0SpriteX npc3SpriteY = npc0SpriteY npc3HP = npc0HP END IF '--- Exit the Active NPC routine once each NPC has taken a turn. ELSE EXIT REPEAT END IF END REPEAT '----NPC SPAWN------------------------------------------------------------------------------- '--- Check which NPCs are alive. npcToSpawn = 0 IF npc3alive = 0 THEN npcToSpawn = 3 IF npc2alive = 0 THEN npcToSpawn = 2 IF npc1alive = 0 THEN npcToSpawn = 1 IF npcToSpawn > 0 THEN enemySpawnChance = RANDOM 5 IF enemySpawnChance = 1 THEN '--- Determine the player's sight radius. minCheckX = playerGridX - 4 minCheckY = playerGridY - 4 maxCheckX = playerGridX + 4 maxCheckY = playerGridY + 4 '--- Prepare variables required for node checking. checkX = maxCheckX checkY = minCheckY - 1 IF checkY < 1 THEN checkY = 0 freeTileList$ = "" freeTileCount = 0 '--- Determine which node to check. REPEAT dropY$ = "No" checkX = checkX + 1 IF checkX < 1 THEN checkX = 1 IF checkX > roomSize THEN dropY$ = "Yes" IF checkX > maxCheckX THEN dropY$ = "Yes" IF dropY$ = "Yes" THEN checkY = checkY + 1 checkX = minCheckX IF checkX < 1 THEN checkX = 1 '--- Determine the collision classes of the X row to be checked. IF checkY = 1 THEN gridRow$ = gridRow1$ IF checkY = 2 THEN gridRow$ = gridRow2$ IF checkY = 3 THEN gridRow$ = gridRow3$ IF checkY = 4 THEN gridRow$ = gridRow4$ IF checkY = 5 THEN gridRow$ = gridRow5$ IF checkY = 6 THEN gridRow$ = gridRow6$ IF checkY = 7 THEN gridRow$ = gridRow7$ IF checkY = 8 THEN gridRow$ = gridRow8$ IF checkY = 9 THEN gridRow$ = gridRow9$ IF checkY = 10 THEN gridRow$ = gridRow10$ IF checkY = 11 THEN gridRow$ = gridRow11$ IF checkY = 12 THEN gridRow$ = gridRow12$ IF checkY = 13 THEN gridRow$ = gridRow13$ IF checkY = 14 THEN gridRow$ = gridRow14$ IF checkY = 15 THEN gridRow$ = gridRow15$ IF checkY = 16 THEN gridRow$ = gridRow16$ IF checkY = 17 THEN gridRow$ = gridRow17$ IF checkY = 18 THEN gridRow$ = gridRow18$ IF checkY = 19 THEN gridRow$ = gridRow19$ IF checkY = 20 THEN gridRow$ = gridRow20$ IF checkY = 21 THEN gridRow$ = gridRow21$ IF checkY = 22 THEN gridRow$ = gridRow22$ IF checkY = 23 THEN gridRow$ = gridRow23$ IF checkY = 24 THEN gridRow$ = gridRow24$ IF checkY = 25 THEN gridRow$ = gridRow25$ END IF
     '--- Determine the XY coordinates of the checker based on the individual X and Y coordinates.      checkXY = roomSize * checkY      checkXY = checkXY - roomSize      checkXY = checkXY + checkX      checkXY$ = STR$ checkXY      '--- Check if the tile is fit for spawning.      tileToCheck$ = MID$ gridRow$ checkX 1      tileOnEdge$ = "No"      IF tileToCheck$ = "0" THEN       IF checkX = minCheckX THEN tileOnEdge$ = "Yes"       IF checkX = maxCheckX THEN tileOnEdge$ = "Yes"       IF checkY = minCheckY THEN tileOnEdge$ = "Yes"       IF checkY = maxCheckY THEN tileOnEdge$ = "Yes"       '--- If the tile is 1 node from the player's sight radius, add it to the list of spawnable tiles.       IF tileOnEdge$ = "Yes" THEN        freeTileList$ = freeTileList$ + checkXY$        freeTileList$ = freeTileList$ + ""        freeTileCount = freeTileCount + 1       END IF      END IF      '--- End the routine when every tile has been checked.      endRoutine = 0      IF checkX => maxCheckX THEN       IF checkY => maxCheckY THEN endRoutine = 1       IF checkY => roomSize THEN endRoutine = 1      END IF      IF checkX => roomSize THEN       IF checkY => maxCheckY THEN endRoutine = 1       IF checkY => roomSize THEN endRoutine = 1      END IF      IF endRoutine = 1 THEN EXIT REPEAT     END REPEAT     '--- Select a tile from the list of spawnable tiles.     IF freeTileList$ <> "" THEN      chosenItemFromList = RANDOM freeTileCount      chosenItemFromList = chosenItemFromList + 1      spawnXY$ = WORD$ freeTileList$ chosenItemFromList      spawnXY = VAL spawnXY$      '--- Determine the NPC's X and Y coordinates based on its XY coordinates.      npc0XY = 0      npc0GridX = 0      npc0GridY = 1      nodesToCalculate = spawnXY      REPEAT       IF nodesToCalculate > roomSize THEN        npc0GridY = npc0GridY + 1        npc0XY = npc0XY + roomSize        nodesToCalculate = nodesToCalculate - roomSize       ELSE        npc0GridX = npc0GridX + nodesToCalculate        npc0XY = npc0XY + nodesToCalculate        EXIT REPEAT       END IF      END REPEAT '--- Determine the NPC's sprite coordinates based on its grid coordinates. npc0SpriteY = npc0GridY * 44 npc0SpriteY = npc0SpriteY - 44 npc0SpriteY = npc0SpriteY + roomSpriteY npc0SpriteX = npc0GridX * 44 npc0SpriteX = npc0SpriteX - 44 npc0SpriteX = npc0SpriteX + roomSpriteX npc0NewGridX = npc0GridX npc0NewGridY = npc0GridY '--- Determine which type of enemy to spawn. npc0Type$ = "Enemy" newEnemyType = RANDOM enemyTypesInRoom IF newEnemyType = 1 THEN npc0Name$ = enemy1Name$ npc0Sprite$ = enemy1Sprite$ npc0Lvl = enemy1Lvl npc0HP = enemy1HP npc0MaxHP = enemy1HP npc0Attack = enemy1Attack npc0Defence = enemy1Defence npc0Accuracy = enemy1Accuracy npc0Evasion = enemy1Evasion END IF IF newEnemyType = 2 THEN npc0Name$ = enemy2Name$ npc0Sprite$ = enemy2Sprite$ npc0Lvl = enemy2Lvl npc0HP = enemy2HP npc0MaxHP = enemy2HP npc0Attack = enemy2Attack npc0Defence = enemy2Defence npc0Accuracy = enemy2Accuracy npc0Evasion = enemy2Evasion END IF IF newEnemyType = 3 THEN npc0Name$ = enemy3Name$ npc0Sprite$ = enemy3Sprite$ npc0Lvl = enemy3Lvl npc0HP = enemy3HP npc0MaxHP = enemy3HP npc0Attack = enemy3Attack npc0Defence = enemy3Defence npc0Accuracy = enemy3Accuracy npc0Evasion = enemy3Evasion END IF IF newEnemyType = 4 THEN npc0Name$ = enemy4Name$ npc0Sprite$ = enemy4Sprite$ npc0Lvl = enemy4Lvl npc0HP = enemy4HP npc0MaxHP = enemy4HP npc0Attack = enemy4Attack npc0Defence = enemy4Defence npc0Accuracy = enemy4Accuracy npc0Evasion = enemy4Evasion END IF IF newEnemyType = 5 THEN npc0Name$ = enemy5Name$ npc0Sprite$ = enemy5Sprite$ npc0Lvl = enemy5Lvl npc0HP = enemy5HP npc0MaxHP = enemy5HP npc0Attack = enemy5Attack npc0Defence = enemy5Defence npc0Accuracy = enemy5Accuracy npc0Evasion = enemy5Evasion END IF
'--- Determine which NPC to spawn. IF npcToSpawn = 1 THEN npc1Type$ = npc0Type$ npc1Name$ = npc0Name$ npc1Sprite$ = npc0Sprite$ npc1GridX = npc0GridX npc1GridY = npc0GridY npc1SpriteX = npc0SpriteX npc1SpriteY = npc0SpriteY npc1Lvl = npc0Lvl npc1HP = npc0HP npc1MaxHP = npc0MaxHP npc1Attack = npc0Attack npc1Defence = npc0Defence npc1Accuracy = npc0Accuracy npc1Evasion = npc0Evasion END IF IF npcToSpawn = 2 THEN npc2Type$ = npc0Type$ npc2Name$ = npc0Name$ npc2Sprite$ = npc0Sprite$ npc2GridX = npc0GridX npc2GridY = npc0GridY npc2SpriteX = npc0SpriteX npc2SpriteY = npc0SpriteY npc2Lvl = npc0Lvl npc2HP = npc0HP npc2MaxHP = npc0MaxHP npc2Attack = npc0Attack npc2Defence = npc0Defence npc2Accuracy = npc0Accuracy npc2Evasion = npc0Evasion END IF IF npcToSpawn = 3 THEN npc3Type$ = npc0Type$ npc3Name$ = npc0Name$ npc3Sprite$ = npc0Sprite$ npc3GridX = npc0GridX npc3GridY = npc0GridY npc3SpriteX = npc0SpriteX npc3SpriteY = npc0SpriteY npc3Lvl = npc0Lvl npc3HP = npc0HP npc3MaxHP = npc0MaxHP npc3Attack = npc0Attack npc3Defence = npc0Defence npc3Accuracy = npc0Accuracy npc3Evasion = npc0Evasion END IF IF npcToSpawn = 1 THEN npc1Alive = 1 IF npcToSpawn = 1 THEN SPRITE npc1SpriteNumber npc1SpriteX npc1SpriteY $npc1Sprite$$ IF npcToSpawn = 2 THEN npc2Alive = 1 IF npcToSpawn = 2 THEN SPRITE npc2SpriteNumber npc2SpriteX npc2SpriteY $npc2Sprite$$ IF npcToSpawn = 3 THEN npc3Alive = 1 IF npcToSpawn = 3 THEN SPRITE npc3SpriteNumber npc3SpriteX npc3SpriteY $npc3Sprite$$ END IF END IF END IF END IFEND TIMERGOTOCARD roomCard
Woah, isn't there a 500LOC limit or something?