関数が作動しない(質問掲示板)
投稿:
退会したユーザー
投稿:2012/11/21 19:15:21(最新:2012/11/22 21:06:22)
setVariable("sh",8)
setVariable("sa",10)
setVariable("sb",10)
setVariable("金",25)
setVariable("mh",10)
setVariable("ma",8)
setVariable("mb",12)
def cmh()
if getVariable("mh") <= 0
speak("倒した")
else
end
end
def csh()
if getVariable("sh") <= 0
speak("死にました")
warp(26047, 99, 0)
else
end
end
def block()
if getVariable("mh") > 0
if getVariable("sb") >= getVariable("ma")
speak("相手の攻撃力が低いようだ")
else
setVariable("sh",getVariable("sh") - getVariable("ma") + getVariable("sb"))
speak("ダメージを受けた")
csh() #ここは作動したかは分からない
end
else
end
end
def mons()
if getVariable("mb") >= getVariable("sa")
speak("相手の防御力が高すぎる!")
else
setVariable("mh", getVariable("mh") - getVariable("sa") + getVariable("mb"))
speak("ダメージを与えた")
cmh() #ここは作動した
block() #ここが作動しない
speak("",getVariable("sh"),"")
if getVariable("sh") > 0 && getVariable("mh") > 0
mons() #ここも作動した
else
end
end
end
エラーが出る事はありませんでした。
1時間ぐらい悩んだんですけど結局分からなくて...
なにかへんなところがありますでしょうか?
コメントする
コメントするには、ログインする必要があります。
ちょっと新たな問題が...
このスレのやつは開始スクリプトです。
#イベントです setVariable("mh",9) setVariable("ma",12) setVariable("mb",8) if getFlag("スライム1") speak("もう倒した") else case speakWithSelect(2,"戦う","予測", "敵がいる") when 0 mons() setFlag("スライム1",true) when 1 if getVariable("sa") <= getVariable("mb") speak("攻撃不可") elsif getVariable("sb") >= getVariable("ma") speak("0ダメージ") else yd = getVariable("sa") - getVariable("mb") yd = getVariable("mh") / yd yd = (yd -1) * (getVariable("ma") - getVariable("sb")) speak(""+yd+"のダメージを受ける") end end end問題は、予測ダメージの方にあって、
この計算式だと、7のダメージってでるんですね。
でも、実際受けるダメージは8
理由は自分でも分かってるんです。
yd = getVariable("sa") - getVariable("mb") #yd = 2 yd = getVariable("mh") / yd #yd = 4.5 yd = (yd -1) * (getVariable("ma") - getVariable("sb")) #yd = 7二個目のydを4.5になってしまうのを切り上げしたいんですが、
切り上げのスクリプトって存在しますか?
切り上げは無さそうです
作るしかなさそうです
皆で共有するユーザー定義関数
知られざるRmakeの記述法
ある程度スクリプトに慣れてきたら
このあたりをメモしておくと
便利かとおもいます
floor関数が切り捨てですね。
ってことは1足してfloor関数を使えば
切り上げになるってことだ!
池ちゃんさん、aoihikawaさん
ありがとうございました
オーバーします
小数点第1位までの考慮の場合
0.5を0.9に変更することで
切り上げとなります