def freezeAffs(targ): if (aff("shivering") in targ.affs): return "frozen" elif (aff("no_caloric") in targ.affs): return "shivering" else: return "no_caloric"
def takeLimbDmg(self, limb, dmg, doBreak = True): if (limb in self.limbs): self.limbs[limb] += dmg; if (not doBreak): return; if (self.limbs[limb] > 1/3 * 100): if (limb not in ["head", "torso"]): self.addAff(aff(limb + "_broken")); self.addAff(aff(limb + "_damaged")); if (self.limbs[limb] > 2/3 * 100): if (limb not in ["head", "torso"]): self.addAff(aff(limb + "_broken")); self.addAff(aff(limb + "_damaged")); self.addAff(aff(limb + "_mangled"));
def addAff(self, affl, stacks = 0, duration = 0, timer = 0, selfVis = True, applierVis = True): if (stacks != 0 and affl in self.affs): stacks = self.affs[affl][1] + stacks; self.affs[affl] = [self.affs[affl][0], stacks, duration, self.affs[affl][3]]; else: self.affs[affl] = [self.curTime, stacks, duration, timer]; if (affl in tickAffs): self.tickableAffs[affl] = True; if (affl == aff("death")): print(self.name + " HAS DIED");
def tickAffs(self, time): remList = []; addList = []; for affl in self.tickableAffs: if (affl == aff("ablaze")): if (self.affs[affl][3] >= 10 or self.affs[affl][1] == 0): self.takeDmg(1 + 1 * self.affs[affl][1]); self.affs[affl][1] += 1; self.affs[affl][3] = 0; elif (affl == aff("paresis")): if (self.affs[affl][3] >= 5): remList.append(affl); addList.append(aff("paralysis")); self.affs[affl][3] += time; if (self.affs[affl][2] != 0 and self.affs[affl][3] > self.affs[affl][2]): remList.append(affl); for rem in remList: self.remAff(rem); for add in addList: self.addAff(add);
def testProne(targ): testList = [ aff("prone"), aff("frozen"), aff("indifference"), aff("unconscious"), aff("asleep"), aff("stun"), aff("paralysis") ] testMin = aff("writhe_armpitlock") testMax = aff("writhe_feed") for affl in testList: if (affl in targ.affs): return True for i in range(testMin, testMax + 1): if (i in targ.affs): return True return False
class Actor: pillCures = { "antipsychotic" : [aff("sadness"), aff("confusion"), aff("dementia"), aff("hallucinations"), aff("paranoia"), aff("hypersomnia"), aff("hatred"), aff("addiction"), aff("blood_curse"), aff("blighted")], "euphoriant" : [aff("self-pity"), aff("stupidity"), aff("dizziness"), aff("faintness"), aff("shyness"), aff("epilepsy"), aff("impatience"), aff("dissonance"), aff("infested"), aff("insomnia")], "decongestant" : [aff("baldness"), aff("clumsiness"), aff("hypochondria"), aff("weariness"), aff("asthma"), aff("sensitivity"), aff("ringing_ears"), aff("impairment"), aff("blood_poison")], "depressant" : [aff("commitment_fear"), aff("merciful"), aff("recklessness"), aff("egocentric"), aff("masochism"), aff("agoraphobia"), aff("loneliness"), aff("berserking"), aff("vertigo"), aff("claustrophobia")], "coagulation" : [aff("body_odor"), aff("lethargy"), aff("allergies"), aff("mental_disruption"), aff("physical_disruption"), aff("vomiting"), aff("exhausted"), aff("thin_blood"), aff("rend"), aff("haemophilia")], "steroid" : [aff("hubris"), aff("pacifism"), aff("peace"), aff("lovers_effect"), aff("laxity"), aff("superstition"), aff("generosity"), aff("justice"), aff("magnanimity")], "opiate" : [aff("paresis"), aff("paralysis"), aff("TREE_PARALYSIS"), aff("mirroring"), aff("crippled_body"), aff("crippled"), aff("blisters"), aff("slickness"), aff("heartflutter"), aff("sandrot")], "panacea" : [aff("patterns")], "amaurosis" : [aff("no_blindness")], "ototoxin" : [aff("no_deafness")], "anabiotic" : [aff("bulimia"), aff("plodding"), aff("idiocy")], "waterbreathing" : [aff("no_waterbreathing")], "acuity" : [aff("no_thirdeye")], "thanatonin" : [aff("no_deathsight")], "kawhe" : [aff("no_insomnia")], "stimulant" : [aff("no_instawake")], } def __init__(self, Name, classSkills): self.name = Name; self.hp = 100.0; self.mp = 100.0; self.bleed = 0.0; self.limbs = {"head": 0.0, "torso": 0.0, "left_arm": 0.0, "right_arm": 0.0, "left_leg": 0.0, "right_leg": 0.0}; self.affs = {}; self.tickableAffs = {}; self.inhibitedCures = {}; self.defs = {}; self.tickableDefs = {}; self.skills = []; self.curTime = 0; self.firstAid = None; for skill in classSkills: self.skills.append(skill); #for skill in Actor.defaultSkills: # self.skills.append(skill); self.classState = {'resonance': None, 'soul': 0.0, 'energy': 0.0, 'kai': 0.0, 'l_charge': 0, 'r_charge': 0, 'b_charge': 0}; # bal, eq, elixir, affelixir, ability, right_arm, left_arm, herb, focus, tree, salve, pipe, renew, moss self.balances = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] self.room = None; self.avgAffDuration = 0.0; self.avgAffDurationCount = 0; def tickBals(self, time): for i in range(len(self.balances)): self.balances[i] -= time; def takeDmg(self, hpDmg = 0, mpDmg = 0): if (hpDmg >= FLOAT_TOLERANCE): self.hp -= hpDmg; if (mpDmg >= FLOAT_TOLERANCE): self.mp -= mpDmg; def healDmg(self, hpHeal = 0, mpHeal = 0): if (hpDmg >= FLOAT_TOLERANCE): self.hp += hpDmg; if (self.hp > 100.0): self.hp = 100.0; if (mpDmg >= FLOAT_TOLERANCE): self.mp += mpDmg; if (self.mp > 100.0): self.mp = 100.0; def takeLimbDmg(self, limb, dmg, doBreak = True): if (limb in self.limbs): self.limbs[limb] += dmg; if (not doBreak): return; if (self.limbs[limb] > 1/3 * 100): if (limb not in ["head", "torso"]): self.addAff(aff(limb + "_broken")); self.addAff(aff(limb + "_damaged")); if (self.limbs[limb] > 2/3 * 100): if (limb not in ["head", "torso"]): self.addAff(aff(limb + "_broken")); self.addAff(aff(limb + "_damaged")); self.addAff(aff(limb + "_mangled")); def printState(self): print(self.hp, self.mp, end="|"); for aff in self.affs: print(aff_id(aff), ":", self.affs[aff][0], self.affs[aff][1], self.affs[aff][2], self.affs[aff][3], end="|"); print(); def addAff(self, affl, stacks = 0, duration = 0, timer = 0, selfVis = True, applierVis = True): if (stacks != 0 and affl in self.affs): stacks = self.affs[affl][1] + stacks; self.affs[affl] = [self.affs[affl][0], stacks, duration, self.affs[affl][3]]; else: self.affs[affl] = [self.curTime, stacks, duration, timer]; if (affl in tickAffs): self.tickableAffs[affl] = True; if (affl == aff("death")): print(self.name + " HAS DIED"); def remAff(self, affl): if (affl in self.affs): self.avgAffDuration += (self.curTime - self.affs[affl][0]); self.avgAffDurationCount += 1; self.affs.pop(affl, None); self.tickableAffs.pop(affl, None); def hasAff(self, aff): return aff in self.affs; def tickAffs(self, time): remList = []; addList = []; for affl in self.tickableAffs: if (affl == aff("ablaze")): if (self.affs[affl][3] >= 10 or self.affs[affl][1] == 0): self.takeDmg(1 + 1 * self.affs[affl][1]); self.affs[affl][1] += 1; self.affs[affl][3] = 0; elif (affl == aff("paresis")): if (self.affs[affl][3] >= 5): remList.append(affl); addList.append(aff("paralysis")); self.affs[affl][3] += time; if (self.affs[affl][2] != 0 and self.affs[affl][3] > self.affs[affl][2]): remList.append(affl); for rem in remList: self.remAff(rem); for add in addList: self.addAff(add); def addDef(self, defense, skill, ability, target, timer, duration): self.defs[defense] = [skill, ability, target, timer, duration]; def remDef(self, defense): self.defs.pop(defense, None); def tickDefs(self, time): for defense in self.tickableDefs: print(defense); def tickRestoration(self, time): if (self.restoration): self.restoration[0] -= time; if (self.restoration[0] <= 0): print("TODO: CURED A LIMB"); def tick(self, time): self.curTime += time; self.curTime = round(self.curTime, 2); self.tickAffs(time); self.tickDefs(time); self.tickBals(time); #self.printState(); if (self.firstAid): self.firstAid(self); def resetBals(self): for i in range(len(self.balances)): self.balances[i] = 0; ## TODO: Make these function def eatPill(self, pill): print("Eating",pill); def applySalve(self, salve, location): print("Applying",salve,location); def smokePipe(self, pipe): print("Smoking",pipe); def sipElixir(self, elixir): print("Sipping", elixir); def focus(self): print("Focusing"); def renew(self): print("Renewing");
import time; from Afflictions import aff_id; from Afflictions import aff; from Tests import *; FLOAT_TOLERANCE = 0.000000000001; tickAffs = [aff("ablaze"), aff("dizziness"), aff("punished_arms"), aff("paresis")]; class Actor: pillCures = { "antipsychotic" : [aff("sadness"), aff("confusion"), aff("dementia"), aff("hallucinations"), aff("paranoia"), aff("hypersomnia"), aff("hatred"), aff("addiction"), aff("blood_curse"), aff("blighted")], "euphoriant" : [aff("self-pity"), aff("stupidity"), aff("dizziness"), aff("faintness"), aff("shyness"), aff("epilepsy"), aff("impatience"), aff("dissonance"), aff("infested"), aff("insomnia")], "decongestant" : [aff("baldness"), aff("clumsiness"), aff("hypochondria"), aff("weariness"), aff("asthma"), aff("sensitivity"), aff("ringing_ears"), aff("impairment"), aff("blood_poison")], "depressant" : [aff("commitment_fear"), aff("merciful"), aff("recklessness"), aff("egocentric"), aff("masochism"), aff("agoraphobia"), aff("loneliness"), aff("berserking"), aff("vertigo"), aff("claustrophobia")], "coagulation" : [aff("body_odor"), aff("lethargy"), aff("allergies"), aff("mental_disruption"), aff("physical_disruption"), aff("vomiting"), aff("exhausted"), aff("thin_blood"), aff("rend"), aff("haemophilia")], "steroid" : [aff("hubris"), aff("pacifism"), aff("peace"), aff("lovers_effect"), aff("laxity"), aff("superstition"), aff("generosity"), aff("justice"), aff("magnanimity")], "opiate" : [aff("paresis"), aff("paralysis"), aff("TREE_PARALYSIS"), aff("mirroring"), aff("crippled_body"), aff("crippled"), aff("blisters"), aff("slickness"), aff("heartflutter"), aff("sandrot")], "panacea" : [aff("patterns")], "amaurosis" : [aff("no_blindness")], "ototoxin" : [aff("no_deafness")], "anabiotic" : [aff("bulimia"), aff("plodding"), aff("idiocy")], "waterbreathing" : [aff("no_waterbreathing")], "acuity" : [aff("no_thirdeye")], "thanatonin" : [aff("no_deathsight")], "kawhe" : [aff("no_insomnia")], "stimulant" : [aff("no_instawake")], } def __init__(self, Name, classSkills):
# First aid. from Afflictions import aff_id from Afflictions import aff herbPriors = [ aff("TREE_PARALYSIS"), aff("paralysis"), aff("asthma"), aff("exhausted"), aff("crippled_body"), aff("thin_blood"), aff("sandrot"), aff("clumsiness"), aff("hypochondria"), aff("weariness"), aff("mirroring"), aff("baldness"), aff("physical_disruption"), aff("mental_disruption"), aff("confusion"), aff("blood_poison"), aff("blood_curse"), aff("impatience"), aff("paresis"), aff("magnanimity"), aff("lethargy"), aff("sensitivity"), aff("recklessness"), aff("ringing_ears"), aff("stupidity"), aff("impairment"),
def disrupt(targ): if (aff("mental_disruption") in targ.affs): return "physical_disruption" else: return "mental_disruption"
def cripple(targ): if (aff("crippled") in targ.affs): return "crippled_body" else: return "crippled"
def asthma(targ): if (aff("no_fitness") in targ.affs): return "asthma" else: return "no_fitness"
def newAb(self, targ, limbTarget=None, venoms=None): if (not targ and targReq): return False for state in hardStateNeeded: preReqs = True if (isinstance(state[1], str)): if (self.classState[state[0]] != state[1]): preReqs = False else: if (self.classState[state[0]] < state[1]): preReqs = False if (not preReqs): print(self.name, "state", state[0], "not", state[1], "for", NAME, "current:", self.classState[state[0]]) return False ## If we require limbs and the user didn't provide enough limbs, end it. if (limbsRequired > 0 and len(limbTarget) != limbsRequired): return False if (notProne and testProne(self)): return False ## If we were given a stopAffList, test it. if (stopAffList): for affliction in stopAffList[0]: if (aff(affliction) in self.affs): return False for affliction in stopAffList[1]: if (aff(affliction) in targ.affs): return False ## If we've hit this point, then we test arms and the balance function. If both true, we do stuff. if (armTest(self) and balFunc[0](self, balFunc[1])): if (hitRebounding and not (aff("no_rebounding") in targ.affs)): targ = self if (targ): print(self.name + " " + NAME + " " + targ.name, end=" ") if (numVenoms > 0): print("(", end="") first = True for venom in venoms: if (not first): print(" ", end="") print(venom, end="") first = False print(")", end="") print() else: print(self.name + " " + NAME) localAffList = [] if (affList): for val in affList: localAffList.append(val) for i in range(numVenoms): if (i < len(venoms)): localAffList.append([None, venoms[i]]) ## Test limb damage. if (limbsRequired > 0): i = 0 for limb in limbTarget: ## Standard limb damage if (limbEffect == 0): targ.takeLimbDmg(limb, limbDmg[i]) ## Limb damage with no break (i.e. frenzy) elif (limbEffect == 1): targ.takeLimbDmg(limb, limbDmg[i], False) ## Auto-cripple/damage/mangle the given limb (shifter). if (limbEffect == 2 and limb not in ["head", "torso"]): targ.addAff(aff(limb + "_broken")) elif (limbEffect == 3 and aff(limb + "_broken") in targ.affs): targ.addAff(aff(limb + "_damaged")) elif (limbEffect == 4 and aff(limb + "_damaged") in targ.affs): targ.addAff(aff(limb + "_mangled")) i += 1 ## For all our affs, do stuff. i = 0 for pair in localAffList: preReqs = False if (isinstance(pair[0], list)): preReqs = True for preReq in pair[0]: if (not (aff(preReq) in targ.affs)): preReqs = False elif (pair[0] == None or aff(pair[0]) in targ.affs): preReqs = True if (stateNeeded[i][0] != None): if (isinstance(stateNeeded[i][1], str)): if (self.classState[stateNeeded[i][0]] != stateNeeded[i][1]): preReqs = False else: if (self.classState[stateNeeded[i][0]] < stateNeeded[i][1]): preReqs = False if (preReqs): ## Bit of repeated code here, but that's probably the least of my sins. if (isinstance(pair[1], list)): for listedAff in pair[1]: if (listedAff in conversion): listedAff = conversion[listedAff](targ) targ.addAff(aff(listedAff), duration=durations[i]) else: if (pair[1] in conversion): pair[1] = conversion[pair[1]](targ) targ.addAff(aff(pair[1]), stacks=stack[i], duration=durations[i], selfVis=visible[0], applierVis=visible[1]) i += 1 if (targ): targ.takeDmg(hpDmg, mpDmg) targ.bleed += bleedDmg ## Update room flags. if (roomFlags): for flag in roomFlags: #print(flag); if (flag[1]): self.room.setFlag(flag[0], flag[1], flag[2]) else: self.room.clearFlag(flag[0]) ## Update class states if (updateState): for entry in updateState: if (len(entry) < 3): self.classState[entry[0]] = entry[1] elif (entry[1] > 0 and self.classState[entry[0]] < entry[2]): self.classState[ entry[0]] = self.classState[entry[0]] + entry[1] if (self.classState[entry[0]] > entry[2]): self.classState[entry[0]] = entry[2] elif (entry[1] < 0 and self.classState[entry[0]] > entry[2]): self.classState[ entry[0]] = self.classState[entry[0]] + entry[1] if (self.classState[entry[0]] < entry[2]): self.classState[entry[0]] = entry[2] chargeMin = min(self.classState['l_charge'], self.classState['r_charge']) self.classState['b_charge'] = chargeMin return True else: return False
def bothArmCheck(self): return not (aff("right_arm_broken")) in self.affs and not ( aff("left_arm_broken") in self.affs)
def consumeElixir(self, amount): if (self.balances[2] and not aff("anorexia") in self.affs): self.balances[2] = amount return True return False
def oneArmCheck(self): return not (aff("left_arm_broken") in self.affs) or not (aff("right_arm_broken") in self.affs)