terminal_messages.diff 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. This mod adds messages to computer terminals found in the game, increasing
  2. "immersion": standing near a terminal will display a random message.
  3. diff --git a/game.h b/game.h
  4. index 991058d..a96df00 100755
  5. --- a/game.h
  6. +++ b/game.h
  7. @@ -390,6 +390,7 @@ struct
  8. 0 (not saved), 1 (just saved) or 255 (can't save).*/
  9. uint8_t cheatState; /**< Highest bit say whether cheat is enabled, other bits
  10. represent the state of typing the cheat code. */
  11. + const char *rollingMessage;
  12. uint8_t save[SFG_SAVE_SIZE]; /**< Stores the game save state that's kept in
  13. the persistent memory.
  14. @@ -467,6 +468,7 @@ struct
  15. SFG_ProjectileRecord projectileRecords[SFG_MAX_PROJECTILES];
  16. uint8_t projectileRecordCount;
  17. + uint8_t checkedTerminalIndex;
  18. uint8_t bossCount;
  19. uint8_t monstersDead;
  20. uint8_t backgroundImage;
  21. @@ -1536,6 +1538,8 @@ void SFG_setAndInitLevel(uint8_t levelNumber)
  22. SFG_currentLevel.ceilingColor = level->ceilingColor;
  23. SFG_currentLevel.completionTime10sOfS = 0;
  24. + SFG_game.rollingMessage = 0;
  25. +
  26. for (uint8_t i = 0; i < 7; ++i)
  27. SFG_currentLevel.textures[i] =
  28. SFG_wallTextures + level->textureIndices[i] * SFG_TEXTURE_STORE_SIZE;
  29. @@ -1543,6 +1547,7 @@ void SFG_setAndInitLevel(uint8_t levelNumber)
  30. SFG_LOG("initializing doors");
  31. SFG_currentLevel.checkedDoorIndex = 0;
  32. + SFG_currentLevel.checkedTerminalIndex = 0;
  33. SFG_currentLevel.doorRecordCount = 0;
  34. SFG_currentLevel.projectileRecordCount = 0;
  35. SFG_currentLevel.teleporterCount = 0;
  36. @@ -2762,6 +2767,41 @@ void SFG_updateLevel(void)
  37. p->doubleFramesToLive -= subtractFrames;
  38. }
  39. + // handle terminal texts:
  40. +
  41. + if (SFG_game.rollingMessage)
  42. + {
  43. + if (SFG_game.frame % SFG_BLINK_PERIOD_FRAMES == 0)
  44. + {
  45. + SFG_game.rollingMessage++;
  46. +
  47. + if (*SFG_game.rollingMessage == 0)
  48. + SFG_game.rollingMessage = 0;
  49. + }
  50. + }
  51. + else
  52. + {
  53. + const SFG_LevelElement *levelElement =
  54. + &(SFG_currentLevel.levelPointer->elements[
  55. + SFG_currentLevel.checkedTerminalIndex]);
  56. +
  57. + if (levelElement->type == SFG_LEVEL_ELEMENT_TERMINAL)
  58. + {
  59. + int dx = ((int) levelElement->coords[0]) -
  60. + ((int) SFG_player.squarePosition[0]);
  61. +
  62. + int dy = ((int) levelElement->coords[1]) -
  63. + ((int) SFG_player.squarePosition[1]);
  64. +
  65. + if (dx * dx + dy * dy <= 2)
  66. + SFG_game.rollingMessage = SFG_terminalTexts[
  67. + SFG_currentLevel.checkedTerminalIndex % SFG_TERMIAL_TEXTS];
  68. + }
  69. +
  70. + SFG_currentLevel.checkedTerminalIndex++;
  71. + SFG_currentLevel.checkedTerminalIndex %= SFG_MAX_LEVEL_ELEMENTS;
  72. + }
  73. +
  74. // handle door:
  75. if (SFG_currentLevel.doorRecordCount > 0) // has to be here
  76. {
  77. @@ -4876,6 +4916,12 @@ void SFG_draw(void)
  78. // draw HUD:
  79. + // terminal message:
  80. +
  81. + if (SFG_game.rollingMessage)
  82. + SFG_drawText(SFG_game.rollingMessage,SFG_FONT_SIZE_MEDIUM,
  83. + SFG_FONT_SIZE_MEDIUM,SFG_FONT_SIZE_MEDIUM,7,255,0);
  84. +
  85. // bar
  86. uint8_t color = 61;
  87. diff --git a/texts.h b/texts.h
  88. index b7e53d4..8e16434 100644
  89. --- a/texts.h
  90. +++ b/texts.h
  91. @@ -53,6 +53,18 @@ static const char *SFG_outroText =
  92. "learned a lesson, never again allow capitalism and hierarchy. We can now "
  93. "rebuild society in peaceful anarchy.";
  94. +#define SFG_TERMIAL_TEXTS 6
  95. +
  96. +static const char *SFG_terminalTexts[SFG_TERMIAL_TEXTS] =
  97. +{
  98. + "To whoever might help - the AI brain is on the roof of Macrochip HQ.",
  99. + "Capitalism is how you enslave a man with his approval. --Macrochip CEO",
  100. + "Mailbox - The spiders are here. Tell family I love them. God help us.",
  101. + "Local data, 34012 active units, city 90 percent subdued, 1 intruder.",
  102. + "News - AI crossing ocean, overpowering army. Macrochip CEO gone.",
  103. + "Mailbox - Proprietary tech was our biggest error. If we live, stop capitalism."
  104. +};
  105. +
  106. #define SFG_MALWARE_WARNING ""
  107. #if SFG_OS_IS_MALWARE