すぅぃった その6B

メインとなるスクリプト
RPG_TEST03_u_main.as

//      RPG_TEST03_u_main.as

//      主人公の各種ステータスの変数宣言と初期設定
#include "RPG_TEST03_u_status.as"

//      使用する関数とサブルーチン
#include "RPG_TEST03_u_func.as"

//      ボタン関係のサブルーチン
#include "RPG_TEST03_u_bt.as"

//      セーブとロードのサブルーチン
#include "RPG_TEST03_u_SL.as"

//      重要な変数
//      ボタンによって選択される選択肢のID
selected_btnext="OP"
//      探索するダンジョンのLV
enter_dglv=0
//      mesを直接入力しない時に用いる
//      叙述内に変数を挿入する場合に用いる事が多い
sdim dr_str,1000
dr_str=""
//      ダンジョン探索の達成度 ダンジョン攻略のレベル
//      1匹倒すごとに1上昇し5になるとダンジョン攻略完成 経験値とお金がもらえる
//      ダンジョンLV5を攻略するとゲームクリア
dg_atteinment=0
//      ポーション購入及び使用の時選択されたポーションのレベル
sl_pos_lv=0

title "テキストRPGサンプル"

//      ここからメインルーチン
*bt_selected_gomain

switch selected_btnext
//      case文には2種類あってselected_btnextの最後の文字がアルファベットなら
//      ボタン内の文字の変更と文章の記述
//      selected_btnextの最後の文字が数字なら変数の操作と強制条件分岐

//      こんなかんじならボタン内の文字の変更と文章の記述
//case "xxxx"
//      btstr_1="NEXT"
//      btnext_1="xxxxx"
//      gosub *one_bt
//      pos 150,0
//      mes {"文章叙述"}
//      gosub *show_player_status
//      swbreak

//      こんなかんじなら変数の操作と強制条件分岐
//      ここではHPの回復を行っていますね
//case "xxx1"
//      player_hp=player_mhp
//      selected_btnext="xxx1x"
//      goto *bt_selected_gomain

//      このプログラムが起動されて最初の文章の叙述
case "OP"       
        btstr_1="newgame"
        btnext_1="OP_a"
        btstr_2="continue"
        btnext_2="OP_b"
        gosub *two_bt
        pos 150,0
        mes "テキストRPGサンプル"
        swbreak

