[RenPy] 纯文本查看 复制代码
# Ren'Py automatically loads all script files ending with .rpy. To use this
# file, define a label and jump to it from another file.
#战斗系统
init python:
#{'skill_1':-50,'skill_2':-100}
class BattlePlayer:
def __init__(self, subordinate='无所属',protrait='none',name='player_1',hp=1000,mp=200,skills=(),exp=0):
self.name = name
self.subordinate = subordinate
self.protrait = "gui/protraits/"+str(protrait)+".png"
self.hp = hp
self.mp = mp
self.hp_range = hp
self.mp_range = mp
self.skills =skills
self.exp = exp
selected_left_player = BattlePlayer(subordinate='无所属',protrait='none',name='player_1',hp=1000,mp=200,skills=(),exp=0)
selected_right_player = BattlePlayer(subordinate='无所属',protrait='none',name='player_1',hp=1000,mp=200,skills=(),exp=0)
left_player_list =[selected_left_player,selected_left_player]
right_player_list =[selected_right_player,selected_right_player]
left_player_leader = BattlePlayer(subordinate='无所属',protrait='none',name='player_1',hp=1000,mp=200,skills=(),exp=0)
right_player_leader = BattlePlayer(subordinate='无所属',protrait='none',name='player_1',hp=1000,mp=200,skills=(),exp=0)
skill_num = 0
default left_player = BattlePlayer()
default right_player = BattlePlayer()
# default selected_left_player = BattlePlayer()
# default selected_right_player = BattlePlayer()
default skill_times = 0
init python:
class LeftPlayer(BattlePlayer):
def __init__(self, subordinate='无所属',protrait='none',name='player_1',hp=1000,mp=200,skills=(),exp=0):
self.name = name
self.subordinate = subordinate
self.protrait = "gui/protraits/"+str(protrait)+".png"
self.hp = hp
self.mp = mp
self.hp_range = hp
self.mp_range = mp
self.skills =skills
self.exp = exp
self.exp_battle = 0
def attack(self,skill_num=0,target=selected_right_player):
global skill_times
if target.hp > 0:#如果敌人体力不低于0
if self.mp >=10:#如果气力足够发动技能
skill_times -= 1
if target.hp + self.skills[skill_num][1] > 0:#如果这轮攻击后敌人体力仍大于零
self.mp -=5#消耗气力
self.exp_battle +=int(abs(self.skills[skill_num][1])*0.8)
self.exp +=int(abs(self.skills[skill_num][1])*0.8)
target.hp += self.skills[skill_num][1]
s = self.skills[skill_num][0]+"伤害:"+str(self.skills[skill_num][1])+"\n经验值:"+str(int(abs(self.skills[skill_num][1])*0.8))
renpy.show_screen("text_title",cps_num=12,s=s,xalign=0.4,yalign=0.5,size=50)
#renpy.call('round_damage_result')
else:
target.hp = 0
if target.name == right_player_leader.name:
renpy.call('battle_victory_result')
def recover(self,skill_num=2):
global skill_times
if self.mp >=10:
if self.mp + self.skills[skill_num][1] < self.mp_range:
self.mp +=10#增加气力
else:
self.mp =self.mp_range
if self.hp + self.skills[skill_num][1] < self.hp_range:
self.hp +=abs(self.skills[skill_num][1])#增加体力
else:
self.hp =self.hp_range
self.exp_battle +=int(abs(self.skills[skill_num][1])*0.8)
self.exp +=int(abs(self.skills[skill_num][1])*0.8)
skill_times -= 1
s = "恢复体力:"+str(self.skills[skill_num][1])+"\n经验值:"+str(int(abs(self.skills[skill_num][1])*0.8))
renpy.show_screen("text_title",cps_num=12,s=s,xalign=0.4,yalign=0.5,size=50)
#renpy.call('round_recover_result')
def recover_all(self,skill_num = 2):
global left_player_list,skill_times
if self.mp >=10:
for member in left_player_list:
if member.hp + self.skills[skill_num][1] < member.hp_range:
member.hp +=abs(self.skills[skill_num][1])
else:
member.hp = member.hp_range
self.exp_battle +=int(abs(self.skills[skill_num][1])*0.8)
self.exp +=int(abs(self.skills[skill_num][1])*0.8)
skill_times -= 1
s = "我方全体体力恢复:"+str(self.skills[skill_num][1])+"\n经验值:"+str(int(abs(self.skills[skill_num][1])*0.8))
renpy.show_screen("text_title",cps_num=12,s=s,xalign=0.4,yalign=0.5,size=50)
class RightPlayer(BattlePlayer):
def __init__(self, subordinate='无所属',protrait='none',name='player_1',hp=1000,mp=200,skills=(),exp=0):
self.name = name
self.subordinate = subordinate
self.protrait = "gui/protraits/"+str(protrait)+".png"
self.hp = hp
self.mp = mp
self.hp_range = hp
self.mp_range = mp
self.skills =skills
def attack(self,skill_num=0,target=selected_left_player):
if target.hp > 0:#如果敌人体力不低于0
if self.mp >=10 or self.mp_range == 0:#角色气力不低于10或者为物品,如果气力足够发动技能
selected_right_player = self #使用技能右方系统自动锁定发动技能人
if target.hp + self.skills[skill_num][1] > 0:#如果这轮攻击后敌人体力仍大于零
if self.mp_range != 0:
self.mp -=5#消耗气力
target.hp += self.skills[skill_num][1]
s = self.skills[skill_num][0]+"\n伤害:"+str(self.skills[skill_num][1])
renpy.show_screen("text_title",cps_num=12,s=s,xalign=0.4,yalign=0.5,size=50)
# renpy.call('round_damage_result')
else:
target.hp = 0
renpy.call('battle_victory_result')
def recover(self,skill_num=2):
if self.mp >=10 or self.mp_range == 0:#角色气力不低于10或者为物品
selected_right_player = self #使用技能右方系统自动锁定发动技能人
if self.mp + self.skills[skill_num][1] < self.mp_range:
self.mp +=10#增加气力
else:
self.mp =self.mp_range
if self.hp + self.skills[skill_num][1] < self.mp_range:
self.hp +=abs(self.skills[skill_num][1])#增加体力
else:
self.hp =self.hp_range
s = "恢复体力:"+str(self.skills[skill_num][1])
renpy.show_screen("text_title",cps_num=12,s=s,xalign=0.4,yalign=0.5,size=50)
#renpy.call('round_recover_result')
def attack_all(self,skill_num = 0):
global left_player_list
if self.mp >=10 or self.mp_range == 0:#角色气力不低于10或者为物品:
selected_right_player = self #使用技能右方系统自动锁定发动技能人
for member in left_player_list:
if member.hp + self.skills[skill_num][1] > 0:
member.hp +=self.skills[skill_num][1]
else:
member.hp = 0
if member.name == left_player_leader.name:#队长体力为零
renpy.call('battle_fail_result')
s = self.skills[skill_num][0]+"\n我方全体伤害:"+str(self.skills[skill_num][1])
renpy.show_screen("text_title",cps_num=12,s=s,xalign=0.4,yalign=0.5,size=50)
def recover_all(self,skill_num = 2):
global right_player_list
if self.mp >=10 or self.mp_range == 0:
#角色气力不低于10或者为物品:
selected_right_player = self #使用技能右方系统自动锁定发动技能人
for member in right_player_list:
if member.hp + self.skills[skill_num][1] < member.hp_range:
member.hp +=abs(self.skills[skill_num][1])
else:
member.hp = member.hp_range
s = "全体恢复:"+str(self.skills[skill_num][1])
renpy.show_screen("text_title",cps_num=12,s=s,xalign=0.4,yalign=0.5,size=50)
define stage_victory_music = "audio/bgm/victory by Ryuichiro Yamaki.mp3"
default irabu_bs = LeftPlayer(name='知念',subordinate='熊野寮',protrait='irabu_bs',hp=500,mp=200,skills=(('刀光剑雨',-50),('价值重估',-100),('苏生',100)))
default kidoutaityou_normal_bs = RightPlayer(name='机动队小队长',subordinate='京都府警',protrait='kidoutaiin_normal_bs',hp=1000,mp=300,skills=(('警棍压制',-20),('盾形冲刺',-100)))
default keibisya_mitubishi_bs = RightPlayer(name='三菱普通警备车',subordinate='第一机动队',protrait = 'keibisya_mitubishi_bs',hp=9900,mp=0,skills=(('停止攻击,否则使用武力!',-50),('放下武器,立即投降!',-100)))
default male_student_bs = LeftPlayer(name='男大学生',subordinate='京都大学',protrait='snow1',hp=600,mp=100,skills=(('投掷',-50),('团结',30),('鼓舞',100)))
default female_student_bs = LeftPlayer(name='女大学生',subordinate='京都大学',protrait='snow1',hp=400,mp=100,skills=(('口号',-50),('团结',30),('苏生',100)))
style battle_stage_text is text:
size 18
transform battle_stage_frame_show_hide(yoffset_start=100,xoffset_start=100):
on show:
alpha 0.0
zoom 0.9
yoffset yoffset_start
xoffset xoffset_start
easein .5 alpha 0.9 yoffset 0 xoffset 0 zoom 1.0
on hide:
zoom 1.0
easein .5 alpha 0.0 yoffset yoffset_start xoffset xoffset_start zoom 0.9
screen battle_stage(stage_title=_('首战'),stage_backround='gokkai',stage_music="audio/bgm/Experimental Weapons Division.mp3"):
on "hide" action With(Dissolve(1.0))
on "show" action [With(Dissolve(1.0)),Play("music",stage_music,fadeout=0.5)]
tag battle
style_prefix "battle_stage"
#modal True
zorder 49#quick_menu100,say50
add stage_backround
frame at battle_stage_frame_show_hide(yoffset_start=-100,xoffset_start=0):#上方状态栏
xsize 1220
ysize 120
xpadding 10
ypadding 5
align (.5,.05)
hbox:#人物属性栏:左
spacing 20
xalign 0
yalign .5
vbox:#头像
xalign .0
spacing 5
yalign .5
xsize 100
frame:
background None
xsize 100
add im.Scale(selected_left_player.protrait, 85, 85) xalign 0.5 yalign 0.5
vbox:#人物状态
xalign .0
spacing 5
hbox:
xalign .0
yalign 1.0
spacing 5
#姓名
text "[selected_left_player.name]" color '#fff' outlines [(2, "#4f4f4f",absolute(0), absolute(0))] size 30
#所属
text "[selected_left_player.subordinate]" color '#fff' outlines [(2, "#4f4f4f",absolute(0), absolute(0))] size 20 yalign 1.0
hbox:
yalign .5
xalign .0
spacing 5
frame:
background None
xsize 150
xalign .5
text "体力 "+"[selected_left_player.hp] "+"/"+"[selected_left_player.hp_range] "
bar:
value AnimatedValue(selected_left_player.hp, range=selected_left_player.hp_range, delay=.5, old_value=None)
xalign 0.5
yalign 0.5
xysize(200,10)
xmaximum 200
hbox:
yalign .5
xalign .0
spacing 5
frame:
background None
xsize 150
xalign .5
text "气力 "+"[selected_left_player.mp]"
bar:
value AnimatedValue(selected_left_player.mp, range=selected_left_player.mp_range, delay=.5, old_value=None)
xalign 0.5
yalign 0.5
xysize(200,10)
xmaximum 200
hbox:
spacing 20
xalign .5
yalign .2
text "本轮我方总计剩余"+"{size=30}[skill_times]{/size}"+"次回合" color '#fff' outlines [(2, "#4f4f4f",absolute(0), absolute(0))] size 20 yalign 1.0
hbox:#人物属性栏:右
spacing 20
xalign 1.0
yalign .5
vbox:#人物状态
xalign .0
spacing 5
hbox:
xalign 1.0
yalign 1.0
spacing 5
#所属
text "[selected_right_player.subordinate]" color '#fff' outlines [(2, "#4f4f4f",absolute(0), absolute(0))] size 20 yalign 1.0
#姓名
text "[selected_right_player.name]" color '#fff' outlines [(2, "#4f4f4f",absolute(0), absolute(0))] size 30
hbox:
yalign .5
xalign .0
spacing 5
frame:
background None
xsize 150
xalign .5
text "体力 "+"[selected_right_player.hp] "+"/"+"[selected_right_player.hp_range] "
bar:
value AnimatedValue(selected_right_player.hp, range=selected_right_player.hp_range, delay=.5, old_value=None)
xalign 0.5
yalign 0.5
xysize(200,10)
xmaximum 200
hbox:
yalign .5
xalign .0
spacing 5
frame:
background None
xsize 150
xalign .5
text "气力 "+"[selected_right_player.mp]"
bar:
value AnimatedValue(selected_right_player.mp, range=selected_right_player.mp_range, delay=.5, old_value=None)
xalign 0.5
yalign 0.5
xysize(200,10)
xmaximum 200
vbox:#头像
xalign .0
spacing 5
yalign .5
xsize 100
frame:
background None
xsize 100
add im.Scale(selected_right_player.protrait, 85, 85) xalign 0.5 yalign 0.5
frame at battle_stage_frame_show_hide(yoffset_start=0,xoffset_start=-50):#左侧成员列表
xalign .05
ypos 180
xsize 250
ysize 400
vbox:
spacing 10
xalign .5
yalign 0.1
for player_member in left_player_list:
button:
style 'music_room'
xysize 200,50
hbox:
spacing 5
xalign 0.0
image im.Scale(player_member.protrait, 40, 40) xalign 0.5 yalign 0.5
vbox:
spacing 3
xalign 0.0
text player_member.name size 20 xalign 0.0 yalign 0.5 style 'music_room_text'
bar:
value AnimatedValue(player_member.hp, range=player_member.hp_range, delay=.5, old_value=None)
xalign 0.0
yalign 0.5
xysize(100,5)
xmaximum 100
action SetVariable('selected_left_player',player_member)
frame at battle_stage_frame_show_hide(yoffset_start=0,xoffset_start=50):#右侧成员列表
xalign .95
ypos 180
xsize 250
ysize 400
vbox:
spacing 10
xalign .5
yalign 0.1
for player_member in right_player_list:
button:
style 'music_room'
xysize 200,50
hbox:
spacing 5
xalign 1.0
vbox:
spacing 3
xalign 1.0
text player_member.name size 20 xalign 1.0 yalign 0.5 style 'music_room_text'
bar:
value AnimatedValue(player_member.hp, range=player_member.hp_range, delay=.5, old_value=None)
xalign 1.0
yalign 0.5
xysize(100,5)
xmaximum 100
image im.Scale(player_member.protrait, 40, 40) xalign 0.5 yalign 0.5
action SetVariable('selected_right_player',player_member)
if skill_times > 0:
frame at battle_stage_frame_show_hide(yoffset_start=100,xoffset_start=0):#下方技能栏
xalign .5
yalign .95
xysize 1200,100
#background None
hbox:
spacing 10
xalign .5
yalign .5
for skill_num in range(len(selected_left_player.skills)):
#$ skill_num_this = skill_num
textbutton selected_left_player.skills[skill_num][0]:
style 'music_room'
if selected_left_player.skills[skill_num][1] < 0:#如果为伤害技能
action [Function(selected_left_player.attack,skill_num=skill_num,target=selected_right_player)]#按钮攻击右方被选中的敌人
elif selected_left_player.hp<selected_left_player.hp_range:
if selected_left_player.skills[skill_num][0] == '团结' or selected_left_player.skills[skill_num][0] == '鼓舞':#如果是恢复全体的技能
action [Function(selected_left_player.recover_all,skill_num=skill_num)]
else:
action [Function(selected_left_player.recover,skill_num=skill_num)]
screen battle_briefring(briefring_title=_('首战'),biefring_backround=gui.main_menu_background,briefring_music="audio/bgm/taiko_test.mp3"):
zorder 51
tag battle
on "hide" action With(Dissolve(1.0))
on "show" action [With(Dissolve(1.0)),Play("music",briefring_music,fadeout=0.5)]
add biefring_backround
fixed:
frame:
background None
align(.03,.03)
text briefring_title:
size 50
style "label_text"
viewport:
draggable True
mousewheel True
scrollbars "vertical"
ypos 100
xpos 50
frame:#左侧成员列表
xsize 450
ysize 500
vbox:
spacing 10
xalign .5
yalign 0.1
for player_member in left_player_list:
button:
style 'music_room'
xysize 400,80
hbox:
spacing 5
xalign 0.0
image im.Scale(player_member.protrait, 60, 60) xalign 0.5 yalign 0.5
vbox:
spacing 3
xalign 0.0
hbox:
spacing 5
text "[player_member.name]" color '#fff' outlines [(2, "#4f4f4f",absolute(0), absolute(0))] size 25
#所属
text "[player_member.subordinate]" color '#fff' outlines [(2, "#4f4f4f",absolute(0), absolute(0))] size 15 yalign 1.0
hbox:
yalign .5
xalign .0
spacing 5
frame:
background None
xsize 150
xalign .5
text "体力 "+"[player_member.hp] "+"/"+"[player_member.hp_range] " size 20
bar:
value AnimatedValue(player_member.hp, range=player_member.hp_range, delay=.5, old_value=None)
xalign 0.0
yalign 0.5
xysize(100,10)
xmaximum 100
action NullAction()#SetVariable('selected_left_player',player_member)
fixed:
frame:
background "#f7f7f7aa"
yalign .95
xalign .5
xysize(1000,60)
xpadding 100
text "选择参加战斗的角色…"#current_collection[1]
textbutton _("开始战斗"):
style "return_button"
yalign 0.9
xalign 0.9
text_size 50
action [Hide('battle_briefring'),Return()]
label battle_victory_result:
show screen text_title(cps_num=12,s="战斗胜利",xalign=0.4,yalign=0.5,size=80)
$ renpy.play(stage_victory_music,"music")
$ renpy.pause(2.0,hard=True)
window show
"机动队员" "攻势太猛裂了,请求支援,撤退!"
ir "我们坚持下来了!"
hide screen text_title
$ renpy.pause(2.0,hard=True)
show screen text_title(cps_num=12,s="战斗总计:\n[left_player.name]经验值获得:[left_player.exp_battle]\n经验值累计:[left_player.exp]",xalign=0.4,yalign=0.5,size=80)
jump battle_end
label battle_fail_result:
if left_player_leader.hp <= 0:
$ s = "战斗失败\n"+"[left_player_leader.name]"+"无法继续战斗"
else:
$ s = "战斗失败\n我方成员均无法继续战斗"
show screen text_title(cps_num=12,s=s,xalign=0.4,yalign=0.5,size=80)
$ renpy.play("audio/bgm/suzusample.mp3","music")
$ renpy.pause(1.0,hard=True)
window show
ir "我们失败了……"
hide screen text_title
show screen text_title(cps_num=12,s="战斗总计:\n[left_player.name]经验值获得:[left_player.exp_battle]\n经验值累计:[left_player.exp]",xalign=0.4,yalign=0.5,size=80)
jump battle_end
label battle_stage_01:
$ quick_menu_enable = False
$ left_player_list=[irabu_bs,male_student_bs,female_student_bs]
$ kidoutaiin_normal_1_bs = RightPlayer(name='普通机动队员',subordinate='京都府警',protrait='kidoutaiin_normal_bs',hp=1000,mp=300,skills=(('警棍压制',-20),('盾形冲刺',-100)))
$ kidoutaiin_normal_2_bs = RightPlayer(name='普通机动队员',subordinate='京都府警',protrait='kidoutaiin_normal_bs',hp=1000,mp=300,skills=(('警棍压制',-20),('盾形冲刺',-100)))
$ kidoutaiin_normal_3_bs = RightPlayer(name='普通机动队员',subordinate='京都府警',protrait='kidoutaiin_normal_bs',hp=1000,mp=300,skills=(('警棍压制',-20),('盾形冲刺',-100)))
$ kidoutaiin_normal_4_bs = RightPlayer(name='普通机动队员',subordinate='京都府警',protrait='kidoutaiin_normal_bs',hp=1000,mp=300,skills=(('警棍压制',-20),('盾形冲刺',-100)))
# init:
# right_player_list=[kidoutaityou_normal_bs]
# for team_num in range(3):
# teammate_name = "kidoutaiin_normal_"+str(team_num)+"_bs"
# teammate_name = RightPlayer(name='普通机动队员',subordinate='京都府警',protrait='kidoutaiin_normal_bs',hp=1000,mp=300,skills=(('警棍压制',-20),('盾形冲刺',-100)))
# right_player_list.append()
$ right_player_list=[kidoutaityou_normal_bs,kidoutaiin_normal_1_bs,kidoutaiin_normal_2_bs,kidoutaiin_normal_3_bs,kidoutaiin_normal_4_bs,keibisya_mitubishi_bs]
call screen battle_briefring
stop music fadeout 1.0
show screen transition_splash(_("正在载入"),xalign=0.9,yalign=0.95,size=25,color="#fff",font="DroidSansFallback.ttf")
$ renpy.pause(6.0,hard=True)
hide screen transition_splash
$ left_player = irabu_bs
$ left_player_leader = irabu_bs
$ selected_left_player = irabu_bs
$ right_player = keibisya_mitubishi_bs
$ right_player_leader = kidoutaityou_normal_bs
$ selected_right_player = keibisya_mitubishi_bs
show screen battle_stage
$ quick_menu_enable = False
scene black
# show
$ irabu_bs.hp-=10
$ renpy.pause(1.0, hard=True)
$ irabu_bs.hp-=10
$ renpy.pause(1.0, hard=True)
$ irabu_bs.hp-=100
$ renpy.pause(1.0, hard=True)
"机动队员" "你们没有必要再负隅抵抗"
"机动队员" "停止攻击,否则我们就要使用武力了"
scene black
#round 1
$ right_player = keibisya_mitubishi_bs
$ selected_right_player = right_player
"警备车" "开始喊话"
$ right_player.attack(skill_num=0,target=left_player_leader)
$ renpy.pause(3.0, hard=True)
$ right_player.attack_all(skill_num=1)
$ renpy.pause(3.0, hard=True)
$ right_player = kidoutaiin_normal_2_bs
$ selected_right_player = right_player
"机动队员" "使用武力驱散!"
$ right_player.attack(skill_num=0,target=left_player_leader)
$ renpy.pause(3.0, hard=True)
$ right_player = kidoutaiin_normal_1_bs
$ selected_right_player = right_player
$ right_player.attack(skill_num=0,target=left_player_leader)
$ renpy.pause(3.0, hard=True)
$ right_player = kidoutaiin_normal_3_bs
$ selected_right_player = right_player
$ selected_left_player = male_student_bs
$ right_player.attack(skill_num=0,target=selected_left_player)
$ renpy.pause(3.0, hard=True)
$ right_player = kidoutaityou_normal_bs
$ selected_right_player = right_player
$ selected_left_player = female_student_bs
$ right_player.attack(skill_num=1,target=selected_left_player)
$ renpy.pause(3.0, hard=True)
#round 2
$ skill_times = 15 #我方本轮总共可发动n次技能
$ renpy.pause(5.0, hard=True)
$ right_player = kidoutaiin_normal_4_bs
$ selected_right_player = right_player
$ right_player.attack(skill_num=1,target=left_player)
$ renpy.pause(2.0, hard=True)
"机动队小队长" "全员开始冲刺!"
$ right_player = kidoutaityou_normal_bs
$ selected_right_player = right_player
$ right_player.attack_all(skill_num=1)
$ renpy.pause(999.0, hard=True)
"机动队员" "攻势太猛裂了,请求支援,撤退!"
scene black
#$ renpy.pause(99.0, hard=True)
i "这句之后退出battle_stage_01"
jump battle_fail_result
return
label battle_end:
hide screen battle_stage
e "战斗演示1到此结束"
i "这句之后退出battle_end"
jump battle_stage_02
# $ renpy.show('')
#$ renpy.pause(99.0, hard=True)
label battle_stage_02:
i "战斗2从这里开始"
return