All right, let's start with how to write MWSE scripts. The Construction Set won't compile with MWSE functions, so you have to use MWEdit. Get that here: http://sourceforge.net/projects/mwedit/files/mwedit/v0.6.1%20-%20Minor%20Update/mwedit-0.6.1.zip/download
Install MWEdit, then get a few support files. First, you need http://www.fliggerty.com/phpBB3/viewtopic.php?f=53&t=1379 Put that in the MWEdit directory, overwriting the one that is already there. Then grab http://dl.dropbox.com/u/31576251/mweditextrafile.esp and put it in your Data Files folder.
Now open up MWEdit and go into the options. Set "Game Data Path" to your Data Files directory. Then put a check in "Extra Script Records" and browse to the mweditextrafile.esp that you downloaded. Finally make sure "Allow Extended Functions" and "Allow Bloodmoon/Tribunal Features" are checked.
Now when you load your mod, you don't load the masters like you would in the CS. Just load your mod. If you are compiling a script that references an object or variable or something that is in one of the esm files, it will fail; but then all you have to do is add it into mweditextrafile.esp. Anything in that can be referenced when MWEdit compiles your scripts.
----------------------
Moving on. Now that you know how to set up MWEdit, use it to write your scripts. I use it for all of my scripts because I like the syntax highlighting and the compiler has more descriptive errors and catches some things the CS misses.
Okay, so to accomplish what you want to do, we have to get the reference to the NPC that you hit with the spell. This is impossible without MWSE, and still somewhat tricky with MWSE. Fortunately I've done this very thing a lot. What we have to do is loop through all of the NPC references in the current cell and look for one that has your spell active.
I will assume you've already determined when the spell is cast and use that to start our script.
In order to loop through the cell, we use the functions xFirstNPC and xNextRef. xFirstNPC will get the reference to the first NPC (or creature actually) in the cell. xNextRef will use that reference we have and get the next one in the list.
The following is a script that will loop through the cell and display the names and health of all the NPCs in the cell.
begin loop_examplelong npcreflong tempfloat healthshort stateif ( MenuMode ) Returnendififx ( state ) ;we set this to 1 when the script needs to end set state to 0 set npcref to 0 StopScript "loop_example" Returnelse ;this is the first thing that will happen when the script is run ifx ( npcref ) ;npcref contains a reference, let's get the next reference setx npcref to xNextRef npcref else ;npcref is 0, so we get the first reference setx npcref to xFirstNPC endif if ( npcref == 0 ) ;if npcref equals 0 after we called xNextRef, it means we got to the end of the list, so we need to end the script set state to 1 Return endif ;we have a reference, let's make sure it is an NPC and not a creature setx ltemp to npcref->xRefType if ( ltemp != 1598246990 ) ;this is the code for NPC ;not an NPC, let's move on to the next frame and the next reference Return endif ;we have an NPC reference here, let's get the name and health and display it setx ltemp to npcref->xGetName ;the function GetHealth is not an MWSE function, so it doesn't accept variables; we have to wrap it with xSetRef xSetRef npcref set health to GetHealth ;now display the name string and the health using xMessageFix xMessageFix "%s has %f health remaining." ltemp health MessageBox " " ;xMessageFix has to be followed with MessageBoxend
So that ought to give you an idea of how to loop through the cell and work with every NPC. Let's see what you can do from here. Let me know if you need health with the next step.