//      オープニングテキスト
case "OP_a"
        btstr_1="NEXT"
        btnext_1="TOWN"
        gosub *one_bt
        pos 150,0
        mes {"ナイトとは国家のいしずえである
        町外れにあるダンジョンの最下層に辿りついたものだけが
        ナイトの称号を得る事ができるのである
        さあ 若者よ立ち上がれ!
        剣を取って険しきその試練へと立ち向かうのだ!"}
        swbreak

//      最初にCONTINUEを選んだ場合
case "OP_b"
        btstr_1="NEXT"
        btnext_1="OP_b1"
        gosub *one_bt
        pos 150,0
        mes {"continueしました"}
        swbreak

//      データのロード
case "OP_b1"
        gosub *player_dat_load
        selected_btnext="TOWN"  
        goto *bt_selected_gomain

//      町でのコマンド入力受付 ここが全てのコマンドの起点となる
case "TOWN"
        btstr_1="shop"
        btnext_1="SHOP"
        btstr_2="guild"
        btnext_2="TALK"
        btstr_3="save"
        btnext_3="SAVE"
        btstr_4="load"
        btnext_4="LOAD"
        btstr_5="dungeon"
        btnext_5="DG"
        btstr_6="HELP"
        btnext_6="HELP"
        gosub *six_bt
        pos 150,0
        mes {"town
        何をしますか?"}
        gosub *show_player_status
        swbreak

//      お店の処理
case "SHOP"
        btstr_1="ポーションLV1"
        btnext_1="SHOP_1"
        btstr_2="ポーションLV2"
        btnext_2="SHOP_2"
        btstr_3="ポーションLV3"
        btnext_3="SHOP_3"
        btstr_4="ポーションLV4"
        btnext_4="SHOP_4"
        btstr_5="ポーションLV5"
        btnext_5="SHOP_5"
        btstr_6="戻る"
        btnext_6="TOWN"
        gosub *six_bt
        pos 150,0
        mes {"shop
        どのポーションを買いますか?\n"}
        gosub *ポーション詳細表示
        gosub *show_player_status
        swbreak

//      ポーションの購入
case "SHOP_1"
        sl_pos_lv=1
        if player_gold >=5{
        player_gold-=5:own_poshon_lv1++
        selected_btnext="SHOP_xa"       }
        else{   selected_btnext="SHOP_xb"       }
        goto *bt_selected_gomain
case "SHOP_2"
        sl_pos_lv=2
        if player_gold >=10{
        player_gold-=10:own_poshon_lv2++
        selected_btnext="SHOP_xa"       }
        else{   selected_btnext="SHOP_xb"       }
        goto *bt_selected_gomain
case "SHOP_3"
        sl_pos_lv=3
        if player_gold >=20{
        player_gold-=20:own_poshon_lv3++
        selected_btnext="SHOP_xa"       }
        else{   selected_btnext="SHOP_xb"       }
        goto *bt_selected_gomain
case "SHOP_4"
        sl_pos_lv=4
        if player_gold >=40{
        player_gold-=40:own_poshon_lv4++
        selected_btnext="SHOP_xa"       }
        else{   selected_btnext="SHOP_xb"       }
        goto *bt_selected_gomain
case "SHOP_5"
        sl_pos_lv=5
        if player_gold >=80{
        player_gold-=80:own_poshon_lv5++
        selected_btnext="SHOP_xa"       }
        else{   selected_btnext="SHOP_xb"       }
        goto *bt_selected_gomain

//      ポーション購入の記述
case "SHOP_xa"
        btstr_1="NEXT"
        btnext_1="SHOP"
        gosub *one_bt
        pos 150,0
        dr_str={"shop
        ポーションLV"}+sl_pos_lv+{"を購入した\n"}
        mes dr_str
        gosub *ポーション詳細表示
        gosub *show_player_status
        swbreak

//      お金が足りなくてポーションが買えなかった場合
case "SHOP_xb"
        btstr_1="NEXT"
        btnext_1="SHOP"
        gosub *one_bt
        pos 150,0
        mes {"shop
        お金が足りません\n"}
        gosub *ポーション詳細表示
        gosub *show_player_status
        swbreak

//      guild内のコマンド誰に話しかけるかを選んでいます
case "TALK"
        btstr_1="ジョン"
        btnext_1="TALK_a"
        btstr_2="スティーブ"
        btnext_2="TALK_b"
        btstr_3="ヨハン"
        btnext_3="TALK_c"
        btstr_4="戻る"
        btnext_4="TOWN"
        gosub *four_bt
        pos 150,0
        mes {"guild
        誰に話しかけますか?"}
        gosub *show_player_status
        swbreak
case "TALK_a"
        btstr_1="NEXT"
        btnext_1="TALK"
        gosub *one_bt
        pos 150,0
        mes {"ジョン\nポーションは余裕を持って
        たくさん買っておいた方がいいよ"}
        gosub *show_player_status
        swbreak
case "TALK_b"
        btstr_1="NEXT"
        btnext_1="TALK"
        gosub *one_bt
        pos 150,0
        mes {"スティーブ\nダンジョンでモンスターを一匹倒したからって
        いい気にならない方がいいよ
        モンスターを何匹も倒さないと
        お金も経験値も手に入れられないのだから"}
        gosub *show_player_status
        swbreak
case "TALK_c"
        btstr_1="NEXT"
        btnext_1="TALK"
        gosub *one_bt
        pos 150,0
        mes {"ヨハン\nダンジョンに挑戦するのかい?
        止めた方がいい その方が身のためだよ"}
        gosub *show_player_status
        swbreak

//      SAVEコマンド
case "SAVE"
        btstr_1="YES"
        btnext_1="SAVE_1"
        btstr_2="NO"
        btnext_2="TOWN"
        gosub *two_bt
        pos 150,0
        mes {"save
        SAVEしますか?"}
        gosub *show_player_status
        swbreak
//      実際にデータをセーブしています
case "SAVE_1"
        gosub *player_dat_save
        selected_btnext="SAVE_1a"
        goto *bt_selected_gomain
case "SAVE_1a"
        btstr_1="NEXT"
        btnext_1="TOWN"
        gosub *one_bt
        pos 150,0
        mes {"save
        SAVEしました"}
        gosub *show_player_status
        swbreak

//      LOADコマンド
case "LOAD"
        btstr_1="YES"
        btnext_1="LOAD_1"
        btstr_2="NO"
        btnext_2="TOWN"
        gosub *two_bt
        pos 150,0
        mes {"load
        LOADしますか?"}
        gosub *show_player_status
        swbreak
//      実際にLOADしています
case "LOAD_1"
        gosub *player_dat_load
        selected_btnext="LOAD_1a"
        goto *bt_selected_gomain
case "LOAD_1a"
        btstr_1="NEXT"
        btnext_1="TOWN"
        gosub *one_bt
        pos 150,0
        mes {"load
        LOADしました"}
        gosub *show_player_status
        swbreak

//      ダンジョンコマンドここでは何LVのダンジョンに入るか選んでいますね
case "DG"
        btstr_1="LV1"
        btnext_1="DG_1"
        btstr_2="LV2"
        btnext_2="DG_2"
        btstr_3="LV3"
        btnext_3="DG_3"
        btstr_4="LV4"
        btnext_4="DG_4"
        btstr_5="LV5"
        btnext_5="DG_5"
        btstr_6="戻る"
        btnext_6="TOWN"
        gosub *six_bt
        pos 150,0
        mes {"dungeon
        ダンジョンLV何に入りますか?"}
        gosub *show_player_status
        swbreak

//      何LVのダンジョンに入ったか代入しています
//      このLVのダンジョンで出現する敵のステータスの代入も行っています
case "DG_1"
        enter_dglv=1
        selected_btnext="DG_xa"
        dg_atteinment=0
        monster_st_set 1
        goto *bt_selected_gomain
case "DG_2"
        enter_dglv=2
        selected_btnext="DG_xa"
        dg_atteinment=0
        monster_st_set 2
        goto *bt_selected_gomain
case "DG_3"
        enter_dglv=3
        selected_btnext="DG_xa"
        dg_atteinment=0
        monster_st_set 3
        goto *bt_selected_gomain
case "DG_4"
        enter_dglv=4
        selected_btnext="DG_xa"
        dg_atteinment=0
        monster_st_set 4
        goto *bt_selected_gomain
case "DG_5"
        enter_dglv=5
        selected_btnext="DG_xa"
        dg_atteinment=0
        monster_st_set 5
        goto *bt_selected_gomain

//      ダンジョン内でのコマンド
case "DG_xa"
        btstr_1="探索"
        btnext_1="DG_xa1"
        btstr_2="ポーション使用"
        btnext_2="DG_xab"
        btstr_3="探索終了"
        btnext_3="DG_xac"
        gosub *three_bt
        pos 150,0
        dr_str="ダンジョンLV"+enter_dglv+"\n何をしますか?"
        mes dr_str
        gosub *show_player_status
        swbreak

//      探索を選んだ場合敵のHPの設定も行っています
case "DG_xa1"
        ene_hpp=ene_mhp
        selected_btnext="BT"
        goto *bt_selected_gomain
//      実際に敵が現れたようです
case "BT"
        btstr_1="NEXT"
        btnext_1="BT_a"
        gosub *one_bt
        pos 150,0
        dr_str="ダンジョンLV"+enter_dglv+" 探索\n"
        dr_str+=ene_name+"が現れた!"
        mes dr_str
        gosub *show_player_status
        swbreak
//      戦闘中のコマンドの入力
case "BT_a"
        btstr_1="BATTLE"
        btnext_1="BT_a1"
        btstr_2="ESCAPE"
        btnext_2="BT_ab"
        gosub *two_bt
        pos 150,0
        dr_str="対"+ene_name+" 戦闘\nどうしますか?"
        mes dr_str
        gosub *show_player_status
        swbreak
//      BATTLEを選んだ場合、勝利、敗北、戦闘継続の条件分岐も行っています
case "BT_a1"
        ene_hpp-=player_atack
        if ene_hpp > 0{
                player_hp-=ene_atp
                if player_hp > 0{       selected_btnext="BT_a1a"        }
                else{                   selected_btnext="BT_a1b"        }       }
        else{   selected_btnext="BT_a1c"        }
        goto *bt_selected_gomain
//      戦闘継続
case "BT_a1a"
        btstr_1="NEXT"
        btnext_1="BT_a"
        gosub *one_bt
        pos 150,0
        dr_str="対"+ene_name+" 戦闘\n"
        dr_str+="冒険者の攻撃! "+player_atack+"のダメージ!\n"
        dr_str+=""+ene_name+"の反撃! "+ene_atp+"のダメージ!"
        mes dr_str
        gosub *show_player_status
        swbreak
//      戦闘に敗北した場合
case "BT_a1b"
        btstr_1="NEXT"
        btnext_1="BT_a1ba"
        gosub *one_bt
        pos 150,0
        dr_str="対"+ene_name+" 戦闘\n"
        dr_str+="冒険者の攻撃! "+player_atack+"のダメージ!\n"
        dr_str+=""+ene_name+"の反撃! "+ene_atp+"のダメージ!\n冒険者は戦いに敗れてしまった"
        mes dr_str
        gosub *show_player_status
        swbreak
case "BT_a1ba"
        btstr_1="NEXT"
        btnext_1="BT_a1ba1"
        gosub *one_bt
        pos 150,0
        dr_str="対"+ene_name+" 戦闘\n冒険者は志半ばでその意思を絶たれてしまった"
        dr_str+="\n嗚呼!意識が遠のいていく\n気がついた時、君は病院のベッドの上だった"
        mes dr_str
        gosub *show_player_status
        swbreak
case "BT_a1ba1"
        player_hp=player_mhp
        selected_btnext="TOWN"
        goto *bt_selected_gomain
//      戦闘に勝利した場合
case "BT_a1c"
        btstr_1="NEXT"
        btnext_1="BT_a1c1"
        gosub *one_bt
        pos 150,0
        dr_str="対"+ene_name+" 戦闘\n"
        dr_str+="冒険者の攻撃! "+player_atack+"のダメージ!"
        dr_str+=""+ene_name+"は倒れた\n冒険者の勝利!"
        mes dr_str
        gosub *show_player_status
        swbreak
//      探索が終了したか?エンディングへの分岐も行っています
case "BT_a1c1"
        dg_atteinment++
        if dg_atteinment<5{     selected_btnext="DG_xa" }
        else{   
                if enter_dglv==5{selected_btnext="ED"   }
                else{           selected_btnext="BT_a1c1b"      }       }
        goto *bt_selected_gomain
//      ダンジョンの探索を終了した場合
case "BT_a1c1b"
        btstr_1="NEXT"
        btnext_1="BT_a1c1b1"
        gosub *one_bt
        pos 150,0
        dr_str ="ダンジョンLV"+enter_dglv+" 探索\n"
        dr_str+="戦いの後君は財宝をみつけた!\n"
        dr_str+="ダンジョンLV"+enter_dglv+"の探索は成功に終わったのだ!\n"
        dr_str+=""+ene_exp+"Pの経験値と"+ene_gpp+"Pのお金を獲得した!"
        mes dr_str
        gosub *show_player_status
        swbreak
//      お金と経験値の取得、LVアップの条件分岐も行っています
case "BT_a1c1b1"
        player_exp+=ene_exp
        player_gold+=ene_gpp
        if (pplayer_exp>=player_next_exp)&(5=1{
        sl_pos_lv=1
        player_hp+=30
        own_poshon_lv1-=1
        if player_hp>player_mhp{        player_hp=player_mhp    }
        selected_btnext="DG_xabxa"      }
        else{   selected_btnext="DG_xabxb"      }
        goto *bt_selected_gomain
case "DG_xab2"
        if own_poshon_lv2>=1{
        sl_pos_lv=2
        player_hp+=60
        own_poshon_lv2-=1
        if player_hp>player_mhp{        player_hp=player_mhp    }
        selected_btnext="DG_xabxa"      }
        else{   selected_btnext="DG_xabxb"      }
        goto *bt_selected_gomain
case "DG_xab3"
        if own_poshon_lv3>=1{
        sl_pos_lv=3
        player_hp+=120
        own_poshon_lv3-=1
        if player_hp>player_mhp{        player_hp=player_mhp    }
        selected_btnext="DG_xabxa"      }
        else{   selected_btnext="DG_xabxb"      }
        goto *bt_selected_gomain
case "DG_xab4"
        if own_poshon_lv4>=1{
        sl_pos_lv=4
        player_hp+=240
        own_poshon_lv4-=
        if player_hp>player_mhp{        player_hp=player_mhp    }
        selected_btnext="DG_xabxa"      }
        else{   selected_btnext="DG_xabxb"      }
        goto *bt_selected_gomain
case "DG_xab5"
        if own_poshon_lv5>=1{
        sl_pos_lv=5
        player_hp+=480
        own_poshon_lv5-=1
        if player_hp>player_mhp{        player_hp=player_mhp    }
        selected_btnext="DG_xabxa"      }
        else{   selected_btnext="DG_xabxb"      }
        goto *bt_selected_gomain
//      ポーションを使用したという記述
case "DG_xabxa"
        btstr_1="NEXT"
        btnext_1="DG_xa"
        gosub *one_bt
        pos 150,0
        dr_str ="ダンジョンLV"+enter_dglv+" ポーション使用\nポーションLV"+sl_pos_lv
        dr_str+="を使用しました"
        mes dr_str
        gosub *ポーション詳細表示
        gosub *show_player_status
        swbreak
//      ポーションが足りなかった場合
case "DG_xabxb"
        btstr_1="NEXT"
        btnext_1="DG_xa"
        gosub *one_bt
        pos 150,0
        dr_str ="ダンジョンLV"+enter_dglv+" ポーション使用\n"
        dr_str+="ポーションが足りません"
        mes dr_str
        gosub *ポーション詳細表示
        gosub *show_player_status
        swbreak
//      探索終了を選んだ場合
case "DG_xac"
        btstr_1="NEXT"
        btnext_1="DG_xac1"
        gosub *one_bt
        pos 150,0
        dr_str ="ダンジョンLV"+enter_dglv+" 探索終了\n"
        dr_str+="探索を途中で打ち切ってダンジョンを後にした"
        mes dr_str
        gosub *show_player_status
        swbreak
case "DG_xac1"
        player_hp=player_mhp
        selected_btnext="TOWN"
        goto *bt_selected_gomain
//      エンディング
case "ED"
        btstr_1="NEXT"
        btnext_1="ED_a"
        gosub *one_bt
        pos 150,0
        dr_str ="ダンジョンLV"+enter_dglv+" 探索\n"
        dr_str+="ダンジョンLV"+enter_dglv+"の探索は成功に終わった!\n"
        dr_str+="戦いの後君は一組のサークレットを目にした\n"
        dr_str+="君はそのサークレットに触れてみた\n"
        dr_str+="君の体に電撃に似た衝撃が走る!\n"
        dr_str+="君は全てのダンジョンを制覇した実感を得たのだった"
        mes dr_str
        gosub *show_player_status
        swbreak
case "ED_a"
        btstr_1="NEXT"
        btnext_1="ED_a1"
        gosub *one_bt
        pos 150,0
        dr_str ="ダンジョンLV"+enter_dglv+" 探索\n"
        dr_str+="一組のサークレットを手にした君は町へと帰還した"
        mes dr_str
        gosub *show_player_status
        swbreak
case "ED_a1"
        player_hp=player_mhp
        selected_btnext="ED_a1a"
        goto *bt_selected_gomain
case "ED_a1a"
        btstr_1="NEXT"
        btnext_1="ED_a1a1"
        gosub *one_bt
        pos 150,0
        mes {"帰還した君はナイトの称号を与えられた
                試練を乗り越え ナイトとして認められた君は
                生涯国家のために忠誠を誓っていくのだろう
                THE END"}
        gosub *show_player_status
        swbreak
case "ED_a1a1"
        gosub*ステータス初期化
        goto *bt_selected_gomain
//      ヘルプの表示
case "HELP"
        btstr_1="町の中で"
        btnext_1="HELP_a"
        btstr_2="ダンジョンの中で"
        btnext_2="HELP_b"
        btstr_3="戦闘中に"
        btnext_3="HELP_c"
        btstr_4="戻る"
        btnext_4="TOWN"
        gosub *four_bt
        pos 150,0
        mes {"HELP\nどの項目に関するヘルプを読みますか?"}
        swbreak
case "HELP_a"
        btstr_1="NEXT"
        btnext_1="HELP"
        gosub *one_bt
        pos 150,0
        mes {"町の中でのコマンド
        shop  ポーションを購入します
        guild 様々な人から冒険に役立つアドバイスを聞けます
        save  データを保存します
        load  データを読み込みます
        dungeon モンスターの潜むダンジョンへと
        財宝と名声を求めて挑みます
        HELP  このゲームのヘルプです"}
        swbreak
case "HELP_b"
        btstr_1="NEXT"
        btnext_1="HELP"
        gosub *one_bt
        pos 150,0
        mes {"ダンジョン内でのコマンド
        探索:ダンジョンを探索します\nダンジョンを探索しているとモンスターが現れるので
        力の限りを尽くしてモンスターと戦いましょう\n
        ポーション使用:ポーションを使用してHPを回復します\n
        探索終了:ダンジョンの探索をあきらめて町へと帰還します"}
        swbreak
case "HELP_c"
        btstr_1="NEXT"
        btnext_1="HELP"
        gosub *one_bt
        pos 150,0
        mes {"戦闘中のコマンド\n
        battle 力を尽くしてモンスターと戦います
        escape モンスターとの戦闘をあきらめて戦線を離脱します\n
        注\nこのゲームは一匹倒すごとにお金と経験値が
        手に入るシステムでは無いので
        一匹倒したからといって満足せずに
        そのまま探索を継続しましょう
        モンスターを何匹か倒してダンジョンの探索に無事成功すると
        見事お金と経験値が手に入ります"}
        swbreak
swend
stop