1) As soon as enemy attacks you your #enemyid changes from N/A To whatever the id is so.
if #enemyid <> N/A
  gosub DoWhatYouHaveToDo ; As you stated, Cast invis on yourself.
Take a closer look - 
http://wiki.easyuo.com/index.php?title=EnemyID2) There are many options, for example you could use #true #false statements, i'm giving you an example bellow, so you could understand how this works. Use words PEST, VEST, to see the script in action. 
set %testword1 PEST ; journal testword 1
set %testword2 VEST ; journal testword 2
set %stopword ST    ; journal test stop word
set %testword1_messages #false
set %testword2_messages #false
set %jrnl #jindex
; ----------------------------------------------------------------------------
; ---------------------------------- MAIN LOOP -------------------------------
; ----------------------------------------------------------------------------
repeat
  gosub CheckMessages
  if %testword1_messages = #true
    gosub DoTestword1
  if %testword2_messages = #true
    gosub DoTestword2
until #charghost = yes
stop
; ----------------------------------------------------------------------------
; ---------------------------------- CHECK MESSAGES --------------------------
; ----------------------------------------------------------------------------
Sub CheckMessages
  while #jindex >= %jrnl   ; Changed > to >= so we would not wait for another message to arrive.
  {
    scanjournal %jrnl
    if %testword1 in #journal
    {
      event macro 1 1 GOT 1!!
      set %testword1_messages #true
      set %testword2_messages #false
    }
    if %testword2 in #journal
    {
      event macro 1 1 GOT 2!!
      set %testword1_messages #false
      set %testword2_messages #true
    }
    if %stopword in #journal
    {
      event macro 1 1 Stoping!!
      stop
    }
    set %jrnl %jrnl + 1
  }
return
; ----------------------------------------------------------------------------
; ---------------------------------- WHATEVER1 -------------------------------
; ----------------------------------------------------------------------------
Sub DoTestword1
  while %testword1_messages = #true
  {
    event macro 1 1 test1
    wait 2s
    gosub checkMessages ; in the end just check the messages, if something has changed, and we need to switch to anohter sub
  }
return
; ----------------------------------------------------------------------------
; ---------------------------------- WHATEVER2 -------------------------------
; ----------------------------------------------------------------------------
Sub DoTestword2
  while %testword2_messages = #true
  {
    event macro 1 1 test2
    wait 2s
    ..... do what you got to do
    gosub checkMessages ; in the end just check the messages, if something has changed, and we need to switch to anohter sub
  }
return
3) One step at the time. The bigest problem with people that start writing scripts in euo, is to find the proper logic behind the script. I will break your script a-part, and comment on few things, that might help you in future.  
a) after the character is dead, we are starting to loop the whole mainloop again, that means, you are trying Heal the character while he is dead. I Doubt that that is intended. a simple "stop", aka "halt" after "until #charGhost = yes", would help, or, we could insert another while loop on top of the mainloop. 
while #charghost = yes  ; optional1
 wait 0                  ; optional1 
b) Return in your mainloop.  From where are you returning? There is no sub to return from. So we are just wasting space.
c) Well not really a issue, but, you are using so many brackets {} for statements with one line, that really just makes the code alot longer.  you can read about it here 
http://www.scriptuo.com  /index.php?topic=8759.0 d) That mainloop, looks sick. Dont get me wrong, I had the shitiest nesting structures when i started writing. You really should look in to your 
nesting structure, as there are so many not needed elses(I will provide an example latter on). 
e) I would add check for mana in CureMe, HealMe, so that your MedMe, would work. 
if #mana >= 5
{...}
f) CureMe could use a while loop, to try to cure while poisoned and mana is more than 5.
while C in #charStatus && #mana > 5 
{...}
g) Check your journal sub. You should use while loop not if to read every possible new coming line and not skip some stuff straight away. The bigest problem in this sub is, that you are seting +1 line just before you are reading it. Do you see logic behind it ? You should bring set %jrnl %jrnl + 1 just before the last } and return. 
    set %jrnl %jrnl + 1
  }
return
h) I see you are using the same code over and over, for the heal and cure. To make your life more easy, why not just copy that code in a sub and use with one line? Shorter code, faster results. 
Gosub Cure/Heal
Final advice would be, keep your code clean, and add header so after each change, you could write up a version change, to realize fast where you at. I've build something pretty mutch fast here, from the code that i gave you above, as an example, so you would have a cleaner platform to work on. Bare in mind, i havent been writing stuff for a while year, or two, so i might have messed some things up. For the Killing Subroutine, check out a subroutine from my ultimate fisher), called check_serpent  - 
http://www.scriptuo.com/index.php?topic=8284.0 . Additionally, i would recomend checking another script of mine, with some similar functions that you are trying to implenent. 
http://www.scriptuo.com/index.php?topic=8440.0. I will keep an eye on this topic, to see how you are doing. And if you got questions ask, I will be glad to answer. 
; Script Name: CommandKiller
; Author: Ultimafreak
; Version: 0.01A
; Client Tested with:
; EUO version tested with:
; Shard OSI / FS:
; Revision Date: 2014.01.23
; Public Release: http://www.scriptuo.com/index.php?topic=12065.0
; Global Variables Used: none
;Instructions:
;
;
;
; ----------------------------------------------------------------------------
; ---------------------------------- EDITABLES -------------------------------
; ----------------------------------------------------------------------------
set %testword1 HEALBRO  ; journal testword 1
set %testword2 INVISBRO ; journal testword 2
set %stopword ST        ; journal test stop word
; ----------------------------------------------------------------------------
; ---------------------------------- DO NOT EDIT -----------------------------
; ----------------------------------------------------------------------------
set %heal_cast_timer #scnt2
set %cure_cast_timer #scnt2
set %invis_cast_timer #scnt2
set %testword1_messages #false
set %testword2_messages #false
set %jrnl #jindex
; ----------------------------------------------------------------------------
; ---------------------------------- MAIN LOOP -------------------------------
; ----------------------------------------------------------------------------
repeat
  gosub CheckMessages
  if %testword1_messages = #true
    gosub DoTestword1
  if %testword2_messages = #true
    gosub DoTestword2
until #charghost = yes
stop
; ----------------------------------------------------------------------------
; ---------------------------------- CHECK MESSAGES --------------------------
; ----------------------------------------------------------------------------
Sub CheckMessages
  while #jindex >= %jrnl   ; Changed > to >= so we would not wait for another message to arrive.
  {
    scanjournal %jrnl
    if %testword1 in #journal
    {
      event macro 1 1 GOT 1!!
      set %testword1_messages #true
      set %testword2_messages #false
    }
    if %testword2 in #journal
    {
      event macro 1 1 GOT 2!!
      set %testword1_messages #false
      set %testword2_messages #true
    }
    if %stopword in #journal
    {
      event macro 1 1 Stoping!!
      stop
    }
    set %jrnl %jrnl + 1
  }
return
; ----------------------------------------------------------------------------
; ---------------------------------- HEAL/CURE -------------------------------
; ----------------------------------------------------------------------------
Sub DoTestword1
  while %testword1_messages = #true
  {
    while #charghost = no && C in #charstatus ; while poisoned, cast cure on yourself
    {
      if  #mana > 5 ; how much do you need for a cure? if not 5, change
      {
        event macro 15 10; cast cure
        target
        event macro 23 0 ; targetself
      }
    }
    while #charghost = no && C notin #charstatus && #hits < ( #maxhits - 20 ) ; Cast Heal while less than 20 and not poisoned.
    {
      if #mana > 5 ; #scnt > %heal_cast_timer &&
      {
        event macro 15 3; cast heal
        target
        event macro 23 0 ; targetself
      }
    }
    gosub checkMessages ; in the end just check the messages, if something has changed, and we need to switch to anohter sub
  }
return
; ----------------------------------------------------------------------------
; ---------------------------------- INVISIBILITY ----------------------------
; ----------------------------------------------------------------------------
Sub DoTestword2
  while %testword2_messages = #true
  {
    while #mana >= 20 && H notin #charstatus && #charghost = no
    {
      event macro 15 43
      target 5s
      event macro 22 0
    }
    gosub checkMessages ; in the end just check the messages, if something has changed, and we need to switch to anohter sub
  }
return
; ----------------------------------------------------------------------------
; ---------------------------------- ATTACK ENEMY ----------------------------
; ----------------------------------------------------------------------------
Sub AttackEnemy
return