diff --git a/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy b/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy index 3618380b..d259170d 100644 --- a/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy +++ b/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy @@ -1529,8 +1529,8 @@ class PackPartitions out.println(" return makeEnemy(" + "\"$name\", " + "${parseDice(hitPoints)}, " + - "PORTRAIT_${humanNameToSymbol(image1, true)}, " + - (image2.size() > 0 ? "PORTRAIT_${humanNameToSymbol(image2, true)}, " : "0, ") + + "PO${humanNameToSymbol(image1, false)}, " + + (image2.size() > 0 ? "PO${humanNameToSymbol(image2, false)}, " : "0, ") + "$attackTypeCode, " + "\"$attackText\", " + "${range.replace("'", "").toInteger()}, " + @@ -1562,7 +1562,7 @@ class PackPartitions } if (animFrameNum <= 1) { ++portraitNum - out.println "const PORTRAIT_${humanNameToSymbol(name, true)} = $portraitNum" + out.println "const PO${humanNameToSymbol(name, false)} = $portraitNum" } } } diff --git a/Platform/Apple/virtual/src/plasma/combat.pla b/Platform/Apple/virtual/src/plasma/combat.pla index 4ea11b80..3e6db327 100644 --- a/Platform/Apple/virtual/src/plasma/combat.pla +++ b/Platform/Apple/virtual/src/plasma/combat.pla @@ -11,6 +11,8 @@ include "gamelib.plh" include "playtype.plh" include "gen_images.plh" +include "gen_enemies.plh" +include "gen_modules.plh" word global @@ -171,7 +173,7 @@ end /////////////////////////////////////////////////////////////////////////////////////////////////// def displayOption(key, str) buildString(@addToString) - printf2(" (%c)^T033%s\n", key, str) + printf2("\n (%c)^T033%s ", key, str) rawDisplayStr(finishString(0)) end @@ -217,7 +219,6 @@ def playerCombatChoose(pl) otherwise displayStr("Decisions, decisions..."); break wend - displayStr("\n") displayOption('M', "Melee") if pWeapon @@ -240,6 +241,7 @@ def playerCombatChoose(pl) while TRUE pl->b_combatChoice = getUpperKey() + displayStr("\n") when pl->b_combatChoice is 'M' return @@ -385,19 +387,54 @@ def determineCombatOrder() loop end +/////////////////////////////////////////////////////////////////////////////////////////////////// +def makeEnemyGroup(enemyFunc) + word p, enem, groupSize + p = mmgr(HEAP_ALLOC, TYPE_ENEMY_GROUP) + enem = enemyFunc() + p->b_enemyGroupRange = max(1, rand16() % (enem->b_enemyAttackRange)) + if enem=>r_groupSize == 0 // handle unique enemies + groupSize = 1 + else + groupSize = rollDice(enem=>r_groupSize) + fin + addToList(p + p_enemies, enem) + while groupSize > 1 + addToList(p + p_enemies, enemyFunc()) + groupSize = groupSize - 1 + loop + + return p +end + +/////////////////////////////////////////////////////////////////////////////////////////////////// +def makeAllEnemies() + word enemiesModule + word enemyNum, enemyTbl, enemyFunc + + enemiesModule = mmgr(QUEUE_LOAD, MODULE_GEN_ENEMIES<<8 | RES_TYPE_MODULE) + mmgr(FINISH_LOAD, 1) // 1 = keep open + + global=>p_enemyGroups = NULL + enemyNum = rand16() % NUM_ENEMIES + enemyTbl = enemiesModule() + enemyFunc = *((enemyNum<<1) + enemyTbl) + addToList(@global=>p_enemyGroups, makeEnemyGroup(enemyFunc)) + + mmgr(FREE_MEMORY, enemiesModule) +end + /////////////////////////////////////////////////////////////////////////////////////////////////// def startCombat() word p, p2, n, s // Setup isFleeing = FALSE + makeAllEnemies() // Display portrait of first group setPortrait(global=>p_enemyGroups=>p_enemies->b_image) - // If portrait was already in memory, the memory mgr load might still be open. Close it. - mmgr(FINISH_LOAD, 0) - // We're going to do all our text drawing in window 2. Also, might as well // set everything up so that the map gets redrawn when combat finishes. setWindow2() @@ -447,10 +484,10 @@ def startCombat() while TRUE n = getUpperKey() if n == 'B' - displayStr("\nBattle!\n") + displayStr("\n\nBattle! \n") return TRUE elsif n == 'F' - displayStr("\nCoward.") + displayStr("\n\nCoward. ") return FALSE fin beep() @@ -481,7 +518,7 @@ def doCombat() p = global=>p_combatFirst while p if !nPlayersFighting - setPortrait(PORTRAIT_DEATH) + setPortrait(POdeath) when rand16() % 2 is 0 displayStr("\nYou bought the farm, with your life! Thanks for playing! Reload last save?\n"); break @@ -495,7 +532,7 @@ def doCombat() fin reboot() elsif !nEnemiesFighting - setPortrait(PORTRAIT_COMBATWIN) + setPortrait(POcombatwin) when rand16() % 3 is 0 displayStr("\nYou survive the ordeal and rifle through the carnage.\n"); break diff --git a/Platform/Apple/virtual/src/plasma/gameloop.pla b/Platform/Apple/virtual/src/plasma/gameloop.pla index 6c42e47a..0c95bde6 100644 --- a/Platform/Apple/virtual/src/plasma/gameloop.pla +++ b/Platform/Apple/virtual/src/plasma/gameloop.pla @@ -1869,31 +1869,8 @@ def _makeEnemy(name, healthDice, image0, image1, attackType, attackText, attackR return p end -/////////////////////////////////////////////////////////////////////////////////////////////////// -def makeEnemyGroup(enemyFunc) - word p, enem, groupSize - p = mmgr(HEAP_ALLOC, TYPE_ENEMY_GROUP) - enem = enemyFunc() - p->b_enemyGroupRange = max(1, rand16() % (enem->b_enemyAttackRange)) - if enem=>r_groupSize == 0 // handle unique enemies - groupSize = 1 - else - groupSize = rollDice(enem=>r_groupSize) - fin - addToList(p + p_enemies, enem) - while groupSize > 1 - addToList(p + p_enemies, enemyFunc()) - groupSize = groupSize - 1 - loop - - return p -end - /////////////////////////////////////////////////////////////////////////////////////////////////// def testCombat() - word globalScripts - word enemiesModule - word enemyNum, enemyTbl, enemyFunc word combatEngine word x, y byte dir @@ -1905,21 +1882,8 @@ def testCombat() mmgr(RESET_MEMORY, 0) renderLoaded = FALSE combatEngine = mmgr(QUEUE_LOAD, MODULE_COMBAT<<8 | RES_TYPE_MODULE) - globalScripts = mmgr(QUEUE_LOAD, MODULE_GLOBAL_SCRIPTS<<8 | RES_TYPE_MODULE) - enemiesModule = mmgr(QUEUE_LOAD, MODULE_GEN_ENEMIES<<8 | RES_TYPE_MODULE) mmgr(FINISH_LOAD, 1) // 1 = keep open - // Create the enemy group(s). - global=>p_enemyGroups = NULL - enemyNum = rand16() % NUM_ENEMIES - enemyTbl = enemiesModule() - enemyFunc = *((enemyNum<<1) + enemyTbl) - addToList(@global=>p_enemyGroups, makeEnemyGroup(enemyFunc)) - - // No need for the global scripts now that everything has been created - mmgr(FREE_MEMORY, globalScripts) - mmgr(FREE_MEMORY, enemiesModule) - // Run the combat engine combatEngine()