RPG战斗框架包含以下四部分的内容:
一、基本战斗流程
二、战斗角色设计
三、战斗伤害计算
四、技能设计
五、BUFF设计
六、战斗AI
1、角色出手和施法物理、法术技能施法
2、战斗伤害的计算
warcommand.py
施法操作:
# -*- coding: utf-8-*-
from war_def import *
class CWarPhysics(object):
def attack(self, tid, att):
vic = self.get_warrior(tid)
delay = self.do_attack(att, vic)
return delay, False
def do_attack(self, att, vic):
delay = 0
damage = self.physics_damage(att, vic)
damage = att.on_hit(vic, damage, None, 0)
vic.receive_damage(damage, att)
return delay
class CWarPerform:
def perform(self, tid, skob, lv, att):
vic = self.get_warrior(tid)
delay = 0
targets = skob.get_targets(self, att, vic, lv)
if targets:
skob.pre_cast(self, att, targets, lv)
delay += skob.do_cast(self, att, targets, lv)
skob.end_cast(self, att, targets, lv)
return delay, False
class CWarCommand(CWarPhysics, CWarPerform):
def escape(self, rate, wobj):
pass
def defence(self, rate, wobj):
pass
warformulas.py
伤害计算:
# -*- coding: utf-8-*-
from war_def import *
class CWarFormulas(object):
def physics_damage(self, att, vic, add=0, def_add=0):
rate = 500
damage = (att.get_attack() + add - vic.get_defense() * (1000 - rate) / 1000) * rand_int(*RANDOM_DAMAGE) / 100
damage = max(0, damage)
return damage
def magic_damage(self, att, vic, add=0):
rate = 500
damage = (att.get_magic_attack() + add - vic.get_magic_defense() * (1000 - rate) / 1000) * rand_int(
*RANDOM_DAMAGE) / 100
damage = max(0, damage)
return damage