
【ティラノスクリプト】アドベンチャーゲームの試作

【仕様】
クリックしたエリアを調査する事で四種類の調査ポイントのうち一つを獲得しタイムリミットまでに調査ポイントを指定された点数まで貯める
調査ポイントは一定の数値で一時的な上限となり、特定のキーワードを取得することで上限が開放される
調査ポイントが目標まで届かなければ失敗となりバッドエンド
調査ポイントが目標まで届けば成功となりハッピーエンド
キーワードをすべて取得し4種のポイントを上限まで到達すると特殊エンディング
【map1.ks】
*start
[cm ]
[clearfix]
[start_keyconfig]
[bg storage="room.jpg" time="100"]
;メニューボタンの表示
@showmenubutton
;メッセージウィンドウの設定
[position layer="message0" left=160 top=500 width=1000 height=200 page=fore visible=true]
;文字が表示される領域を調整
[position layer=message0 page=fore margint="45" marginl="50" marginr="70" marginb="60"]
;メッセージウィンドウの表示
@layopt layer=message0 visible=true
;キャラクターの名前が表示される文字領域
[ptext name="chara_name_area" layer="message0" color="white" size=28 bold=true x=180 y=510]
;上記で定義した領域がキャラクターの名前表示であることを宣言(これがないと#の部分でエラーになります)
[chara_config ptext="chara_name_area"]
[iscript]
f.point = [];
f.point[0] = 0;
f.point[1] = 0;
f.point[2] = 0;
f.point[3] = 0;
f.point_max = [];
f.point_max[0] = 1;
f.point_max[1] = 1;
f.point_max[2] = 1;
f.point_max[3] = 1;
f.keyword = [];
f.keyword[0] = false;
f.keyword[1] = false;
f.keyword[2] = false;
f.keyword[3] = false;
f.time = 0;
f.time_max = 8;
f.area = {};
[endscript]
*map1
[cm]
[button graphic="area1.png" storage="" target="*area1" name="" x="180" y="40" width="" height=""]
[button graphic="area2.png" storage="" target="*area2" name="" x="420" y="40" width="" height=""]
[button graphic="area3.png" storage="" target="*area3" name="" x="660" y="40" width="" height=""]
[button graphic="area4.png" storage="" target="*area4" name="" x="900" y="40" width="" height=""]
[button graphic="area5.png" storage="" target="*area5" name="" x="180" y="280" width="" height=""]
[button graphic="area6.png" storage="" target="*area6" name="" x="420" y="280" width="" height=""]
[button graphic="area7.png" storage="" target="*area7" name="" x="660" y="280" width="" height=""]
[button graphic="area8.png" storage="" target="*area8" name="" x="900" y="280" width="" height=""]
[button graphic="right.png" storage="map2.ks" target="" name="" x="1126" y="196" width="" height=""]
[s]
*area1
[cm]
[iscript]
if (f.area.area1 == undefined) {
f.area.area1 = true;
f.point[0] += 1;
f.keyword[0] = true;
f.point_max[0] += 1;
}
f.time += 1;
[endscript]
#
area1を探索しました[p]
[call storage="limit.ks"]
[jump target="*map1"]
*area2
[cm]
[iscript]
if (f.area.area2 == undefined) {
f.area.area2 = true;
f.point[1] += 1;
f.keyword[1] = true;
f.point_max[1] += 1;
}
f.time += 1;
[endscript]
#
area2を探索しました[p]
[call storage="limit.ks"]
[jump target="*map1"]
*area3
[cm]
[iscript]
if (f.area.area3 == undefined) {
f.area.area3 = true;
f.point[2] += 1;
f.keyword[2] = true;
f.point_max[2] += 1;
}
f.time += 1;
[endscript]
#
area3を探索しました[p]
[call storage="limit.ks"]
[jump target="*map1"]
*area4
[cm]
[iscript]
if (f.area.area4 == undefined) {
f.area.area4 = true;
f.point[3] += 1;
f.keyword[3] = true;
f.point_max[3] += 1;
}
f.time += 1;
[endscript]
#
area4を探索しました[p]
[call storage="limit.ks"]
[jump target="*map1"]
*area5
[cm]
[iscript]
if (f.area.area5 == undefined) {
f.area.area5 = true;
f.point[0] += 1;
}
f.time += 1;
[endscript]
#
area5を探索しました[p]
[jump target="*map1"]
*area6
[cm]
[iscript]
if (f.area.area6 == undefined) {
f.area.area6 = true;
f.point[1] += 1;
}
f.time += 1;
[endscript]
#
area6を探索しました[p]
[call storage="limit.ks"]
[jump target="*map1"]
*area7
[cm]
[iscript]
if (f.area.area7 == undefined) {
f.area.area7 = true;
f.point[2] += 1;
}
f.time += 1;
[endscript]
#
area7を探索しました[p]
[call storage="limit.ks"]
[jump target="*map1"]
*area8
[cm]
[iscript]
if (f.area.area8 == undefined) {
f.area.area8 = true;
f.point[3] += 1;
}
f.time += 1;
[endscript]
#
area8を探索しました[p]
[call storage="limit.ks"]
[jump target="*map1"]
【map2.ks】
*map2
[cm]
[button graphic="area9.png" storage="" target="*area9" name="" x="180" y="40" width="" height=""]
[button graphic="area10.png" storage="" target="*area10" name="" x="420" y="40" width="" height=""]
[button graphic="area11.png" storage="" target="*area11" name="" x="660" y="40" width="" height=""]
[button graphic="area12.png" storage="" target="*area12" name="" x="900" y="40" width="" height=""]
[button graphic="area13.png" storage="" target="*area13" name="" x="180" y="280" width="" height=""]
[button graphic="area14.png" storage="" target="*area14" name="" x="420" y="280" width="" height=""]
[button graphic="area15.png" storage="" target="*area15" name="" x="660" y="280" width="" height=""]
[button graphic="area16.png" storage="" target="*area16" name="" x="900" y="280" width="" height=""]
[button graphic="left.png" storage="map1.ks" target="*map1" name="" x="26" y="196" width="" height=""]
[s]
*area9
[cm]
[iscript]
if (f.area.area9 == undefined) {
f.area.area9 = true;
f.point[0] += 1;
}
f.time += 1;
[endscript]
#
area9を探索しました[p]
[call storage="limit.ks"]
[jump target="*map2"]
*area10
[cm]
[iscript]
if (f.area.area10 == undefined) {
f.area.area10 = true;
f.point[1] += 1;
}
f.time += 1;
[endscript]
#
area10を探索しました[p]
[call storage="limit.ks"]
[jump target="*map2"]
*area11
[cm]
[iscript]
if (f.area.area11 == undefined) {
f.area.area11 = true;
f.point[2] += 1;
}
f.time += 1;
[endscript]
#
area11を探索しました[p]
[call storage="limit.ks"]
[jump target="*map2"]
*area12
[cm]
[iscript]
if (f.area.area12 == undefined) {
f.area.area12 = true;
f.point[3] += 1;
}
f.time += 1;
[endscript]
#
area12を探索しました[p]
[call storage="limit.ks"]
[jump target="*map2"]
*area13
[cm]
[iscript]
if (f.area.area13 == undefined) {
f.area.area13 = true;
f.point[0] += 1;
}
f.time += 1;
[endscript]
#
area13を探索しました[p]
[jump target="*map2"]
*area14
[cm]
[iscript]
if (f.area.area14 == undefined) {
f.area.area14 = true;
f.point[1] += 1;
}
f.time += 1;
[endscript]
#
area14を探索しました[p]
[call storage="limit.ks"]
[jump target="*map2"]
*area15
[cm]
[iscript]
if (f.area.area15 == undefined) {
f.area.area15 = true;
f.point[2] += 1;
}
f.time += 1;
[endscript]
#
area15を探索しました[p]
[call storage="limit.ks"]
[jump target="*map2"]
*area16
[cm]
[iscript]
if (f.area.area16 == undefined) {
f.area.area16 = true;
f.point[3] += 1;
}
f.time += 1;
[endscript]
#
area16を探索しました[p]
[call storage="limit.ks"]
[jump target="*map2"]
【limit.ks】
[jump storage="time_is_up.ks" cond="f.time == f.time_max"]
[iscript]
for (let i = 0; i < f.point.length; i++) {
if (f.point[i] > f.point_max[i]) {
f.point[i] = f.point_max[i];
}
}
[endscript]
[return]
【time_is_up.ks】
[clearstack]
#
時間切れです。[p]
[iscript]
const isAllCompleted = f.keyword.every(value => value === true);
const isAllMax = f.point.every((value, index) => value === f.point_max[index]);
if (isAllCompleted == true && isAllMax == true) {
f.target = "*end3";
} else if (f.point[0] >= 1 && f.point[1] >= 1 && f.point[2] >= 1 && f.point[3] >= 1 && isAllMax == true) {
f.target = "*end1";
} else {
f.target = "*end2";
}
[endscript]
[jump target="&f.target"]
[s]
*end1
#
ポイントが目標まで届きました。[p]
[s]
*end2
#
ポイントが目標まで届きませんでした。[p]
[s]
*end3
#
特殊エンディングです。[p]
[s]