I'm curious as to whether this is supposed to be something happening with every baddy of that type, or just one specific baddy.
If it's a one-off baddy then within the class script it might be a good idea to do something like:
PHP Code:
function onWasH1t(){
this.hearts -= player.swordpower; //or whatever would be relevant damage/function name for the attack, I personally approach this in a much more sophisticated way
if(this.hearts <= 0){
this.trigger("BaddyKilled", player);
}
}
And then within the level NPC script which is joining the class:
PHP Code:
function onBaddyKilled(temp.killer){
temp.killer.addweapon("nameofweapon");
}