赞 | 2 |
VIP | 0 |
好人卡 | 0 |
积分 | 4 |
经验 | 17283 |
最后登录 | 2021-6-5 |
在线时间 | 308 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 374
- 在线时间
- 308 小时
- 注册时间
- 2015-7-2
- 帖子
- 56
|
1星屑
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
=begin
■ 简单的偷盗系统 - 在地图上对npc进行偷盗
by 灼眼的夏娜
main前直接插入
用法:1、对目标npc进行设置,进参照截图,或 下载工程参照。
第一行:不需变
第二行:不变
第三行:数据库中敌人id,和 该npc的过失率 设置,注意标点符号
第四行:npc身上物品设置,填写数据库中物品id,★ 最后有","
第五行:防具,与物品设置相同
第六行:武器,同上
2、脚本中某些设置:
在 module Stolen 模块中可以设置 偷盗的方式 和 偷盗特技 id。
3、特技的动画自己设置。
4、注意 可 偷盗npc里最后的那个脚本不能缺少。
说明:脚本268行那些定义了 偷盗失败时的话,可以自己更改,不清楚的最好不改。
脚本372行那里定义的是 偷盗成功率的计算公式,看的懂的可自行设置。
脚本中 $game_party.add_sexp(n) 为 偷盗 经验值的增加。
补充说明:队伍中要有人会 “偷盗” 的技能 才能对 “可进行偷盗的npc”进行盗窃。
=end
#-------------------------------------------------------------------------
# ★★★★★★
#-------------------------------------------------------------------------
module Stolen
STEAL_TYPE = "rand" # 偷盗方式:选择 和 随机 两种
# "select" or "rand"
STEAL_SKILL_ID = 84 # 偷盗特技id
end
#-------------------------------------------------------------------------
# ★★★★★★
#-------------------------------------------------------------------------
class Scene_Map
attr_accessor :spriteset
end
#-------------------------------------------------------------------------
# ★★★★★★
#-------------------------------------------------------------------------
class Window_Npc_Status < Window_Base
#--------------------------------------------------------------------------
def initialize(npc_id,item)
super(80, 80, 480, 320)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 20
self.opacity = 160
@NPC = $data_enemies[npc_id]
@item = item
refresh
end
#--------------------------------------------------------------------------
def refresh
self.contents.clear
bitmap = RPG::Cache.battler(@npc.battler_name,@npc.battler_hue)
src_rect = Rect.new(0,0,bitmap.width,bitmap.height)
self.contents.blt(480-32-bitmap.width,0,bitmap,src_rect)
x = 16
self.contents.font.color = Color.new(0,255,0)
self.contents.draw_text(x, 0, 120, 32, @npc.name)
self.contents.font.color = system_color
self.contents.draw_text(x, 32*1, 120, 32, "生命值:")
self.contents.draw_text(x, 32*2, 120, 32, "魔法值:")
self.contents.draw_text(x, 32*3, 120, 32, "力量:")
self.contents.draw_text(x, 32*4, 120, 32, "灵巧:")
self.contents.draw_text(x, 32*5, 120, 32, "速度:")
self.contents.draw_text(x, 32*6, 120, 32, "魔力:")
self.contents.draw_text(x, 32*7, 120, 32, "回避:")
self.contents.font.color = normal_color
self.contents.draw_text(70+x, 32*1, 120, 32, @npc.maxhp.to_s)
self.contents.draw_text(70+x, 32*2, 120, 32, @npc.maxsp.to_s)
self.contents.draw_text(50+x, 32*3, 120, 32, @npc.str.to_s)
self.contents.draw_text(50+x, 32*4, 120, 32, @npc.dex.to_s)
self.contents.draw_text(50+x, 32*5, 120, 32, @npc.agi.to_s)
self.contents.draw_text(50+x, 32*6, 120, 32, @npc.int.to_s)
self.contents.draw_text(50+x, 32*7, 120, 32, @npc.eva.to_s)
self.contents.font.color = system_color
self.contents.draw_text(x, 32*8, 120, 32, "携带品:")
for i in [email protected]
bitmap = RPG::Cache.icon(@item.icon_name)
self.contents.blt(x+70+28*i, 32*8 + 4, bitmap, Rect.new(0, 0, 24, 24))
end
end
end
#-------------------------------------------------------------------------
# ★★★★★★
#-------------------------------------------------------------------------
class Window_Npc_Item < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize(item)
super(224, 80, 188, 320)
@column_max = 1
@item = item
@item_max = @item.size
self.height = @item.size*32+32
self.y = (480-self.height)/2
self.opacity = 160
refresh
self.index = 0
end
#--------------------------------------------------------------------------
def item
return @item[self.index]
end
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
def draw_item(index)
item = @item[index]
x = 4
y = index * 32
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
end
end
#-------------------------------------------------------------------------
# ★★★★★★
#-------------------------------------------------------------------------
class Game_Party
attr_reader :stealexp
attr_accessor :stealnpc
alias initialize_old initialize
def initialize
initialize_old
@stealexp = 0
@stealnpc = {}
end
def add_sexp(n)
@stealexp = [[@stealexp + n, 0].max, 100].min
end
end
#-------------------------------------------------------------------------
# ★★★★★★
#-------------------------------------------------------------------------
class Game_Map
alias setup_old setup
def setup(map_id)
setup_old(map_id)
for i in $game_party.stealnpc
if i[0][0] == @map_id
@events[i[0][1]] = i[1]
end
end
end
end
#-------------------------------------------------------------------------
# ★★★★★★
#-------------------------------------------------------------------------
class Interpreter
def judge
@npc_item = []
@npc_item.clear
if @list[0].code == 108
if @list[0].parameters[0].split(/:/)[0] == "可偷盗对象"
unless @list[0].parameters[0].split(/:/)[1] == nil
@npc_item = eval(@list[0].parameters[0].split(/:/)[1])
end
# @list[0].parameters[0] = "不可偷盗"
end
end
end
# 调查
def search_window
win = Window_Npc_Status.new(@list[2].parameters[0].split(/,/)[0].split(/:/)[1].to_i,@npc_item)
loop do
$game_map.update
$scene.spriteset.update
Graphics.update
Input.update
win.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
break
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.cancel_se)
break
end
end
win.dispose
end
# 偷盗
def steal
unless judge_skill
@message_waiting = true
$game_temp.message_proc = Proc.new { @message_waiting = false }
$game_temp.message_text = "无人会偷盗技能!"
return
end
if @npc_item.size == 0
@message_waiting = true
$game_temp.message_proc = Proc.new { @message_waiting = false }
$game_temp.message_text = "敌人身上已经无任何道具."
return
end
if Stolen::STEAL_TYPE == "select"
win = Window_Npc_Item.new(@npc_item)
loop do
$game_map.update
$scene.spriteset.update
Graphics.update
Input.update
win.update
if Input.trigger?(Input::B)
win.dispose
$game_system.se_play($data_system.cancel_se)
break
end
if Input.trigger?(Input::C)
win.dispose
# 动画显示
$game_map.events[@event_id].animation_id = $data_skills[Stolen::STEAL_SKILL_ID].animation2_id
for i in 1..$data_animations[$data_skills[Stolen::STEAL_SKILL_ID].animation2_id].frame_max*4
Graphics.update
$game_map.update
$game_player.update
$scene.spriteset.update
end
if successful?(@list[2].parameters[0].split(/,/)[1].split(/:/)[1].to_i)
# 偷盗经验值上升
$game_party.add_sexp(2)
item = win.item
case item
when RPG::Item
$game_party.gain_item(item.id, 1)
@list[4].parameters[0].slice!(item.id.to_s+",")
when RPG::Weapon
$game_party.gain_weapon(item.id, 1)
@list[6].parameters[0].slice!(item.id.to_s+",")
when RPG::Armor
$game_party.gain_armor(item.id, 1)
@list[5].parameters[0].slice!(item.id.to_s+",")
end
@message_waiting = true
$game_temp.message_proc = Proc.new { @message_waiting = false }
$game_temp.message_text = "从NPC出偷到了:"+item.name
else
# 偷盗经验值上升
$game_party.add_sexp(1)
@message_waiting = true
$game_temp.message_proc = Proc.new { @message_waiting = false }
$game_temp.message_text = $data_enemies[@list[2].parameters[0].
split(/,/)[0].split(/:/)[1].to_i].name+": 好啊,你几个小混混,给我下地狱去吧!"
if $data_troops[@list[3].parameters[0].split(/:/)[1].to_i] != nil
$game_temp.battle_abort = true
$game_temp.battle_calling = true
$game_temp.battle_troop_id = @list[3].parameters[0].split(/:/)[1].to_i
$game_temp.battle_can_escape = false
$game_temp.battle_can_lose = false
current_indent = @list[@index].indent
$game_temp.battle_proc = Proc.new { |n| @branch[current_indent] = n }
end
end
break
end # c'end
end
elsif Stolen::STEAL_TYPE == "rand"
# 动画显示
$game_map.events[@event_id].animation_id = $data_skills[Stolen::STEAL_SKILL_ID].animation2_id
for i in 1..$data_animations[$data_skills[Stolen::STEAL_SKILL_ID].animation2_id].frame_max*4
Graphics.update
$game_map.update
$game_player.update
$scene.spriteset.update
end
if successful?(@list[2].parameters[0].split(/,/)[1].split(/:/)[1].to_i)
# 偷盗经验值上升
$game_party.add_sexp(2)
item = @npc_item[rand(@npc_item.size)]
case item
when RPG::Item
$game_party.gain_item(item.id, 1)
@list[4].parameters[0].slice!(item.id.to_s+",")
when RPG::Weapon
$game_party.gain_weapon(item.id, 1)
@list[6].parameters[0].slice!(item.id.to_s+",")
when RPG::Armor
$game_party.gain_armor(item.id, 1)
@list[5].parameters[0].slice!(item.id.to_s+",")
end
@message_waiting = true
$game_temp.message_proc = Proc.new { @message_waiting = false }
$game_temp.message_text = "从NPC出偷到了:"+item.name
else
# 偷盗经验值上升
$game_party.add_sexp(1)
@message_waiting = true
$game_temp.message_proc = Proc.new { @message_waiting = false }
$game_temp.message_text = $data_enemies[@list[2].parameters[0].
split(/,/)[0].split(/:/)[1].to_i].name+": 好啊,你几个小混混,给我下地狱去吧!"
if $data_troops[@list[3].parameters[0].split(/:/)[1].to_i] != nil
$game_temp.battle_abort = true
$game_temp.battle_calling = true
$game_temp.battle_troop_id = @list[3].parameters[0].split(/:/)[1].to_i
$game_temp.battle_can_escape = false
$game_temp.battle_can_lose = false
current_indent = @list[@index].indent
$game_temp.battle_proc = Proc.new { |n| @branch[current_indent] = n }
end
end
end
end
# 是否有“盗窃”技能判断
def judge_skill
actor = $game_party.actors
for i in 0...actor.size
if actor.skills.include?(Stolen::STEAL_SKILL_ID)
return true
end
end
return false
end
# 取得物品
def get_item
temp_item = []
# 是 物品 判断
if @list[4].parameters[0].split(/:/)[0] == "Item"
if @list[4].parameters[0].split(/:/)[1] != nil
b1 = @list[4].parameters[0].split(/:/)[1].split(/,/)
for i in 0...b1.size
temp_item.push($data_items[b1.to_i])
end
end
end
# 是 武器 判断
if @list[6].parameters[0].split(/:/)[0] == "Weapon"
if @list[6].parameters[0].split(/:/)[1] != nil
b2 = @list[6].parameters[0].split(/:/)[1].split(/,/)
for i in 0...b2.size
temp_item.push($data_weapons[b2.to_i])
end
end
end
# 是 防具 判断
if @list[5].parameters[0].split(/:/)[0] == "Armor"
if @list[5].parameters[0].split(/:/)[1] != nil
b3 = @list[5].parameters[0].split(/:/)[1].split(/,/)
for i in 0...b3.size
temp_item.push($data_armors[b3.to_i])
end
end
end
# 返回物品数组
return temp_item
end
# 偷盗成功判断
def successful?(n) # n - 对象npc的过失率
if $game_party.stealexp > 100 - [n,0].max
rate = 70
else
rate = 30
end
return rand(100) < rate
end
#------------------------------------------
# 保存可偷盗的NPC
def savenpc
if $game_party.stealnpc.include?([@map_id,@event_id])
$game_party.stealnpc.delete([@map_id,@event_id])
end
$game_party.stealnpc[[@map_id,@event_id]] = $game_map.events[@event_id]
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#============================================================================== |
|