Need Help with script for my new boss :)

hello guys, im making my first web based game. its a 2D game. I have run into a snag and am not sure why this is happening. To start off with this is my long @%% code for my boss. Pretty simple really:


var enemySpeed: int;
static var bosshp = 20;
static var bosslives = 2;
var bossfallobj : Transform;
var savedTime=0;
function Update ()
{
amtToMove = enemySpeed * Time.deltaTime;
transform.Translate(Vector3.down * amtToMove);
if(transform.position.y <= -3)
{
switch(bosslives)
{
case 2:
break;
case 1:
break;
case 0:
Destroy(gameObject);
Application.LoadLevel(7);
break;
}
switch(bosshp)
{
case 30:
break;
case 29:
break;
case 28:
break;
case 27:
break;
case 26:
break;
case 25:
break;
case 24:
break;
case 23:
break;
case 22:
break;
case 21:
break;
case 20:
break;
case 19:
break;
case 18:
break;
case 17:
break;
case 16:
break;
case 15:
break;
case 14:
break;
case 13:
break;
case 12:
break;
case 11:
break;
case 10:
break;
case 9:
break;
case 8:
break;
case 7:
break;
case 6:
break;
case 5:
break;
case 4:
break;
case 3:
break;
case 2:
break;
case 1:
break;
case 0:
enemybossScript.bosslives --;
break;
}
var seconds : int = Time.time;
var oddeven = (seconds % 2);
if(oddeven)
{
Shoot(seconds);
}
}
function Shoot(seconds)<==This is where line 96 is :stuck_out_tongue:
{
if(seconds!=savedTime)
{
Instantiate(bossfallobj, transform.position, transform.rotation);
}
}


So basically I am getting this error code:

Assets/Scripts/Levels/L3/enemybossScript.js(96,10): BCE0044: expecting (, found ‘Shoot’.

Please tell me what I am doing wrong, thank you.

From a quick look, it seems like you’re missing one } at the end. From what I see, you opened 7 times and only closed 6

A yes ^^ man some of the simplest things screw me over haha, thanks man

No problem.
Just a little tip for this kind of error.

When strange, unexpected errors start showing up – if you’re using monedevelop, don’t know how other code editors work – go to search, input { it shows how many of them exist on the code, “1 of 20” for example, then repeat for } , if the number doesn’t match you already know what the problem is :smile:

You need to indent your code and use some reasonable vertical whitespace to separate logical sections of code. If you did this is what you’d see:

var enemySpeed: int;
static var bosshp = 20;
static var bosslives = 2;
var bossfallobj : Transform;
var savedTime=0

function Update () 
{
	amtToMove = enemySpeed * Time.deltaTime;
	transform.Translate(Vector3.down * amtToMove);

	if(transform.position.y <= -3)
	{
		switch(bosslives)
		{
			case 2:
				break;
			case 1:
				break;
			case 0:
				Destroy(gameObject);
				Application.LoadLevel(7);
				break;
		}

		switch(bosshp)
		{
			case 30:
				break;
			case 29:
				break;
			case 28:
				break;
			case 27:
				break;
			case 26:
				break;
			case 25:
				break;
			case 24:
				break;
			case 23:
				break;
			case 22:
				break;
			case 21:
				break;
			case 20:
				break;
			case 19:
				break;
			case 18:
				break;
			case 17:
				break;
			case 16:
				break;
			case 15:
				break;
			case 14:
				break;
			case 13:
				break;
			case 12:
				break;
			case 11:
				break;
			case 10:
				break;
			case 9:
				break;
			case 8:
				break;
			case 7:
				break;
			case 6:
				break;
			case 5:
				break;
			case 4:
				break;
			case 3:
				break;
			case 2:
				break;
			case 1:
				break;
			case 0:
				enemybossScript.bosslives --;
				break;
		}

		var seconds : int = Time.time;
		var oddeven = (seconds % 2);
		if(oddeven)
		{
			Shoot(seconds);
		}
	}


	function Shoot(seconds)
	{
		if(seconds!=savedTime)
		{
			Instantiate(bossfallobj, transform.position, transform.rotation);
		}
	}

At this point, it becomes obvious that the indentations are not satisfied, that you are missing a curly brace somewhere and you can easily see that the Update function does not have a matching closing brace.

Also, you don’t need to explicitly declare a case for each value, but I’m guessing since you only have one non-empty case that you plan on filling in the rest with stuff? If not, then you can do this:

var enemySpeed: int;
static var bosshp = 20;
static var bosslives = 2;
var bossfallobj : Transform;
var savedTime=0

function Update () 
{
	amtToMove = enemySpeed * Time.deltaTime;
	transform.Translate(Vector3.down * amtToMove);

	if(transform.position.y <= -3)
	{
		if (bosslives == 0)
		{
			Destroy(gameObject);
			Application.LoadLevel(7);
			break;
		}

		if (bosshp == 0)
		{
			enemybossScript.bosslives--;
		}

		var seconds : int = Time.time;
		var oddeven = (seconds % 2);
		if(oddeven)
		{
			Shoot(seconds);
		}
	}
}

function Shoot(seconds)
{
	if(seconds!=savedTime)
	{
		Instantiate(bossfallobj, transform.position, transform.rotation);
	}
}