Healing Systems: Ins/Outs/and everything in between.

Post Reply
Delrayne
Posts: 159
Joined: Tue Jun 07, 2011 7:07 pm
Contact:

Healing Systems: Ins/Outs/and everything in between.

Post by Delrayne »

Hello everyone, I guess I'll get started by saying that I'm fixing to start jumping the hurdle that is a healing system. While I know there are tons of them floating around out there, I'd like to know what you all(people I consider in the know) consider efficient coding practices when creating a healing system. Things you should/shouldn't have, ways to set up certain tables for optimization, overall concise and to the point code that functions really well.

This is a function I've used in the past for healing:
Code: [show] | [select all] lua
--Called on every prompt
function Heal.Herb()
  --Check to see if we have herb balance, or aren't afflicted with something that prevents eating.
  if (CanEat()) then
    --Loop through my herb curing order and check it against my afflictions
    for k, v in ipairs (Priority.Herb) do
      if (table.contains(Healing.Afflictions, v)) then
        --Making sure another cure method isn't trying to heal this already.
	if (Try(v)) then
          --Take balance to prevent spamming
	  Healing.Balance.Herb = false
	  Healing.Try.Herb = v
	  cecho("\n<green>||<white>Herb<green>:<white>" .. Healing.Try.Herb .. "<green>||")
	  send("outr " .. Healing.Cure.Herb[v].cure)
	  send("eat " .. Healing.Cure.Herb[v].cure)
          --Create timers to reset balances on failed cures.
	  if (table.contains(Healing.Afflictions, "stupidity")) then
	      StupidityTimer(.5, "Herb")
	  else
	      TimerOn(2, "Herb")
	  end
          --Since we've found an affliction to heal, we'll jump out of our 'for' loop
          break
        end
      end
    end
  end
end
I'd love to hear everyone's thoughts and opinions on it. What are your suggestions on improving it? Would you go a different route entirely? Would the way you have your affliction tracking/tables setup prevent you from doing something similar?


EDIT: Don't hate on my table setup :cry: ...I wasn't happy with it then, not happy about it now, so it will be changed.

Post Reply