Last active
August 29, 2015 14:04
-
-
Save lctseng/42069bf65b605df7bcc6 to your computer and use it in GitHub Desktop.
RGSS3片段解析:技能增加變數
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 先到腳本Game_Battler的第411行附近找到以下腳本片段: | |
#-------------------------------------------------------------------------- | |
# ● 技能/使用物品 | |
# 對使用目標使用完畢后,應用對于使用目標以外的效果。 | |
#-------------------------------------------------------------------------- | |
def use_item(item) | |
pay_skill_cost(item) if item.is_a?(RPG::Skill) | |
consume_item(item) if item.is_a?(RPG::Item) | |
item.effects.each {|effect| item_global_effect_apply(effect) } | |
end | |
# 然後修改以下: | |
#-------------------------------------------------------------------------- | |
# ● 技能/使用物品 | |
# 對使用目標使用完畢后,應用對于使用目標以外的效果。 | |
#-------------------------------------------------------------------------- | |
def use_item(item) | |
pay_skill_cost(item) if item.is_a?(RPG::Skill) | |
consume_item(item) if item.is_a?(RPG::Item) | |
change_variable(item) if item.is_a?(RPG::Skill) # 這一行被改了 | |
item.effects.each {|effect| item_global_effect_apply(effect) } | |
end | |
# 並加入以下腳本,這個腳本的用途就是用來新增技能變數用的 | |
#-------------------------------------------------------------------------- | |
# ● 技能增加變數 | |
#-------------------------------------------------------------------------- | |
def change_variable(item) | |
if item.id == 5 # 如果技能ID是5 | |
$game_variables[7] += 1 # 則7號變數+1,但是無論是誰使用(敵人or我方),都會計算 | |
end | |
# 依此類推 | |
end | |
# 如此一來應該可以在使用5號技能時,增加變數,如果還需要判斷角色,可以利用self.id == 角色ID來判斷 | |
# 例如:新增一個"當玩家的2號角色使用6號技能時,8號變數+10" | |
#-------------------------------------------------------------------------- | |
# ● 技能增加變數 | |
#-------------------------------------------------------------------------- | |
def change_variable(item) | |
if item.id == 5 # 如果技能ID是5 | |
$game_variables[7] += 1 # 則7號變數+1 | |
end | |
if self.is_a?(Game_Actor) && self.id == 2 && item.id == 6 # 如果是玩家角色 且 角色ID是2 且 技能ID是6 | |
$game_variables[8] += 10 # 則8號變數+10 | |
end | |
# 依此類推 | |
end | |
# 同理,敵人的判斷則是使用:self.is_a?(Game_Enemy)來得知是否是敵人使用的 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment