/*var goodXDis = 180;
var goodYDis = 120;

function start(args:Array<Dynamic>) : Null<Int>
{
	var rb: RocketBot = args[0];
	
	rb.tlNew(null);
	rb.tlPushAct(null, "fallBack", [rb], 50);
	return null;
}

function update(args:Array<Dynamic>) : Null<Int>
{
	return null;
}

function onClose(args:Array<Dynamic>) : Null<Int>
{
	var rb: RocketBot = args[0];
	var pl: Player = args[1];
	
	rb.brainFlush();
	return null;
}

function onMiddle(args:Array<Dynamic>) : Null<Int>
{
	var rb: RocketBot = args[0];
	var pl: Player = args[1];
	var xDis: Float = Math.abs(pl.x - rb.x);
	var yDis: Float = pl.y - rb.y;
	
	rb.brainFlush();
	rb.storageKill("shifts");
	
	if (xDis < 40 && yDis < 0 && yDis > -64)
	{
		rb.tlNew(null);
		rb.tlPushAct(null, "moveEase", [rb, 0, 128, 20]);
	}
	else
	{
		var th0: ThinkLink = rb.tlNew(null);
		rb.tlPushAct(null, "moveToDShoot", [rb, pl, 30]);
		var th1: ThinkLink = rb.tlNew("just shoot", true);
		rb.tlPushAct("just shoot", "dShoot", [rb, pl]);
		var thGate0: ThinkLink = rb.tlNew("check done", true);
		rb.tlPushAct("check done", "shootGate", [rb], 10);
		var thGate1: ThinkLink = rb.tlNew("loop gate", true);
		rb.tlPushAct("loop gate", "shiftGate", [rb, 2]);
		var thT0: ThinkLink = rb.tlNew("retreat", true);
		rb.tlPushAct("retreat", "runAway", [rb, pl, 40]);
		var thF0: ThinkLink = rb.tlNew("vertical step", true);
		rb.tlPushAct("vertical step", "randomVStep", [rb, 32, 15]);
		rb.tlPushAct("vertical step", "blank", [], 20);
		
		th0.makeLink(th1, true);
		
		th1.makeLink(thGate0, true);
		thGate0.makeLink(thGate1, true);
		thGate0.makeLink(thGate0, false);
		thGate1.makeLink(thT0, true);
		thGate1.makeLink(thF0, false);
		thF0.makeLink(th1, true);
	}
	
	
	return null;
}

function onFar(args:Array<Dynamic>) : Null<Int>
{
	var rb: RocketBot = args[0];
	var pl: Player = args[1];
	
	rb.brainFlush();
	return null;
}

function onHit(args:Array<Dynamic>) : Null<Int>
{
	return null;
}

function die(args:Array<Dynamic>) : Bool
{
	// TODO: Add deathstuffs
	return true;
}

function blank(args:Array<Dynamic>) : Null<Int>
{
	return null;
}

function randomVStep(args:Array<Dynamic>) : Null<Int>
{
	var rb: RocketBot = args[0];
	var vspace: Float = args[1] * (Math.random() < .5 ? -1 : 1);
	var dur: Float = args[2];
	
	rb.tlPushAct(null, "moveEaseChild", [rb, rb.vx, rb.vy, 0, vspace], dur);
	
	return null;
}

function moveToDShoot(args:Array<Dynamic>) : Null<Int>
{
	var rb: RocketBot = args[0];
	var pl: Player = args[1];
	var dur: Int = args[2];
	var sx: Float = rb.vx;
	var sy: Float = rb.vy;
	
	var playerVP: Point = rb.worldToVirtualPoint(pl.x, pl.y);
	var playerWallDir: Int = Toolbelt.f("entityClosestWall", [pl, 10, rb.dodgeThese]);
	var vDir: Int = rb.y > HXP.camera.y + HXP.halfHeight ? 1 : -1;
	if (vDir > 0)
		vDir = (rb.y + goodYDis > HXP.camera.y + HXP.height) ? 1 : 0;
	else
		vDir = (rb.y - goodYDis < HXP.camera.y) ? -1 : 0;
	vDir = vDir == 0 ? (Math.random() > .5 ? 1 : -1) : vDir;
	playerWallDir = playerWallDir == 0 ? (Math.random() > .5 ? 1 : -1) : playerWallDir;
	var mx: Float = playerVP.x - goodXDis * playerWallDir - sx;
	//var my: Float = playerVP.y + ((goodYDis + (Math.random() - .5) * 64) * vDir) - sy;
	var my: Float = playerVP.y + (goodYDis * vDir) - sy;
	
	var path: Point = Toolbelt.f("eGetClearPath", [rb, mx, my]);
	rb.tlPushAct(null, "moveEaseChild", [rb, rb.vx, rb.vy, path.x, path.y], dur);
	
	return null;
}

function dShoot(args:Array<Dynamic>) : Null<Int>
{
	var rb: RocketBot = args[0];
	var pl: Player = args[1];
	
	var dir: Float = Math.atan2(pl.y - rb.y, pl.x - rb.x);
	
	rb.shoot(dir);
	
	return null;
}

function shootGate(args:Array<Dynamic>) : Bool
{
	var rb: RocketBot = args[0];
	return !rb.shooting;
}

function shiftGate(args:Array<Dynamic>) : Bool
{
	var rb: RocketBot = args[0];
	var shiftMax: Int = args[1];
	rb.storageNew("shifts", 0);
	rb.storageOld("shifts", rb.storageGet("shifts") + 1);
	return rb.storageGet("shifts") >= shiftMax;
}

function moveEase(args:Array<Dynamic>) : Null<Int>
{
	var rb: RocketBot = args[0];
	var mx: Float = args[1];
	var my: Float = args[2];
	var dur: Float = args[3];
	
	var path: Point = Toolbelt.f("eGetClearPath", [rb, mx, my]);
	rb.tlPushAct(null, "moveEaseChild", [rb, rb.vx, rb.vy, path.x, path.y], dur);
	return null;
}
function moveEaseChild(args:Array<Dynamic>) : Null<Int>
{
	var rb: RocketBot = args[0];
	var sx: Float = args[1];
	var sy: Float = args[2];
	var mx: Float = args[3];
	var my: Float = args[4];
	var time: Float = args[5];
	Toolbelt.f("eMoveEase", [rb, sx, sy, sx + mx, sy + my, time]);
	return null;
}

function runAway(args:Array<Dynamic>) : Null<Int>
{
	var rb: RocketBot = args[0];
	var pl: Player = args[1];
	var dur: Float = args[2];
	
	var dx: Float = pl.x - rb.x;
	var dy: Float = pl.y - rb.y;
	var mx: Float = (dx > 0 ? 1 : -1) * goodXDis * 2; // might be inverted
	var my: Float = (dy > 0 ? 1 : -1) * goodYDis * 2 ; // might be inverted
	
	var path: Point = Toolbelt.f("eGetClearOvalPath", [rb, mx, my]);
	trace("the movement: " + mx + " anda " + path.x);
	rb.tlPushAct(null, "runAwayChild", [rb, rb.vx, rb.vy, path.x, path.y], dur);
	return null;
}

function runAwayChild(args:Array<Dynamic>) : Null<Int>
{
	var rb: RocketBot = args[0];
	var sx: Float = args[1];
	var sy: Float = args[2];
	var mx: Float = args[3];
	var my: Float = args[4];
	var time: Float = args[5];
	Toolbelt.f("eOvalEase", [rb, sx, sy, sx + mx, sy + my, time]);
	return null;
}

function fallBack(args:Array<Dynamic>) : Null<Int>
{
	Toolbelt.f("eFallBack", args);
	return null;
}*/