#简单防修改,防止基本数据被修改 by:抠脚大汉 2020.7.10
#仅针对金钱数量、物品武器护甲数量、角色基础能力值、角色等级
#对存档进行简单的压缩保护,防止RM存档通用修改器修改
#因为抠脚也是小白,所以本脚本仅仅针对小白,防不了大佬。
#encoding:utf-8
#==============================================================================
# ■ DataManager
#------------------------------------------------------------------------------
# 数据库和游戏实例的管理器。所有在游戏中使用的全局变量都在这里初始化。
#==============================================================================
module DataManager
#--------------------------------------------------------------------------
# ● 执行存档(没有错误处理)
#--------------------------------------------------------------------------
def self.save_game_without_rescue(index)
File.open(make_filename(index), "wb") do |file|
$game_system.on_before_save
Marshal.dump(Zlib::Deflate.deflate(Marshal.dump(make_save_header)).reverse, file)
Marshal.dump(Zlib::Deflate.deflate(Marshal.dump(make_save_contents)).reverse, file)
@last_savefile_index = index
end
return true
end
#--------------------------------------------------------------------------
# ● 执行读档(没有错误处理)
#--------------------------------------------------------------------------
def self.load_game_without_rescue(index)
File.open(make_filename(index), "rb") do |file|
Marshal.load(file)
extract_save_contents(Marshal.load((Zlib::Inflate.inflate(Marshal.load(file).reverse))))
reload_map_if_updated
@last_savefile_index = index
end
return true
end
#--------------------------------------------------------------------------
# ● 读取存档的头数据(没有错误处理)
#--------------------------------------------------------------------------
def self.load_header_without_rescue(index)
File.open(make_filename(index), "rb") do |file|
return Marshal.load(Zlib::Inflate.inflate(Marshal.load(file).reverse))
end
return nil
end
end
#encoding:utf-8
#==============================================================================
# ■ Game_System
#------------------------------------------------------------------------------
# 处理系统附属数据的类。保存存档和菜单的禁止状态之类的数据。
# 本类的实例请参考 $game_system 。
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :gold_data # 储存金钱数据
attr_accessor :item_data # 储存物品数据
attr_accessor :params_data # 储存角色数据
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
alias kjdh_initialize initialize
def initialize
kjdh_initialize
@gold_data = 1888
@item_data = 666
@params_data = 1
end
end
#encoding:utf-8
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
# 管理角色的类。
# 本类在 Game_Actors 类 ($game_actors) 的内部使用。
# 具体使用请查看 Game_Party 类 ($game_party) 。
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● 获取普通能力值之和
#--------------------------------------------------------------------------
def all_param_base
param_base(0) + param_base(1) + param_base(2) + param_base(3) +
param_base(4) + param_base(5) + param_base(6) + param_base(7)
end
#--------------------------------------------------------------------------
# ● 获取附加能力值之和
#--------------------------------------------------------------------------
def all_param_plus
param_plus(0) + param_plus(1) + param_plus(2) + param_plus(3) +
param_plus(4) + param_plus(5) + param_plus(6) + param_plus(7)
end
#--------------------------------------------------------------------------
# ● 获取普通能力值(百分比)之和
#--------------------------------------------------------------------------
def all_param_rate
param_rate(0) + param_rate(1) + param_rate(2) + param_rate(3) +
param_rate(4) + param_rate(5) + param_rate(6) + param_rate(7)
end
#--------------------------------------------------------------------------
# ● 获取所有能力值之和 + 等级
#--------------------------------------------------------------------------
def all_params
all_param_base + all_param_plus + all_param_rate + @level
end
#--------------------------------------------------------------------------
# ● 等级上升
#--------------------------------------------------------------------------
alias kjdh_level_up level_up
def level_up
kjdh_level_up
$game_system.params_data = $game_party.all_params / 2 + 1
end
#--------------------------------------------------------------------------
# ● 等级下降
#--------------------------------------------------------------------------
alias kjdh_level_down level_down
def level_down
kjdh_level_down
$game_system.params_data = $game_party.all_params / 2 + 1
end
#--------------------------------------------------------------------------
# ● 等级变化
# show : 等级上升显示的标志
#--------------------------------------------------------------------------
alias kjdh_change_level change_level
def change_level(level, show)
kjdh_change_level(level, show)
$game_system.params_data = $game_party.all_params / 2 + 1
end
#--------------------------------------------------------------------------
# ● 更换装备
# slot_id : 装备栏 ID
# item : 武器/护甲(为 nil 时装备解除)
#--------------------------------------------------------------------------
alias kjdh_change_equip change_equip
def change_equip(slot_id, item)
kjdh_change_equip(slot_id, item)
$game_system.params_data = $game_party.all_params / 2 + 1
end
#--------------------------------------------------------------------------
# ● 强制更换装备
# slot_id : 装备栏 ID
# item : 武器/护甲(为 nil 时装备解除)
#--------------------------------------------------------------------------
alias kjdh_force_change_equip force_change_equip
def force_change_equip(slot_id, item)
kjdh_force_change_equip(slot_id, item)
$game_system.params_data = $game_party.all_params / 2 + 1
end
#--------------------------------------------------------------------------
# ● 丢弃装备
# item : 丢弃的武器/护甲
#--------------------------------------------------------------------------
alias kjdh_discard_equip discard_equip
def discard_equip(item)
kjdh_discard_equip(item)
$game_system.params_data = $game_party.all_params / 2 + 1
end
#--------------------------------------------------------------------------
# ● 应用“能力提升”效果
#--------------------------------------------------------------------------
alias kjdh_item_effect_grow item_effect_grow
def item_effect_grow(user, item, effect)
kjdh_item_effect_grow(user, item, effect)
$game_system.params_data = $game_party.all_params / 2 + 1
end
end
#encoding:utf-8
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
# 管理队伍的类。保存有金钱及物品的信息。本类的实例请参考 $game_party 。
#==============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# ● 增加/减少持有金钱
#--------------------------------------------------------------------------
alias kjdh_gain_gold gain_gold
def gain_gold(amount)
kjdh_gain_gold(amount)
$game_system.gold_data = ($game_party.gold + 111) * 3 + 1555
end
#--------------------------------------------------------------------------
# ● 取得所有物品数
#--------------------------------------------------------------------------
def all_item_num
(@items.values + @weapons.values + @armors.values).inject(0){|m,n| m + n }
end
#--------------------------------------------------------------------------
# ● 增加/减少物品
# include_equip : 是否包括装备
#--------------------------------------------------------------------------
alias kjdh_gain_item gain_item
def gain_item(item, amount, include_equip = false)
kjdh_gain_item(item, amount, include_equip = false)
$game_system.item_data = ($game_party.all_item_num + 101) * 3 + 363
end
#--------------------------------------------------------------------------
# ● 获取队伍成员的属性值之和
#--------------------------------------------------------------------------
def all_params
all_members.collect {|actor| actor.all_params }.inject(0){|m,n| m + n}
end
#--------------------------------------------------------------------------
# ● 角色入队
#--------------------------------------------------------------------------
alias kjdh_add_actor add_actor
def add_actor(actor_id)
kjdh_add_actor(actor_id)
$game_system.params_data = $game_party.all_params / 2 + 1
end
#--------------------------------------------------------------------------
# ● 角色离队
#--------------------------------------------------------------------------
alias kjdh_remove_actor remove_actor
def remove_actor(actor_id)
kjdh_remove_actor(actor_id)
$game_system.params_data = $game_party.all_params / 2 + 1
end
end
class << Input
alias kjdh_update update
def update
kjdh_update
unless SceneManager.scene_is?(Scene_Battle)
if $game_system.gold_data != ($game_party.gold + 111) * 3 + 1555 ||
$game_system.item_data != ($game_party.all_item_num + 101) * 3 + 363 ||
$game_system.params_data != $game_party.all_params / 2 + 1
msgbox "数据校验失败!游戏无法正常运行!"
exit
end
end
end
end