#============================================================================== # ** Game_Battler #------------------------------------------------------------------------------ # 本类处理战斗者。此类作为 Game_Actor 类和 Game_Enemy 类的超类使用。 #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # * 判定即死状态 (覆盖原方法以添加自定义逻辑) #-------------------------------------------------------------------------- alias original_slip_damage? slip_damage? def slip_damage? # 首先执行原有的即死/持续伤害判定 if original_slip_damage? return true end # 自定义逻辑:检查状态 18 # 条件: # 1. 当前战斗者拥有状态 18 # 2. 对手(如果存在)也拥有状态 18 # 3. 当前 HP < 最大 HP 的 50% # 4. 随机数 < 30% (即 0, 1, 2 在 0-9 之间) if @states.include?(18) # 获取对手引用 opponent = nil if self.is_a?(Game_Actor) # 如果是演员,对手通常是当前的敌人目标,这里简化为检查是否存在任意敌人也有状态18 # 在 RMXP 默认战斗中,通常是一对多或多对一,这里假设“双方”指战场上的对立阵营 $game_troop.enemies.each do |enemy| if enemy.exist? && enemy.states.include?(18) opponent = enemy break end end elsif self.is_a?(Game_Enemy) # 如果是敌人,检查演员队伍中是否有状态18 $game_party.actors.each do |actor| if actor.exist? && actor.states.include?(18) opponent = actor break end end end # 如果找到了对立阵营也有状态18的单位 if opponent != nil # 检查血量是否低于 50% if self.hp > 0 && self.hp < (self.maxhp / 2.0) # 30% 几率即死 if rand(10) < 3 # 设置为即死状态 (状态 ID 通常为 1,具体取决于数据库设置,这里直接扣血至0或添加即死状态) # 更稳妥的方式是添加即死状态,让系统处理死亡 self.add_state(1) # 假设状态1是即死/战斗不能 return true end end end end return false end end
if self.armor2_id==150 or self.armor3_id==150 or self.armor4_id==150 if $message_string != "涉死" case $game_variables[550] when 0 self.damage /= [[$game_party.actors.size,4].min-rand(2),1.3].max self.damage = self.damage.to_i when 1 self.damage /= [[$game_party.actors.size,4].min,1.3].max self.damage = self.damage.to_i when 2 self.damage /= [[$game_party.actors.size,4].min+rand(4),1.3].max self.damage = self.damage.to_i when 3 num = 0 for enemy in $game_troop.enemies if enemy.exist? num+=1 end end self.damage /= [[$game_party.actors.size,4].min+num,1.3].max self.damage = self.damage.to_i $message_string = "共产主义" when 4 num = 0 for enemy in $game_troop.enemies if enemy.exist? num+=1 end end self.damage /= [[$game_party.actors.size,4].min+num+rand(5),1.3].max self.damage = self.damage.to_i end else self.damage /= 10 $message_string = "共产主义涉死" end end
if target.armor2_id==150 or target.armor3_id==150 or target.armor4_id==150 if $message_string == "共产主义" target.animation_id = 37 target.animation_hit = true case $game_variables[550] when 0 for j in 0...[$game_party.actors.size,4].min if $game_party.actors[j] != target $game_party.actors[j].animation_id = 155 $game_party.actors[j].animation_hit = true $game_party.actors[j].hp -= target.damage $game_party.actors[j].damage = target.damage $game_party.actors[j].damage_pop = true end end when 1 for j in 0...[$game_party.actors.size,4].min if $game_party.actors[j] != target $game_party.actors[j].animation_id = 155 $game_party.actors[j].animation_hit = true $game_party.actors[j].hp -= target.damage $game_party.actors[j].damage = target.damage $game_party.actors[j].damage_pop = true end end when 2 for j in 0...[$game_party.actors.size,4].min if $game_party.actors[j] != target $game_party.actors[j].animation_id = 155 $game_party.actors[j].animation_hit = true $game_party.actors[j].hp -= target.damage $game_party.actors[j].damage = target.damage $game_party.actors[j].damage_pop = true end end when 3 for j in 0...[$game_party.actors.size,4].min if $game_party.actors[j] != target $game_party.actors[j].animation_id = 155 $game_party.actors[j].animation_hit = true $game_party.actors[j].hp -= target.damage $game_party.actors[j].damage = target.damage $game_party.actors[j].damage_pop = true end end for enemy in $game_troop.enemies if enemy.exist? enemy.animation_id = 155 enemy.animation_hit = true enemy.hp -= target.damage enemy.damage = target.damage enemy.damage_pop = true end end when 4 for j in 0...[$game_party.actors.size,4].min if $game_party.actors[j] != target $game_party.actors[j].animation_id = 155 $game_party.actors[j].animation_hit = true $game_party.actors[j].hp -= target.damage $game_party.actors[j].damage = target.damage $game_party.actors[j].damage_pop = true end end for enemy in $game_troop.enemies if enemy.exist? enemy.animation_id = 155 enemy.animation_hit = true enemy.hp -= target.damage enemy.damage = target.damage enemy.damage_pop = true end end end target.damage_pop = true @status_window.refresh @status_window.update @phase4_step = 6 end end
y967 发表于 2026-5-31 10:34
1,共情者/高阶共情者
会给与别人同情的角色,类似于奶妈又不是,圣骑,对,圣骑,牺牲自我50%血量,给同 ...
actor_main = $game_party.actors[0] return if actor_main.nil? || actor_main.dead? # 计算转移HP量:1号角色当前HP的50%,保底1点 transfer_hp = (actor_main.hp * 0.5).to_i transfer_hp = [transfer_hp, 1].max # 1号角色扣血 actor_main.hp -= transfer_hp # 其他存活队员加等量HP for actor in $game_party.actors next if actor == actor_main || actor.nil? || actor.dead? actor.hp = [actor.hp + transfer_hp, actor.maxhp].min end
# 敌方全体存活敌人,加等量HP for enemy in $game_troop.enemies next unless enemy.exist? # 仅给存活的敌人生效,跳过已死亡/不存在的 enemy.hp = [enemy.hp + transfer_hp, enemy.maxhp].min end
# ------------------------------------------------------------------ # 脚本名称: CheckLevelAndReset.rb # 功能: 检查队伍等级,若有人大于10级,则记录TXT,删档,退出 # 使用方法: 在事件中使用 "脚本" 命令,输入: check_level_and_reset # ------------------------------------------------------------------ def check_level_and_reset # 1. 遍历角色,检查等级 level_check_passed = false for actor in $game_party.actors if actor.level > 10 level_check_passed = true break end end # 2. 如果条件满足 if level_check_passed # 设置全局变量1为10 (虽然马上要退出,但为了保险起见先设置,尽管存档会被删) $game_variables = 10 # 3. 记录到 TXT 文件 (使用 Game 目录下的 data 文件夹,或者根目录) # 注意:RMXP 默认工作目录是游戏根目录 file_path = "./persistent_var1.txt" File.open(file_path, "w") do |f| f.write("10") end # 4. 销毁所有存档 for i in 1..4 # RMXP 通常有4个存档位 Save1.rxdata 到 Save4.rxdata save_file = "Save#{i}.rxdata" if FileTest.exist?(save_file) File.delete(save_file) end end # 5. 提示用户 (可选,因为马上退出) # $game_message.add("检测到高等级角色,正在重置游戏...") # 6. 退出游戏 # 使用 exit 会直接关闭进程,是最彻底的退出方式 exit else # 如果没满足条件,可以做其他处理,这里留空 end end
# ------------------------------------------------------------------ # 脚本名称: AutoLoadVarFromTxt.rb # 功能: 在新游戏开始时,检查是否存在 persistent_var1.txt,如有则读取并赋值给变量1 # 安装: 放在主脚本列表的底部,确保在 Scene_Title 之后 # ------------------------------------------------------------------ class Scene_Title # 别名原有的 new_game 命令,以便插入我们的逻辑 alias :original_command_new_game :command_new_game def command_new_game # 执行原有的新游戏初始化逻辑 original_command_new_game # --- 自定义逻辑开始 --- # 尝试读取持久化变量文件 file_path = "./persistent_var1.txt" if FileTest.exist?(file_path) begin content = File.read(file_path).strip if content != "" # 将读取到的字符串转换为整数并赋值给全局变量1 $game_variables = Integer(content) # 可选:读取后删除文件,防止下次新游戏再次覆盖(根据需求决定) # 如果希望每次新游戏都重置,则保留删除;如果希望永久保留直到再次被脚本覆盖,则注释掉下一行 File.delete(file_path) end rescue => e # 如果读取失败(如格式错误),忽略错误,避免游戏崩溃 print("读取持久化变量失败: #{e.message}") end end # --- 自定义逻辑结束 --- end end
y967 发表于 2026-6-2 10:09
灭世轮回
# ------------------------------------------------------------------
| 欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |