- 注册时间
- 2004-9-18
- 最后登录
- 2005-10-5
⑤进阶
- 积分
- 854
|
有網友問我,他想用主角空手攻擊應該如何做。
在原本的腳本,
當主角沒有裝備武器時,攻擊力是0的。
計算後,傷害也是0的。
要解決這個問題,很容易。
在Class Game_Battler 內的Method attack_effect(attacker) 作修改。
#--------------------------------------------------------------------------
# ● 應用通常攻擊效果
# attacker : 攻擊者 (battler)
#--------------------------------------------------------------------------
def attack_effect(attacker)
# 清除會心一擊標誌
self.critical = false
# 第一命中判定
hit_result = (rand(100) < attacker.hit)
# 命中的情況下
if hit_result == true
# 計算基本傷害
atk = [attacker.atk - self.pdef / 2, 5].max
# 限制角色攻擊力最少是5
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 的傷害計算
self.hp -= self.damage
# 狀態變化
@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
在修改後,就可以看到無論敵人物理防禦有多強,
還是你的攻擊力有多弱,
即使是0攻擊力的空手,都能傷害敵人。
但是你會發覺竟然沒有攻擊動畫!?
在Class Game_Actor 的 Method animation1_id 和 Method animation2_id
#--------------------------------------------------------------------------
# ● 普通攻擊 獲取攻擊方動畫 ID
#--------------------------------------------------------------------------
def animation1_id
weapon = $data_weapons[@weapon_id]
return weapon != nil ? weapon.animation1_id : 11
#11 本來是0 的,現在會在攻擊方顯示11號的動畫
#可以把它改做你要顯示的動畫
end
#--------------------------------------------------------------------------
# ● 普通攻擊 獲取對像方動畫 ID
#--------------------------------------------------------------------------
def animation2_id
weapon = $data_weapons[@weapon_id]
return weapon != nil ? weapon.animation2_id : 4
#4 本來是0 的,現在會在攻擊方顯示4號的動畫
#可以把它改做你要顯示的動畫
end
再試一次,現在可以顯示動畫,
以後主角便可以用空手攻擊了!
歡迎到天空工作室討論及參考更多教學文章
http://skystudio.no-ip.com |
|