Enemy Damage Script - addition

In addition to the enemy dying due to hits from Lerpz, I want to create another condition in which if a variable meets a specific state requirement, the function (Die) takes place. However, this isn’t working. The second problem is that I don’t know the controls to have Lerpz punch! Every key and mouse button I’ve tried doesn’t seem to work. I have also made sure that the ThirdPersonAttack script is added onto the player.

var rand : Pickup;
var exchange : Pickup;
var hitPoints = 3;
var explosionPrefab : Transform;
var deadModelPrefab : Transform;
var healthPrefab : DroppableMover;
var fuelPrefab : DroppableMover;
var dropMin = 0;
var dropMax = 0;

// sound clips:
var struckSound : AudioClip;

private var dead = false;

function ApplyDamage (damage : int)
{
// we’ve been hit, so play the ‘struck’ sound. This should be a metallic ‘clang’.
if (audio struckSound)
audio.PlayOneShot(struckSound);

if (hitPoints <= 0)
return;

hitPoints -= damage;
if (!dead hitPoints <= 0)
{
Die();
dead = true;
}
if (exchange == 0 rand == 0)
{
Die();
dead = true;
}
}

function Die ()
{
// Kill ourselves
Destroy(gameObject);

Are you getting any errors with this? If so, can you post them?

No errors for the addition. The robot keeps circling around attacking Lerpz. This is the EnemyDamage script that I’ve adapted. Maybe it’s because Pickup.js doesn’t reference this? Thanks!

function ApplyDamage (damage : int)
{
// we've been hit, so play the 'struck' sound. This should be a metallic 'clang'.
	if (audio  struckSound)
		audio.PlayOneShot(struckSound);

	if (hitPoints <= 0)
		return;

	hitPoints -= damage;
	if ((!dead  hitPoints <= 0) || (yeah == true  rand == 0))
	{
		Die();
		dead = true;
	}	
}

[/code]