mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-02-24 00:29:12 +00:00
Proper support for setting/increasing/decreasing stats by a variable amount.
This commit is contained in:
parent
2fb2f3660f
commit
8933f2ef38
@ -106,6 +106,7 @@
|
||||
</block>
|
||||
</value>
|
||||
</block>
|
||||
<block type="text_printnum"></block>
|
||||
<block type="text_storybook">
|
||||
<value name="INTRO">
|
||||
<block type="text">
|
||||
@ -136,8 +137,11 @@
|
||||
<category name="Interaction">
|
||||
<block type="interaction_get_stat"></block>
|
||||
<block type="interaction_increase_stat"></block>
|
||||
<block type="interaction_increase_stat_expr"></block>
|
||||
<block type="interaction_decrease_stat"></block>
|
||||
<block type="interaction_decrease_stat_expr"></block>
|
||||
<block type="interaction_set_stat"></block>
|
||||
<block type="interaction_set_stat_expr"></block>
|
||||
<block type="interaction_get_flag"></block>
|
||||
<block type="interaction_set_flag"></block>
|
||||
<block type="interaction_clr_flag"></block>
|
||||
|
@ -507,6 +507,18 @@ if (typeof Mythos === "undefined") {
|
||||
this.setTooltip('Print text and leave cursor at end of last printed character');
|
||||
}
|
||||
};
|
||||
Blockly.Blocks['text_printnum'] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Mythos.helpUrl);
|
||||
this.setColour(54);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.appendValueInput("VALUE")
|
||||
.appendField("Print number");
|
||||
this.setOutput(false);
|
||||
this.setTooltip('Print a number and leave cursor at end of last printed character');
|
||||
}
|
||||
};
|
||||
Blockly.Blocks['text_storybook'] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Mythos.helpUrl);
|
||||
@ -628,7 +640,7 @@ if (typeof Mythos === "undefined") {
|
||||
Blockly.Blocks['text_getnumber'] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Mythos.helpUrl);
|
||||
this.setColour(54);
|
||||
this.setColour(Blockly.Blocks.logic.HUE);
|
||||
this.appendDummyInput()
|
||||
.appendField("Get Number");
|
||||
this.setOutput(true, "Number");
|
||||
@ -820,6 +832,20 @@ if (typeof Mythos === "undefined") {
|
||||
this.setTooltip('Set a player stat');
|
||||
}
|
||||
};
|
||||
Blockly.Blocks['interaction_set_stat_expr'] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Mythos.helpUrl);
|
||||
this.setColour(54);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.appendValueInput("EXPR")
|
||||
.appendField("Set player's")
|
||||
.appendField(new Blockly.FieldTextInput(""), "NAME")
|
||||
.appendField("stat to");
|
||||
this.setOutput(false);
|
||||
this.setTooltip('Set a player stat by variable amount');
|
||||
}
|
||||
};
|
||||
Blockly.Blocks['interaction_increase_stat'] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Mythos.helpUrl);
|
||||
@ -835,6 +861,20 @@ if (typeof Mythos === "undefined") {
|
||||
this.setTooltip('Increase stat of player');
|
||||
}
|
||||
};
|
||||
Blockly.Blocks['interaction_increase_stat_expr'] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Mythos.helpUrl);
|
||||
this.setColour(54);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.appendValueInput("EXPR")
|
||||
.appendField("Increase player's")
|
||||
.appendField(new Blockly.FieldTextInput(""), "NAME")
|
||||
.appendField("stat by");
|
||||
this.setOutput(false);
|
||||
this.setTooltip('Increase stat of player by variable amount');
|
||||
}
|
||||
};
|
||||
Blockly.Blocks['interaction_decrease_stat'] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Mythos.helpUrl);
|
||||
@ -850,6 +890,20 @@ if (typeof Mythos === "undefined") {
|
||||
this.setTooltip('Decrease stat of player');
|
||||
}
|
||||
};
|
||||
Blockly.Blocks['interaction_decrease_stat_expr'] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Mythos.helpUrl);
|
||||
this.setColour(54);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.appendValueInput("EXPR")
|
||||
.appendField("Decrease player's")
|
||||
.appendField(new Blockly.FieldTextInput(""), "NAME")
|
||||
.appendField("stat by");
|
||||
this.setOutput(false);
|
||||
this.setTooltip('Decrease stat of player by variable amount');
|
||||
}
|
||||
};
|
||||
Blockly.Blocks['interaction_increase_party_stats'] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Mythos.helpUrl);
|
||||
|
@ -4901,6 +4901,8 @@ end
|
||||
case 'text_print':
|
||||
case 'text_println':
|
||||
packTextPrint(blk, 'VALUE'); break
|
||||
case 'text_printnum':
|
||||
packTextPrintNum(blk); break
|
||||
case 'text_storybook':
|
||||
packStoryBook(blk); break
|
||||
case 'text_clear_window':
|
||||
@ -4957,8 +4959,11 @@ end
|
||||
case 'interaction_unbench_player':
|
||||
packUnbenchPlayer(blk); break
|
||||
case 'interaction_increase_stat':
|
||||
case 'interaction_increase_stat_expr':
|
||||
case 'interaction_decrease_stat':
|
||||
case 'interaction_decrease_stat_expr':
|
||||
case 'interaction_set_stat':
|
||||
case 'interaction_set_stat_expr':
|
||||
packChangeStat(blk); break
|
||||
case 'interaction_increase_party_stats':
|
||||
case 'interaction_decrease_party_stats':
|
||||
@ -5053,6 +5058,16 @@ end
|
||||
outTextBlock(valBlk, blk.@type == 'text_println', true)
|
||||
}
|
||||
|
||||
def packTextPrintNum(blk)
|
||||
{
|
||||
def valBlk = getSingle(blk.value, 'VALUE').block
|
||||
assert valBlk.size() == 1
|
||||
outIndented("scriptDisplayStr(sprintf1(\"%d\", ")
|
||||
assert valBlk.size() == 1
|
||||
packExpr(valBlk[0])
|
||||
out << "))\n"
|
||||
}
|
||||
|
||||
def packStoryBook(blk)
|
||||
{
|
||||
assert blk.value[0].@name == 'INTRO'
|
||||
@ -5212,20 +5227,31 @@ end
|
||||
|
||||
def packChangeStat(blk)
|
||||
{
|
||||
assert blk.field.size() == 2
|
||||
assert blk.field.size() >= 1
|
||||
assert blk.field[0].@name == 'NAME'
|
||||
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)
|
||||
if (blk.@type == 'interaction_set_stat')
|
||||
outIndented("setStat(global=>p_players, $stat, $amount)\n")
|
||||
if (blk.@type == 'interaction_set_stat' || blk.@type == 'interaction_set_stat_expr')
|
||||
outIndented("setStat(global=>p_players, $stat, ")
|
||||
else {
|
||||
def operator = blk.@type == 'interaction_increase_stat' ? '+' : '-'
|
||||
def operator = (blk.@type == 'interaction_increase_stat' || blk.@type == 'interaction_increase_stat_expr') ? '+' : '-'
|
||||
outIndented(
|
||||
"setStat(global=>p_players, $stat, getStat(global=>p_players, $stat) $operator $amount)\n")
|
||||
"setStat(global=>p_players, $stat, getStat(global=>p_players, $stat) $operator ")
|
||||
}
|
||||
|
||||
if (blk.field.size() >= 2) {
|
||||
assert blk.field.size() == 2
|
||||
assert blk.field[1].@name == 'AMOUNT' || blk.field[1].@name == 'NUMBER'
|
||||
def amount = blk.field[1].text().toInteger()
|
||||
assert amount > 0 && amount < 32767
|
||||
out << amount
|
||||
}
|
||||
else {
|
||||
assert blk.value.size() == 1
|
||||
packExpr(blk.value[0].block[0], false)
|
||||
}
|
||||
|
||||
out << ")\n"
|
||||
}
|
||||
|
||||
def packChangePartyStats(blk)
|
||||
@ -5452,6 +5478,9 @@ end
|
||||
case 'text_getcharacter':
|
||||
out << "getCharResponse()"
|
||||
break
|
||||
case 'text_getnumber':
|
||||
out << "parseDec(getStringResponse())"
|
||||
break
|
||||
case 'logic_compare':
|
||||
packLogicCompare(blk)
|
||||
break
|
||||
|
@ -187,6 +187,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_TIME, S_XP, S_SP
|
||||
byte[] S_BANK_BAL
|
||||
|
||||
// Next: common events
|
||||
byte[] S_ENTER, S_LEAVE, S_USE
|
||||
@ -196,5 +197,4 @@ import gamelib
|
||||
|
||||
// Load/save filename
|
||||
byte[] S_GAME1_FILENAME
|
||||
|
||||
end
|
||||
|
@ -188,6 +188,7 @@ export byte[] S_GOLD = "Gold"
|
||||
export byte[] S_TIME = "Time"
|
||||
export byte[] S_XP = "XP"
|
||||
export byte[] S_SP = "SP"
|
||||
export byte[] S_BANK_BAL = "Bank bal"
|
||||
export byte[] S_PACK_SIZE = "Pack size"
|
||||
export byte[] S_ENTER = "Enter"
|
||||
export byte[] S_LEAVE = "Leave"
|
||||
@ -195,7 +196,6 @@ export byte[] S_USE = "Use"
|
||||
export byte[] S_HIS = "his"
|
||||
export byte[] S_HER = "her"
|
||||
export byte[] S_THEIR = "their"
|
||||
export byte[] S_BANK_BAL = "Bank bal"
|
||||
|
||||
word lastTick = 0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user