TimpaniでRPGを作ろう!

―番外編 スクリプト集―


トップページに戻る





Timpaniで使えるスクリプトを集めてみました。全てテストプレイ済みです。






回復関係






宿屋に入らずに回復するハンドラ(暗転有)

置き場所:マップバックグラウンドスクリプト
使用方法:イベント中、「カスタム」で呼び出し


on [任意の文字列]
global MDATA
push cd
visual dissolve
go cd "Black"
repeat with i=1 to 3
if item 1 of line i of MDATA is not empty then
put item 4 of line i of MDATA into item 3 of line i of MDATA
put item 6 of line i of MDATA into item 5 of line i of MDATA
end if
end repeat
saveMDATA
wait 50
visual dissolve fast
go cd "White"
visual dissolve fast
pop cd
end [任意の文字列]







宿屋に入らずに回復するハンドラ(暗転無し)

置き場所:マップバックグラウンドスクリプト
使用方法:イベント中、「カスタム」で呼び出し


on [任意の文字列]
global MDATA
repeat with i=1 to 3
if item 1 of line i of MDATA is not empty then
put item 4 of line i of MDATA into item 3 of line i of MDATA
put item 6 of line i of MDATA into item 5 of line i of MDATA
end if
end repeat
saveMDATA
end [任意の文字列]







個人の家に宿泊するイベント

置き場所:キャストイベント


castTell "女の子「『シカ』ちゃん、今日はうちに泊まってよ。」",8,11013
answer "つばめ「どうしようかな……。」" with "ごめんね" or "うん"
if it is "ごめんね" then exit talk
castTell "女の子「わーい!」",8,11013
[宿屋に入らずに回復するスクリプト(暗転有)、またはそのハンドラ名]
castTell "女の子「もう行っちゃうの?」",8,11003
castTell "つばめ「ごめんね。また、今度ね。」",0,11002







アイテム関係




いろいろなアイテムを無料でとるキャストイベント

置き場所:キャストイベント
備考:UDIさんの「UxAnswer」が必要です。


get UxAnswer( "清火「どのアイテム持っていこうかな……。」", ~
"気付薬小1,気付薬小5,気付薬大1,気付薬大5,濃縮気付薬小1,濃縮気付薬小5,濃縮気付薬大1,濃縮気付薬大5,キャンセル" )
if it is "気付薬小1" then
getitem 1,1,1
else if it is "気付薬小5" then
getitem 1,1,5
else if it is "気付薬大1" then
getitem 1,2,1
else if it is "気付薬大5" then
getitem 1,2,5
else if it is "濃縮気付薬小1" then
getitem 1,3,1
else if it is "濃縮気付薬小5" then
getitem 1,3,5
else if it is "濃縮気付薬大1" then
getitem 1,4,1
else if it is "濃縮気付薬大5" then
getitem 1,4,5
else if it is "キャンセル" then
castTell "清火「今はいらないか……。」",0,11002
end if







装備品を強制的に変えるハンドラ

作者:名取さん
置き場所:マップバックグラウンドスクリプト
使用方法:イベント中、「カスタム」で呼び出し


on [任意の文字列] cn,kind,itemID
global MDATA
put itemID into item (kind+16) of line cn of MDATA
SaveMDATA
InitMDATA cn
end [任意の文字列]







所持アイテムをすべて消すことのできるスクリプト

置き場所:イベント内


global MDATA
delete line 27 to (number of lines of MDATA) of MDATA
saveMDATA







アイテムを取るたびにアイテム欄が自動的に整頓されるスクリプト改造

作者:S口さん
場所:スタックスクリプト

「getitem」ハンドラ内の
sort lines of line 27 to it2+1 of MDATA --descending by item 1 of each
の部分を、以下の二行に置き換えます。


sort lines of line 27 to (number of lines of MDATA) of MDATA ascending numeric by second item of each
sort lines of line 27 to (number of lines of MDATA) of MDATA ascending numeric by first item of each






戦闘関係




戦闘練習ができるキャストイベント

置き場所:キャストイベント
備考:UDIさんの「UxAnswer」が必要です。


get UxAnswer( "練習機械初級「ドノれべるデノ訓練ヲ開始シマスカ?」","Lv1・1体,Lv1・3体,Lv3・1体,Lv3・3体,Lv5・1体,Lv5・3体,キャンセル" )
if it is "Lv1・1体" then
EventFight 1,0,0,1,1,1,2 --ここは、Timpani内で編集します。
else if it is "Lv1・3体" then
EventFight 1,1,1,1,1,1,2
else if it is "Lv3・1体" then
EventFight 1,0,0,3,1,1,2
else if it is "Lv3・3体" then
EventFight 1,1,1,3,3,3,2
else if it is "Lv5・1体" then
EventFight 1,0,0,5,1,1,2
else if it is "Lv5・3体" then
EventFight 1,1,1,5,5,5,2
else if it is "キャンセル" then
castTell "清火「今はいいか……。」",0,11002
end if







