Page 1 of 1

Problems With New Scripts In Mantis

Posted: Wed Jun 30, 2010 1:57 am
by Jules
Hey there, everyone. I apologize for not being vocal about Mantis' development for a while. I recently got an internship over the summer, and I've been really busy with that, so I haven't had too much time to update the downloads of Mantis. That will change soon, though, since I HAVE been hard at work changing it up for the 5.1 release, including the addition of a lot of new functions used specifically for curing, making the cures more accurate and safe.

However, I've been having problems with just those cures, and I need some help!

I'll run you through how I do basic testing of scripts, to see how my logic works and if it needs changing. The logic for my curing functions is roughly the same (I'll post an example below). First, check for afflictions that would otherwise hinder the type of curing, with the type being based on the balance used for the cure (herb, purgative, etc...). When that's cleared, send the cure, set a balance variable, then reset the balance variable. The balance variable is used to stop repetitive cures being sent, since that would cause serious spam and waste a lot of cures!

Anyhow, here's a basic example of how I test my curing. I generally test curing based on if I can cure the "prone" affliction, which I get by sending "sit". I get this trigger line:
Code: [show] | [select all] lua
You sit yourself down.
That executes the function to add the "prone" affliction to the queue:
Code: [show] | [select all] lua
function mantis:add_affliction(affliction)
  if table.contains(mantis.current_afflictions, affliction) then
    return
  else
    table.insert(mantis.current_afflictions, affliction)
  end

  selectString(line, 1)
  setFgColor(0,0,0)
  setBgColor(255,0,0)

  mtell(string.format("Adding Affliction: %s", affliction))
