Fixed streqi logic for matching encounter zone codes. Added a Blockly for starting an encounter.

This commit is contained in:
Martin Haye 2016-06-28 07:40:09 -07:00
parent 30f3e92d37
commit 8ebbc16da8
6 changed files with 42 additions and 13 deletions

View File

@ -68,6 +68,7 @@
<block type="events_set_sky"></block>
<block type="events_set_ground"></block>
<block type="events_add_encounter_zone"></block>
<block type="events_start_encounter"></block>
</category>
<category name="Text">
<block type="text_window"></block>

View File

@ -391,6 +391,19 @@ if (typeof Mythos === "undefined") {
this.setTooltip('Add an encounter zone');
}
};
Blockly.Blocks['events_start_encounter'] = {
init: function () {
this.setHelpUrl(Mythos.helpUrl);
this.setColour(54);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.appendDummyInput()
.appendField("Start encounter with enemy code")
.appendField(new Blockly.FieldTextInput(""), "CODE");
this.setOutput(false);
this.setTooltip('Start an encounter');
}
};
Blockly.Blocks['text_window'] = {
init: function () {
this.setHelpUrl(Mythos.helpUrl);

View File

@ -2674,6 +2674,8 @@ end
packSetGround(blk); break
case 'events_add_encounter_zone':
packAddEncounterZone(blk); break
case 'events_start_encounter':
packStartEncounter(blk); break
case 'events_teleport':
packTeleport(blk); break
case 'events_move_backward':
@ -2900,6 +2902,13 @@ end
outIndented("addEncounterZone(${escapeString(code)}, $x, $y, $maxDist, $chance)\n")
}
def packStartEncounter(blk)
{
assert blk.field.size() == 1
def code = getSingle(blk.field, 'CODE')
outIndented("doCombat(${escapeString(code)})\n")
}
def packTeleport(blk)
{
assert blk.field.size() == 3

View File

@ -436,6 +436,10 @@ def startCombat(mapCode)
// Display portrait of first group
setPortrait(global=>p_enemyGroups=>p_enemies->b_image)
// Clear keyboard stobe, because while wandering the map, the player may have
// queued up movement keys, which are made obsolete by the surprise of combat.
^kbdStrobe
// 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()

View File

@ -16,6 +16,11 @@ const NULL = 0
const INT_MAX = 32767
const INT_MIN = -32768
///////////////////////////////////////////////////////////////////////////////////////////////////
// IO locations
const kbd = $C000
const kbdStrobe = $C010
///////////////////////////////////////////////////////////////////////////////////////////////////
// Memory manager definitions
@ -123,7 +128,7 @@ const calcPlayerArmor = gameLibVecs + 3*54
const diskActivity = gameLibVecs + 3*55
const rdkey = gameLibVecs + 3*56
const initHeap = gameLibVecs + 3*57
const UNUSED_FN_58 = gameLibVecs + 3*58
const doCombat = gameLibVecs + 3*58
const UNUSED_FN_59 = gameLibVecs + 3*59
const UNUSED_FN_60 = gameLibVecs + 3*60
const UNUSED_FN_61 = gameLibVecs + 3*61

View File

@ -19,9 +19,6 @@ const fontEngine = $E000 // main mem
///////////////////////////////////////////////////////////////////////////////////////////////////
// Other constants
const kbd = $C000
const kbdStrobe = $C010
const CHAR_WND_LIFE_X = 91
const CHAR_WND_GUN_X = 114
@ -109,7 +106,7 @@ predef _reboot, _brk, _encodeDice, _rollDice
predef _setPlural, _getStringResponse, _streqi, _addEncounterZone, _fatal
predef _pause, _tossStrings, _showMapName, _setMapWindow
predef _makeModifier, _randomFromArray, _calcPlayerArmor, _diskActivity
predef _rdkey, _initHeap
predef _rdkey, _initHeap, _doCombat
word gameLib_addrs = @_setScriptInfo, @_scriptDisplayStr, @_scriptDisplayStrNL, @_getYN
word = @_queue_setMap, @_setSky, @_setGround, @_queue_teleport, @_setPortrait, @_clearPortrait
@ -125,7 +122,7 @@ word = @_reboot, @_brk, @_encodeDice, @_rollDice
word = @_setPlural, @_getStringResponse, @_streqi, @_addEncounterZone, @_fatal
word = @_pause, @_tossStrings, @_showMapName, @_setMapWindow
word = @_makeModifier, @_randomFromArray, @_calcPlayerArmor, @_diskActivity
word = @_rdkey, @_initHeap
word = @_rdkey, @_initHeap, @_doCombat
word = 0 // end of library functions
@ -1893,19 +1890,19 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Compare two strings for equality, ignoring case.
def _streqi(a, b)
word limit
word limit, leneq
leneq = ^a == ^b
limit = a + min(^a, ^b)
while a < limit
a++; b++
while a <= limit
if charToUpper(^a) <> charToUpper(^b); return FALSE; fin
a++; b++
if charToUpper(^a) <> charToUpper(^b)
return FALSE
fin
loop
return ^a == ^b
return leneq
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def doCombat(mapCode)
def _doCombat(mapCode)
// Handled in a separate module. Clear enemies out of the heap when finished.
loadEngine(MODULE_COMBAT)=>combat_zoneEncounter(mapCode)
global=>p_enemyGroups = NULL