<h2>Encounter creation</h2>|MONSTER_LIST>[{
<ul>
<li>Player - SKILL: (print: $player's skill) STAMINA: (print: $player's stamina) LUCK: (print: $player's luck)</li>
(if: $monsters is not (a:))[
(set: _i to 0)
(for: each _monster, ...$monsters)[
(set: _i to it + 1)
(set: _monster's index to _i)
(set: $monsters's (_i) to _monster)
<li>(print:_monster's name) - SKILL: (print: _monster's skill) STAMINA: (print: _monster's stamina) - (link-reveal:"Remove")[(set: $monsters to it - (a: _monster))(rerun: ?MONSTER_LIST)]</li>
]
]
</ul>
(if: $monsters's length > 1)[
<div>(dropdown: 2bind $method,
"Roll Attack Strength against each adversary",
"Roll Attack Strength only once per round")</div>
]
(if: $monsters is not (a:))[
[[Begin combat!->Battle]]
]
}]
<div class="player-stats">
Player LUCK
(input-box: bind $p_luck, "XXXX=", 1, "9")
Player SKILL
(input-box: bind $p_skill, "XXXX=", 1, "9")
Player STAMINA
(input-box: bind $p_stamina, "XXXX=", 1, "19")
(link-repeat:"Update player stats")[{
(if: $p_skill matches (p: (p-many:digit)))[
(set: $player's max_skill to (num: $p_skill))
(set: $player's skill to (num: $p_skill))
]
(if: $p_stamina matches (p: (p-many:digit)))[
(set: $player's max_stamina to (num: $p_stamina))
(set: $player's stamina to (num: $p_stamina))
]
(if: $p_luck matches (p: (p-many:digit)))[
(set: $player's max_luck to (num: $p_luck))
(set: $player's luck to (num: $p_luck))
]
(rerun: ?MONSTER_LIST)
}]
</div><div class="enemy-stats">
Enemy name:
(input-box: bind $m_name, "XXXX=", 1)
Enemy SKILL:
(input-box: bind $m_skill, "XXXX=", 1)
Enemy STAMINA
(input-box: bind $m_stamina, "XXXX=", 1)
(link-repeat:"Add monster to encounter")[{
(if: $m_skill matches (p: (p-many:digit)) and
$m_stamina matches (p: (p-many:digit)) and
$m_name is not an empty
) [
(set:_monster to (dm:
"name", $m_name,
"skill", (num: $m_skill),
"stamina", (num: $m_stamina)
))
(set: $monsters to it + (a: _monster))
(rerun: ?MONSTER_LIST)
](else:)[
(dialog:"Invalid input(s), please check and retry.")
]
}]
</div>[{(display: "FUNCTIONS")
(set: $player to (dm:
"max_skill", 9,
"max_stamina", 19,
"max_luck", 9,
"skill", 9,
"stamina", 19,
"luck", 9
))
(set: $monsters to (a:))
(set: $method to "Roll Attack Strength against each adversary")
}]{(set: $monster_backup to $monsters)
(if: $method is "Roll Attack Strength against each adversary")[
(set: $attack_rules to "DEFAULT ATTACK")
](else:)[
(set: $attack_rules to "ALTERNATIVE ATTACK")
]
<h2>Battle Testing</h2>
}(display: "FIGHT")
|win)[
(set: $monsters to $monster_backup)
(set: $player's stamina to $player's max_stamina)
(set: $player's skill to $player's max_skill)
(set: $player's luck to $player's max_luck)
(goto: "Start")
]
|lose)[(show: ?win)](if: $monsters is not (a:))[{
|TALLY_MONSTERS>[
(for: each _monster, ...$monsters) [
(if: _monster's stamina <= 0) [
(set: $monsters to it - (a: _monster))
]
]
]
|INITIAL_MONSTER_LIST>[
<span>YOU: <b>SKILL</b>: (print: $player's skill)
<b>STAMINA</b>: (print: $player's stamina)
<b>LUCK</b>: (print: $player's luck)</span>
<ol>
(rerun:?TALLY_MONSTERS)(hide:?ATTACK_ACTIONS)
(set: _i to 1)
(for: each _monster, ...$monsters) [
(set: _monster's index to _i)
<li>(print: _monster's name)
<b>SKILL</b>: (print: _monster's skill)
<b>STAMINA</b>: (print: _monster's stamina)
(link: "Attack!")|ATTACK_OPTION>[
(set: $target to _monster)
(hide: ?INITIAL_MONSTER_LIST)
(show: ?ATTACK)
]
(set: _i to it + 1)
</li>
]
</ol>]
|MONSTER_LIST)[<ol>
(rerun:?TALLY_MONSTERS)(hide:?ATTACK_ACTIONS)
<span>YOU: <b>SKILL</b>: (print: $player's skill)
<b>STAMINA</b>: (print: $player's stamina)
<b>LUCK</b>: (print: $player's luck)</span>
(set: _i to 1)
(for: each _monster, ...$monsters) [
(set: _monster's index to _i)
<li>(print: _monster's name)
<b>SKILL</b>: (print: _monster's skill)
<b>STAMINA</b>: (print: _monster's stamina)
(link: "Attack!")|ATTACK_OPTION>[
(set: $target to _monster)
(hide: ?MONSTER_LIST)
(rerun: ?ATTACK)
]
(set: _i to it + 1)
</li>
]
</ol>]
|ATTACK)[
(rerun: ?TALLY_MONSTERS)
(show:?ATTACK_RESULTS)
(set: $combat_stage to "combat")
(display: $attack_rules)
(show:?ATTACK_ACTIONS)
(rerun:?ATTACK_ACTIONS)
(set: $combat_stage to "post-combat")
(for: each _monster, ...$monsters) [
(if: _monster contains "special")[
(display: _monster's special)
]
]
]
|ATTACK_RESULTS)[]
|ATTACK_ACTIONS)[
(rerun: ?TALLY_MONSTERS)
[
(if: $monsters is an empty) [
(link-rerun:'<p class="win">The battle is won.</p>')[(show: ?win)]
] (elseif: $player's stamina <= 0) [
(link-rerun:'<p class="lose">The battle is lost.</p>')[(show: ?lose)]
] (else:) [
(link-rerun:"Combat continues...")[(display: "ATTACK ACTIONS")]
]
]<ACTION_OPTIONS|
(set: $combat_stage to "combat-actions")
(for: each _monster, ...$monsters) [
(if: _monster contains "special")[
(display: _monster's special)
]
]
]
}](replace:?ATTACK_RESULTS)[{
(set: _order to (range: 1, $monsters's length))
<ol>
(for: each _i, ..._order) [
<li>
(set: _monster to $monsters's (_i))
(set: _die_1 to (random: 1, 6))
(set: _die_2 to (random: 1, 6))
(set: _die_3 to (random: 1, 6))
(set: _die_4 to (random: 1, 6))
(set: _player_roll to _die_1 + _die_2 + $player's skill)
(set: _monster_roll to _die_3 + _die_4 + _monster's skill)
|CALCULATE_DAMAGE>[
(if: _player_roll < _monster_roll)[
($STAMINA: -2)
] (elseif: _player_roll > _monster_roll) [
(if: $target's index is _i) [
(set: _monster's stamina to it - 2)
]
]
]
|DISPLAY_RESULTS>[
<ul>
(if: $target's index is _i) [
<li>You attack <b>(print: _monster's name)</b>, rolling (str: _die_1) + (str: _die_2). ATTACK STRENGTH: (str: _player_roll)</li>
<li>It rolls: (str: _die_3) + (str: _die_4). ATTACK STRENGTH: (print: _monster_roll).</li>
] (else:) [
<li>(print: _monster's name) attacks, rolling (str: _die_3) + (str: _die_3). ATTACK STRENGTH: (str: _monster_roll).</li>
<li>Your roll: (str: _die_1) + (str: _die_2). ATTACK STRENGTH: (str: _player_roll)</li>
]
(if: _player_roll is _monster_roll) [
(if: $target's index is _i) [
<li>You dodge each other's blows.</li>
] (else:) [
<li>You parry the attack.</li>
]
] (elseif: $target's index is _i) [
(if: _player_roll < _monster_roll) [
<li>It hits! (display: "LUCKY DODGE")</li>
] (else:) [
<li>You hit it!
(if: _monster's stamina > 0)[
(display: "LUCKY STRIKE")
] (else:) [
The blow is fatal!
]
</li>]
] (else:) [
(if: _player_roll < _monster_roll) [
<li>It hits! (display: "LUCKY DODGE")</li>
] (else:) [
<li>You parry the attack.</li>
]
]
</ul>
]
(if: _monster contains "special")[
(display: _monster's special)
]
(set: $monsters's (_i) to _monster)
</li>
]
</ol>
|CHECK_DEATHS>[
(if: $player's stamina <= 0) [
Your wounds are fatal.
(rerun:?ATTACK_ACTIONS)
]
(for: each _monster, ...$monsters)[
(if: _monster's stamina <= 0) [
(print: _monster's name) has fallen!
(rerun:?ATTACK_ACTIONS)
]
]
]
}](set: $STAMINA to (macro: num-type _amount, [{
(set: $player's stamina to it + _amount)(rerun:?stats)(output:)[]}]))
(set: $SKILL to (macro: num-type _amount, [{
(set: $player's skill to (max: 0, (min: 12, it + _amount)))(rerun:?stats)(output:)[]}]))
(set: $LUCK to (macro: num-type _amount, [{
(set: $player's luck to (max: 0, it + _amount))(rerun:?stats)(output:)[]}]))(link: "Test your luck?")[{
(set: _lucky_1 to (random: 1, 6))
(set: _lucky_2 to (random: 1, 6))
(set: _roll to _lucky_1 + _lucky_2)
Luck roll: (str: _lucky_1) + (str: _lucky_2) = (str: _roll).
(if: _roll <= $player's luck) [
<i>Lucky strike!</i> 2 additional damage.
(set: _monster's stamina to it - 2)
(if: _monster's stamina <= 0) [
The blow is fatal.
]
] (else:) [
<i>Grazed!</i> 1 less damage.
(set: _monster's stamina to it + 1)
]
(set: $monsters's (_i) to _monster)
($LUCK: -1)
(rerun: ?CHECK_DEATHS)
}]<luckystrike|(link: "Test your luck?")[{
(set: _lucky_1 to (random: 1, 6))
(set: _lucky_2 to (random: 1, 6))
(set: _roll to _lucky_1 + _lucky_2)
Luck roll: (str: _lucky_1) + (str: _lucky_2) = (str: _roll).
(if: _roll <= $player's luck) [
Lucky dodge! Restore 1 STAMINA.
($STAMINA: 1)
(rerun: ?ATTACK_ACTIONS)
] (else:) [
Failed to dodge! 1 additional damage.
($STAMINA: -1)
]
($LUCK: -1)
(rerun: ?CHECK_DEATHS)
}]<testyourluck|(replace:?ATTACK_ACTIONS)[{
(rerun:?TALLY_MONSTERS)
(hide:?ATTACK_RESULTS)
(hide:?ATTACK_ACTIONS)
(show:?MONSTER_LIST)
(rerun:?MONSTER_LIST)
}][{(replace: ?sidebar)[
(meter: bind $player's skill, 12, "X", " SKILL: (str:$player's skill) / (str:$player's max_skill)", #d0b000)
(meter: bind $player's stamina, 24, "X", " STAMINA: (str:$player's stamina) / (str:$player's max_stamina)", #00b000)
(meter: bind $player's luck, 12, "X", " LUCK: (str:$player's luck) / (str:$player's max_luck)", blue)
<br/>
(link-rerun:"About")[(dialog:"FF Encounter sim v0.1 by splendid")]
]}]<stats|(replace:?ATTACK_RESULTS)[{
(set: _order to (range: 1, $monsters's length))
(set: _die_1 to (random: 1, 6))
(set: _die_2 to (random: 1, 6))
(set: _player_roll to _die_1 + _die_2 + $player's skill)
<li>You attack <b>(print: $target's name)</b>, rolling (str: _die_1) + (str: _die_2). Your ATTACK STRENGTH: (str: _player_roll)</li>
<ul>
(for: each _i, ..._order) [
(set: _monster to $monsters's (_i))
(set: _die_3 to (random: 1, 6))
(set: _die_4 to (random: 1, 6))
(set: _monster_roll to _die_3 + _die_4 + _monster's skill)
|CALCULATE_DAMAGE>[
(if: _player_roll < _monster_roll)[
($STAMINA: -2)
] (elseif: _player_roll > _monster_roll) [
(if: $target's index is _i) [
(set: _monster's stamina to it - 2)
]
]
]
|DISPLAY_RESULTS>[
<ul>
(if: $target's index is _i) [
<li>(print: _monster's name) defends, rolling: (str: _die_3) + (str: _die_4). ATTACK STRENGTH: (print: _monster_roll).</li>
] (else:) [
<li>(print: _monster's name) attacks, rolling (str: _die_3) + (str: _die_3). ATTACK STRENGTH: (str: _monster_roll).</li>
]
(if: _player_roll is _monster_roll) [
(if: $target's index is _i) [
<li>You dodge each other's blows.</li>
] (else:) [
<li>You parry the attack.</li>
]
] (elseif: $target's index is _i) [
(if: _player_roll < _monster_roll) [
<li>It hits! (display: "LUCKY DODGE")</li>
] (else:) [
<li>You hit it!
(if: _monster's stamina > 0)[
(display: "LUCKY STRIKE")
] (else:) [
The blow is fatal!
]
</li>]
] (else:) [
(if: _player_roll < _monster_roll) [
<li>It hits! (display: "LUCKY DODGE")</li>
] (else:) [
<li>You parry the attack.</li>
]
]
</ul>
]
(if: _monster contains "special")[
(display: _monster's special)
]
(set: $monsters's (_i) to _monster)
]
</ul>
|CHECK_DEATHS>[
(if: $player's stamina <= 0) [
Your wounds are fatal.
(rerun:?ATTACK_ACTIONS)
]
(for: each _monster, ...$monsters)[
(if: _monster's stamina <= 0) [
(print: _monster's name) has fallen!
(rerun:?ATTACK_ACTIONS)
]
]
]
}]