| 赞 | 2 |
| VIP | |
| 好人卡 | |
| 积分 | 18 |
| 经验 | |
| 最后登录 | 2026-5-24 |
| 在线时间 | 1313 小时 |
- 梦石
- 0
- 星屑
- 1788
- 在线时间
- 1313 小时
- 注册时间
- 2012-8-4
- 回帖
- 724
|
发表于 2016-9-18 09:34:52
|
显示全部楼层
本帖最后由 夜狠简单 于 2016-9-22 19:34 编辑
有趣的功能,不少游戏里面都有这个偷盗的功能。
不过你要的偷盗系统 介绍太少了。如果有详细的设计流程(也就是这个系统的具体介绍 它的开启条件、偷盗能力会不会升级之类的)那么写起来就方便添加功能。
要求不高的话,公共事件就可以做。连接一个技能来弄。
按1l要求弄的,基本能满足大部分条件
行窃系统[pre lang="ruby"]#==============================================================================
#●行窃系统 by Rk 16921
#------------------------------------------------------------------------------
=begin
————注释开始
1.偷盗的东西需要在★★★开始设置★★★—★★★结束设置★★★里面设置
#------------------------------------------------------------------------------
2.怪被打一下后,或者偷过一次(即使没成功)不掉东西了
#------------------------------------------------------------------------------
3.下一轮偷东西的人将受到所有敌人的攻击(包括技能)
#------------------------------------------------------------------------------
这几个参数每次读档后就会恢复默认值,
$game_temp.steal_continue=true 被群殴后(true会,false不会)被所有人警惕
begin
$game_temp.steal_continue=false
end
使用类似于$game_switches[1] = false这样的事件脚本,游戏会卡死
由于是RGSS1的著名BUG之一,如果脚本的最后一句返回false或者nil,游戏会卡死。
解决办法很简单在后面填一行注释或者加 begin 内容 end
特殊敌人临时改变就在战斗事件页里修改就好。
$game_temp.steal_mass_wait=x #被围攻的回合数在偷东西之后的第x回合数
$game_temp.steal[敌人id]=[[物品],[武器]],[防具],[金钱]]改变敌人的被窃数据
————注释结束
=end
#==============================================================================
#设置能使用这个技能的角色id。大写字母开头好像就是全局变量的意思
Power_919 =[1,8] #表示1号角色和8号角色可以使用行窃技能
#用120号变量记录结果
Steal_variablse_919 =120
#关闭默认的结果提示窗口开关:120号开关打开时 即不用默认的结果提示窗口
Steal_help_switches_919 =120
#行窃的特技ID有81,如果还有其他技能可以这样些[81,55,66].
Steal_skill_id_919 =[81]
#行窃成功播放的SE
Steal_success_919 ="Audio/SE/056-Right02"
#行窃失败播放的SE
Steal_fail_919 ="Audio/SE/057-Wrong01"
#游戏测试时输出角色各个等级对敌人的基础窃取成功率,ctrl+f搜索 Lvi级是对敌人名称n
if $DEBUG
$data_actors = load_data("Data/Actors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
Power_919.each{|index| file =
File.open("#{$data_actors[index].name}窃取率.txt","w")
(1...$data_enemies.size).each{|n|
file.write("【#{$data_enemies[n].name}】"+"\n")
$data_actors[index].initial_level.upto($data_actors[index].final_level){|i|
prob=Integer($data_actors[index].parameters[3,i]*20/$data_enemies[n].dex)
file.write("Lv#{i}时对#{$data_enemies[n].name}窃取成功率:#{prob}"+"\n")}}}
#行窃成功率=取行窃者灵巧×20÷行窃目标灵巧
end
#==============================================================================
# ■ Game_Temp
#------------------------------------------------------------------------------
# 在没有存档的情况下,处理临时数据的类。这个类的实例请参考
# $game_temp 。
#==============================================================================
class Game_Temp
attr_accessor :steal #能被行窃敌人的数据
attr_accessor :steal_index #行窃目标与行窃者
attr_accessor :steal_switches #行窃进行开关
attr_accessor :mass_brawl #群殴对象
attr_accessor :steal_found #行窃被发现的开关
attr_accessor :steal_continue #被群殴后(true会,false不会)被所有敌人警惕
attr_accessor :harvest #收获
attr_accessor :steal_mass_wait #被围攻的回合数在偷东西之后的第几回合数
alias initialize16918 initialize
def initialize
initialize16918
@mass_brawl={}
@harvest=[]
@steal_index=[]
@steal_switches=false
@steal_continue=false
@steal_mass_wait=1 #为0时就是偷东西的回合被群殴,小于0不会被群殴
@steal_found={}
@steal||={}
=begin
————注释开始
添加敌人数据,和敌人掉落的物件,没有限制游戏里敌人能被偷次数。
每次战斗开始敌人都有可能被偷。
写法1: [[[物品id],数量],[[武器id],数量],[[防具id],数量],[金钱]]
默认数量为1,金钱不能偷就不填,最好直接写成[].可以小于0
写法2: [[物品id],[武器id]],[防具id],[金钱]]
#一定几率偷到1~3号物品中其中一样,最多能偷到2个
@steal[敌人id]=[[[1,2,3],2],[],[],[]]
#一定几率偷到4,5号武器,最多能偷到5个;1,2防具,最多能偷到3个
@steal[敌人id]=[[],[[4,5],rand(5)+1],[[1,2],rand(3)+1],[]]
@steal[敌人id]=[[],[],[],[rand(1000)+1]]#随机掉落1-1000个金币
————注释结束
=end
#★★★★★★★★★★★开始设置★★★★★★★★★★
#一定几率偷到1~4号物品、武器、防具,物品最多能偷1个,
#武器每次可以偷2个,防具每次最多可以偷3个,能偷到金钱16
@steal[1]=[[[1,2,3,4],1],[[1,2,3,4],2],[[1,2,3,4],rand(3)+1],[16]]
#一定几率偷到5,6,7,8号物品、武器、13~16防具1个,金钱1~23个
@steal[2]=[[5,6,7,8],[5,6,7,8],[13,14,15,16],[rand(23)+1]]
@steal[3]=[[],[],[],[rand(1000)-500]]
#★★★★★★★★★★★结束设置★★★★★★★★★★
end
end
#==============================================================================
# ■ Scene_Battle (分割定义 4)
#------------------------------------------------------------------------------
# 处理战斗画面的类。
#==============================================================================
class Scene_Battle
# 初始化战斗用的各种暂时数据
alias main16918 main
def main
$game_temp.steal_found={}#初始化被发现的行窃者
$game_temp.mass_brawl={}#初始化群欧对象
main16918
end
#回合结束处理
alias start_phase416918 start_phase4
def start_phase4
@mass_brawl919||=0;@mass_brawl919+=1;@play919||=0
#在群殴回合被群殴后清除被群殴的行窃者
$game_temp.mass_brawl.each {|key, value|
@key_920=key;@value_920=value
value.each{|i|$game_temp.mass_brawl[@key_920].delete(i)if @mass_brawl919>i}
$game_temp.mass_brawl.delete(key) if value.empty? }
start_phase416918
end
#--------------------------------------------------------------------------
# ● 刷新画面 (主回合步骤 2 : 开始行动)
#--------------------------------------------------------------------------
alias update_phase4_step216918 update_phase4_step2
def update_phase4_step2
@play919=(@active_battler.is_a?(Game_Enemy)||@play919>0)?1:0
update_phase4_step216918
end
#--------------------------------------------------------------------------
# ● 生成基本行动结果
#--------------------------------------------------------------------------
alias make_basic_action_result16918 make_basic_action_result
def make_basic_action_result
@vice_919=0
$game_temp.mass_brawl.each_value {|value|
@vice_919+=1 if value.include?(@mass_brawl919)}
if $game_temp.mass_brawl.empty? or @vice_919==0
make_basic_action_result16918
else
# 攻击的情况下
if @active_battler.current_action.basic == 0
# 设置攻击 ID
@animation1_id = @active_battler.animation1_id
@animation2_id = @active_battler.animation2_id
# 行动方的战斗者是敌人的情况下
if @active_battler.is_a?(Game_Enemy)
if @active_battler.restriction == 3
target = $game_troop.random_target_enemy
elsif @active_battler.restriction == 2
@index_919=0
$game_temp.mass_brawl.each{|key,value|
@index_919+=1 if value.include?(@mass_brawl919)}
index = $game_temp.mass_brawl.keys[rand(@index_919)]
target = $game_party.smooth_target_actor(index) #目标取行窃者
else
@index_919=0
$game_temp.mass_brawl.each{|key,value|
@index_919+=1 if value.include?(@mass_brawl919)}
index = $game_temp.mass_brawl.keys[rand(@index_919)]
target = $game_party.smooth_target_actor(index) #目标取行窃者
end
end
# 行动方的战斗者是角色的情况下
if @active_battler.is_a?(Game_Actor)
if @active_battler.restriction == 3
target = $game_party.random_target_actor
elsif @active_battler.restriction == 2
target = $game_troop.random_target_enemy
else
index = @active_battler.current_action.target_index
target = $game_troop.smooth_target_enemy(index)
end
end
# 设置对像方的战斗者序列
@target_battlers = [target]
# 应用通常攻击效果
for target in @target_battlers
target.attack_effect(@active_battler)
end
return
end
# 防御的情况下
if @active_battler.current_action.basic == 1
# 帮助窗口显示"防御"
@help_window.set_text($data_system.words.guard, 1)
return
end
# 逃跑的情况下
if @active_battler.is_a?(Game_Enemy) and
@active_battler.current_action.basic == 2
# 帮助窗口显示"逃跑"
@help_window.set_text("逃跑", 1)
# 逃跑
@active_battler.escape
return
end
# 什么也不做的情况下
if @active_battler.current_action.basic == 3
# 清除强制行动对像的战斗者
$game_temp.forcing_battler = nil
# 移至步骤 1
@phase4_step = 1
return
end
end
end
#--------------------------------------------------------------------------
# ● 生成特技行动结果
#--------------------------------------------------------------------------
alias make_skill_action_result16918 make_skill_action_result
def make_skill_action_result
#如果不是使用行窃技能的话,就不用去计算了,减少运算量
if Steal_skill_id_919.include?($data_skills[
@active_battler.current_action.skill_id].id)
steal_index=@active_battler.current_action.target_index
#记录行窃目标与行窃者
steal=[$game_troop.smooth_target_enemy(steal_index).id,@active_battler.id,
steal_index,@active_battler.index,@mass_brawl919+$game_temp.steal_mass_wait]
0.upto(steal.size-1){|i|$game_temp.steal_index=steal}
#群殴后被敌人警惕
$game_temp.steal_found[steal_index]=(@play919==1 &&
$game_temp.steal_continue ==true||
$game_temp.steal_found[steal_index]==true) ? true : false
#判断窃取结果
$game_variables[Steal_variablse_919]=Steal.new.resul($game_temp.steal_index)
$game_temp.steal_switches=true
make_skill_action_result16918
else
$game_temp.steal_switches=false
make_skill_action_result16918
end
end
#--------------------------------------------------------------------------
# ● 设置物品或特技对像方的战斗者
# scope : 特技或者是物品的范围
#--------------------------------------------------------------------------
alias set_target_battlers16918 set_target_battlers
def set_target_battlers(scope)
@vice_919=0
$game_temp.mass_brawl.each_value {|value|
@vice_919+=1 if value.include?(@mass_brawl919)}
if $game_temp.mass_brawl.empty? or @vice_919==0
set_target_battlers16918(scope)
else
set_target_battlers16918(scope)
#行动方的战斗者是敌人的情况下
if @active_battler.is_a?(Game_Enemy)
# 效果范围分支
case scope
when 1 # 敌单体
#目标取行窃者
@index_919=0
$game_temp.mass_brawl.each{|key,value|
@index_919+=1 if value.include?(@mass_brawl919)}
@target_battlers_vive=@target_battlers.clone
#记录删掉的位置,记录位置,记录跳过的数,记录全体攻击位置,
@target_vive0=[];@target_vive1=0;@target_vive2=0;@target_vive3=[]
for actor in $game_party.actors
if actor.exist?
@target_vive3<<(actor)
end
end
@target_battlers_vive.each{|i|@target_vive2=@target_vive1+
@target_vive3.size if @target_battlers_vive[@target_vive1,
@target_vive3.size]==@target_vive3;@target_vive1+=1
@target_vive0<<(@target_vive1-1) if @target_vive2<@target_vive1 &&
!i.is_a?(Game_Enemy)}
@target_vive0.each{|i|@target_battlers=
$game_party.smooth_target_actor(
$game_temp.mass_brawl.keys[rand(@index_919)])}
end
end
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (主回合步骤 5 : 显示伤害)
#--------------------------------------------------------------------------
alias update_phase4_step516918 update_phase4_step5
def update_phase4_step5
if @active_battler.is_a?(Game_Actor)
for target in @target_battlers
if target.damage != nil
$game_temp.steal_found[target.index]=true
end
end
end
update_phase4_step516918
#当Steal_help_switches_919号开关为OFF 并且 $game_temp.steal_switches=true时
if (!$game_switches[Steal_help_switches_919] && $game_temp.steal_switches)
Steal_help_switches($game_variables[Steal_variablse_919])
end
end
#--------------------------------------------------------------------------
# ● 行窃帮助窗口
#--------------------------------------------------------------------------
def Steal_help_switches(resul)
#失败的情况下播放失败SE,成功的情况播放成功SE,如果需要每种情况音效不一样,在下面的when里面加
resul<=5 ?Audio.se_play(Steal_fail_919):Audio.se_play(Steal_success_919)
#播放SE:Audio.se_play("文件名",音量,节奏速度)
case resul
when 1#使用者是不能掌握该技能的角色
@help_window.set_text("无法掌握该技能", 1)
when 2#被行窃目标高度警惕
@help_window.set_text("目标处于高度警惕状态", 1)
when 3#行窃目标无数据
@help_window.set_text("什么都没有发现", 1)
when 4#行窃有数据但设置内容全为空
@help_window.set_text("什么都没有发现", 1)
when 5#被行窃目标发现
@help_window.set_text("被目标识破意图了", 1)
when 6#窃取物是物品
n=$data_items[$game_temp.harvest[0]].name
m=$game_temp.harvest[1]
@help_window.set_text("获得物品 #{n} : #{m}", 1)
when 7#窃取物是武器
n=$data_weapons[$game_temp.harvest[0]].name
m=$game_temp.harvest[1]
@help_window.set_text("获得武器 #{n} : #{m}", 1)
when 8#窃取物是防具
n=$data_armors[$game_temp.harvest[0]].name
m=$game_temp.harvest[1]
@help_window.set_text("获得防具 #{n} : #{m}", 1)
when 9#窃取物是金钱
n=$game_temp.harvest[1];m=$data_system.words.gold
n<0 ?@help_window.set_text("失去#{n} #{m}",1):
@help_window.set_text("获得#{n} #{m}",1)
end
#等待40帧
40.times{Graphics.update;@help_window.update}
$game_temp.steal_switches=false#本次行窃完成,这句不要删
end
end
#==============================================================================
# ■ Scene_Steal
#------------------------------------------------------------------------------
# 处理行窃系统判断的类。RK
#==============================================================================
class Steal
def resul(steal_index)#返回行窃结果
#当技能使用者没有行使权时返回false,即行窃失败,但不受到群殴
return 1 unless Power_919.include?(steal_index[1])
#当行窃者被发现,本次战斗再也偷不到东西,但会受到群殴
if $game_temp.steal_found[steal_index[2]]==true
$game_temp.mass_brawl[steal_index[3]]||=[]
$game_temp.mass_brawl[steal_index[3]]<<steal_index[4]
return 2
else#当行窃者没有被惊动时的情况
#下面开始判断能被行窃敌人数据是否存在
if $game_temp.steal.include?(steal_index[0])
@empty=[]#取不能被窃取的项目
@n=0
$game_temp.steal[steal_index[0]].each{|i|
$game_temp.steal[steal_index[0]][@n][1]||=1 unless i.empty?
@empty<<@n if i.empty? or i[1]<=0 or (@n==3 && i[0]==0)
@n+=1}
if @empty.size<4
#行窃成功率判定,行窃成功率=取行窃者灵巧×20÷行窃目标灵巧
treasure_prob=Integer($game_actors[steal_index[1]].dex*20/
$data_enemies[steal_index[0]].dex)
#判断是否被发现
if rand(100) < treasure_prob
#在能被窃取的项目中随机选一项
begin
@index=rand(4)
end until !@empty.include?(@index)
case @index
when 0 #偷到物品,并记录下回合将被围攻的角色
$game_temp.harvest[0]=$game_temp.steal[steal_index[0]][0][0][rand(
$game_temp.steal[steal_index[0]][0][0].size)]
$game_temp.harvest[1]=$game_temp.steal[steal_index[0]][0][1]
$game_party.gain_item($game_temp.harvest[0],
$game_temp.harvest[1])
$game_temp.mass_brawl[steal_index[3]]||=[]
$game_temp.mass_brawl[steal_index[3]]<<steal_index[4]
return 6
when 1 #偷到武器,并记录下回合将被围攻的角色
$game_temp.harvest[0]=$game_temp.steal[steal_index[0]][1][0][rand(
$game_temp.steal[steal_index[0]][1][0].size)]
$game_temp.harvest[1]=$game_temp.steal[steal_index[0]][1][1]
$game_party.gain_weapon($game_temp.harvest[0],
$game_temp.harvest[1])
$game_temp.mass_brawl[steal_index[3]]||=[]
$game_temp.mass_brawl[steal_index[3]]<<steal_index[4]
return 7
when 2 #偷到防具,并记录下回合将被围攻的角色
$game_temp.harvest[0]=$game_temp.steal[steal_index[0]][2][0][rand(
$game_temp.steal[steal_index[0]][2][0].size)]
$game_temp.harvest[1]=$game_temp.steal[steal_index[0]][2][1]
$game_party.gain_armor($game_temp.harvest[0],
$game_temp.harvest[1])
$game_temp.mass_brawl[steal_index[3]]||=[]
$game_temp.mass_brawl[steal_index[3]]<<steal_index[4]
return 8
when 3 #偷到金钱,并记录下回合将被围攻的角色
$game_temp.harvest[1]=$game_temp.steal[steal_index[0]][3][0]
$game_party.gain_gold($game_temp.harvest[1])
$game_temp.mass_brawl[steal_index[3]]||=[]
$game_temp.mass_brawl[steal_index[3]]<<steal_index[4]
return 9
end
else#行窃被发现,记录下回合将被围攻角色
$game_temp.mass_brawl[steal_index[3]]||=[]
$game_temp.mass_brawl[steal_index[3]]<<steal_index[4]
return 5
end
else#能被行窃敌人数据存在但设置内容全为空时,记录被围攻角色
$game_temp.mass_brawl[steal_index[3]]||=[]
$game_temp.mass_brawl[steal_index[3]]<<steal_index[4]#不被围攻就注释掉该行
return 4
end
else
#能被行窃敌人数据不存在,记录被围攻的角色。
$game_temp.mass_brawl[steal_index[3]]||=[]
$game_temp.mass_brawl[steal_index[3]]<<steal_index[4]#不被围攻就注释掉该行
return 3
end
end
end
end
[/pre]
做的很痛苦,因为我用的菜鸟横版战斗系统,敌人有时候出来打人的动作会带着其他敌人。我以为是我写的这个弄的,然后删了一些地方,又写上去了。
不过自由度有所提高,但是获取行动顺序有点固定死了。
def make_basic_action_result
if $game_temp.mass_brawl.empty? or @vice_919==0
make_basic_action_result16918
else
.....内容
end
end
里面的【...内容】使用的是默认的系统,如果自己游戏里面有改了这部分,就自己改下【...内容】.
然后举个例子 如果默认下回合被敌人攻击
主角在第一回合进行偷东西,然后第二回合主角被群殴,第二回合继续偷东西,那么主角第三回合被群殴。第三回合不偷了,就不被群殴了。
不过这个 不适合 RTAB 即时制全动画战斗系统(这些系统下,主角被偷东西被围攻不能这样记录。),回合制可以用
|
评分
-
查看全部评分
|