标题: 问战斗程序段 [打印本页] 作者: kvkv97 时间: 2021-3-13 15:12 标题: 问战斗程序段 for action in self.actions
# 确认回合条件
n = $game_temp.battle_turn
a = action.condition_turn_a
b = action.condition_turn_b
if (b == 0 and n != a) or
(b > 0 and (n < 1 or n < a or n % b != a % b))
next
end
# 确认 HP 条件
if self.hp * 100.0 / self.maxhp > action.condition_hp
next
end
# 确认等级条件
if $game_party.max_level < action.condition_level
next
end
# 确认开关条件
switch_id = action.condition_switch_id
if switch_id > 0 and $game_switches[switch_id] == false
next
end
# 符合条件 : 添加本行动
available_actions.push(action)
if action.rating > rating_max
rating_max = action.rating
end
end
请问:if (b == 0 and n != a) or
(b > 0 and (n < 1 or n < a or n % b != a % b))
next
end
上面的程序怎么理解?作者: guoxiaomi 时间: 2021-3-13 17:36
这里的condition_turn_a和condition_turn_b就是所谓的触发条件:回合a+bx。
1. (b == 0 and n !=a)是说,a+0x的时候,如果回合数n!=a,则不会触发
2. (b > 0)是说a+bx,这个时候应该是a+b触发第一次,a+b*2触发第二次,以此类推……
3. (n < 1 or n < a or n % b != a % b)是说,如果n<a则不会触发,第3句是说如果n-a mod b != 0也不会触发