Topic:   Roguesoft RPG Engine?   (Read 94834 times)


0 Members and 2 Guests are viewing this topic.

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Roguesoft RPG Engine?
« Reply #105 on: April 30, 2010, 04:27:04 AM »
Main Keydown (continued)
Code: [Select]
    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"
I survived the spammage of 2007

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Roguesoft RPG Engine?
« Reply #106 on: April 30, 2010, 04:27:57 AM »
Main Keydown (continued)
Code: [Select]
      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 IF

END KEYDOWN
I survived the spammage of 2007

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Roguesoft RPG Engine?
« Reply #107 on: April 30, 2010, 04:30:20 AM »
Main Timer
Code: [Select]
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
« Last Edit: April 30, 2010, 04:30:48 AM by Silverwind »
I survived the spammage of 2007

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Roguesoft RPG Engine?
« Reply #108 on: April 30, 2010, 04:33:37 AM »
Main Timer (continued)
Code: [Select]
      '--- 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
I survived the spammage of 2007

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Roguesoft RPG Engine?
« Reply #109 on: April 30, 2010, 04:35:09 AM »
Main Timer (continued)
Code: [Select]
        '--- 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 IF
END 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
« Last Edit: April 30, 2010, 04:36:02 AM by Silverwind »
I survived the spammage of 2007

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Roguesoft RPG Engine?
« Reply #110 on: April 30, 2010, 04:36:57 AM »
Main Timer (continued)
Code: [Select]
      '--- 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
I survived the spammage of 2007

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Roguesoft RPG Engine?
« Reply #111 on: April 30, 2010, 04:37:40 AM »
Main Timer (continued)
Code: [Select]
          '--- 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
« Last Edit: April 30, 2010, 04:38:11 AM by Silverwind »
I survived the spammage of 2007

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Roguesoft RPG Engine?
« Reply #112 on: April 30, 2010, 04:39:08 AM »
Main Timer (continued)
Code: [Select]
          '--- 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 IF
END TIMER

GOTOCARD roomCard
I survived the spammage of 2007

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Roguesoft RPG Engine?
« Reply #113 on: April 30, 2010, 07:51:09 AM »
I've got everything working now except for the Use/Equip button. I'm nearly at 500 lines too, but I think I'll manage.
I survived the spammage of 2007

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: Roguesoft RPG Engine?
« Reply #114 on: April 30, 2010, 09:37:08 AM »
The best part bout silvers codes is the fact that I can read it ;)
This Cannot be, NOOOOOOOO!!!!

-Gnomes Cry when the McRib was discontinued again.

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Roguesoft RPG Engine?
« Reply #115 on: April 30, 2010, 03:34:21 PM »
Aye, we must all become well versed in "the Way of the Tab".

I'm getting better at giving variables explanatory names too. :)
« Last Edit: April 30, 2010, 03:36:07 PM by Silverwind »
I survived the spammage of 2007

Mystor


  • GMG-er

  • **


  • Posts: 696

  • I am the myst that consumes us all.
Re: Roguesoft RPG Engine?
« Reply #116 on: May 02, 2010, 01:24:29 PM »
Woah, isn't there a 500LOC limit or something? (Or is that 500LOC and I suck at guesstimating)
I have a load of homework ATM, but I may get started on a RPG soon with some of that stuffs :P

EDIT: also, this code deserves it's own topic.
« Last Edit: May 02, 2010, 01:24:57 PM by mistron »
"I'll lie to him."
"And if that doesn't work?"
"Then I'll tell the truth. We're allowed to do that, in emergencies. We can't plan for everything, you know."
   -Colonel Graff, Ender&

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: Roguesoft RPG Engine?
« Reply #117 on: May 02, 2010, 04:20:13 PM »
Quote
Woah, isn't there a 500LOC limit or something?

The current limit for lines of code in GameMaker is 750 lines per script.

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Roguesoft RPG Engine?
« Reply #118 on: May 02, 2010, 04:59:19 PM »
Yup, although 1,500 is required to make a room work. I'm using the cross card natures of KEYDOWN and TIMER events to great effect. :)
I survived the spammage of 2007

Mystor


  • GMG-er

  • **


  • Posts: 696

  • I am the myst that consumes us all.
Re: Roguesoft RPG Engine?
« Reply #119 on: May 02, 2010, 05:39:52 PM »
haha, ok
Just checking, because it LOOKED like you were a BIT over 500LOC there :P
"I'll lie to him."
"And if that doesn't work?"
"Then I'll tell the truth. We're allowed to do that, in emergencies. We can't plan for everything, you know."
   -Colonel Graff, Ender&