ステータス変化系魔法の上限を決めるためのスクリプト改造

作者:S口さん
オリジナルスクリプト:スタックスクリプト

on ReMultiplyST what,Num --かける
global gcount,MDATA
get item Num of
",,,9999,,9999,45,70,54,58,9999,9999,9999,9999,9999,63" --この数字を、ステータス書式に合わせて書き換えます。ステータス書式は、「TimpaniBase」スタック中、「高度な情報」にあります。
put min((item (Num) of line (gcount) of MDATA)*what,it) into item (Num) of line (gcount) of MDATA
end ReMultiplyST







戦闘のあと、所得金額とアイテムが表示されないようにするスクリプト改造

作者:名取さん
置き場所:マップバックグラウンドスクリプト

WinFightハンドラ中、
「--レベルチェック」
というコメントの直後の
「show cd fld id 15」
を削除、または注釈に変更







魔法や召喚を含む、攻撃によるダメージに、山なりの偏差をつけるスクリプト改造

オリジナルスクリプト:戦闘カードバックグラウンドスクリプト
「ShokanAtk1」ハンドラ、「HiddenAtk1」ハンドラそれぞれ全体を、次のものに置き換えます。

ダメージにランダム要素を付け加えるというアイデアは、S口さんから頂きました。本当にありがとうございました。
on ShokanAtk1 MagN,StOffset,Dchar,Ochar --召喚は相手の物理/魔法平均防御、回避を使う
global gcount,gDchar,MDATA,gAtkFlg
if Dchar is empty then put gDchar into Dchar else put Dchar into gDchar
if Ochar is empty then put gcount into Ochar
if MagN is empty then put 1 into MagN
if item 3 of line Dchar of MDATA <= 0 then
put empty into line Dchar of gAtkFlg
else
--攻撃がヒットしたら
if the random of 100 < (100*item (11+2) of (line Ochar of MDATA)/((item 12 of line Dchar of MDATA)+(item 14 of line Dchar of MDATA))*2) then
--ダメージ算出
put any item of "-4,-3,-3,-2,-2,-2,-1,-1,-1,-1,0,0,0,0,0,1,1,1,1,2,2,2,3,3,4" into R -- 改造分
-- 「""」内の数字の数をコントロールすることによって、山の形の乱数を制御します。
-- 『HyperPiece++』中、UDIさんの「偏った乱数」の項を参考にしました。
-- put round(-MagN*((item (7+2) of line Ochar of MDATA)^2/((item 8 of line Dchar of MDATA)+(item 10 of line Dchar of MDATA))*2)) into line Dchar of gAtkFlg
-- ↑元のスクリプトです
put round(-MagN*((item (7+2) of line Ochar of MDATA)^2/((item 8 of line Dchar of MDATA)+(item 10 of line Dchar of MDATA))*2)) into A -- 改造分
put A+R into line Dchar of gAtkFlg -- 改造分
else --攻撃をミスったら
put "Miss!" into line Dchar of gAtkFlg
end if
end if
end ShokanAtk1


--統合攻撃ハンドラ。内部演算と画像表示が分離しており、魔法攻撃も統合したもの。
--StOffsetに2を入れると魔法攻撃、空なら物理攻撃
on HiddenAtk1 MagN,StOffset,Dchar,Ochar --特技などで使うサンドイッチの前部分
global gcount,gDchar,MDATA,gAtkFlg
if Dchar is empty then put gDchar into Dchar else put Dchar into gDchar
if Ochar is empty then put gcount into Ochar
if MagN is empty then put 1 into MagN
if item 3 of line Dchar of MDATA <= 0 then
put empty into line Dchar of gAtkFlg
else
--攻撃がヒットしたら
if the random of 100 < (100*item (11+StOffset) of (line Ochar of MDATA)/item (12+StOffset) of line Dchar of MDATA) then
--ダメージ算出
put any item of "-4,-3,-3,-2,-2,-2,-1,-1,-1,-1,0,0,0,0,0,1,1,1,1,2,2,2,3,3,4" into R -- 改造分。
-- 「""」内の数字の数をコントロールすることによって、山の形の乱数を制御します。
-- 『HyperPiece++』中、UDIさんの「偏った乱数」の項を参考にしました。
-- put round(-MagN*((item (7+StOffset) of line Ochar of MDATA)^2/item (8+StOffset) of line Dchar of MDATA)) into line Dchar of gAtkFlg
-- ↑元のスクリプトです
put round(-MagN*((item (7+StOffset) of line Ochar of MDATA)^2/item (8+StOffset) of line Dchar of MDATA)) into A -- 改造分
put A+R into line Dchar of gAtkFlg -- 改造分
else --攻撃をミスったら
put "Miss!" into line Dchar of gAtkFlg
end if
end if
end HiddenAtk1







