pinv = player.getInventory();
hasQuiver = false;
hasBombBag = false;
var playeralive = player.isAlive();

//*******************************//
//  Start of Code for            //
//  Item Management v2.1         //
//                               //
//*******************************//

  ///////////
 // DataB //
///////////
var im_db = new Array(
	new Array(265,500,false,"gui/items.png",new Array(112,15),true),
	new Array(262,100,false,"gui/items.png",new Array(80,33),false),
	new Array(466,100,false,"gui/items.png",new Array(94,145),false),
	new Array(473,64,true,"gui/items.png",new Array(96,145),false)
)
//var im_locks = new Array()

  //////////////////////
 // Single Load Vars //
//////////////////////
var im_sh   = ui.getHeight();
var im_pinv = player.getInventory();

//*******************************//
//  End of Code for              //
//  Item Management v2.1         //
//                               //
//*******************************//

// Boss //

function Vec2(x, z){
    this.x = x;
    this.z = z;
}

Vec2.prototype.set = function(x,z){
    this.x = x;
    this.z = z;
}

Vec2.prototype.copy = function() {
    return new Vec2f(this.x, this.z);
}

Vec2.prototype.length = function() {
    return Math.sqrt(this.x*this.x+this.z*this.z);
}

Vec2.prototype.normalize = function() {
    var l = this.length();
    if(l > 0){
        this.x = this.x / l;
        this.z = this.z / l;
    }
    return this;
}

Vec2.prototype.getTheta = function() {
    var a = Math.atan2(this.z, this.x);
    if(a < 0){
        a += 2 * Math.PI;
    }
    return 180 * a / Math.PI; 
}

Vec2.prototype.setTheta = function(theta) {
    if ((theta <= -360) || (theta >= 360)) {
        theta = theta % 360;
    }
    if (theta < 0) {
        theta = 360 + theta;
    }
    theta = Math.PI * theta / 180;
    var l = this.length();
    this.x = l * Math.cos(theta);
    this.z = l * Math.sin(theta);
    return this;
}
worm_init = false;
worm_finished = false;
worm_dir = new Vec2(1.0,0.0);

//npc interact

width = ui.getWidth();
height = ui.getHeight();
centerX = width/2;
centerY = height/2;
//start Interaction GUI
talkOther0 = UILabel(" ", centerX - 120, centerY - 80);
talkOther1 = UILabel(" ", centerX - 120, centerY - 70);
talkOther2 = UILabel(" ", centerX - 120, centerY - 60);
talkOption10 = UILabel(" ", centerX - 120, centerY - 40);
talkOption11 = UILabel(" ", centerX - 120, centerY - 30);
talkOption12 = UILabel(" ", centerX - 120, centerY - 20);
talkOption20 = UILabel(" ", centerX - 120, centerY);
talkOption21 = UILabel(" ", centerX - 120, centerY + 10);
talkOption22 = UILabel(" ", centerX - 120, centerY + 20);
talkOption30 = UILabel(" ", centerX - 120, centerY + 40);
talkOption31 = UILabel(" ", centerX - 120, centerY + 50);
talkOption32 = UILabel(" ", centerX - 120, centerY + 60);
talkBackground = UIRect(centerX - 130, centerY - 85, 280, 170, 0.2,0.2,0.2,0.5);
talkBackground.removeFromScreen();
talkInstructionsSL = ui.getStringWidth("(Use the NumberPad 1-3 to talk)");
talkInstructions = UILabel("(Use the NumberPad 1-3 to talk)", centerX - talkInstructionsSL / 2, centerY + 80);
talkInstructions.removeFromScreen();
interactSeq = 0;
interactKeySwitch = 0;

//Acide

pie = 0;

//Herbes

world.triggerBlock(-143,72,58);
world.triggerBlock(-143,72,60);
world.triggerBlock(-143,72,62);
world.triggerBlock(-143,72,64);
world.triggerBlock(-145,72,60);
world.triggerBlock(-145,72,62);
world.triggerBlock(-147,71,60);
world.triggerBlock(-147,71,62);
world.triggerBlock(-149,70,61);

//marcheur

etat_marcheurgrandeplace=2;
time.sleep(0.5);
etat_marcheurgrandeplace=0;

//robot

var fireProjectiles = new Array();
magicMissile = [];
oldPosX = [];
oldPosY = [];
oldPosZ = [];
newPosX = [];
newPosY = [];
newPosZ = [];
particle = 0;
o = 0;