def default_slot(this): this.cmnslots = slot.Slots() this.cmnslots.c.att = this.conf.c.att this.cmnslots.c.wt = this.conf.c.wt this.cmnslots.c.stars = this.conf.c.stars this.cmnslots.c.ele = this.conf.c.ele this.slot_common = this.conf.slot_common[0] this.slot_common(this.cmnslots) this.slots = this.cmnslots
def get(name): global conf get_skillframe(name) csvconf = csv2conf.get(name) conf += csvconf slots = slot.Slots() conf.slot_common = [slot_common.set] import wep wt = conf.c.wt weapon = getattr(wep, wt) wepconf = weapon.conf conf += Conf(wepconf) return conf
def preconfig(this): tmpconf = Conf() tmpconf += this.conf_default tmpconf += globalconf.get(this.name) tmpconf += Conf(this.conf) #tmpconf += conf tmpconf(this.conf_init) tmpconf.slots(tmpconf.slot) this.slots.c.att = tmpconf.c.att this.slots.c.wt = tmpconf.c.wt this.slots.c.stars = tmpconf.c.stars this.slots.c.ele = tmpconf.c.ele slots_save = slot.Slots() slots_save.w = this.slots.w slots_save.d = this.slots.d slots_save.a = this.slots.a this.slot_common = tmpconf.slot_common[0] this.slot_common(this.slots) if slots_save.w: this.slots.w = tmpconf.slots.w if slots_save.d: this.slots.d = tmpconf.slots.d if slots_save.a: this.slots.a = tmpconf.slots.a if tmpconf.slots.w: this.slots.w = tmpconf.slots.w if tmpconf.slots.d: this.slots.d = tmpconf.slots.d if tmpconf.slots.a: this.slots.a = tmpconf.slots.a this.conf = tmpconf this.base_att = this.slots.att(globalconf.forte) this.displayed_att = int(this.slots._att(globalconf.forte))
def __init__(this, conf={}, cond=0): this.Event = Event this.Buff = Buff this.Debuff = Debuff this.Selfbuff = Selfbuff this.Teambuff = Teambuff this.Modifier = Modifier this.Conf = Conf this.log = log this.conf_init = conf this.ctx = Ctx().on() this.condition = m_condition.on this.m_condition = m_condition this.m_condition.set(cond) this._log = [] loginit(this._log) if not this.conf: this.conf = Conf() this.slots = slot.Slots() if not this.name: this.name = this.__class__.__name__ if 1: this.crit_mod = this.solid_crit_mod else: this.crit_mod = this.rand_crit_mod this.skill = Skill() this._acl = None #this.classconf = this.conf this.pre() this.preconfig()
from adv import * from adv.mikoto import * import slot s = slot.Slots('elisanne') s.d = slot.d.water.Leviathan() s.w = slot.WeaponBase() s.w.wt = 'lance' s.a = slot.a.VC() + slot.a.Witchs_Kitchen() s.a = slot.a.RR() + slot.a.Bellathorna() conf = Conf() conf.acl = Conf() conf.acl = """ `s1,seq=5 and cancel `s2,seq=5 and cancel `s3,seq=5 and cancel """ Mikoto(conf).run() #logcat() sum_dmg() print(s.att()) print(s.tmp.a.a) print(s.att()) print(s.tmp.a.a)
class Adv(object): # vvvvvvvvv rewrite this to provide advanced tweak vvvvvvvvvv adv_name = None def s1_proc(this, e): pass def s2_proc(this, e): pass def s3_proc(this, e): pass def fs_proc(this, e): pass def dmg_proc(this, name, amount): pass def speed(this): return 1 def pre(this): pass def init(this): pass #def condition(this): # return '' # ^^^^^^^^^ rewrite this to provide advanced tweak ^^^^^^^^^^ comment = '' #x_status = (0,0) conf = {} slots = slot.Slots() conf_default = { 'latency' : {'x':0.05, 'sp':0.05, 'default':0.05, 'idle':0}, 'latency' : {'x':0.00, 'sp':0.00, 'default':0.00, 'idle':0}, 's1_dmg' : 0 , 's1_sp' : 0 , 's1_startup' : 0.1 , 's1_recovery' : 1.9 , 's2_dmg' : 0 , 's2_sp' : 0 , 's2_startup' : 0.1 , 's2_recovery' : 1.9 , 's3_dmg' : 0 , 's3_sp' : 0 , 's3_startup' : 0.1 , 's3_recovery' : 1.9 , 'dodge_startup' : 0 , 'dodge_recovery' : 43 / 60.0 , 'fsf_startup' : 0 , 'fsf_recovery' : 41 / 60.0 , } conf_default['acl'] = ''' `s1 `s2 `s3 ''' acl_prepare_default = ''' #pin=e.pin #dname=e.dname #dstat=e.dstat #didx=e.didx #prev = this.action.getprev() #pname=prev.name #pidx=prev.index #pstat=prev.status #xseq = -1 #if dname[0] == 'x': xseq = didx #if dstat == -2: xseq = 0 #seq = xseq #cancel=0 #x=0 #fsc=0 #if pin == 'x': \n x=1\n cancel=1\n x_cancel=1 #if pin == 'fs':\n fsc=1\n cancel=1 #s=0 #sx=0 #if pin[0] == 's' and pin[1] != 'p':\n s=int(pin[1]) #if pin[-2:] == '-x':\n s=int(pin[1])\n sx=s\n #sp=0 #if pin == 'sp': sp=dname #s1=this.s1 #s2=this.s2 #s3=this.s3 #fs=this.fs #fsf=this.fsf #dodge=this.dodge ''' #if pin[-2:] == '-x':\n s=pidx\n sx=pidx\n print sx\n print pin\n exit() def preconfig(this,conf={}): tmpconf = {} tmpconf.update(this.conf_default) tmpconf.update(globalconf.get(this.adv_name)) tmpconf.update(this.conf) tmpconf.update(conf) if 'adv_name' in tmpconf : if this.adv_name != tmpconf['adv_name']: if this.adv_name == this.__class__.__name__: this.adv_name = tmpconf['adv_name'] this.setconf(conf) return this.slots.c.ele = tmpconf['element'] this.slots.c.wt = tmpconf['weapon'] this.slots.c.att = tmpconf['str_adv'] this.slots.w.wt = tmpconf['weapon'] this.slots.w.ele = tmpconf['element'] this.slots.w.att = tmpconf['str_w']/1.5 tmpconf['slot_common'](this.slots) this.conf = tmpconf this.base_att = this.slots.att(globalconf.forte) this.conf['base_att'] = this.base_att this.conf['displayed_str'] = this.slots._att(globalconf.forte) def setconfig(this,conf={}): this.preconfig(conf) # set buff this.action = Action() this.action._static.spd_func = this.speed # set buff this.buff = Buff() this.all_buffs = [] this.buff._static.all_buffs = this.all_buffs this.buff._static.time_func = this.bufftime # set modifier this.modifier = Modifier(0,0,0,0) this.all_modifiers = [] this.modifier._static.all_modifiers = this.all_modifiers # init actions this.a_s1 = Action(('s1',1),this.conf) this.a_s2 = Action(('s2',2),this.conf) this.a_s3 = Action(('s3',3),this.conf) this.a_x1 = Action(('x1',1),this.conf) this.a_x2 = Action(('x2',2),this.conf) this.a_x3 = Action(('x3',3),this.conf) this.a_x4 = Action(('x4',4),this.conf) this.a_x5 = Action(('x5',5),this.conf) this.a_dodge = Action('dodge', this.conf) this.a_fsf = Action('fsf', this.conf) fsconf = {} xnfsconf = {} xn = {} for i in this.conf: if i[:3] == 'fs_': fsconf[i] = this.conf[i] if i[2:5] == 'fs_': xnfsconf[i] = this.conf[i] xn[i[:4]] = 1 this.a_fs = Action('fs',fsconf) for i in ['x1fs','x2fs','x3fs','x4fs','x5fs']: tmpconf = {} for j in xnfsconf: if j[:4] == i: tmpconf[j[2:]] = xnfsconf[j] if tmpconf == {}: setattr(this, 'a_'+i, this.a_fs ) else: for j in fsconf: if j not in tmpconf: tmpconf[j] = fsconf[j] setattr(this, 'a_'+i, Action('fs' ,tmpconf) ) this.a_x1.cancel_by = ['dodge','fs','fsf','s1','s2','s3'] this.a_x2.cancel_by = ['dodge','fs','fsf','s1','s2','s3'] this.a_x3.cancel_by = ['dodge','fs','fsf','s1','s2','s3'] this.a_x4.cancel_by = ['dodge','fs','fsf','s1','s2','s3'] this.a_x5.cancel_by = ['dodge','fs','fsf','s1','s2','s3'] this.a_fs.cancel_by = ['dodge','s1','fsf','s2','s3'] this.a_x1fs.cancel_by = ['dodge','s1','s2','s3'] this.a_x2fs.cancel_by = ['dodge','s1','s2','s3'] this.a_x3fs.cancel_by = ['dodge','s1','s2','s3'] this.a_x4fs.cancel_by = ['dodge','s1','s2','s3'] this.a_x5fs.cancel_by = ['dodge','s1','s2','s3'] this.a_x1.interrupt_by = ['dodge', 'fs','fsf','s1','s2','s3'] this.a_x2.interrupt_by = ['dodge', 'fs','fsf','s1','s2','s3'] this.a_x3.interrupt_by = ['dodge', 'fs','fsf','s1','s2','s3'] this.a_x4.interrupt_by = ['dodge', 'fs','fsf','s1','s2','s3'] this.a_x5.interrupt_by = ['dodge', 'fs','fsf','s1','s2','s3'] this.a_fs.interrupt_by = ['s1','s2','s3'] this.a_x1fs.interrupt_by = ['s1','s2','s3'] this.a_x2fs.interrupt_by = ['s1','s2','s3'] this.a_x3fs.interrupt_by = ['s1','s2','s3'] this.a_x4fs.interrupt_by = ['s1','s2','s3'] this.a_x5fs.interrupt_by = ['s1','s2','s3'] this.s1 = Skill('s1',this.conf['s1_sp'],this.a_s1.tap) this.s2 = Skill('s2',this.conf['s2_sp'],this.a_s2.tap) this.s3 = Skill('s3',this.conf['s3_sp'],this.a_s3.tap) if this.conf['x_type']== 'ranged': this.l_x = this.l_range_x this.l_fs = this.l_range_fs #this.fs_success = this.range_fs_sucess elif this.conf['x_type']== 'melee': this.l_x = this.l_melee_x this.l_fs = this.l_melee_fs #this.fs_success = this.melee_fs_success # set cmd this.x1 = this.a_x1 this.x2 = this.a_x2 this.x3 = this.a_x3 this.x4 = this.a_x4 this.x5 = this.a_x5 #this.fs = this.a_fs this.fsf = this.a_fsf this.dodge = this.a_dodge for i in this.conf: if i[:3] == 'mod': j = this.conf[i] if type(j) == tuple: Modifier(i,*j) elif type(j) == list: idx = 0 for k in j: Modifier(i+'_%d'%idx,*k) idx += 1 def __init__(this,conf={},cond=0): this.Event = Event this.Buff = Buff this.Debuff = Debuff this.Selfbuff = Selfbuff this.Teambuff = Teambuff this.Modifier = Modifier this.log = log this.conf_init = conf this.ctx = Ctx().on() this.condition = m_condition.on this.m_condition = m_condition this.m_condition.set(cond) this._log = [] loginit(this._log) if not this.adv_name: this.adv_name = this.__class__.__name__ this.preconfig(conf) if 1: this.crit_mod = this.solid_crit_mod else: this.crit_mod = this.rand_crit_mod this.skill = Skill() this._acl = None #this.ctx.off() def dmg_mod(this, name): if name[:2] == 'o_': name = name[2:] #if name.find('o_') != -1: # name = name.replace('o_','') if name[0] == 's': return this.mod('s') elif name[0:2] == 'fs': return this.mod('fs') elif name[0] == 'x': return this.mod('x') else: return 1 def mod(this, mtype): m = {} for i in this.all_modifiers: if mtype == i.mod_type: if i.mod_order in m: m[i.mod_order] += i.get() else: m[i.mod_order] = 1 + i.get() ret = 1.0 for i in m: ret *= m[i] return ret def crit_mod(this): pass def solid_crit_mod(this): m = {'chance':0, 'dmg':0, 'damage':0, 'passive':0, 'rate':0,} for i in this.all_modifiers: if 'crit' == i.mod_type: if i.mod_order in m: m[i.mod_order] += i.get() else: print 'err in crit_mod' exit() chance = m['chance']+m['passive']+m['rate'] if chance > 1: chance = 1 cdmg = m['dmg'] + m['damage'] + 1.7 average = chance * (cdmg-1) + 1 return average def rand_crit_mod(this): m = {'chance':0, 'dmg':0, 'damage':0, 'passive':0} for i in this.all_modifiers: if 'crit' == i.mod_type: if i.mod_order in m: m[i.mod_order] += i.get() else: print 'err in crit_mod' exit() chance = m['chance']+m['passive'] if chance > 1: chance = 1 cdmg = m['dmg'] + m['damage'] + 1.7 r = random.random() if r < chance: return cdmg else: return 1 def att_mod(this): att = this.mod('att') cc = this.crit_mod() return cc * att def def_mod(this): m = this.mod('def') if m < 0.5: return 0.5 else: return m def sp_mod(this, name): return this.mod('sp') def bufftime(this): return this.mod('buff') def l_idle(this, e): this.think_pin('idle') prev = this.action.getprev() if prev.name[0] == 's': this.think_pin(prev.name) if this.skill._static.first_x_after_s : this.skill._static.first_x_after_s = 0 s_prev = this.skill._static.s_prev this.think_pin('%s-x'%s_prev) this.x() def getxseq(this): doing = this.action.getdoing() if doing.name[0] == 'x': return doing.index, doing.status else: return doing.name, doing.index def getprev(this): prev = this.action.getprev() return prev.name, prev.index, prev.status def fs(this): doing = this.action.getdoing() if doing.name[0] == 'x': a = getattr(this, 'a_'+doing.name+'fs') return a() else: return this.a_fs() def x(this): prev = this.action.getprev() x_next = 1 if prev.name[0] == 'x': if prev.index != 5: x_next = prev.index + 1 a = getattr(this, 'x%d'%x_next)() return 1 def l_range_x(this, e): xseq = e.name dmg_coef = this.conf['%s_dmg'%xseq] sp_gain = this.conf['%s_sp'%xseq] if xseq == 'x5': log('x', '%s'%xseq, 0,'-------------------------------------c5') else: log('x', '%s'%xseq, 0) missile_timer = Timer(this.cb_missile, this.conf['missile_iv'][xseq] ) missile_timer.dname = '%s_missile'%xseq missile_timer.amount = dmg_coef missile_timer.samount = sp_gain missile_timer() this.think_pin('x') def cb_missile(this, t): this.dmg_make(t.dname, t.amount) this.charge(t.dname, t.samount) def l_melee_x(this, e): xseq = e.name dmg_coef = this.conf['%s_dmg'%xseq] sp = this.conf['%s_sp'%xseq] if xseq == 'x5': log('x', '%s'%xseq, 0,'-------------------------------------c5') else: log('x', '%s'%xseq, 0) this.dmg_make('%s'%xseq, dmg_coef) this.think_pin('x') this.charge('%s'%xseq, sp) def run(this, d = 300): this.pre() this.ctx.on() this.setconfig() this.l_idle = Listener('idle',this.l_idle) this.l_x = Listener(['x1','x2','x3','x4','x5'],this.l_x) this.l_fs = Listener(['fs','x1fs','x2fs','x3fs','x4fs','x5fs'],this.l_fs) this.l_s = Listener(['s1','s2','s3'],this.l_s) this.l_silence_end = Listener('silence_end' , this.l_silence_end ) this.l_dmg_make = Listener('dmg_make' , this.l_dmg_make ) this.l_true_dmg = Listener('true_dmg' , this.l_true_dmg ) this.l_dmg_formula = Listener('dmg_formula' , this.l_dmg_formula ) this.init() this.slots.oninit(this) this.ctx.on() Event('idle')() if not this._acl: this._acl, this._acl_str = acl.acl_func_str( this.acl_prepare_default+this.conf['acl'] ) Timeline.run(d) def think_pin(this, pin): def cb_think(t): if loglevel >= 2: log('think', t.pin, t.dname) this._acl(this, t) if pin in this.conf['latency'] : latency = this.conf['latency'][pin] else: latency = this.conf['latency']['default'] t = Timer(cb_think).on(latency) doing = this.action.getdoing() t.pin = pin t.dname = doing.name t.dstat = doing.status t.didx = doing.index def l_silence_end(this, e): doing = this.action.getdoing() sname = this.skill._static.s_prev if doing.name[0] == 'x': this.skill._static.first_x_after_s = 1 else: this.think_pin(sname+'-x') # best choice this.think_pin(sname) #if doing.name[0] == 's': # no_deed_to_do_anythin def charge_p(this, name, sp): if type(sp) == str and sp[-1] == '%': percent = int(sp[:-1]) this.s1.charge(this.conf['s1_sp']*percent/100) this.s2.charge(this.conf['s2_sp']*percent/100) this.s3.charge(this.conf['s3_sp']*percent/100) log('sp', name, '%d%% '%percent,'%d/%d, %d/%d, %d/%d'%(\ this.s1.charged, this.s1.sp, this.s2.charged, this.s2.sp, this.s3.charged, this.s3.sp) ) this.think_pin('prep') return def charge(this, name, sp): sp = sp * this.sp_mod(name) this.s1.charge(sp) this.s2.charge(sp) this.s3.charge(sp) this.think_pin('sp') log('sp', name, sp,'%d/%d, %d/%d, %d/%d'%(\ this.s1.charged, this.s1.sp, this.s2.charged, this.s2.sp, this.s3.charged, this.s3.sp) ) def l_dmg_formula(this, e): name = e.dname dmg_coef = e.dmg_coef if hasattr(e, 'dtype'): name = e.dtype if 'modifiers' in e.__dict__ : if e.modifiers!=None and e.modifiers != 0: this.all_modifiers = e.modifiers e.dmg = this.dmg_formula(name, dmg_coef) this.all_modifiers = this.modifier._static.all_modifiers e.ret = e.dmg return def dmg_formula(this, name, dmg_coef): att = 1.0 * this.att_mod() * this.base_att armor = 10.0 * this.def_mod() return 5.0/3 * dmg_coef * this.dmg_mod(name) * att/armor # true formula #return att/armor * dmg_coef * this.dmg_mod(name) def l_true_dmg(this, e): log('dmg', e.dname, e.count, e.comment) def l_dmg_make(this, e): dmg_make(e.dname, e.dmg_coef) def dmg_make(this, name, dmg_coef, dtype=None): if dtype == None: dtype = name count = this.dmg_formula(dtype, dmg_coef) log('dmg', name, count) this.dmg_proc(name, count) def dmg_make_withspshow(this, name, dmg_coef, dtype=None): if dtype == None: dtype = name count = this.dmg_formula(dtype, dmg_coef) if name[0] == 'x': spgain = this.conf[name[:2]+'_sp'] log('dmg', name, count, '%d/%d, %d/%d, %d/%d (+%d)'%(\ this.s1.charged, this.s1.sp, this.s2.charged, this.s2.sp, this.s3.charged, this.s3.sp, spgain) ) elif name[:2] == 'fs': spgain = this.conf['fs'+'_sp'] log('dmg', name, count, '%d/%d, %d/%d, %d/%d (+%d)'%(\ this.s1.charged, this.s1.sp, this.s2.charged, this.s2.sp, this.s3.charged, this.s3.sp, spgain) ) else: spgain = 0 if name[:2]+'_sp' in this.conf: spgain = this.conf[name[:2]+'_sp'] log('dmg', name, count, '%d/%d, %d/%d, %d/%d (-%d)'%(\ this.s1.charged, this.s1.sp, this.s2.charged, this.s2.sp, this.s3.charged, this.s3.sp, spgain) ) this.dmg_proc(name, count) def l_melee_fs(this, e): log('fs','succ') dmg_coef = this.conf['fs_dmg'] this.dmg_make('fs', dmg_coef) this.fs_proc(e) this.think_pin('fs') this.charge('fs',this.conf['fs_sp']) def l_range_fs(this, e): log('fs','succ') dmg_coef = this.conf['fs_dmg'] sp_gain = this.conf['fs_sp'] missile_timer = Timer(this.cb_missile, this.conf['missile_iv']['fs'] ) missile_timer.dname = 'fs_missile' missile_timer.amount = dmg_coef missile_timer.samount = sp_gain missile_timer() this.fs_proc(e) this.think_pin('fs') def l_s(this, e): prev, index, stat = this.getprev() if prev == 'fs': log('cast', e.name, 0,'<cast> %d/%d, %d/%d, %d/%d (%s after fs)'%(\ this.s1.charged, this.s1.sp, this.s2.charged, this.s2.sp, this.s3.charged, this.s3.sp, e.name) ) elif prev[0] == 'x': log('cast', e.name, 0,'<cast> %d/%d, %d/%d, %d/%d (%s after c%s)'%(\ this.s1.charged, this.s1.sp, this.s2.charged, this.s2.sp, this.s3.charged, this.s3.sp, e.name, index ) ) else: log('cast', e.name, 0,'<cast> %d/%d, %d/%d, %d/%d (%s after %s)'%(\ this.s1.charged, this.s1.sp, this.s2.charged, this.s2.sp, this.s3.charged, this.s3.sp, e.name, prev ) ) dmg_coef = this.conf[e.name+'_dmg'] if dmg_coef : this.dmg_make(e.name , dmg_coef) if e.name+'_buff' in this.conf: buffarg = this.conf[e.name+'_buff'] wide = buffarg[0] buffarg = buffarg[1:] if wide == 'team': Teambuff(e.name, *buffarg).on() elif wide == 'self': Selfbuff(e.name, *buffarg).on() elif wide == 'debuff': Debuff(e.name, *buffarg).on() else: Buff(e.name, *buffarg).on() func = e.name + '_proc' getattr(this, func)(e)