戦闘によるアイテム所得にランダム要素を付け加えるスクリプト

オリジナルスクリプト:戦闘カードバックグラウンドスクリプト
「WinFight」ハンドラ全体を、次のものに置き換えます。


on WinFight
global MDATA,gcount,GTconsItems,GTWeapItems,GTProtItems,GTAcceItems
--見事に勝利
--経験値
put (item 20 of line 4 of MDATA)+(item 20 of line 5 of MDATA)+(item 20 of line 6 of MDATA) into Exp
put 0 into MemN --頭数は?
repeat with i=1 to 3
if first item of line i of MDATA is not empty then add 1 to MemN
end repeat
--金、アイテム
put (item 35 of line 4 of MDATA)+(item 35 of line 5 of MDATA)+(item 35 of line 6 of MDATA) into Money
put empty into SoItems
repeat with i=1 to 3
get the random of 3 -- ここから改造スクリプト。ここではアイテム所得率を三分の一にします
if it is not 1 then
next repeat
end if -- 改造スクリプトはここまで
put item 27 of line i+3 of MDATA into kind
put item 28 of line i+3 of MDATA into what
if kind is not empty then
getItem kind,what
get offset(RETURN&kind&","&what,RETURN&SoItems)
put number of lines of char 1 to it of SoItems into LN
if it is not 0 then
add 1 to item 3 of line LN of SoItems
else put kind&","&what&",1" into line (number of lines of SoItems)+1 of SoItems
end if
end repeat
if Money > 0 then
setflg 1,ReadFlg(1)+Money
get "敵の所持金"&Money&"を手に入れた!"&RETURN&RETURN
else get "敵の所持金は手に入らなかった!"&RETURN&RETURN
if SoItems is not empty then
put empty into TempDATA
repeat with i=1 to number of lines of SoItems
put item 1 of line (item 2 of line i of SoItems) of the value of (item (item 1 of line i of SoItems) of
"GTconsItems,GTweapItems,GTprotItems,GTacceItems")~
into line i of TempDATA
if (item 3 of line i of SoItems) > 1 then put " x"&(item 3 of line i of SoItems) after line i of TempDATA
end repeat
put "手に入れたアイテム:"&RETURN&RETURN&TempDATA after it
else put "アイテムは手に入らなかった。" after it
set height of cd fld id 15 to 16*(number of lines of it)+16
put it into cd fld id 15
-- 本番行きまーす
PlaySnd 5
--レベルチェック
show cd fld id 15
repeat with i=1 to 3
if item 3 of line i of MDATA > 0 then
add round(Exp/MemN) to item 20 of line i of MDATA
put round(100*(1.3)^(item 21 of line i of MDATA)) into REXP
if (item 20 of line i of MDATA) >= REXP then
--レベルアップだ
numdisp i,"LEVEL UP!"
subtract REXP from item 20 of line i of MDATA
add 1 to item 21 of line i of MDATA
multiply item 3 of line i of MDATA by 1.1
multiply item 5 of line i of MDATA by 1.1
else numdisp i,"Exp:"&round(Exp/MemN)
end if
end repeat
wait 30
hidem
end WinFight







その他




リターンキーを押すとステータス画面が表示されるようにするハンドラ

作者:名取さん
置き場所:マップカードバックグラウンドスクリプト

on returnKey -- ステータス画面をリターンキーでも表示できるように
get icon of cd btn "Cast0"
set icon of cd btn "Cast0" to ((icon of cd btn "Cast0") div 100)*100
set cursor to Busy
--charjump short id of cd btn "Cast0"
set icon of cd btn "Cast0" to it
push card
lock screen
go cd "Info"
Send "MasterInit" to cd "Info"
unlock screen with stretch from bottom fast
end returnKey







シフトキーを押しながらキャストをクリックすると、他のことが起こるキャストイベント

置き場所:キャストイベント

if the shiftkey is down then
castTell "清火「ウチ専用の掲示板を見てみよう。」",0,11010
castTell "清火「こうして見てみると、関係ない書き込みばっか。。」",0,11009
end if







「テキスト実行」時に、空行の表示に時間をかけないようにもできるスクリプト改造

オリジナルスクリプト:スタックスクリプト

「DispTextGo」ハンドラ全体を、次のものに置き換えます。
テキスト登録時に、「 」を入力すると、その空行の表示には、文字が入っている行と同じ時間がかかります。スクリプト改造前と同じです。
「[任意の文字列]」を入力した行は、待ち時間なく表示されるため、次の文字の入っている行とほぼ同時に表示されるようになります。もちろん、この[任意の文字列]は表示されません。

