Project1
标题:
如何让防具有金钱代替伤害特殊的效果?
[打印本页]
作者:
苹果星ねこ
时间:
2012-5-6 15:56
标题:
如何让防具有金钱代替伤害特殊的效果?
本帖最后由 苹果星ねこ 于 2012-5-6 18:24 编辑
就是装饰此身体防具后,可以用金钱代替伤害,没有钱就是废物。 dsu_plus_rewardpost_czw
作者:
hys111111
时间:
2012-5-6 18:19
module ITEM
TYPE = 4#0:武器,1:盾,2:头部,3:身体,4:装饰品
ID = 4#装备4号装饰品时,使用金钱代替伤害
end
class Game_Battler
#--------------------------------------------------------------------------
# ● 应用通常攻击效果
# attacker : 攻击者 (battler)
#--------------------------------------------------------------------------
def attack_effect(attacker)
#金钱代替伤害off
hit_gold = false
# 清除会心一击标志
self.critical = false
# 第一命中判定
hit_result = (rand(100) < attacker.hit)
# 命中的情况下
if hit_result == true
# 计算基本伤害
atk = [attacker.atk - self.pdef / 2, 0].max
self.damage = atk * (20 + attacker.str) / 20
# 属性修正
self.damage *= elements_correct(attacker.element_set)
self.damage /= 100
# 伤害符号正确的情况下
if self.damage > 0
# 会心一击修正
if rand(100) < 4 * attacker.dex / self.agi
self.damage *= 2
self.critical = true
end
# 防御修正
if self.guarding?
self.damage /= 2
end
end
# 分散
if self.damage.abs > 0
amp = [self.damage.abs * 15 / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# 第二命中判定
eva = 8 * self.agi / attacker.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
end
# 命中的情况下
if hit_result == true
# 状态冲击解除
remove_states_shock
# HP 的伤害计算
if self.is_a?(Game_Actor)
case ITEM::TYPE
when 0
if self.weapon_id == ITEM::ID and $game_party.gold >= 1
hit_gold = true
end
when 1
self.armor1_id == ITEM::ID and $game_party.gold >= 1
hit_gold = true
end
when 2
self.armor2_id == ITEM::ID and $game_party.gold >= 1
hit_gold = true
end
when 3
self.armor3_id == ITEM::ID and $game_party.gold >= 1
hit_gold = true
end
when 4
self.armor4_id == ITEM::ID and $game_party.gold >= 1
hit_gold = true
end
end
end
if hit_gold
$game_party.lose_gold(self.damage)
gold_result = (self.damage).to_s + "金钱"
self.damage = gold_result
else
self.hp -= self.damage
end
# 状态变化
@state_changed = false
states_plus(attacker.plus_state_set)
states_minus(attacker.minus_state_set)
# Miss 的情况下
else
# 伤害设置为 "Miss"
self.damage = "Miss"
# 清除会心一击标志
self.critical = false
end
# 过程结束
return true
end
#--------------------------------------------------------------------------
# ● 应用特技效果
# user : 特技的使用者 (battler)
# skill : 特技
#--------------------------------------------------------------------------
def skill_effect(user, skill)
# 清除会心一击标志
self.critical = false
# 特技的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
# 或者特技的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
# 过程结束
return false
end
# 清除有效标志
effective = false
# 公共事件 ID 是有效的情况下,设置为有效标志
effective |= skill.common_event_id > 0
# 第一命中判定
hit = skill.hit
if skill.atk_f > 0
hit *= user.hit / 100
end
hit_result = (rand(100) < hit)
# 不确定的特技的情况下设置为有效标志
effective |= hit < 100
# 命中的情况下
if hit_result == true
# 计算威力
power = skill.power + user.atk * skill.atk_f / 100
if power > 0
power -= self.pdef * skill.pdef_f / 200
power -= self.mdef * skill.mdef_f / 200
power = [power, 0].max
end
# 计算倍率
rate = 20
rate += (user.str * skill.str_f / 100)
rate += (user.dex * skill.dex_f / 100)
rate += (user.agi * skill.agi_f / 100)
rate += (user.int * skill.int_f / 100)
# 计算基本伤害
self.damage = power * rate / 20
# 属性修正
self.damage *= elements_correct(skill.element_set)
self.damage /= 100
# 伤害符号正确的情况下
if self.damage > 0
# 防御修正
if self.guarding?
self.damage /= 2
end
end
# 分散
if skill.variance > 0 and self.damage.abs > 0
amp = [self.damage.abs * skill.variance / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# 第二命中判定
eva = 8 * self.agi / user.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
# 不确定的特技的情况下设置为有效标志
effective |= hit < 100
end
# 命中的情况下
if hit_result == true
# 威力 0 以外的物理攻击的情况下
if skill.power != 0 and skill.atk_f > 0
# 状态冲击解除
remove_states_shock
# 设置有效标志
effective = true
end
# HP 的伤害减法运算
last_hp = self.hp
if self.is_a?(Game_Actor)
case ITEM::TYPE
when 0
self.weapon_id == ITEM::ID and $game_party.gold >= 1
hit_gold = true
end
when 1
self.armor1_id == ITEM::ID and $game_party.gold >= 1
hit_gold = true
end
when 2
self.armor2_id == ITEM::ID and $game_party.gold >= 1
hit_gold = true
end
when 3
self.armor3_id == ITEM::ID and $game_party.gold >= 1
hit_gold = true
end
when 4
self.armor4_id == ITEM::ID and $game_party.gold >= 1
hit_gold = true
end
end
end
if hit_gold
$game_party.lose_gold(self.damage)
gold_result = (self.damage).to_s + "金钱"
self.damage = gold_result
else
self.hp -= self.damage
end
effective |= self.hp != last_hp
# 状态变化
@state_changed = false
effective |= states_plus(skill.plus_state_set)
effective |= states_minus(skill.minus_state_set)
# 威力为 0 的场合
if skill.power == 0
# 伤害设置为空的字串
self.damage = ""
# 状态没有变化的情况下
unless @state_changed
# 伤害设置为 "Miss"
self.damage = "Miss"
end
end
# Miss 的情况下
else
# 伤害设置为 "Miss"
self.damage = "Miss"
end
# 不在战斗中的情况下
unless $game_temp.in_battle
# 伤害设置为 nil
self.damage = nil
end
# 过程结束
return effective
end
#--------------------------------------------------------------------------
# ● 应用连续伤害效果
#--------------------------------------------------------------------------
def slip_damage_effect
# 设置伤害
self.damage = self.maxhp / 10
# 分散
if self.damage.abs > 0
amp = [self.damage.abs * 15 / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# HP 的伤害减法运算
if self.is_a?(Game_Actor)
case ITEM::TYPE
when 0
self.weapon_id == ITEM::ID and $game_party.gold >= 1
hit_gold = true
end
when 1
self.armor1_id == ITEM::ID and $game_party.gold >= 1
hit_gold = true
end
when 2
self.armor2_id == ITEM::ID and $game_party.gold >= 1
hit_gold = true
end
when 3
self.armor3_id == ITEM::ID and $game_party.gold >= 1
hit_gold = true
end
when 4
self.armor4_id == ITEM::ID and $game_party.gold >= 1
hit_gold = true
end
end
end
if hit_gold
$game_party.lose_gold(self.damage)
gold_result = (self.damage).to_s + "金钱"
self.damage = gold_result
else
self.hp -= self.damage
end
# 过程结束
return true
end
end
复制代码
使用方法:插入后,改TYPE和ID就可以了
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1