2DRPGメモ
投稿者:
一 けん
投稿日:2014/07/07 19:00
疑似ランダムエンカウントターンバトルを試行錯誤してみた感じ。
※とりあえず動く感じのものです。
☆イベントの設定☆
キャラクタ:無し
あたり判定:無し
移動タイプ:プレイヤーを追う
開始方法:接触
有効条件:ご自由に
#イベント実行内容#
これで、
A(ID(9240)の敵)
B(ID(9240)の敵、ID(9241)の敵、ID(9242)の敵)
C(ID(9241)の敵、ID(9240)の敵)
ABCの3パターンの内の1パターンで敵が出現する。
☆作成中に得た情報☆
ターンバトル開始関数startTurnBattleでリソースに無いIDを
指定するとIDが-1のキャラが出てくる。(エラーにならない)
そして、このキャラのLV1時ステータスは、ALL1、各状態異常耐性△。
最弱ステータスのキャラである。
ターンバトル開始関数startTurnBattleで
6キャラ以上指定すると実行されない。
イベントキャラ変更関数setEventCharacterで
プレーヤーキャラ、パーティーキャラを変更する時
リソースに無いIDを指定すると
『Error #1009 null』エラーになる。
ちなみにこの状態でXメニューからステータスを見ることが出来る。
(その他イベントの変更時はエラーにならない。)
アイテム最大所持数設定関数setMaxItemCountで
0を指定するとアイテムが持てない……
アイテムが一杯の時は
装備中の装備を外せない。
つまり、装備中の装備はアイテム所持数に含まれない。
プレーヤーが倒した敵を数える関数getKillCountで
倒した数が加算されるのは
ターンバトルで勝った時のみ。
逃げるのに成功した時
パーティーが一人だけでも
『キャラ名たちは逃げ出した。』と出る……
ツイート
※とりあえず動く感じのものです。
#####開始スクリプトに書く#####
####変数設定####
##パーティーメンバー経験値配列##
setVariable("EXP", createArray())
getVariable("EXP")[0] = createArray()
getVariable("EXP")[0][0] = "playerCharacter"#プレイヤーキャラID
getVariable("EXP")[0][1] = 0#プレイヤー経験値
getVariable("EXP")[1] = createArray()
getVariable("EXP")[1][0] = 9241#メンバー1キャラID
getVariable("EXP")[1][1] = 0#メンバー1キャラ経験値
getVariable("EXP")[2] = createArray()
getVariable("EXP")[2][0] = 9242#メンバー2キャラID
getVariable("EXP")[2][1] = 0#メンバー2キャラ経験値
getVariable("EXP")[3] = createArray()
getVariable("EXP")[3][0] = 9243#メンバー3キャラID
getVariable("EXP")[3][1] = 0#メンバー3キャラ経験値
###敵キャラ情報変数配列###
setVariable("ENM", createArray())
getVariable("ENM")[0] = createArray()
getVariable("ENM")[0][0] = 9240#敵キャラID
getVariable("ENM")[0][1] = 1#取得経験値
getVariable("ENM")[0][2] = 10#取得money
getVariable("ENM")[0][3] = 9112#取得NアイテムID
getVariable("ENM")[0][4] = 18124#取得RアイテムID
getVariable("ENM")[1] = createArray()
getVariable("ENM")[1][0] = 9241#敵キャラID
getVariable("ENM")[1][1] = 2#取得経験値
getVariable("ENM")[1][2] = 0#取得money
getVariable("ENM")[1][3] = 9112#取得NアイテムID
getVariable("ENM")[1][4] = 18124#取得RアイテムID
getVariable("ENM")[2] = createArray()
getVariable("ENM")[2][0] = 9242#敵キャラID
getVariable("ENM")[2][1] = 3#取得経験値
getVariable("ENM")[2][2] = 0#取得money
getVariable("ENM")[2][3] = 9112#取得NアイテムID
getVariable("ENM")[2][4] = 18124#取得RアイテムID
getVariable("ENM")[2] = createArray()
getVariable("ENM")[2][0] = 9243#敵キャラID
getVariable("ENM")[2][1] = 4#取得経験値
getVariable("ENM")[2][2] = 0#取得money
getVariable("ENM")[2][3] = 9112#取得NアイテムID
getVariable("ENM")[2][4] = 18124#取得RアイテムID
###お金設定###
setMoneyName("お金")#通貨の名前
setDenomination("エン")#通貨の単位
###エンカウント###
setVariable("encounter",0)
###逃走成功確率設定###
setTurnBattleRunAwayRate(1.0)#0.0~1.0#0.0で必ず失敗#1.0で必ず成功
####ターンバトル設定####
def set_RandTurnBattle(set)
tbst = splitString(set, "/")
l = getArrayLength(tbst)
r = rand(l)
a = tbst[r]
enemy = splitString(a, ",")
ln = getArrayLength(enemy) - 1
case ln
when 0
startTurnBattle(enemy[0])
when 1
startTurnBattle(enemy[0],enemy[1])
when 2
startTurnBattle(enemy[0],enemy[1],enemy[2])
when 3
startTurnBattle(enemy[0],enemy[1],enemy[2],enemy[3])
when 4
startTurnBattle(enemy[0],enemy[1],enemy[2],enemy[3],enemy[4])
when 5
startTurnBattle(enemy[0], enemy[1], enemy[2], enemy[3], enemy[4], enemy[5])
end
return enemy#出現敵のキャラID配列
end
####経験値取得####
def get_EXP(e)
#パーティーメンバーID#
n = 0
a = createArray()
aa = 0
while n < 4
b = getPartyMember(n)
if b != -1
nn = 0
nnn = 0
while nn < getArrayLength(getVariable("EXP"))
if getVariable("EXP")[nn][0] == b
a[aa] = nn
aa = aa + 1
nn = getArrayLength(getVariable("EXP"))
end
nn = nn + 1
end
n = n + 1
else
n = 4
end
end
#出現敵ID#
n = 0
c = createArray()
aa = 0
while n < getArrayLength(e)
b = e[n]
if b != -1
nn = 0
while nn < getArrayLength(getVariable("ENM"))
if getVariable("ENM")[nn][0] == b
c[aa] = nn
aa = aa + 1
nn = getArrayLength(getVariable("ENM"))
end
nn = nn + 1
end
n = n + 1
else
n = 4
end
end
#経験値取得、レベルアップ#
aa = 0
#mlv = 0
while aa < getArrayLength(a)
mlv = 0
enl = 0
while enl < getArrayLength(c)
mlv = mlv + (10 * floor(getVariable("ENM")[c[enl]][1] / getLevelPartyMember(getPartyMember(aa))))
enl = enl + 1
end
speak(getValueFromCharacterParam(getPartyMemberParam(getPartyMember(aa)), getCharacterNameIndex()) + "は、" +mlv + "の経験値を手に入れた!")
getVariable("EXP")[a[aa]][1] = getVariable("EXP")[a[aa]][1] + mlv
up = 0
while 100 <= getVariable("EXP")[a[aa]][1]
getVariable("EXP")[a[aa]][1] = getVariable("EXP")[a[aa]][1] - 100
levelUpPartyMember(getPartyMember(aa))
up = up + 1
end
if up != 0
speak(getValueFromCharacterParam(getPartyMemberParam(getPartyMember(aa)), getCharacterNameIndex()) + "のレベルが" + up + "上がって" + getLevelPartyMember(getPartyMember(aa)) + "になった!")
end
aa = aa + 1
end
end
####お金取得####
def get_money(e)
n = 0
c = 0
aa = 0
while n < getArrayLength(e)
b = e[n]
if b != -1
nn = 0
while nn < getArrayLength(getVariable("ENM"))
if getVariable("ENM")[nn][0] == b
c = c + getVariable("ENM")[nn][2]
aa = aa + 1
nn = getArrayLength(getVariable("ENM"))
end
nn = nn + 1
end
n = n + 1
else
n = 4
end
end
addMoney(c)
speak(c + getDenomination() + "手に入れた!")
end
####アイテム取得####
def get_item(id)
item_id = id
ni = getValueFromItemParam(getItemParamWithId(item_id), getItemViewNameIndex())#IDからアイテム名取得
loop = true
while loop
speak("「" + ni + "をゲットしたよ~」")
if giveItem(item_id)#アイテム取得成功
loop = false
else#アイテム取得失敗
speak("「ふぇぇ~、持ち物がいっぱいだから" + ni + "が持てないよ~」")
A = createArray()
n = 0
while n < getMaxItemCount()
A[n] = getValueFromItemParam(getItemParamWithIndex(n), getItemViewNameIndex())#所持アイテムのインデックスからアイテム名取得
n = n + 1
end
pushArray(A, "捨てなくていいや")
#a = 1
a = speakWithSelectArray(A, "「いらないの捨てちゃお~っと」")
if a == getArrayLength(A)-1#(getArrayLength(A)-1)
loop = false
speak("拾わなかった。")
else
removeItemWithIndex(a)#選んだアイテムを捨てる。
end
end
end
end
####ドロップアイテム取得####
def drop_item(e)
n = 0
n_d = createArray()
r_d = createArray()
aa = 0
while n < getArrayLength(e)
b = e[n]
if b != -1
nn = 0
while nn < getArrayLength(getVariable("ENM"))
if getVariable("ENM")[nn][0] == b
n_d[n] = getVariable("ENM")[nn][3]
r_d[n] = getVariable("ENM")[nn][4]
aa = aa + 1
nn = getArrayLength(getVariable("ENM"))
end
nn = nn + 1
end
n = n + 1
else
n = 4
end
end
##Nアイテムドロップ##
n = 0
while n < getArrayLength(n_d)
r = rand(10)
if r == 0
get_item(n_d[n])
end
n = n + 1
end
##Rアイテムドロップ##
n = 0
while n < getArrayLength(r_d)
r = rand(50)
if r == 0
get_item(r_d[n])
end
n = n + 1
end
end
####疑似ランダムエンカウントターンバトル####
def retb(e)
if getVariable("encounter") == 10
r = rand(5)
if r == 0
#ターンバトル開始#
enemy = set_RandTurnBattle(e)#
#ターンバトル終了#
if getTurnBattleResult() ==
getTurnBattleWin()#0
#勝ったとき#
get_EXP(enemy)#経験値取得
get_money(enemy)#お金取得
drop_item(enemy)#アイテム取得
elsif getTurnBattleResult() ==
getTurnBattleLose()#1
#負けたとき#
elsif getTurnBattleResult() ==
getTurnBattleRunAway()#2
#逃げたとき#
end
setVariable("encounter", 0)
end
else
setVariable("encounter", getVariable("encounter") + 1)
end
end
☆イベントの設定☆
キャラクタ:無し
あたり判定:無し
移動タイプ:プレイヤーを追う
開始方法:接触
有効条件:ご自由に
#イベント実行内容#
retb("9240/9240,9241,9242/9241,9240")
これで、
A(ID(9240)の敵)
B(ID(9240)の敵、ID(9241)の敵、ID(9242)の敵)
C(ID(9241)の敵、ID(9240)の敵)
ABCの3パターンの内の1パターンで敵が出現する。
☆作成中に得た情報☆
ターンバトル開始関数startTurnBattleでリソースに無いIDを
指定するとIDが-1のキャラが出てくる。(エラーにならない)
そして、このキャラのLV1時ステータスは、ALL1、各状態異常耐性△。
最弱ステータスのキャラである。
ターンバトル開始関数startTurnBattleで
6キャラ以上指定すると実行されない。
イベントキャラ変更関数setEventCharacterで
プレーヤーキャラ、パーティーキャラを変更する時
リソースに無いIDを指定すると
『Error #1009 null』エラーになる。
ちなみにこの状態でXメニューからステータスを見ることが出来る。
(その他イベントの変更時はエラーにならない。)
アイテム最大所持数設定関数setMaxItemCountで
0を指定するとアイテムが持てない……
アイテムが一杯の時は
装備中の装備を外せない。
つまり、装備中の装備はアイテム所持数に含まれない。
プレーヤーが倒した敵を数える関数getKillCountで
倒した数が加算されるのは
ターンバトルで勝った時のみ。
逃げるのに成功した時
パーティーが一人だけでも
『キャラ名たちは逃げ出した。』と出る……
コメントする
コメントするには、ログインする必要があります。
コメント一覧
コメントはありません。