end
Note that this function first checks to see if that same affliction is already in the queue (no sense adding something that's already there), and if it is, inserts it. This also highlights the trigger line and sets the color appropriately, in this case, black on red. Then it outputs a little prompt that looks like:
Code: [show] | [select all] lua
(Mantis): Adding Affliction: prone
It's just a little way to display to the user what you're afflicted with.

Next, fired off on the actual Lusternia prompt, is the cure script:
Code: [show] | [select all] lua
function mantis:cure_afflictions()
  
  --Local variables for later use
  local is_diagnosing = mantis.diagnose.diagnosing
  local current_afflictions = mantis.current_afflictions
  local balance_priorities = mantis.balance_priorities
  local is_paused = mantis.paused
  local is_dead = mantis.dead
  local is_stunned = mantis.stunned
  local is_asleep = mantis.current_afflictions.asleep

  if not is_paused and not is_dead and not is_diagnosing and not is_asleep and not is_stunned then --Make sure you do not have any of these conditions
    if #current_afflictions > 0 then --Don't try to cure something that isn't there!
      for _,balance in ipairs(balance_priorities) do --Go through your curing balances
        if balance == 1 then --Make sure that the balance is usable, else we cannot use it to cure!
		  local affliction_priorities = mantis.affliction_priorities[balance] --Sets a variable who's value is the entire affliction priority table, based on balance
          for _,priority_affliction in ipairs(affliction_priorities) do --Go through the list of afflictions in the order that they need to be cured
            for _,current_affliction in ipairs(current_afflictions) do --Scan through the list of afflictions which you are currently afflicted with
              if current_affliction == priority_affliction then --This checks if the affliction you want to cure is the affliction you should cure
                mantis.cures[balance][priority_affliction]() --Send the cure
                mantis.balances[balance] = 0.5 --Set the balance variable to show that a cure was attempted
                mantis:reset_balance(balance) --Reset the balance variable, just incase the cure wasn't properly sent
              end
            end
          end
        end
      end
    end
  end
end
Just in case you were wondering what the Affliction Priorities and Cures lists are, here you go!:

Priorities:
Code: [show] | [select all] lua
mantis.affliction_priorities = {

  special ={
    "aeon",
  },

  balance = {
    "no_equilibrium",
    "impaled",
    "pinned_left_leg",
    "pinned_right_leg",
    "pinned_leg",
    "sap",
    "prone",
    "deathmark",
    "ectoplasm",
    "mud",
    "asleep",
    "grappled",
    "bound",
    "unwielded_weapon",
    "choke",
  },

  purgative = {
    "crotamine",
    "vapors",
    "dysentery",
    "healthleech",
    "hypersomnia",
    "powersink",
    "scalped",
    "vomiting_blood",
    "frozen",
    "confusion",
    "powersap",
    "disloyalty",
    "ablaze",
    "burst_vessels",
    "haemophilia",
    "love_potion",
    "furrowed_brow",
    "shyness",
    "vomiting",
    "weakness",
    "worms",
  },

  salve = {
    "asthma",
    "concussion",
    "slitThroat",
    "burst_organs",
    "disemboweled",
    "chestPain",
    "crushed_chest",
    "severed_left_leg",
    "severed_right_leg",
    "severed_leg",
    "collapsed_lung",
    "shortness_of_breath",
    "ruptured_stomach",
    "mangled_left_leg",
    "mangled_right_leg",
    "mangled_leg",
    "severed_left_arm",
    "severed_right_arm",
    "severed_arm",
    "severed_left_tendon",
    "severed_right_tendon",
    "severed_tendon",
    "partially_damaged_head",
    "fractured_skull",
    "severed_spine",
    "twistedLeg",
    "broken_left_wrist",
    "broken_right_wrist",
    "broken_wrist",
    "broken_left_leg",
    "broken_right_leg",
    "broken_leg",
    "punctured_lung",
    "shattered_left_ankle",
    "shattered_right_ankle",
    "shattered_ankle",
    "black_lung",
    "twisted_left_arm",
    "twisted_right_arm",
    "twisted_arm",
    "shattered_jaw",
    "broken_jaw",
    "mangled_left_arm",
    "mangled_right_arm",
    "mangled_arm",
    "broken_left_arm",
    "broken_right_arm",
    "broken_arm",
    "trembling",
    "sunallergy",
    "scabies",
    "pox",
    "itch",
    "pecked_eyes",
  },

  herb = {
    "anorexia",
    "slickness",
    "crushed_windpipe",
    "temporary_insanity",
    "timewarp",
    "blindness",
    "stupidity",
    "hypochondria",
    "sliced_gut",
    "vapors",
    "bedevil",
    "lightheaded",
    "jinx",
    "aura_warp",
    "hip_clotting",
    "malignant_blood_clots",
    "shoulder_clotting",
    "severed_left_ear",
    "severed_right_ear",
    "severed_ear",
    "narcolepsy",
    "sliced_chest",
    "omniphobia",
    "impatience",
    "scrambled_brain",
    "gashed_cheek",
    "addiction",
    "fractured_left_arm",
    "fractured_right_arm",
    "fractured_arm",
    "sliced_left_bicep",
    "sliced_right_bicep",
    "sliced_bicep",
    "sliced_left_thigh",
    "sliced_right_thigh",
    "sliced_thigh",
    "succumb",
    "daydreaming",
    "crushed_left_foot",
    "crushed_right_foot",
    "crushed_foot",
    "clumsiness",
    "confusion",
    "lacerated_left_arm",
    "lacerated_right_arm",
    "lacerated_arm",
    "lacerated_left_leg",
    "lacerated_right_leg",
    "lacerated_leg",
    "sliced_left_arm_artery",
    "sliced_right_arm_artery",
    "sliced_leg_artery",
    "sliced_left_arm_artery",
    "sliced_right_arm_artery",
    "sliced_arm_artery",
    "bleeding",
    "severphrenic",
    "deadening",
    "deafness",
    "dislocated_left_leg",
    "dislocated_right_leg",
    "dislocated_leg",
    "dislocated_left_arm",
    "dislocated_right_arm",
    "dislocated_arm",
    "pierced_left_leg",
    "pierced_right_leg",
    "pierced_leg",
    "pierced_left_arm",
    "pierced_right_arm",
    "pierced_arm",
    "left_hemiplegy",
    "right_hemiplegy",
    "lower_hemiplegy",
    "recklessness",
    "vestiphobia",
    "manabarbs",
    "dementia",
    "dizziness",
    "epilepsy",
    "gluttony",
    "hallucinations",
    "healthleech",
    "haemophelia",
    "claustrophobia",
    "agoraphobia",
    "justice",
    "lovers_curse",
    "power_spikes",
    "egovice",
    "achromatic_aura",
    "pacified",
    "paranoia",
    "peace",
    "powersink",
    "punctured_chest",
    "snapped_ribs",
    "broken_chest",
    "relapse",
    "rigormortis",
    "sensitivity",
    "vertigo",
    "masochism",
    "broken_nose",
    "shyness",
    "sliced_tongue",
    "weakness",
 },

  focus = {
    "impatience",
    "paralysis",
    "throat_lock",
    "anorexia",
    "locked_legs",
    "stupidity",
    "timewarp",
    "temporary_insanity",
    "recklessness",
    "void",
    "addiction",
    "sickening",
    "darkmoon",
    "treebane",
    "omen",
    "illuminated",
    "infidel",
    "aurawarp",
    "agoraphobia",
    "claustrophobia",
    "confusion",
    "dizziness",
    "epilepsy",
    "lightheaded",
    "loneliness",
    "manabarbs",
    "masochism",
    "pacifism",
    "power_spikes",
    "shyness",
    "weakness",
    "egovice",
  },
}
Cures:
Code: [show] | [select all] lua
mantis.cures = {

  special = {
    aeon = mantis:do_special("aeon"),
    bleeding = mantis:do_special("clot"),
    fear = mantis:do_special("compose"),
  },

  balance = {
    no_equilibrium = mantis:do_balance("concentrate"),
    deathmark = mantis:do_balance("scrub"),
    ectoplasm = mantis:do_balance("scrub"),
    mud = mantis:do_balance("scrub"),
    sap = mantis:do_balance("scrub"),
    stench = mantis:do_balance("scrub"),
    prone = mantis:do_balance("stand"),
    bound = mantis:do_balance("writhe"),
    asleep = mantis:do_balance("wake"),
    crucified = mantis:do_balance("writhe"),
    grappled = mantis:do_balance("writhe"),
    impaled = mantis:do_balance("writhe"),
    pinned_left_leg = mantis:do_balance("writhe"),
    pinned_right_leg = mantis:do_balance("writhe"),
    pinned_leg = mantis:do_balance("writhe"),
    ropes = mantis:do_balance("writhe"),
    shackled = mantis:do_balance("writhe"),
    transfixed = mantis:do_balance("writhe"),
    trussed = mantis:do_balance("writhe"),
    vined = mantis:do_balance("writhe"),
  },

  purgative = {
    crotamine = mantis:drink_purgative("antidote"),
    escozul = mantis:drink_purgative("antidote"),
    dysentery = mantis:drink_purgative("choleric"),
    hypersomnia = mantis:drink_purgative("choleric"),
    love_potion = mantis:drink_purgative("choleric"),
    vomiting = mantis:drink_purgative("choleric"),
    vomiting_blood = mantis:drink_purgative("choleric"),
    worms = mantis:drink_purgative("choleric"),
    generosity = mantis:drink_purgative("phlegmatic"),
    powersink = mantis:drink_purgative("phlegmatic"),
    shyness = mantis:drink_purgative("phlegmatic"),
    weakness = mantis:drink_purgative("phlegmatic"),
    confusion = mantis:drink_purgative("sanguine"),
    furrowed_brow = mantis:drink_purgative("sanguine"),
    haemophelia = mantis:drink_purgative("sanguine"),
    healthleech = mantis:drink_purgative("sanguine"),
    lethargy = mantis:drink_purgative("sanguine"),
    scalped = mantis:drink_purgative("sanguine"),
    disloyalty = mantis:drink_purgative("love"),
    frozen = mantis:drink_purgative("fire"),
    ablaze = mantis:drink_purgative("frost"),
  },

  salve = {
    pox = mantis:apply_salve("liniment"),
    scabies = mantis:apply_salve("liniment"),
    sunallergy = mantis:apply_salve("liniment"),
    burns = mantis:apply_salve("liniment"),
    broken_left_arm = mantis:apply_salve("mending", "arms"),
    broken_right_arm = mantis:apply_salve("mending", "arms"),
    broken_arm = mantis:apply_salve("mending", "arms"),
    broken_left_leg = mantis:apply_salve("mending", "legs"),
    broken_right_leg = mantis:apply_salve("mending", "legs"),
    broken_leg = mantis:apply_salve("mending", "legs"),
    broken_jaw = mantis:apply_salve("mending", "head"),
    slit_throat = mantis:apply_salve("mending", "head"),
    twisted_left_arm = mantis:apply_salve("mending", "arms"),
    twisted_right_arm = mantis:apply_salve("mending", "arms"),
    twisted_arm = mantis:apply_salve("mending", "arms"),
    asthma = mantis:apply_salve("melancholic", "chest"),
    black_lung = mantis:apply_salve("melancholic", "chest"),
    punctured_lung = mantis:apply_salve("melancholic", "chest"),
    trembling = mantis:apply_salve("melancholic", "head"),
    dizziness = mantis:apply_salve("melancholic", "head"),
    sensitivity = mantis:apply_salve("melancholic", "head"),
    vapors = mantis:apply_salve("melancholic", "head"),
    shortness_of_breath = mantis:apply_salve("melancholic"),
    amputated_left_arm = mantis:apply_salve("regeneration", "arms"),
    amputated_right_arm = mantis:apply_salve("regeneration", "arms"),
    amputated_arm = mantis:apply_salve("regeneration", "arms"),
    cracked_left_elbow = mantis:apply_salve("regeneration", "arms"),
    cracked_right_elbow = mantis:apply_salve("regeneration", "arms"),
    cracked_elbow = mantis:apply_salve("regeneration", "arms"),
    mangled_left_arm = mantis:apply_salve("regeneration", "arms"),
    mangled_right_arm = mantis:apply_salve("regeneration", "arms"),
    mangled_arm = mantis:apply_salve("regeneration", "arms"),
    collapsed_left_nerve = mantis:apply_salve("regeneration", "arms"),
    collapsed_right_nerve = mantis:apply_salve("regeneration", "arms"),
    collapsed_nerve = mantis:apply_salve("regeneration", "arms"),
    chest_pain = mantis:apply_salve("regeneration", "chest"),
    collapsed_lung = mantis:apply_salve("regeneration", "chest"),
    crushed_chest = mantis:apply_salve("regeneration", "chest"),
    burst_organs = mantis:apply_salve("regeneration", "gut"),
    ruptured_stomach = mantis:apply_salve("regeneration", "gut"),
    severed_spine = mantis:apply_salve("regeneration", "gut"),
    disembowel = mantis:apply_salve("regeneration", "gut"),
    concussion = mantis:apply_salve("regeneration", "head"),
    partially_damaged_head = mantis:apply_salve("regeneration", "head"),
    pecked_eyes = mantis:apply_salve("regeneration", "head"),
    shattered_jaw = mantis:apply_salve("regeneration", "head"),
    amputated_left_leg = mantis:apply_salve("regeneration", "legs"),
    amputated_right_leg = mantis:apply_salve("regeneration", "legs"),
    amputated_leg = mantis:apply_salve("regeneration", "legs"),
    cracked_left_kneecap = mantis:apply_salve("regeneration", "legs"),
    cracked_right_kneecap = mantis:apply_salve("regeneration", "legs"),
    cracked_kneecap = mantis:apply_salve("regeneration", "legs"),
    mangled_left_leg = mantis:apply_salve("regeneration", "legs"),
    mangled_right_leg = mantis:apply_salve("regeneration", "legs"),
    mangled_leg = mantis:apply_salve("regeneration", "legs"),
    severed_left_tendon = mantis:apply_salve("regeneration", "legs"),
    severed_right_tendon = mantis:apply_salve("regeneration", "legs"),
    severed_tendon = mantis:apply_salve("regeneration", "legs"),
    shattered_left_ankle = mantis:apply_salve("regeneration", "legs"),
    shattered_right_ankle = mantis:apply_salve("regeneration", "legs"),
    shattered_ankle = mantis:apply_salve("regeneration", "legs"),
  },

  herb = {
    broken_chest = mantis:apply_herb("arnica", "chest"),
    broken_nose = mantis:apply_herb("arnica", "head"),
    crushed_windpipe = mantis:apply_herb("arnica", "head"),
    fractured_left_arm = mantis:apply_herb("arnica", "arms"),
    fractured_right_arm = mantis:apply_herb("arnica", "arms"),
    fractured_arm = mantis:apply_herb("arnica", "arms"),
    fractured_ribs = mantis:apply_herb("arnica", "arms"),
    slickness = mantis:eat_herb("calamus"),
    bleeding = mantis:eat_herb("chervil"),
    anorexia = mantis:smoke_herb("coltsfoot"),
    impatience = mantis:smoke_herb("coltsfoot"),
    loneliness = mantis:smoke_herb("coltsfoot"),
    masochism = mantis:smoke_herb("coltsfoot"),
    shyness = mantis:smoke_herb("coltsfoot"),
    deafness = mantis:eat_herb("earwort"),
    blindness = mantis:eat_herb("myrtle"),
    addiction = mantis:eat_herb("galingale"),
    gluttony = mantis:eat_herb("galingale"),
    lovers_curse = mantis:eat_herb("galingale"),
    achromatic_aura = mantis:eat_herb("horehound"),
    egovice = mantis:eat_herb("horehound"),
    healthleech = mantis:eat_herb("horehound"),
    manabarbs = mantis:eat_herb("horehound"),
    powerspikes = mantis:eat_herb("horehound"),
    recklessness = mantis:eat_herb("horehound"),
    timewarp = mantis:eat_herb("horehound"),
    daydreaming = mantis:eat_herb("kafe"),
    narcolepsy = mantis:eat_herb("kafe"),
    clumsiness = mantis:eat_herb("kombu"),
    deadening = mantis:eat_herb("kombu"),
    epilepsy = mantis:eat_herb("kombu"),
    omniphobia = mantis:eat_herb("kombu"),
    vapors = mantis:eat_herb("kombu"),
    dislocated_left_arm = mantis:eat_herb("marjoram"),
    dislocated_right_arm = mantis:eat_herb("marjoram"),
    dislocated_arm = mantis:eat_herb("marjoram"),
    dislocated_left_leg = mantis:eat_herb("marjoram"),
    dislocated_right_leg = mantis:eat_herb("marjoram"),
    dislocated_leg = mantis:eat_herb("marjoram"),
    gashed_cheek = mantis:eat_herb("marjoram"),
    mangled_tongue = mantis:eat_herb("marjoram"),
    punctured_chest = mantis:eat_herb("marjoram"),
    rigormortis = mantis:eat_herb("marjoram"),
    severedEar = mantis:eat_herb("marjoram"),
    sliced_left_bicep = mantis:eat_herb("marjoram"),
    sliced_right_bicep = mantis:eat_herb("marjoram"),
    sliced_bicep = mantis:eat_herb("marjoram"),
    sliced_chest = mantis:eat_herb("marjoram"),
    sliced_gut = mantis:eat_herb("marjoram"),
    sliced_left_thigh = mantis:eat_herb("marjoram"),
    sliced_right_thigh = mantis:eat_herb("marjoram"),
    sliced_thigh = mantis:eat_herb("marjoram"),
    weakness = mantis:eat_herb("marjoram"),
    crushed_windpipe = mantis:smoke_herb("myrtle"),
    hemiplegy_left = mantis:smoke_herb("myrtle"),
    hemiplegy_right = mantis:smoke_herb("myrtle"),
    hemiplegy_lower = mantis:smoke_herb("myrtle"),
    pierced_left_arm = mantis:smoke_herb("myrtle"),
    pierced_right_arm = mantis:smoke_herb("myrtle"),
    pierced_arm = mantis:smoke_herb("myrtle"),
    pierced_left_leg = mantis:smoke_herb("myrtle"),
    pierced_right_leg = mantis:smoke_herb("myrtle"),
    pierced_leg = mantis:smoke_herb("myrtle"),
    severphrenic = mantis:smoke_herb("myrtle"),
    vertigo = mantis:smoke_herb("myrtle"),
    confusion = mantis:eat_herb("pennyroyal"),
    dementia = mantis:eat_herb("pennyroyal"),
    hallucinations = mantis:eat_herb("pennyroyal"),
    paranoia = mantis:eat_herb("pennyroyal"),
    scrambledBrain = mantis:eat_herb("pennyroyal"),
    stupidity = mantis:eat_herb("pennyroyal"),
    temporary_insanity = mantis:eat_herb("pennyroyal"),
    aurawarp = mantis:eat_herb("reishi"),
    bedevil = mantis:eat_herb("reishi"),
    justice = mantis:eat_herb("reishi"),
    pacified = mantis:eat_herb("reishi"),
    peace = mantis:eat_herb("reishi"),
    powersink = mantis:eat_herb("reishi"),
    punctured_aura = mantis:eat_herb("reishi"),
    succumb = mantis:eat_herb("reishi"),
    jinx = mantis:eat_herb("reishi"),
    agoraphobia = mantis:eat_herb("wormwood"),
    claustrophobia = mantis:eat_herb("wormwood"),
    hypochondria = mantis:eat_herb("wormwood"),
    vestiphobia = mantis:eat_herb("wormwood"),
    sliced_left_arm_artery = mantis:eat_herb("yarrow"),
    sliced_right_arm_artery = mantis:eat_herb("yarrow"),
    sliced_arm_artery = mantis:eat_herb("yarrow"),
    sliced_left_leg_artery = mantis:eat_herb("yarrow"),
    sliced_right_leg_artery = mantis:eat_herb("yarrow"),
    sliced_leg_artery = mantis:eat_herb("yarrow"),
    haemophilia = mantis:eat_herb("yarrow"),
    hip_clotting = mantis:eat_herb("yarrow"),
    lacerated_left_arm = mantis:eat_herb("yarrow"),
    lacerated_right_arm = mantis:eat_herb("yarrow"),
    lacerated_left_leg = mantis:eat_herb("yarrow"),
    lacerated_right_leg = mantis:eat_herb("yarrow"),
    lethargy = mantis:eat_herb("yarrow"),
    malignant_blood_clot = mantis:eat_herb("yarrow"),
    relapse = mantis:eat_herb("yarrow"),
    shoulder_clotting = mantis:eat_herb("yarrow"),
    sliced_forehead = mantis:eat_herb("yarrow"),
  },

  focus = {
    locked_legs = mantis:focus("body"),
    throat_lock = mantis:focus("body"),
    paralysis = mantis:focus("body"),
    addiction = mantis:focus("mind"),
    agoraphobia = mantis:focus("mind"),
    anorexia = mantis:focus("mind"),
    claustrophobia = mantis:focus("mind"),
    confusion = mantis:focus("mind"),
    dizziness = mantis:focus("mind"),
    epilepsy = mantis:focus("mind"),
    fear = mantis:focus("mind"),
    hallucinations = mantis:focus("mind"),
    impatience = mantis:focus("mind"),
    loneliness = mantis:focus("mind"),
    lovers_curse = mantis:focus("mind"),
    masochism = mantis:focus("mind"),
    pacified = mantis:focus("mind"),
    paranoia = mantis:focus("mind"),
    recklessness = mantis:focus("mind"),
    shyness = mantis:focus("mind"),
    stupidity = mantis:focus("mind"),
    vertigo = mantis:focus("mind"),
    weakness = mantis:focus("mind"),
    timewarp = mantis:focus("mind"),
    temporary_insanity = mantis:focus("mind"),
    darkmoon = mantis:focus("spirit"),
    infidel = mantis:focus("spirit"),
    heretic = mantis:focus("spirit"),
    omen = mantis:focus("spirit"),
    treebane = mantis:focus("spirit"),
    faeriefire = mantis:focus("spirit"),
    sickening = mantis:focus("spirit"),
    punctured_aura = mantis:focus("spirit"),
  },
}
Looks familiar enough, and the comments are in place so I don't have to waste more forum space explaining it all. What's interesting to note is the actual "Send the cure" script: "mantis.cures[balance][priority_affliction]()". In this case, because being "prone" is cured by sending "stand", a balance cure, it sends:
Code: [show] | [select all] lua
function mantis:do_balance(balance)
  local has_paralysis = mantis.current_afflictions.paralysis
  local has_balance = mantis.balances.balance
  
  if has_balance and not has_paralysis then
    send(balance, false)
  end
end
After, I should be standing, and the affliction removed from the queue appropriately... However, that's not happening. Anything in my code that's not adding up? Any tips or suggestions would be helpful. I'll also attach the .zip of my current Mantis build, so you can take a look at everything that I have. Note, I haven't re-optimized the Triggers yet (there're still some missing), but that'll be coming soon.

Thanks for your help!!