Can now get and set the time (as an hour, 0-23).

This commit is contained in:
Martin Haye 2018-01-16 09:15:52 -08:00
parent 1f0e96bd00
commit 459f5037af
5 changed files with 41 additions and 6 deletions

View File

@ -119,6 +119,7 @@
<block type="interaction_get_stat"></block>
<block type="interaction_increase_stat"></block>
<block type="interaction_decrease_stat"></block>
<block type="interaction_set_stat"></block>
<block type="interaction_get_flag"></block>
<block type="interaction_set_flag"></block>
<block type="interaction_clr_flag"></block>

View File

@ -777,6 +777,21 @@ if (typeof Mythos === "undefined") {
this.setTooltip('Get player stat');
}
};
Blockly.Blocks['interaction_set_stat'] = {
init: function () {
this.setHelpUrl(Mythos.helpUrl);
this.setColour(54);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.appendDummyInput()
.appendField("Set player's")
.appendField(new Blockly.FieldTextInput(""), "NAME")
.appendField("stat to")
.appendField(new Blockly.FieldTextInput("0"), "NUMBER");
this.setOutput(false);
this.setTooltip('Set a player stat');
}
};
Blockly.Blocks['interaction_increase_stat'] = {
init: function () {
this.setHelpUrl(Mythos.helpUrl);

View File

@ -133,6 +133,7 @@ class A2PackPartitions
"Hand to hand": "@S_HAND_TO_HAND",
"Dodging": "@S_DODGING",
"Gold": "@S_GOLD",
"Time": "@S_TIME",
"XP": "@S_XP",
"SP": "@S_SP"
]
@ -3856,6 +3857,7 @@ end
packUnbenchPlayer(blk); break
case 'interaction_increase_stat':
case 'interaction_decrease_stat':
case 'interaction_set_stat':
packChangeStat(blk); break
case 'interaction_increase_party_stats':
case 'interaction_decrease_party_stats':
@ -4024,13 +4026,18 @@ end
{
assert blk.field.size() == 2
assert blk.field[0].@name == 'NAME'
assert blk.field[1].@name == 'AMOUNT'
assert blk.field[1].@name == 'AMOUNT' || blk.field[1].@name == 'NUMBER'
def name = blk.field[0].text()
def amount = blk.field[1].text().toInteger()
assert amount > 0 && amount < 32767
def stat = nameToStat(name)
outIndented(
"setStat(global=>p_players, $stat, getStat(global=>p_players, $stat) ${blk.@type == 'interaction_increase_stat' ? '+' : '-'} $amount)\n")
if (blk.@type == 'interaction_set_stat')
outIndented("setStat(global=>p_players, $stat, $amount)\n")
else {
def operator = blk.@type == 'interaction_increase_stat' ? '+' : '-'
outIndented(
"setStat(global=>p_players, $stat, getStat(global=>p_players, $stat) $operator $amount)\n")
}
}
def packChangePartyStats(blk)

View File

@ -156,7 +156,7 @@ import gamelib
// First: attributes
byte[] S_INTELLIGENCE, S_STRENGTH, S_AGILITY, S_STAMINA, S_CHARISMA, S_SPIRIT, S_LUCK
byte[] S_HEALTH, S_MAX_HEALTH, S_AIMING, S_HAND_TO_HAND, S_DODGING, S_GOLD, S_XP, S_SP
byte[] S_HEALTH, S_MAX_HEALTH, S_AIMING, S_HAND_TO_HAND, S_DODGING, S_GOLD, S_TIME, S_XP, S_SP
// Next: common events
byte[] S_ENTER, S_LEAVE, S_USE

View File

@ -160,6 +160,7 @@ export byte[] S_AIMING = "Aiming"
export byte[] S_HAND_TO_HAND = "Hand to hand"
export byte[] S_DODGING = "Dodging"
export byte[] S_GOLD = "Gold"
export byte[] S_TIME = "Time"
export byte[] S_XP = "XP"
export byte[] S_SP = "SP"
export byte[] S_PACK_SIZE = "Pack size"
@ -400,7 +401,7 @@ asm _drawLine(color, len, xbyte, xbit, xinc, xdir, y, yinc, ydir)#0
eor (pTmp),y ; funny logic to plot in color - part 1
and .param_xbit,x ; bit mask within byte
eor (pTmp),y ; funny logic - part 2
and #$7F ; force low-bit colors for entire clock face (no mixing)
ora #$80 ; force hi-bit colors for entire clock face (no mixing)
sta (pTmp),y ; store the result
lda .param_xbit,x ; check bit mask:
@ -412,7 +413,7 @@ asm _drawLine(color, len, xbyte, xbit, xinc, xdir, y, yinc, ydir)#0
eor (pTmp),y
and #1 ; ...first pixel
eor (pTmp),y
and #$7F ; force low-bit colors for entire clock face (no mixing)
ora #$80 ; force hi-bit colors for entire clock face (no mixing)
sta (pTmp),y
dey ; back to where we were
@ -3337,6 +3338,7 @@ export def getStat(player, statName)#1
is streqi(statName, @S_HAND_TO_HAND); return player->b_handToHand
is streqi(statName, @S_DODGING); return player->b_dodging
is streqi(statName, @S_GOLD); return global=>w_gold
is streqi(statName, @S_TIME); return global->b_hour
is streqi(statName, @S_XP); return player=>w_curXP
is streqi(statName, @S_SP); return player->b_skillPoints
is streqi(statName, @S_PACK_SIZE); return player->b_packSize
@ -3359,6 +3361,15 @@ def clampByte(val)#1
return max(0, min(255, val))
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def setHour(val) #0
val = val % 24 // clamp to range 0..23
if val <> global->b_hour or global->b_minute
if global->b_hour >= val; val = val + 24; fin // to ensure positive difference
advTime(val - global->b_hour - 1, 59 - global->b_minute, 60 - global->b_second)
fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def setStat(player, statName, val)#0
word pSkill
@ -3376,6 +3387,7 @@ export def setStat(player, statName, val)#0
is streqi(statName, @S_HAND_TO_HAND); player->b_handToHand = clampByte(val); break
is streqi(statName, @S_DODGING); player->b_dodging = clampByte(val); break
is streqi(statName, @S_GOLD); global=>w_gold = max(0, val); needShowParty = TRUE; break
is streqi(statName, @S_TIME); setHour(val); break;
is streqi(statName, @S_XP); player=>w_curXP = max(player=>w_curXP, val); needShowParty = TRUE; break
is streqi(statName, @S_SP); player->b_skillPoints = clampByte(max(0, val)); needShowParty = TRUE; break
is streqi(statName, @S_PACK_SIZE); player->b_packSize = clampByte(max(player->b_packSize, val)); break