on DispTextGo what --実行
if what is empty then
if cd fld 1 of cd "DispText" is empty then exit DispTextGo
else put cd fld 1 of cd "DispText" into what
end if
push card
lock screen
go cd "DispText"
if the optionkey is up then
put empty into cd fld 1
unlock screen with dissolve
wait 30
repeat with i=1 to number of lines of what
if line i of what is "[任意の文字列]" then
next repeat
end if
lock screen
put line i of what into line i of cd fld 1
unlock screen with dissolve
wait 40
end repeat
wait 60
lock screen
put empty into cd fld 1
end if
unlock screen with dissolve
visual dissolve fast
go cd "White"
visual dissolve fast
pop card
end DispTextGo







挿入曲/タイトル曲をフェードアウトしたのち、停止できるスクリプト

置き場所:マップカードバックグラウンドスクリプト
使用する時には、[任意の文字列1][半角スペース][フェードアウト+制止したい曲のファイル名]を、イベントまたはキャストイベントに入力します。
当サイトにある、BGMのつけ方の、BGMのセットが2つある場合のスクリプトを使っているのを前提として作ったスクリプトです。BGMのセットが1つの場合には、3行目の「put (line 5 of BGMDATA) into [任意の文字列3]」→「put (line 3 of BGMDATA) into [任意の文字列3]」になります。
下から4行目の、「wait 2」の部分で、フェードアウトの速度を設定することができます。数字が大きいほど、フェードアウトは遅くなります。
on [任意の文字列1] [任意の文字列2]
global BGMDATA
put (line 5 of BGMDATA) into [任意の文字列3]
repeat until [任意の文字列3]=0
set the AudioLevel of window [任意の文字列2] to [任意の文字列3]
get [任意の文字列3]-5
put it into [任意の文字列3]
wait 2
end repeat
send GoTop to window [任意の文字列2]
end [任意の文字列1]

この方法だと、最初に設定する音量を5の倍数にしないと、フリーズする可能性があるそうです。また、音量が5だと、フェードアウトしないのと同じになるそうです。S口さん、ご教示ありがとうございました。
repeat構文でフェードアウトを処理するという手法は、S口さんに教えていただきました。本当にありがとうございました。S口さんにいただいたスクリプトでは、さらにフェードアウトの速度も個別に設定できるという機能が追加されています。






効果音を鳴らすか鳴らさないか制御できるスクリプト

置き場所:スタックスクリプト
事前に、環境設定カードに、チェックボックス形式のボタンを作っておきます。「オートハイライト」機能をオンにしないと使えないので、注意してください。

on play
if hilite of cd btn [効果音制御ボタンの番号] of cd id [環境設定カードのID] then pass play
end play

このスクリプトは、スタメ研の「HyperPiece++」に加筆(カードの選択部分)ののち転載いたしました。このスクリプトの作者は慎氏です。

また、このスクリプトに加筆する方法は、S口さんに教えていただきました。本当にありがとうございました。






「入る/出る」形式のマップ移動の時に、移動先のプレイヤーキャラの向きを、あらかじめ指定できるスクリプト改造

オリジナルスクリプト:マップバックグラウンドスクリプト

「MapZoom」ハンドラ全体を、次のものに置き換えます。
HyperCard LiteでRPGを開き、「入る/出る」で移動を行う移動元マップの該当するキャスト、または移動データを格納してあるバックグラウンドフィールドを開き(詳細はこちら)、移動ハンドラの最後に「,[移動先のプレイヤーキャラアイコンの下2桁] 」を入力します。半角スペースは使わないでください。
上記の方法で手を入れなかった箇所は、今まで通り、移動前の向き=移動後の向きになります。


on MapZoom ZM,CdName,x,y,[任意の文字列] --マップ移動:入る/出る--open or close
if there is not a cd CdName then exit MapZoom
if [任意の文字列] is not empty then --ここから追加
put icon of cd btn "Cast0" into PlIcon1
repeat for 2
delete last char of PlIcon1
end repeat
put PlIcon1&[任意の文字列] into PlIcon
else --追加ここまで
put icon of cd btn "Cast0" into PlIcon
end if --この一行も追加
do ("visual effect iris"&&ZM)
LeaveCard
go cd "Black"
lock screen
go cd CdName
send "initCard" to this card
castLocate 0,s,x,y,PlIcon
do "unlock screen with iris"&&(ZM)
send "startcard" to this card
end MapZoom







スクリプトを提供してくださった名取さんS口さん、本当にありがとうございました。また、UDIさんには、「UxAnswer」について書く許可を頂きました。本当にありがとうございました。



トップページに戻る










最終更新:2007年2月19日