Organise scripts with the same name?

Say I have a generic health script and that links into a script called onDeath when you die. Now I have several versions of onDeath depending on what happens if you die. So each character will only have one death script and according to what it says, that's how they die.

The problem is I can't seem to have more than one script with the same name and I don't necessary know which death script I'm calling before hand, it depends on what character dies. This is also good I think for organising my code into separate components. Is there any other way I can keep things like the different ways to die separate and then hook them on when the character initialises?

Any suggestions or alternate methods of implementing what I'm talking about in case I have completely the wrong approach?

Extend new classes from OnDeath (or whatever the class name)

in Javascript, I believe its

class PlayerDeath extends OnDeath{

}
class EnemyDeath extends OnDeath{

}

... or in C#

public class PlayerDeath : OnDeath{

}

If you are using C# (and maybe Javascript, though I haven't tried) you can also use interfaces to accomplish a similar result. Read more about interfaces here

The beauty of this is your health script can simply reference all the various scripts as type OnDeath. Make sure to save each one in its own file with the same name as the class.

Specify any functions you want accessible to all subclasses in OnDeath, and then override them in the subclasses, if necessary.

EDIT Further details below: Sorry, I'm switching to C#, it's far easier to do / find examples for more advanced coding.

using UnityEngine;
using System.Collections;

public abstract class OnDeath : MonoBehaviour {

    public abstract void Die();
}

Above is an example abstract class in C#. What's nice about this, it that it forces all scripts inheriting from it to implement the Die function, that way you can be sure it is always possible to call Die().

Below is the subclass:

using UnityEngine;
using System.Collections;

public class EnemyDeath : OnDeath{

    public override void Die(){
        Debug.Log("I'm a subclass");
    }
}

And below the test class. Attach both this and EnemyDeath to the same GameObject, and woila! Notice we are casting to type OnDeath, not enemy death... You can treat the object as an OnDeath as well.

using UnityEngine;
using System.Collections;

public class TestScript : MonoBehaviour {

    void Start(){
        ((OnDeath)GetComponent(typeof(OnDeath))).Die();
    }
}

If readers must use Javascript, it can sort of be done. C# is far superior for good OO though. Note that commenting out Die() on EnemyDeath does not trigger an error, as it does with overriding an abstract class in C#.

class OnDeath extends MonoBehaviour {

    virtual function Die(){ 	
    }
}

class EnemyDeath extends OnDeath{

    function Die(){ 
        Debug.Log("blah");
    }
}

It was asked about a c# reference - Accelerated C# 2008 is the one I used to learn C# while meddling in Unity. It's a great book for the new C# programmer who has some basic knowledge about programming, or has programmed in other languages. One day someone should write one specific to Unity....