Frame 1
Frame 2
function Sprites() {
var sroot = createEmptyMovieClip("sprite_root", 0);
var zRange = 500;
var zArray = new Array(zRange);
var _local2 = 0;
while (_local2 < zRange) {
zArray[_local2] = zRange - _local2;
_local2++;
}
var groupList = new Object();
this.getNumFree = function () {
return(zArray.length);
};
this.create = function (props) {
var _local4 = zArray.pop() + zRange;
var _local5 = "sprite" + _local4;
var _local3;
if ((typeof(props.group) == "string") && (groupList[props.group])) {
groupList[props.group].createEmptyMovieClip(_local5, _local4);
_local3 = groupList[props.group][_local5];
} else {
sroot.createEmptyMovieClip(_local5, _local4);
_local3 = sroot[_local5];
}
if (typeof(props.member) == "string") {
_local3.attachMovie(props.member, "member_mc", _local4);
}
_local3._x = ((typeof(props.x) == "number") ? (props.x) : (Stage.width / 2));
_local3._y = ((typeof(props.y) == "number") ? (props.y) : (Stage.height / 2));
if (typeof(props.width) == "number") {
_local3._width = props.width;
}
if (typeof(props.height) == "number") {
_local3._height = props.height;
}
if (typeof(props.xscale) == "number") {
_local3._xscale = props.xscale;
}
if (typeof(props.yscale) == "number") {
_local3._yscale = props.yscale;
}
_local3._visible = ((typeof(props.visible) == "boolean") ? (props.visible) : true);
_local3._alpha = ((typeof(props.alpha) == "number") ? (props.alpha) : 100);
_local3.zIndex = _local4;
_local3.toBack = function () {
this.toLevel(1);
};
_local3.toFront = function () {
this.toLevel(4);
};
_local3.toLevel = function (_l) {
var _local3 = this.zIndex;
var _local2 = ((_l - 1) * zRange) + (this.zIndex % zRange);
this.swapDepths(_local2);
this.member_mc.swapDepths(_local2);
this.zIndex = _local2;
};
return(_local3);
};
this.createGroup = function (props) {
if (typeof(props.group) == "string") {
var _local2 = props.group;
props.group = null;
if (groupList[_local2]) {
wr("Alert! generating an already existing group: ", _local2);
} else {
groupList[_local2] = this.create(props);
groupList[_local2].groupName = _local2;
}
}
return(groupList[_local2]);
};
this.removeGroup = function (nameOrSprite) {
if (typeof(nameOrSprite) == "string") {
var _local1 = nameOrSprite;
} else {
var _local1 = nameOrSprite.groupName;
}
if (groupList[_local1]) {
sprites.remove(groupList[_local1]);
groupList[_local1] = null;
}
};
this.setMember = function (sprite, member) {
sprite.attachMovie(member, "member_mc", sprite.getDepth());
};
this.createText = function (props) {
var _local5 = this.create({x:props.x, y:props.y});
_local5.createTextField("member_mc", _local5.zIndex, 0, 0, 1, 1);
var _local3 = _local5.member_mc;
_local3.autosize = ((typeof(props.align) == "string") ? (props.align) : "left");
_local3.multiline = false;
_local3.wordWrap = false;
_local3.border = false;
_local3.selectable = false;
_local3.type = "dynamic";
_local3.embedFonts = true;
var _local4 = new TextFormat();
_local4.color = ((typeof(props.color) == "string") ? (props.color) : "0xffffff");
_local4.size = props.size || 9;
_local4.font = ((typeof(props.font) == "string") ? (props.font) : "Arial");
_local4.align = ((typeof(props.align) == "string") ? (props.align) : "left");
_local4.bold = ((typeof(props.bold) == "boolean") ? (props.bold) : false);
_local3.setNewTextFormat(_local4);
_local3.text = ((typeof(props.text) == "string") ? (props.text) : "");
return(_local5);
};
this.remove = function (sprite) {
if (!sprite.zIndex) {
return(undefined);
}
var _local1 = sprite.zIndex % zRange;
sprite.removeMovieClip();
zArray.unshift(_local1);
return(_local1);
};
}
function Events() {
var listeners = new Array();
var stopCount = 0;
this.runIt = function (object) {
if (typeof(object.run) == "function") {
var _local1 = 0;
while (_local1 < listeners.length) {
if (listeners[_local1] == object) {
return(undefined);
}
_local1++;
}
object.eventOrphan = false;
listeners.push(object);
} else {
wr("tried to run bad object!");
wrObj(object);
}
};
this.stopIt = function (object) {
var _local1 = 0;
while (_local1 < listeners.length) {
if (listeners[_local1] == object) {
stopCount++;
listeners[_local1].eventOrphan = true;
return(undefined);
}
_local1++;
}
};
onEnterFrame = function () {
var _local2 = listeners;
var _local1 = 0;
while (_local1 < _local2.length) {
if (!_local2[_local1].eventOrphan) {
_local2[_local1].run();
}
_local1++;
}
if (stopCount > 0) {
_local1 = 0;
while (_local1 < listeners.length) {
if (listeners[_local1].eventOrphan) {
listeners[_local1].eventOrphan = false;
listeners.splice(_local1, 1);
_local1--;
stopCount--;
}
_local1++;
}
}
};
this.putEventList = function () {
wr("Running Object list:");
var _local1 = 0;
while (_local1 < listeners.length) {
wr(listeners[_local1]);
_local1++;
}
};
this.checkEventList = function () {
var _local2 = listeners;
var _local1 = 0;
while (_local1 < _local2.length) {
if (typeof(_local2[_local1]) != "object") {
wr("invalid object in event: ", _local1);
}
_local1++;
}
};
}
function SoundFx() {
var _local3 = ["rail.wav", "cage4.wav", "attention.wav", "penalty.wav", "ticking.wav", "wallhit1.wav", "ballhit0.wav", "cuehit0.wav", "railstop.wav", "introsound.wav", "wah.wav", "gameover.wav"];
var _local5 = createEmptyMovieClip("sound_fx_base", 100000);
var _local6 = 0;
var sounds = new Object();
var _local2 = 0;
while (_local2 < _local3.length) {
var _local4 = new Sound(_local5.createEmptyMovieClip("sound_" + (_local2 + 1), 100001 + _local2));
_local4.attachSound(_local3[_local2]);
_local4.onSoundComplete = function () {
this.playing = false;
};
sounds[_local3[_local2]] = _local4;
sounds[_local3[_local2]].playing = false;
sounds[_local3[_local2]].soundName = _local3[_local2];
_local2++;
}
this.play = function (sound, nostop, vol) {
if (sounds[sound].playing) {
if (nostop) {
return(undefined);
}
this.stop(sound);
}
sounds[sound].playing = true;
if (vol) {
sounds[sound].setVolume(vol);
} else {
sounds[sound].setVolume(100);
}
sounds[sound].start();
};
this.playLooped = function (sound) {
if (sounds[sound].playing) {
return(undefined);
}
sounds[sound].playing = true;
sounds[sound].start(0, 99);
};
this.stop = function (sound) {
sounds[sound].stop();
sounds[sound].playing = false;
};
}
function miniSortFunc(a, b) {
if (a <= b) {
return(-1);
}
return(1);
}
function miniSortObjOnDistanceFunc(a, b) {
if (a.distance <= b.distance) {
return(-1);
}
return(1);
}
function wr() {
var _local3 = "> ";
var _local2 = 0;
while (_local2 < arguments.length) {
_local3 = _local3 + arguments[_local2];
_local2++;
if (arguments.length != _local2) {
_local3 = _local3 + " ";
}
}
}
function wrObj(obj, rec) {
function wrObjDump(obj, rec, currprop) {
currprop = ((typeof(currprop) == "string") ? (currprop + ".") : "");
for (prop in obj) {
if (rec) {
if (typeof(obj[prop]) == "object") {
wrObjDump(obj[prop], rec, currprop + prop);
}
}
}
}
wrObjDump(obj, rec);
}
function fill(width, p) {
var _local2 = "";
var _local3 = ((typeof(p) != "string") ? " " : (p));
var _local1 = 0;
while (_local1 < width) {
_local2 = _local2 + _local3;
_local1++;
}
return(_local2);
}
function distance(x1, y1, x2, y2) {
var _local2 = x1 - x2;
var _local1 = y1 - y2;
return(Math.sqrt((_local2 * _local2) + (_local1 * _local1)));
}
function parseArgString(argstr) {
var _local5 = [];
var _local2 = false;
var _local1 = "";
var _local3;
var _local4 = 0;
while (_local4 < argstr.length) {
_local3 = argstr.substr(_local4, 1);
if ((_local3 == "\"") && (!_local2)) {
_local2 = true;
} else if ((_local3 == " ") && (!_local2)) {
if (_local1 != "") {
_local5.push(_local1);
_local1 = "";
}
} else if ((_local3 == "\"") && (_local2)) {
_local2 = false;
_local5.push(_local1);
_local1 = "";
} else {
_local1 = _local1 + _local3;
}
_local4++;
}
if (_local1 != "") {
_local5.push(_local1);
}
return(_local5);
}
function Random() {
var seed = 0;
var seed2 = 0;
this.range = function (start, stop) {
var _local2 = stop - start;
var _local1 = Math.random() * (_local2 + 1);
_local1 = Math.floor(start + _local1);
return(Math.min(_local1, stop));
};
this.setSeed = function (s) {
seed = s & 65535;
seed2 = seed;
};
this.rangeFromSeed = function (start, stop) {
var _local3 = stop - start;
var _local2 = this.floatFromSeed() * (_local3 + 1);
_local2 = Math.floor(start + _local2);
return(Math.min(_local2, stop));
};
this.rangeFromSeed2 = function (start, stop) {
var _local3 = stop - start;
var _local2 = this.floatFromSeed2() * (_local3 + 1);
_local2 = Math.floor(start + _local2);
return(Math.min(_local2, stop));
};
this.floatFromSeed = function () {
seed = ((seed * 732573) + 3545443) & 65535;
var _local1 = seed / 65536;
return(_local1);
};
this.floatFromSeed2 = function () {
seed2 = ((seed2 * 732573) + 3545443) & 65535;
var _local1 = seed2 / 65536;
return(_local1);
};
}
function Delay(what, frames) {
this.what = what;
this.counter = 0;
this.nFrames = frames;
this.run = function () {
this.counter++;
if (this.counter > this.nFrames) {
events.stopIt(this);
this.what();
}
};
events.runIt(this);
}
function prepare_gamedata(_data) {
var _local3 = {};
_local3.text = {};
_local3.mp = {};
_local3.players = [];
if (typeof(_data) != "string") {
return(_local3);
}
var _local6 = new XML();
_local6.ignoreWhite = true;
_local6.parseXML(_data);
var _local4 = _local6.firstChild.attributes;
for (var _local5 in _local4) {
_local3[_local5] = _local4[_local5];
}
var _local2 = _local6.firstChild.childNodes;
var _local1 = 0;
while (_local1 < _local2.length) {
if (_local2[_local1].nodeName == "text") {
_local3.text[_local2[_local1].attributes.id] = _local2[_local1].firstChild.nodeValue;
} else if (_local2[_local1].nodeName == "multiplayer") {
for (var _local5 in _local2[_local1].attributes) {
_local3.mp[_local5] = _local2[_local1].attributes[_local5];
}
}
_local1++;
}
return(_local3);
}
function Gui() {
this.window = null;
this.windowActive = "";
var gCenterX = 417;
var gCenterY = 207;
var p_automat;
var b_automat;
this.init = function (_gd) {
this.main_bg = _root.main_bg_placeholder;
this.endgamebutton = sprites.create({member:"mc_endgame", x:628, y:423});
this.endgamebutton.toLevel(5);
this.endgamebutton.member_mc.btn.onRelease = function () {
if (net_debug) {
game.send_net_debug_data();
}
game.sock.send_string("GEG");
game.evaluateEvent({action:"endbutton", playernum:game.playernum});
game.setGameOver("endbutton");
};
this.spinball_shadow_visible(false);
if (game.netGame) {
if (_gd.gametype == "9ball") {
this.nextball_stopframe = 15;
this.main_bg.gotoAndStop(1);
} else {
this.nextball_stopframe = 28;
this.main_bg.gotoAndStop(2);
}
this.nextball = sprites.create({member:"ball_0", x:101, y:233, width:34, height:34});
this.nextball.member_mc.gotoAndStop(this.nextball_stopframe);
this.nextball.shad = sprites.create({member:"BallShade", x:101, y:233, width:34, height:34});
this.nextball._visible = false;
this.nextball.shad._visible = false;
this.nextball2 = sprites.create({member:"ball_0", x:101, y:271, width:34, height:34});
this.nextball2.member_mc.gotoAndStop(this.nextball_stopframe);
this.nextball2.shad = sprites.create({member:"BallShade", x:101, y:271, width:34, height:34});
this.nextball2._visible = false;
this.nextball2.shad._visible = false;
this.endgamebutton._y = this.endgamebutton._y + 20;
this.player1 = new PlayerBox(1, _gd.gametype);
this.player1.setName("");
this.player2 = new PlayerBox(2, _gd.gametype);
this.player2.setName("");
this.msgBox = new GuiBar();
this.msgBox.init({template:"msgbox_widget", x:gCenterX, y:gCenterY - 32});
this.msgBox.sp.toLevel(9);
this.msgBox.sp._visible = false;
} else {
this.nextball_stopframe = 15;
this.nextball = sprites.create({member:"ball_1", x:58, y:284, width:73, height:73});
this.nextball.member_mc.gotoAndStop(this.nextball_stopframe);
sprites.create({member:"BallShade", x:58, y:284, width:73, height:73});
}
if (!game.netGame) {
this.main_bg.text_tag_1.text = _gd.text.score;
this.main_bg.text_tag_2.text = _gd.text.time_left;
this.main_bg.text_tag_3.text = _gd.text.shot_bonus;
this.main_bg.text_tag_4.text = _gd.text.next;
this.main_bg.text_tag_5.text = _gd.text.spin;
}
this.main_bg.text_tag_6.text = _gd.text.end_game;
if (!game.netGame) {
p_automat = new ScoreAutomat(this.main_bg.text_1);
events.runIt(p_automat);
b_automat = new ScoreAutomat(this.main_bg.text_3);
events.runIt(b_automat);
}
this.setTime(game.time_format_str(_gd.duration));
if (!game.netGame) {
this.showInstructions();
}
};
this.swapNextBall = function (ballno) {
sprites.setMember(this.nextball, "ball_" + ballno);
this.nextball.member_mc.gotoAndStop(this.nextball_stopframe);
};
this.swapNextBallPlayer1 = function (ballno) {
if (ballno < 0) {
this.nextball._visible = false;
this.nextball.shad._visible = false;
} else {
sprites.setMember(this.nextball, "ball_" + ballno);
this.nextball.member_mc.gotoAndStop(this.nextball_stopframe);
this.nextball._visible = true;
this.nextball.shad._visible = true;
}
};
this.swapNextBallPlayer2 = function (ballno) {
if (ballno < 0) {
this.nextball2._visible = false;
this.nextball2.shad._visible = false;
} else {
sprites.setMember(this.nextball2, "ball_" + ballno);
this.nextball2.member_mc.gotoAndStop(this.nextball_stopframe);
this.nextball2._visible = true;
this.nextball2.shad._visible = true;
}
};
this.spinball_shadow_visible = function (vis) {
this.main_bg.spinball_shadow._visible = vis;
};
this.showInstructions = function () {
if (this.windowActive == "instructions") {
return(undefined);
}
this.windowActive = "instructions";
this.window = sprites.create({x:gCenterX, y:gCenterY, member:"mc_instructions"});
this.window.toLevel(8);
this.window.onRelease = function () {
game.gui.localHideInstructions();
};
var _local2 = this.window.member_mc;
_local2.text_header.text = game.gd.text.instruction_header;
if (game.netGame) {
var _local3 = game.gd.text.instruction_text_1 + "\n\n";
_local3 = _local3 + (game.gd.text.instruction_text_2 + "\n\n");
_local3 = _local3 + game.gd.text.instruction_text_3;
_local2.text_body.text = _local3;
} else {
_local2.text_body.text = game.gd.text.instruction_text;
}
_local2.text_time.text = "";
_local2.text_start.text = game.gd.text.start;
new Delay(function () {
game.gui.localHideInstructions();
}, 375);
this.localInstructionsClick = false;
this.netInstructionsClick = false;
};
this.localHideInstructions = function () {
if (this.windowActive != "instructions") {
return(undefined);
}
if (game.netGame) {
if (game.player_current == null) {
return(undefined);
}
if (this.localInstructionsClick) {
return(undefined);
}
this.localInstructionsClick = true;
this.killActiveWindow();
game.player_current.absorb("CIR", 0);
if (this.netInstructionsClick) {
soundFx.play("introsound.wav");
game.callStart();
} else {
this.showMsgBox(game.gd.text.waiting_for_opponent);
this.wf_opponent_timer = {timeout:120, start:getTimer()};
this.wf_opponent_timer.run = function () {
var _local2 = getTimer() - this.start;
if ((_local2 / 1000) > this.timeout) {
wr("timeout reached...");
events.stopIt(this);
game.handleCommError("opponent_noconnect");
}
};
wr("start: wf_opponent_timer");
events.runIt(this.wf_opponent_timer);
}
} else {
this.killActiveWindow();
soundFx.play("introsound.wav");
game.callStart();
}
};
this.netHideInstructions = function () {
this.netInstructionsClick = true;
if (this.localInstructionsClick) {
if (this.wf_opponent_timer) {
wr("stop: wf_opponent_timer");
events.stopIt(this.wf_opponent_timer);
}
this.hideMsgBox();
soundFx.play("introsound.wav");
game.callStart();
}
};
this.killActiveWindow = function () {
if (!this.window) {
return(undefined);
}
sprites.remove(this.window);
this.window = null;
this.windowActive = "";
};
this.showGameOver = function () {
if (this.windowActive == "gameover") {
return(undefined);
}
if (this.window) {
sprites.remove(this.window);
}
this.windowActive = "gameover";
this.window = sprites.create({x:gCenterX, y:gCenterY, member:"mc_gameover"});
this.window._y = (-this.window._height) / 2;
this.window.toLevel(8);
var _local2 = this.window.member_mc;
_local2.text_header.text = game.gd.text.game_over;
_local2.text_1.text = game.gd.text.score;
_local2.text_2.text = game.gd.text.shot_bonus;
_local2.text_3.text = game.gd.text.time_bonus;
_local2.text_4.text = game.gd.text.final_score;
_local2.text_1b.text = game.getGameScore();
_local2.text_2b.text = game.getShotBonus();
_local2.text_3b.text = game.getTimeBonus();
_local2.text_4b.text = game.getFinalScore();
p_automat.setScore(_local2.text_1b.text | 0);
if (game.gd.relaxMode == "true") {
_local2.text_2._visible = false;
_local2.text_2b._visible = false;
_local2.text_3._visible = false;
_local2.text_3b._visible = false;
}
this.window.slider = new SlideInOut({sprite:this.window, y:gCenterY, nFrames:12});
this.window.slider.start("in");
soundFx.play("gameover.wav");
};
this.showWhoWon = function (winner) {
if (this.windowActive == "whowon") {
return(undefined);
}
this.hideMsgBox();
if (this.window) {
sprites.remove(this.window);
}
this.windowActive = "whowon";
this.window = sprites.create({x:gCenterX, y:gCenterY, member:"mc_whowon"});
this.window._y = (-this.window._height) / 2;
this.window.toLevel(8);
var _local2 = this.window.member_mc;
_local2.text_header.text = game.gd.text.game_over;
if (winner) {
_local2.text_1.text = game.gd.text.you_won;
} else {
_local2.text_1.text = game.gd.text.you_lost;
}
this.window.slider = new SlideInOut({sprite:this.window, y:gCenterY, nFrames:12});
this.window.slider.start("in");
soundFx.play("gameover.wav");
};
this.showMsgBox = function (str) {
this.killActiveWindow();
this.msgBox.setText(str);
this.msgBox.sp._visible = true;
};
this.hideMsgBox = function () {
this.msgBox.sp._visible = false;
};
this.createAndShowBreakBox = function () {
if (this.windowActive == "breakbox") {
return(undefined);
}
this.windowActive = "breakbox";
this.breakbox = sprites.create({member:"mc_choose_lag", x:gCenterX, y:gCenterY});
this.breakbox.toLevel(8);
this.breakbox.member_mc.text_select.text = game.gd.text.select;
this.breakbox.member_mc.text_break.text = game.gd.text.break;
this.breakbox.member_mc.text_opponent_break.text = game.gd.text.opponent_break;
this.breakbox._y = (-this.breakbox._height) / 2;
this.breakbox.slider = new SlideInOut({sprite:this.breakbox, y:gCenterY, nFrames:12});
this.breakbox.slider.start("in");
new Delay(function () {
game.gui.slideOutBreakBox(true);
}, 125);
this.breakbox.member_mc.b1.onRelease = function () {
game.gui.slideOutBreakBox(false);
};
this.breakbox.member_mc.b2.onRelease = function () {
game.gui.slideOutBreakBox(true);
};
};
this.slideOutBreakBox = function (breakyesno) {
if (this.windowActive != "breakbox") {
return(undefined);
}
var _local2 = (breakyesno ? (game.playernum) : (game.playernum ^ 1));
game.player_local.absorb("GBS", _local2);
game.setCurrentPlayer(_local2);
game.setBreakPlayerAndStart(_local2);
this.breakbox.slider.callback = function () {
sprites.remove(game.gui.breakbox);
};
this.breakbox.slider.start("out");
this.windowActive = "";
};
this.addPoints = function (points) {
p_automat.addScore(points);
};
this.addBonus = function (points) {
b_automat.addScore(points);
};
this.setTime = function (time) {
this.main_bg.text_2.text = time;
};
this.setInfo = function (str, nosound) {
this.main_bg.text_info.text = str;
if ((str != "") && (!nosound)) {
}
};
this.getLevel = function () {
return(game.getLevel());
};
}
function ScoreAutomat(_field) {
function updateScore() {
var _local1 = dest_p - curr_p;
var _local2 = _local1 * speed;
if (Math.abs(_local1) <= 2) {
curr_p = dest_p;
} else {
curr_p = curr_p + _local2;
}
txt_field.text = Math.round(curr_p);
if (dest_p == curr_p) {
calcReady();
}
}
function calcReady() {
running = false;
}
var running = false;
var speed = 0.2;
var curr_p = 0;
var dest_p = 0;
var txt_field = _field;
txt_field.text = "0";
this.addScore = function (howMuch) {
running = true;
dest_p = dest_p + howMuch;
};
this.setScore = function (val) {
dest_p = val;
curr_p = val;
txt_field.text = "" + val;
running = false;
};
this.run = function () {
if (running) {
updateScore();
}
};
}
function PlayerBox(_player, _gametype) {
if (_player == 1) {
this.mysprite = sprites.create({member:"player_box1", x:5, y:96});
} else {
this.mysprite = sprites.create({member:"player_box2", x:5, y:253});
}
this.mysprite.member_mc.gotoAndStop(1);
this.activepos = ((_gametype == "9ball") ? 2 : 3);
this.setTime = function (t) {
this.mysprite.member_mc.playertime.text = "" + t;
};
this.setName = function (n) {
this.mysprite.member_mc.playername.text = n;
};
this.setActive = function () {
this.mysprite.member_mc.gotoAndStop(this.activepos);
};
this.setInactive = function () {
this.mysprite.member_mc.gotoAndStop(1);
};
}
function Score() {
var currentScore = 0;
var eventCodes = {};
eventCodes.version = 112;
eventCodes.shoot = 426;
eventCodes["hit first ball"] = 6361;
eventCodes["hit wall"] = 43;
eventCodes["ball sunk"] = 6782;
eventCodes["shot done"] = 4025;
eventCodes["end button pressed"] = 9799;
eventCodes["time bonus"] = 812;
eventCodes["shot bonus"] = 1929;
eventCodes["place ball"] = 6002;
var currentBallScore = 100;
var shotBonus = 2000;
var timeBonus = 0;
var currentPenaltyScore = 0;
var ballScores = [];
var shotNo = 0;
var ballsSunk = [];
var ballsSunkLastHit = [];
var nextBall = 1;
this.firstHitLegal;
this.firstHitLegal_2;
var cueBallSunk;
var gameFinsished = false;
var gameCleared = false;
this.findNextLegalBall = function () {
var _local1 = 1;
while (_local1 <= 9) {
if (!ballsSunk[_local1]) {
return(_local1);
}
_local1++;
}
return(0);
};
this.roundReset = function () {
ballScores = [];
shotNo = 0;
ballsSunk = [];
ballsSunkLastHit = [];
nextBall = 1;
cueBallSunk = false;
gameFinsished = false;
gameCleared = false;
};
this.restoreLastState = function () {
var _local1 = 0;
while (_local1 < ballsSunkLastHit.length) {
ballsSunk[ballsSunkLastHit[_local1]] = false;
_local1++;
}
cueBallSunk = false;
shotNo--;
};
this.getScore = function () {
return(currentScore);
};
this.getFinalScore = function () {
return(Math.max(0, currentScore));
};
this.getGameFinsished = function () {
return(gameFinsished);
};
this.getShotBonus = function () {
return(shotBonus);
};
this.getTimeBonus = function () {
if (game.gd.relaxMode == "true") {
return(0);
}
return(timeBonus);
};
this.getGameScore = function () {
return((currentScore - this.getTimeBonus()) - this.getShotBonus());
};
this.clearShotBonus = function () {
shotBonus = 0;
};
this.ballClearToPutOnRail = function (ballno) {
if ((ballno == 9) && (shotNo == 1)) {
return(false);
}
return(true);
};
this.evaluateEvent = function (event) {
var _local3 = 0;
event.code = eventCodes[event.action] || -1;
if (event.action == "shoot") {
this.firstHitLegal = false;
this.firstHitLegal_2 = false;
cueBallSunk = false;
shotNo++;
ballsSunkLastHit = [];
} else if (event.action == "place ball") {
} else if (event.action == "ball sunk") {
if (this.firstHitLegal) {
this.firstHitLegal_2 = true;
}
ballsSunkLastHit.push(event.value);
if (event.value == 0) {
cueBallSunk = true;
}
} else {
if (event.action == "hit wall") {
if (this.firstHitLegal && (!this.firstHitLegal_2)) {
this.firstHitLegal_2 = true;
// unexpected jump
}
return(undefined);
}
if (event.action == "hit first ball") {
if (this.findNextLegalBall() == event.value) {
this.firstHitLegal = true;
} else {
this.firstHitLegal = false;
}
} else if (event.action == "shot done") {
var _local5 = false;
var _local2 = 0;
while (_local2 < ballsSunkLastHit.length) {
if (ballsSunkLastHit[_local2] == 9) {
_local5 = true;
}
_local2++;
}
if (cueBallSunk && ((_local5 == false) || (shotNo == 1))) {
game.ballz.setRestoreBallList(ballsSunkLastHit);
this.restoreLastState();
currentPenaltyScore = currentPenaltyScore + 50;
_local3 = -currentPenaltyScore;
} else if (this.firstHitLegal_2 && (!cueBallSunk)) {
_local2 = 0;
while (_local2 < ballsSunkLastHit.length) {
if ((ballsSunkLastHit[_local2] != 9) || (shotNo > 1)) {
_local3 = _local3 + currentBallScore;
currentBallScore = currentBallScore + 50;
ballsSunk[ballsSunkLastHit[_local2]] = true;
} else {
if (!game.gameOver) {
game.ballz.restoreNineBall();
}
_local3 = _local3 + 100;
}
_local2++;
}
if (_local5 && (shotNo > 1)) {
gameFinsished = true;
gameCleared = true;
_local2 = 1;
while (_local2 <= 9) {
if (!ballsSunk[_local2]) {
ballsSunk[_local2] = true;
_local3 = _local3 + currentBallScore;
currentBallScore = currentBallScore + 50;
}
_local2++;
}
} else if (!game.gameOver) {
game.gui.swapNextBall(this.findNextLegalBall());
}
} else {
_local2 = 0;
while (_local2 < ballsSunkLastHit.length) {
ballsSunk[ballsSunkLastHit[_local2]] = true;
_local2++;
}
currentPenaltyScore = currentPenaltyScore + 50;
_local3 = -currentPenaltyScore;
if (_local5) {
if (shotNo > 1) {
shotBonus = 0;
gameFinsished = true;
} else if (!game.gameOver) {
game.ballz.restoreNineBall();
game.gui.swapNextBall(this.findNextLegalBall());
soundFx.play("penalty.wav", true);
}
} else if (!game.gameOver) {
game.gui.swapNextBall(this.findNextLegalBall());
soundFx.play("penalty.wav", true);
}
}
if ((!gameFinsished) && (shotBonus >= 100)) {
shotBonus = shotBonus - 100;
if (!game.gameOver) {
game.gui.addBonus(-100);
}
}
} else if (event.action == "time bonus") {
if (gameCleared) {
var _local8 = event.value;
var _local7 = game.gd.duration;
timeBonus = Math.max(0, Math.min(300, Math.round((_local8 / _local7) * 300)));
_local3 = timeBonus;
}
} else if (event.action == "shot bonus") {
_local3 = shotBonus;
} else if (event.action == "version") {
} else if (event.action == "end button pressed") {
shotBonus = 0;
}
}
var _local6 = currentScore;
currentScore = currentScore + _local3;
if (((!game.gameOver) && (event.action != "time bonus")) && (event.action != "shot bonus")) {
game.gui.addPoints(_local3);
}
event.score = currentScore - _local6;
if (event.code > 0) {
this.sendEvent(event);
}
return(_local3);
};
this.sendEvent = function (props) {
if (game.gameOver) {
return(undefined);
}
var _local1 = "" + props.code;
if (props.value != null) {
_local1 = _local1 + ("," + props.value);
}
_local1 = _local1 + ("=" + String(props.score));
fscommand ("playData", _local1);
};
}
function Physics() {
var tmpVector1 = new Array();
var tmpVector2 = new Array();
var _local58 = new Array();
var tmpVector4 = new Array();
var tmpVector5 = new Array();
var tmpVector6 = new Array();
var comboMovevec = [];
var bounceDamp = 0.87;
var ballDamp = 0.98;
var rollDamp = 0.99;
var rollDamp2 = 0.1;
this.sqrtFunc = Math.sqrt;
this.shortestHit = 2;
this.shortestHitData = {};
this.getRollDamp = function () {
return(rollDamp);
};
this.getRollDamp2 = function () {
return(rollDamp2);
};
this.resetCollisionData = function () {
this.shortestHit = 2;
this.shortestHitData = {};
};
this.getCollisionData = function () {
if (this.shortestHit == 2) {
return(null);
}
return(this.shortestHitData);
};
this.checkCollide = function (A, B, movevec, magn) {
var _local6 = B.x - A.x;
var _local5 = B.y - A.y;
var _local8 = this.sqrtFunc((_local6 * _local6) + (_local5 * _local5));
var _local7 = B.radius + A.radius;
var _local17 = _local8 - _local7;
if (magn < _local17) {
return(false);
}
var _local16 = movevec[0] / magn;
var _local15 = movevec[1] / magn;
var _local3 = (_local16 * _local6) + (_local15 * _local5);
if (_local3 <= 0) {
return(false);
}
var _local13 = (_local8 * _local8) - (_local3 * _local3);
var _local14 = _local7 * _local7;
if (_local13 >= _local14) {
return(false);
}
var _local9 = _local14 - _local13;
if (_local9 < 0) {
return(false);
}
var _local22 = _local3 - this.sqrtFunc(_local9);
if (magn < _local22) {
return(false);
}
var _local2 = _local22 / magn;
if (_local2 < this.shortestHit) {
this.shortestHit = _local2;
this.shortestHitData = {ball:A, distance:_local22, mvx:movevec[0] * _local2, mvy:movevec[1] * _local2, targetBall:B, mvx_b:0, mvy_b:0};
return(true);
}
return(false);
};
this.checkCollide_25 = function (A, B, movevec, magn) {
var _local6 = B.x - A.x;
var _local5 = B.y - A.y;
var _local8 = (_local6 * _local6) + (_local5 * _local5);
if (magn < (this.sqrtFunc(_local8) - 25)) {
return(false);
}
var _local14 = movevec[0] / magn;
var _local13 = movevec[1] / magn;
var _local4 = (_local14 * _local6) + (_local13 * _local5);
if (_local4 <= 0) {
return(false);
}
var _local10 = _local8 - (_local4 * _local4);
if (_local10 >= 625) {
return(false);
}
var _local7 = 625 - _local10;
if (_local7 < 0) {
return(false);
}
var _local19 = _local4 - this.sqrtFunc(_local7);
if (magn < _local19) {
return(false);
}
var _local3 = _local19 / magn;
if (_local3 < this.shortestHit) {
this.shortestHit = _local3;
this.shortestHitData = {ball:A, distance:_local19, mvx:movevec[0] * _local3, mvy:movevec[1] * _local3, targetBall:B, mvx_b:0, mvy_b:0, impactspeed:magn};
return(true);
}
return(false);
};
this.checkCollide_125_2 = function (A, B, movevec, magn) {
var _local6 = B.x - A.x;
var _local5 = B.y - A.y;
var _local8 = (_local6 * _local6) + (_local5 * _local5);
if (magn < (this.sqrtFunc(_local8) - 15.5)) {
return(false);
}
var _local14 = movevec[0] / magn;
var _local13 = movevec[1] / magn;
var _local3 = (_local14 * _local6) + (_local13 * _local5);
if (_local3 <= 0) {
return(false);
}
var _local10 = _local8 - (_local3 * _local3);
if (_local10 >= 240.25) {
return(false);
}
var _local7 = 240.25 - _local10;
if (_local7 < 0) {
return(false);
}
var _local19 = _local3 - this.sqrtFunc(_local7);
if (magn < _local19) {
return(false);
}
var _local2 = _local19 / magn;
if (_local2 < this.shortestHit) {
this.shortestHit = _local2;
this.shortestHitData = {ball:A, distance:_local19, mvx:movevec[0] * _local2, mvy:movevec[1] * _local2, targetBall:B, mvx_b:0, mvy_b:0};
return(true);
}
return(false);
};
this.checkCollide_125_05 = function (A, B, movevec, magn) {
var _local6 = B.x - A.x;
var _local5 = B.y - A.y;
var _local8 = (_local6 * _local6) + (_local5 * _local5);
if (magn < (this.sqrtFunc(_local8) - 13)) {
return(false);
}
var _local14 = movevec[0] / magn;
var _local13 = movevec[1] / magn;
var _local3 = (_local14 * _local6) + (_local13 * _local5);
if (_local3 <= 0) {
return(false);
}
var _local10 = _local8 - (_local3 * _local3);
if (_local10 >= 169) {
return(false);
}
var _local7 = 169 - _local10;
if (_local7 < 0) {
return(false);
}
var _local19 = _local3 - this.sqrtFunc(_local7);
if (magn < _local19) {
return(false);
}
var _local2 = _local19 / magn;
if (_local2 < this.shortestHit) {
this.shortestHit = _local2;
this.shortestHitData = {ball:A, distance:_local19, mvx:movevec[0] * _local2, mvy:movevec[1] * _local2, targetBall:B, mvx_b:0, mvy_b:0};
return(true);
}
return(false);
};
this.createLine = function (_x1, _y1, _x2, _y2) {
var _local4 = _x2 - _x1;
var _local3 = -(_y2 - _y1);
var _local2 = this.sqrtFunc((_local4 * _local4) + (_local3 * _local3));
var _local5 = {x1:_x1, y1:_y1, x2:_x2, y2:_y2, l:_local2};
var _local6 = [_local4 / _local2, (-_local3) / _local2, 0, _local3 / _local2, _local4 / _local2, 0, 0, 0, 1];
var _local7 = [_local4 / _local2, _local3 / _local2, 0, (-_local3) / _local2, _local4 / _local2, 0, 0, 0, 1];
var _local10 = [1, 0, -_x1, 0, 1, -_y1, 0, 0, 1];
var _local11 = [1, 0, _x1, 0, 1, _y1, 0, 0, 1];
_local5.rotMatrix = _local6;
_local5.transRotMatrix = MULM(_local6, _local10, []);
_local5.negRotTransMatrix = MULM(_local11, _local7, []);
_local5.negRotMatrix = _local7;
return(_local5);
};
this.checkLineCollide = function (ball, line) {
var _local2 = line.transRotMatrix;
tmpVector1[1] = ((_local2[3] * ball.x) + (_local2[4] * ball.y)) + _local2[5];
tmpVector2[1] = ((_local2[3] * (ball.x + ball.movevec[0])) + (_local2[4] * (ball.y + ball.movevec[1]))) + _local2[5];
if ((tmpVector2[1] < ball.radius) && (tmpVector1[1] >= ball.radius)) {
tmpVector1[0] = ((_local2[0] * ball.x) + (_local2[1] * ball.y)) + _local2[2];
tmpVector2[0] = ((_local2[0] * (ball.x + ball.movevec[0])) + (_local2[1] * (ball.y + ball.movevec[1]))) + _local2[2];
var _local4;
if (tmpVector1[0] == tmpVector2[0]) {
_local4 = tmpVector1[0];
} else {
_local4 = tmpVector1[0] + (((ball.radius - tmpVector1[1]) * (tmpVector1[0] - tmpVector2[0])) / (tmpVector1[1] - tmpVector2[1]));
}
if ((_local4 >= 0) && (_local4 <= line.l)) {
var _local3 = MULMV_simple(line.rotMatrix, ball.vx, ball.vy, tmpVector4);
_local3[1] = -_local3[1];
var _local8 = MULMV_simple(line.negRotMatrix, _local3[0], _local3[1], tmpVector5);
var _local11 = _local4 - tmpVector1[0];
var _local9 = ball.radius - tmpVector1[1];
var _local7 = MULMV_simple(line.negRotMatrix, _local11, _local9, tmpVector6);
var _local13 = this.sqrtFunc((_local11 * _local11) + (_local9 * _local9));
var _local6 = _local13 / ball.movevecLen;
if (_local6 < this.shortestHit) {
this.shortestHit = _local6;
this.shortestHitData = {ball:ball, distance:_local13, mvx:_local7[0], mvy:_local7[1], targetBall:null, mvx_b:0, mvy_b:0, vx_new:_local8[0], vy_new:_local8[1]};
return(true);
}
return(false);
}
}
return(false);
};
this.bounceLine = function () {
var _local2 = this.shortestHitData.ball;
_local2.x = _local2.x + this.shortestHitData.mvx;
_local2.y = _local2.y + this.shortestHitData.mvy;
var _local4 = this.shortestHitData.vx_new * bounceDamp;
var _local5 = this.shortestHitData.vy_new * bounceDamp;
if (_local2.no == 0) {
if ((_local2.spinx != 0) || (_local2.spiny != 0)) {
var _local3 = this.sqrtFunc((_local2.vx * _local2.vx) + (_local2.vy * _local2.vy));
_local4 = _local4 + ((_local2.vy / _local3) * (-_local2.spinx));
_local5 = _local5 + (((-_local2.vx) / _local3) * (-_local2.spinx));
_local2.spiny = _local2.spiny * 0.5;
_local4 = _local4 + ((_local2.vx / _local3) * (-_local2.spiny));
_local5 = _local5 + ((_local2.vy / _local3) * (-_local2.spiny));
_local2.spinx = 0;
_local2.spiny = 0;
}
}
_local2.vx = _local4;
_local2.vy = _local5;
_local2.movevecLen = _local2.movevecLen - Math.abs(this.shortestHitData.distance);
var _local6 = _local2.movevecLen / _local2.originalMovevecLen;
_local2.movevec[0] = _local2.vx * _local6;
_local2.movevec[1] = _local2.vy * _local6;
_local2.movevecLen = this.sqrtFunc((_local2.movevec[0] * _local2.movevec[0]) + (_local2.movevec[1] * _local2.movevec[1]));
_local2.originalMovevecLen = this.sqrtFunc((_local2.vx * _local2.vx) + (_local2.vy * _local2.vy));
};
this.collideBounce = function (A, B) {
if ((A.movevecLen == 0) && (B.movevecLen == 0)) {
return(false);
}
if ((A.movevecLen != 0) && (B.movevecLen != 0)) {
comboMovevec[0] = A.movevec[0] - B.movevec[0];
comboMovevec[1] = A.movevec[1] - B.movevec[1];
var _local5 = this.sqrtFunc((comboMovevec[0] * comboMovevec[0]) + (comboMovevec[1] * comboMovevec[1]));
if (this.checkCollide_25(A, B, comboMovevec, _local5)) {
var _local4 = this.shortestHitData.distance / _local5;
this.shortestHitData.mvx = A.movevec[0] * _local4;
this.shortestHitData.mvy = A.movevec[1] * _local4;
this.shortestHitData.distance = vectorMagnitude(A.movevec) * _local4;
this.shortestHitData.mvx_b = B.movevec[0] * _local4;
this.shortestHitData.mvy_b = B.movevec[1] * _local4;
return(true);
}
} else {
if (B.movevecLen != 0) {
var _local6 = A;
A = B;
B = _local6;
}
if (this.checkCollide_25(A, B, A.movevec, A.movevecLen)) {
return(true);
}
}
return(false);
};
this.executeBounce = function () {
var _local2 = this.shortestHitData.ball;
var _local3 = this.shortestHitData.targetBall;
if ((_local3.movevecLen != 0) && (_local2.movevecLen == 0)) {
wr(" swap A & B");
var _local6 = _local2;
_local2 = _local3;
_local3 = _local6;
}
_local2.x = _local2.x + this.shortestHitData.mvx;
_local2.y = _local2.y + this.shortestHitData.mvy;
if (!_local3.moving) {
game.ballz.setBallMoving(_local3);
}
_local3.x = _local3.x + this.shortestHitData.mvx_b;
_local3.y = _local3.y + this.shortestHitData.mvy_b;
var _local4 = ballDamp;
this.bounce(_local2, _local3);
if (_local3.radius < 1) {
_local4 = bounceDamp;
}
_local2.vx = _local2.vx * _local4;
_local2.vy = _local2.vy * _local4;
_local3.vx = _local3.vx * _local4;
_local3.vy = _local3.vy * _local4;
if (Math.abs(_local2.vx) < 0.001) {
_local2.vx = 0;
}
if (Math.abs(_local2.vy) < 0.001) {
_local2.vy = 0;
}
if (Math.abs(_local3.vx) < 0.001) {
_local3.vx = 0;
}
if (Math.abs(_local3.vy) < 0.001) {
_local3.vy = 0;
}
_local2.movevecLen = _local2.movevecLen - Math.abs(this.shortestHitData.distance);
if (_local2.originalMovevecLen == 0) {
wr("div by zero alert in physics.executeBounce()!!!!!");
}
var _local5 = _local2.movevecLen / _local2.originalMovevecLen;
_local2.movevec[0] = _local2.vx * _local5;
_local2.movevec[1] = _local2.vy * _local5;
_local2.movevecLen = this.sqrtFunc((_local2.movevec[0] * _local2.movevec[0]) + (_local2.movevec[1] * _local2.movevec[1]));
_local2.originalMovevecLen = this.sqrtFunc((_local2.vx * _local2.vx) + (_local2.vy * _local2.vy));
_local3.movevec[0] = _local3.vx * _local5;
_local3.movevec[1] = _local3.vy * _local5;
_local3.movevecLen = this.sqrtFunc((_local3.movevec[0] * _local3.movevec[0]) + (_local3.movevec[1] * _local3.movevec[1]));
_local3.originalMovevecLen = this.sqrtFunc((_local3.vx * _local3.vx) + (_local3.vy * _local3.vy));
};
this.bounce = function (A, B) {
var _local9 = A.x - B.x;
var _local8 = A.y - B.y;
var _local12 = this.sqrtFunc((_local9 * _local9) + (_local8 * _local8));
var _local6 = _local9 / _local12;
var _local5 = _local8 / _local12;
var _local16 = (A.vx * _local6) + (A.vy * _local5);
var _local15 = (B.vx * _local6) + (B.vy * _local5);
var _local4 = (2 * (_local16 - _local15)) / (A.mass + B.mass);
var _local10 = A.vx - ((_local4 * B.mass) * _local6);
var _local11 = A.vy - ((_local4 * B.mass) * _local5);
var _local13 = B.vx + ((_local4 * A.mass) * _local6);
var _local14 = B.vy + ((_local4 * A.mass) * _local5);
if (A.no == 0) {
if ((A.spinx != 0) || (A.spiny != 0)) {
var _local7 = this.sqrtFunc((A.vx * A.vx) + (A.vy * A.vy));
_local10 = _local10 + ((A.vy / _local7) * (-A.spinx));
_local11 = _local11 + (((-A.vx) / _local7) * (-A.spinx));
_local10 = _local10 + ((A.vx / _local7) * (-A.spiny));
_local11 = _local11 + ((A.vy / _local7) * (-A.spiny));
A.spinx = 0;
A.spiny = 0;
}
}
A.vx = _local10;
A.vy = _local11;
B.vx = _local13;
B.vy = _local14;
};
}
function vectorAdd(v1, v2) {
return([v1[0] + v2[0], v1[1] + v2[1]]);
}
function vectorSub(v1, v2) {
return([v1[0] - v2[0], v1[1] - v2[1]]);
}
function vectorNormalize(v) {
var _local2 = Math.sqrt((v[0] * v[0]) + (v[1] * v[1]));
v[0] = v[0] / _local2;
v[1] = v[1] / _local2;
}
function vectorDot(v1, v2) {
return((v1[0] * v2[0]) + (v1[1] * v2[1]));
}
function vectorCross(v1, v2) {
return((v1[0] * v2[1]) - (v1[1] * v1[0]));
}
function vectorMagnitude(v) {
return(Math.sqrt((v[0] * v[0]) + (v[1] * v[1])));
}
function distance(p1, p2) {
var _local2 = p2[0] - p1[0];
var _local1 = p2[1] - p1[1];
return(Math.sqrt((_local2 * _local2) + (_local1 * _local1)));
}
function MULMV_simple(m, vx, vy, result) {
result[0] = ((m[0] * vx) + (m[1] * vy)) + m[2];
result[1] = ((m[3] * vx) + (m[4] * vy)) + m[5];
return(result);
}
function MULMV(m, vx, vy, vz, result) {
result[0] = ((m[0] * vx) + (m[1] * vy)) + (m[2] * vz);
result[1] = ((m[3] * vx) + (m[4] * vy)) + (m[5] * vz);
result[2] = ((m[6] * vx) + (m[7] * vy)) + (m[8] * vz);
return(result);
}
function MULM(q, r, result) {
var _local3 = 0;
while (_local3 < 3) {
var _local2 = 0;
while (_local2 < 3) {
result[(_local3 * 3) + _local2] = 0;
var _local1 = 0;
while (_local1 < 3) {
result[(_local3 * 3) + _local2] = result[(_local3 * 3) + _local2] + (q[(_local3 * 3) + _local1] * r[(_local1 * 3) + _local2]);
_local1++;
}
_local2++;
}
_local3++;
}
return(result);
}
function createRotationMatrixAlpha(v) {
return([1, 0, 0, 0, Math.cos(v), Math.sin(v), 0, -Math.sin(v), Math.cos(v)]);
}
function createRotationMatrixBeta(v) {
return([Math.cos(v), 0, -Math.sin(v), 0, 1, 0, Math.sin(v), 0, Math.cos(v)]);
}
function createRotationMatrixGamma(v) {
return([Math.cos(v), Math.sin(v), 0, -Math.sin(v), Math.cos(v), 0, 0, 0, 1]);
}
function Table() {
var wallcoords = [[20.422, 3.171, 67.388, 37.9], [67.388, 37.9, 273.218, 37.9], [273.218, 37.9, 281.073, -1.5], [306.366, -1.55, 313.86, 37.9], [313.86, 37.9, 519.992, 37.9], [519.992, 37.9, 565.737, 3.022], [581.6, 21.885, 549.689, 66.599], [549.689, 66.599, 549.689, 271.201], [549.689, 271.201, 582.457, 316.983], [564.737, 334.988, 520.992, 299.901], [520.992, 299.901, 313.86, 299.901], [313.86, 299.901, 305.938, 343.563], [282.217, 343.991, 273.018, 299.901], [273.018, 299.901, 66.388, 299.901], [66.388, 299.901, 20.845, 334.988], [2.411, 318.555, 37.689, 271.201], [37.689, 271.201, 37.689, 66.599], [37.689, 66.599, 3.982, 21.028]];
var holecoords = [[552.857, 304.209], [552.689, 33.9], [293.689, 315.901], [293.689, 21.9], [34.002, 303.901], [34.202, 34]];
var hole_cage = [[50.808, -0.206], [-38.883, -32.73], [36.072, 35.782], [-4.349, -50.639], [0.205, 50.809], [32.732, -38.881], [-35.781, 36.074], [50.638, -4.35], [-50.808, 0.206], [38.881, 32.729], [-36.073, -35.781], [4.35, 50.637], [-0.207, -50.809], [-32.731, 38.881], [35.78, -36.072], [-50.637, 4.349]];
var railcoords = [[417, -9], [417, -8], [417, -7], [417, -6], [417, -5], [417, -4], [417, -3], [417, -2], [417, -1], [416.992, 0], [416.975, 1.05], [416.923, 2.093], [416.837, 3.128], [416.717, 4.153], [416.564, 5.169], [416.379, 6.175], [416.161, 7.169], [415.912, 8.151], [415.632, 9.122], [415.321, 10.079], [414.98, 11.022], [414.61, 11.952], [414.212, 12.866], [413.785, 13.764], [413.33, 14.646], [412.849, 15.512], [412.342, 16.36], [411.671, 17.395], [411.105, 18.201], [410.517, 18.988], [409.904, 19.755], [409.269, 20.501], [408.611, 21.227], [407.758, 22.104], [407.052, 22.779], [406.326, 23.433], [405.58, 24.062], [404.815, 24.668], [404.033, 25.249], [403.232, 25.806], [402.416, 26.336], [401.582, 26.842], [400.733, 27.32], [399.87, 27.772], [398.992, 28.197], [398.102, 28.593], [397.197, 28.962], [396.282, 29.303], [395.354, 29.614], [394.417, 29.896], [393.47, 30.148], [392.513, 30.371], [391.548, 30.564], [390.575, 30.726], [389.595, 30.857], [388.608, 30.958], [387.617, 31.027], [386.62, 31.064], [385.92, 31], [384.912, 31], [383.902, 31], [382.89, 31], [381.874, 31], [380.855, 31], [379.835, 31], [378.812, 31], [377.785, 31], [376.756, 31], [375.725, 31], [374.69, 31], [373.653, 31], [372.613, 31], [371.57, 31], [370.569, 31], [369.565, 31], [368.559, 31], [367.549, 31], [366.538, 31], [365.523, 31], [364.505, 31], [363.485, 31], [362.462, 31], [361.437, 31], [360.408, 31], [359.376, 31], [358.342, 31], [357.304, 31], [356.264, 31], [355.221, 31], [354.22, 31], [353.216, 31], [352.21, 31], [351.201, 31], [350.188, 31], [349.174, 31], [348.156, 31], [347.135, 31], [346.112, 31], [345.085, 31], [344.056, 31], [343.023, 31], [341.987, 31], [340.949, 31], [339.907, 31], [338.908, 31], [337.907, 31], [336.903, 31], [335.896, 31], [334.886, 31], [333.873, 31], [332.856, 31], [331.837, 31], [330.815, 31], [329.79, 31], [328.761, 31], [327.73, 31], [326.695, 31], [325.657, 31], [324.616, 31], [323.619, 31], [322.619, 31], [321.616, 31], [320.61, 31], [319.601, 31], [318.589, 31], [317.574, 31], [316.555, 31], [315.533, 31], [314.508, 31], [313.48, 31], [312.449, 31], [311.414, 31], [310.375, 31], [309.334, 31], [308.337, 31], [307.338, 31], [306.335, 31], [305.329, 31], [304.32, 31], [303.308, 31], [302.292, 31], [301.272, 31], [300.25, 31], [299.225, 31], [298.195, 31], [297.162, 31], [296.126, 31], [295.086, 31], [294.093, 31], [293.096, 31], [292.095, 31], [291.092, 31], [290.085, 31], [289.074, 31], [288.061, 31], [287.043, 31], [286.022, 31], [284.998, 31], [283.97, 31], [282.938, 31], [281.903, 31], [280.864, 31], [279.821, 31], [278.826, 31], [277.827, 31], [276.824, 31], [275.818, 31], [274.809, 31], [273.795, 31], [272.778, 31], [271.758, 31], [270.733, 31], [269.706, 31], [268.673, 31], [267.638, 31], [266.598, 31], [265.606, 31], [264.611, 31], [263.613, 31], [262.61, 31], [261.604, 31], [260.594, 31], [259.581, 31], [258.563, 31], [257.542, 31], [256.516, 31], [255.487, 31], [254.453, 31], [253.416, 31], [252.374, 31], [251.382, 31], [250.386, 31], [249.386, 31], [248.382, 31], [247.374, 31], [246.362, 31], [245.347, 31], [244.327, 31], [243.303, 31], [242.274, 31], [241.242, 31], [240.205, 31], [239.164, 31], [238.173, 31], [237.179, 31], [236.18, 31], [235.177, 31], [234.17, 31], [233.159, 31], [232.144, 31], [231.124, 31], [230.1, 31], [229.071, 31], [228.039, 31], [227.001, 31], [225.958, 31], [224.968, 31], [223.974, 31], [222.975, 31], [221.972, 31], [220.964, 31], [219.952, 31], [218.936, 31], [217.915, 31], [216.889, 31], [215.858, 31], [214.823, 31], [213.783, 31], [212.796, 31], [211.804, 31], [210.809, 31], [209.808, 31], [208.803, 31], [207.793, 31], [206.778, 31], [205.759, 31], [204.734, 31], [203.705, 31], [202.67, 31], [201.631, 31], [200.646, 31], [199.656, 31], [198.662, 31], [197.662, 31], [196.658, 31], [195.648, 31], [194.634, 31], [193.615, 31], [192.59, 31], [191.56, 31], [190.525, 31], [189.484, 31], [188.5, 31], [187.51, 31], [186.515, 31], [185.515, 31], [184.51, 31], [183.499, 31], [182.483, 31], [181.462, 31], [180.435, 31], [179.402, 31], [178.364, 31], [177.383, 31], [176.396, 31], [175.405, 31], [174.408, 31], [173.405, 31], [172.397, 31], [171.383, 31], [170.364, 31], [169.338, 31], [168.307, 31], [167.269, 31], [166.29, 31], [165.306, 31], [164.316, 31], [163.32, 31], [162.319, 31], [161.311, 31], [160.297, 31], [159.277, 31], [158.251, 31], [157.219, 31], [156.179, 31], [155.201, 31], [154.217, 31], [153.226, 31], [152.229, 31], [151.227, 31], [150.217, 31], [149.201, 31], [148.179, 31], [147.149, 31], [146.113, 31], [145.069, 31], [144.088, 31], [143.101, 31], [142.107, 31], [141.107, 31], [140.1, 31], [139.085, 31], [138.064, 31], [137.035, 31], [135.999, 31], [135.027, 31], [134.049, 31], [133.063, 31], [132.071, 31], [131.071, 31], [130.064, 31], [129.049, 31], [128.027, 31], [126.997, 31], [125.959, 31], [124.987, 31], [124.008, 31], [123.022, 31], [122.028, 31], [121.026, 31], [120.016, 31], [118.999, 31], [117.972, 31], [116.937, 31], [115.971, 31], [114.997, 31], [114.014, 31], [113.024, 31], [112.025, 31], [111.018, 31], [110.002, 31], [108.978, 31], [107.943, 31], [106.899, 31], [105.927, 31], [104.946, 31], [103.956, 31], [102.957, 31], [101.949, 31], [100.931, 31], [99.903, 31], [98.866, 31], [97.901, 31], [96.928, 31], [95.945, 31], [94.952, 31], [93.95, 31], [92.938, 31], [91.914, 31], [90.88, 31], [89.922, 31], [88.954, 31], [87.976, 31], [86.987, 31], [85.988, 31], [84.977, 31], [83.956, 31], [82.922, 31], [81.967, 31], [81.001, 31], [80.024, 31], [79.036, 31], [78.036, 31], [77.024, 31], [76, 31], [74.961, 31], [74.005, 31], [73.038, 31], [72.058, 31], [71.065, 31], [70.059, 31], [69.04, 31], [68.006, 31], [67.057, 31], [66.095, 31], [65.12, 31], [64.131, 31], [63.127, 31], [62.109, 31], [61.075, 31], [60.129, 31], [59.169, 31], [58.194, 31], [57.205, 31], [56.198, 31], [55.175, 31], [54.134, 31], [53.185, 31], [52.221, 31], [51.239, 31], [50.24, 31], [49.222, 31], [48.185, 31], [47.244, 31], [46.285, 31], [45.308, 31], [44.311, 31], [43.292, 31], [42.252, 31], [41.313, 31], [40.354, 31], [39.373, 31], [38.369, 31], [37.341, 31], [36.419, 31], [35.475, 31], [34.506, 31], [33.514, 31], [32.493, 31], [31.583, 31], [30.649, 31], [29.688, 31], [28.698, 31], [27.678, 31], [26.772, 31], [25.839, 31], [24.875, 31], [23.877, 31], [22.841, 31], [21.928, 31], [20.979, 31], [19.993, 31], [18.962, 31], [18.06, 31], [17.118, 31], [16.129, 31], [15.275, 31], [14.378, 31], [13.432, 31], [12.428, 31], [11.566, 31], [10.648, 31], [9.662, 31], [8.826, 31], [7.922, 31], [6.934, 31], [6.101, 31]];
var railcoords_end;
var railoffsetx = 205;
var railoffsety = 361;
var railActive = false;
var railList = [];
var cageActive = false;
var cageList = [];
this.walls = new Array();
this.wallpoints = new Array();
this.holes = new Array();
this.holeCages = new Array();
var ballRadius = 12.5;
var hiddenPocket = new Array();
this.init = function () {
this.offset_x = 123;
this.offset_y = 41;
this.center_x = this.offset_x + 294;
this.center_y = this.offset_y + 169;
this.bounds = [wallcoords[16][0] + this.offset_x, wallcoords[1][1] + this.offset_y, wallcoords[7][0] + this.offset_x, wallcoords[10][1] + this.offset_y];
this.boundsMinusRadius = [this.bounds[0] + ballRadius, this.bounds[1] + ballRadius, this.bounds[2] - ballRadius, this.bounds[3] - ballRadius];
var _local21 = (this.bounds[2] - this.bounds[0]) + 32;
var _local20 = (this.bounds[3] - this.bounds[1]) + 32;
this.diagonal = Math.sqrt((_local21 * _local21) + (_local20 * _local20));
this.tablesprite = sprites.create({member:"pooltable_top", x:this.offset_x, y:this.offset_y});
this.tablesprite.toLevel(4);
if (game.netGame) {
if (game.gd.gametype == "9ball") {
this.tablesprite.member_mc.gotoAndStop(1);
} else {
this.tablesprite.member_mc.gotoAndStop(2);
}
}
railcoords_end = railcoords.length - 1;
railActive = false;
var _local4 = -1;
var _local5 = -1;
var _local10 = 0;
this.walls.push(new Array());
this.wallpoints.push(new Array());
var _local3 = 0;
while (_local3 < wallcoords.length) {
var _local9 = wallcoords[_local3][0] + this.offset_x;
var _local7 = wallcoords[_local3][1] + this.offset_y;
var _local8 = wallcoords[_local3][2] + this.offset_x;
var _local6 = wallcoords[_local3][3] + this.offset_y;
this.walls[_local10].push(game.physics.createLine(_local9, _local7, _local8, _local6));
var _local14 = _local9 - _local4;
var _local13 = _local7 - _local5;
if (Math.sqrt((_local14 * _local14) + (_local13 * _local13)) < 1) {
tmpWallBall.x = _local4;
tmpWallBall.y = _local5;
this.wallpoints[_local10].push({radius:0.5, mass:100000, vx:0, vy:0, x:_local4, y:_local5, dx:0, dy:0, type:"wallpoint"});
}
_local4 = _local8;
_local5 = _local6;
if (((_local3 == 5) || (_local3 == 8)) || (_local3 == 14)) {
this.wallpoints.push(new Array());
this.walls.push(new Array());
_local10++;
}
_local3++;
}
_local3 = 0;
while (_local3 < holecoords.length) {
this.holes.push({radius:3, mass:200000, x:holecoords[_local3][0] + this.offset_x, y:holecoords[_local3][1] + this.offset_y, dx:0, dy:0, type:"hole"});
this.holeCages.push([]);
var _local2 = 0;
while (_local2 < hole_cage.length) {
this.holeCages[_local3].push(game.physics.createLine((hole_cage[_local2 + 1][0] + holecoords[_local3][0]) + this.offset_x, (hole_cage[_local2 + 1][1] + holecoords[_local3][1]) + this.offset_y, (hole_cage[_local2][0] + holecoords[_local3][0]) + this.offset_x, (hole_cage[_local2][1] + holecoords[_local3][1]) + this.offset_y));
_local2 = _local2 + 2;
}
_local3++;
}
events.runIt(this);
};
this.run = function () {
if (cageActive) {
this.updateCage();
}
if (railActive) {
this.updateRail();
}
};
this.cageOrRailActive = function () {
if (game.netGame) {
return(cageActive);
}
return(cageActive | railActive);
};
this.railActive = function () {
return(railActive);
};
this.addToCage = function (ball) {
var _local2 = cageList.length - 1;
while (_local2 >= 0) {
if (ball.holeno == cageList[_local2].holeno) {
var _local3 = cageList[_local2];
this.addToRail(_local3);
_local3._alpha = 100;
cageList.splice(_local2, 1);
break;
}
_local2--;
}
ball.enteredHole = false;
ball.clearToPutOnRail = game.ballClearToPutOnRail(ball.no);
cageList.push(ball);
cageActive = true;
};
this.printBounceDebug = function (ball) {
var _local4 = ball.x - (holecoords[ball.holeno][0] + this.offset_x);
var _local3 = ball.y - (holecoords[ball.holeno][1] + this.offset_y);
return((((((("bouncedebug: " + _local4) + " ") + _local3) + " ") + ball.movevec[0]) + " ") + ball.movevec[1]);
};
this.updateCage = function () {
var _local2;
var _local5;
var _local6;
var _local15 = false;
var _local8 = cageList.length - 1;
while (_local8 >= 0) {
_local2 = cageList[_local8];
_local5 = this.holeCages[_local2.holeno];
_local2.movevec[0] = _local2.vx;
_local2.movevec[1] = _local2.vy;
_local2.movevecLen = Math.sqrt((_local2.vx * _local2.vx) + (_local2.vy * _local2.vy));
_local2.originalMovevecLen = _local2.movevecLen;
_local6 = true;
while (_local6) {
_local6 = false;
game.physics.resetCollisionData();
var _local3 = 0;
while (_local3 < _local5.length) {
game.physics.checkLineCollide(_local2, _local5[_local3]);
_local3++;
}
var _local7 = game.physics.getCollisionData();
if (_local7) {
game.physics.bounceLine();
var _local4 = Math.acos(_local2.vx / _local2.originalMovevecLen);
if (_local2.movevec[1] < 0) {
_local4 = -_local4;
}
_local2.anim_mc._rotation = _local4 * 57.3;
_local6 = true;
_local15 = true;
}
}
_local2.frame = _local2.frame + _local2.movevecLen;
_local2.anim_mc.gotoAndStop(Math.round((_local2.frame / 1.23) & 31) + 1);
_local2.x = _local2.x + _local2.movevec[0];
_local2.y = _local2.y + _local2.movevec[1];
_local2._x = _local2.x;
_local2._y = _local2.y;
var _local9 = Math.sqrt((_local2.vx * _local2.vx) + (_local2.vy * _local2.vy));
if (!_local2.enteredHole) {
var _local11 = (holecoords[_local2.holeno][0] + this.offset_x) - _local2.x;
var _local10 = (holecoords[_local2.holeno][1] + this.offset_y) - _local2.y;
var _local13 = Math.sqrt((_local11 * _local11) + (_local10 * _local10));
if (_local13 < 3.5) {
_local2.enteredHole = true;
}
_local2.vx = _local2.vx + (_local11 / 10);
_local2.vy = _local2.vy + (_local10 / 10);
} else if (_local9 > 4) {
var _local14 = Math.max(0, (_local9 * 0.95) - 0.05);
var _local12 = _local14 / _local9;
_local2.vx = _local2.vx * _local12;
_local2.vy = _local2.vy * _local12;
} else {
_local2._alpha = _local2._alpha - 25;
if (_local2._alpha <= 20) {
cageList.splice(_local8, 1);
_local2._alpha = 100;
if (cageList.length == 0) {
cageActive = false;
}
this.addToRail(_local2);
}
}
_local8--;
}
if (_local15) {
soundFx.play("cage4.wav", true);
}
};
this.forceToRail = function (ballno) {
var _local2 = cageList.length - 1;
while (_local2 >= 0) {
if (cageList[_local2].no == ballno) {
var _local3 = cageList[_local2];
cageList.splice(_local2, 1);
_local3._alpha = 100;
if (cageList.length == 0) {
cageActive = false;
}
this.addToRail(_local3);
}
_local2--;
}
};
this.addToRail = function (ball) {
if (ball.clearToPutOnRail) {
ball.railpos = ((railList.length == 0) ? 0 : (Math.min(0, railList[railList.length - 1].railpos - 25)));
ball.railpos = ball.railpos - ((ball.holeno * 60) + 25);
ball._visible = false;
ball.anim_mc._rotation = 0;
railList.push(ball);
railActive = true;
soundFx.playLooped("rail.wav");
} else {
ball._visible = false;
hiddenPocket.push(ball);
if (!this.cageOrRailActive()) {
if (!game.netGame) {
game.ballz.railIsDone();
}
}
}
if (game.netGame && (!this.cageOrRailActive())) {
game.ballz.localRailIsDone();
}
};
this.removeFromRail = function (ballno) {
var _local2;
var _local3 = 0;
while (_local3 < railList.length) {
_local2 = railList[_local3];
if (_local2.no == ballno) {
railList.splice(_local3, 1);
railcoords_end = railcoords_end + 25;
if (_local3 == (railList.length - 1)) {
railActive = false;
soundFx.stop("rail.wav");
}
return(_local2);
}
_local3++;
}
_local3 = cageList.length - 1;
while (_local3 >= 0) {
_local2 = railList[_local3];
if (_local2.no == ballno) {
cageList.splice(_local3, 1);
_local2._alpha = 100;
if (cageList.length == 0) {
cageActive = false;
}
return(_local2);
}
_local3--;
}
return(this.removeFromHiddenPocket(ballno));
};
this.removeFromHiddenPocket = function (ballno) {
var _local1 = 0;
while (_local1 < hiddenPocket.length) {
var _local2 = hiddenPocket[_local1];
if (_local2.no == ballno) {
hiddenPocket.splice(_local1, 1);
return(_local2);
}
_local1++;
}
return(null);
};
this.updateRail = function () {
var _local1;
var _local2 = 0;
while (_local2 < railList.length) {
_local1 = railList[_local2];
if (_local1.railpos >= railcoords_end) {
} else {
_local1.railpos = _local1.railpos + 8;
if (_local1.railpos >= 0) {
_local1._visible = true;
_local1.railpos = Math.min(railcoords_end, _local1.railpos);
_local1._x = railoffsetx + railcoords[_local1.railpos][0];
_local1._y = railoffsety + railcoords[_local1.railpos][1];
_local1.frame = _local1.frame - 8;
_local1.anim_mc.gotoAndStop(Math.round((_local1.frame / 1.23) & 31) + 1);
}
if (_local1.railpos >= railcoords_end) {
_local1.railpos = railcoords_end;
railcoords_end = railcoords_end - 25;
if (_local2 == (railList.length - 1)) {
railActive = false;
soundFx.stop("rail.wav");
soundFx.play("railstop.wav");
if (!cageActive) {
if (game.netGame) {
} else {
game.ballz.railIsDone();
}
}
break;
}
}
}
_local2++;
}
};
this.getHolecoords = function () {
return(holecoords);
};
}
function Ballz() {
var damp = game.physics.getRollDamp();
var damp2 = game.physics.getRollDamp2();
var _local37 = 3;
this.balls = new Array();
this.ballsMoving = new Array();
this.ballsStill = new Array();
this.ballCount;
this.ballsMovingCount = 0;
this.ballsStillCount = 0;
this.ballKillList = new Array();
this.firsthitdone;
this.restoreBallList = null;
this.sqrtFunc = Math.sqrt;
this.opponentShotDone = false;
this.localShotDone = false;
this.shotDoneExecuted = false;
this.init = function (_game) {
this.destroyBallSprites();
if (_game == "8ball") {
this.balls = this.create8ballSprites();
} else if (_game == "Xball") {
this.balls = this.createXballSprites();
} else {
this.balls = this.create9ballSprites();
}
this.ballCount = this.balls.length;
this.ballsStillCount = this.balls.length;
this.firsthitdone = false;
if (game.netGame) {
this.netRailDone = false;
this.localRailDone = false;
}
var _local3 = 0;
while (_local3 < this.ballCount) {
var _local2 = this.balls[_local3];
_local2.mass = 5;
_local2.radius = 12.5;
_local2.vx = 0;
_local2.vy = 0;
_local2.last_x = _local2.x;
_local2.last_y = _local2.y;
_local2.movevec = [0, 0];
_local2.movevecLen = 0;
_local2.originalMovevecLen = 0;
_local2.frame = 16;
_local2.anim_mc.gotoAndStop(_local2.frame);
_local2.rotationMatrix = [0, 0, -1, 0, 1, 0, 1, 0, 0];
_local2.type = "ball";
_local2.moving = false;
this.ballsStill.push(_local2);
_local3++;
}
events.runIt(this);
};
this.setBallMoving = function (ball) {
if (ball.radius < 1) {
return(undefined);
}
var _local2 = 0;
while (_local2 < this.ballsStillCount) {
if (this.ballsStill[_local2] == ball) {
ball.moving = true;
this.ballsStill.splice(_local2, 1);
this.ballsMoving.push(ball);
this.ballsStillCount--;
this.ballsMovingCount++;
return(undefined);
}
_local2++;
}
};
this.setBallStill = function (ball) {
var _local2 = 0;
while (_local2 < this.ballsMovingCount) {
if (this.ballsMoving[_local2] == ball) {
ball.moving = false;
this.ballsMoving.splice(_local2, 1);
this.ballsStill.push(ball);
this.ballsMovingCount--;
this.ballsStillCount++;
return(undefined);
}
_local2++;
}
};
this.restoreCueBall = function () {
this.restoreBallList = [0];
};
this.setRestoreBallList = function (ballNoList) {
this.restoreBallList = ballNoList;
if (!game.table.cageOrRailActive()) {
if (game.netGame) {
this.localRailIsDone();
} else {
this.railIsDone();
}
}
};
this.localRailIsDone = function () {
if (!this.localShotDone) {
return(undefined);
}
this.localRailDone = true;
game.player_local.absorb("GRD");
if ((this.netRailDone && (this.opponentShotDone)) && (this.localShotDone)) {
if (!this.shotDoneExecuted) {
this.shotDone();
}
this.railIsDone();
}
};
this.netRailIsDone = function () {
this.netRailDone = true;
if ((this.localRailDone && (this.opponentShotDone)) && (this.localShotDone)) {
if (!this.shotDoneExecuted) {
this.shotDone();
}
this.railIsDone();
}
};
this.railIsDone = function () {
if (this.restoreBallList) {
this.restoreBalls(this.restoreBallList);
this.restoreBallList = null;
}
};
this.restoreBalls = function (ballNoList) {
wr("restoreBalls()", ballNoList);
if (game.gameOver) {
return(undefined);
}
soundFx.play("wah.wav", true);
var _local6 = false;
var _local5 = 0;
while (_local5 < ballNoList.length) {
var _local2 = game.table.removeFromRail(ballNoList[_local5]);
if (_local2 != eval("NULL")) {
this.balls.push(_local2);
this.ballCount++;
this.ballsStill.push(_local2);
this.ballsStillCount++;
} else {
var _local3 = 0;
while (_local3 < this.ballCount) {
if (this.balls[_local3].no == ballNoList[_local5]) {
_local2 = this.balls[_local3];
}
_local3++;
}
}
if (ballNoList[_local5] == 0) {
_local6 = _local2;
}
_local5++;
}
if (game.netGame) {
if (_local6) {
game.holeselector.hide();
game.hand.grabBall(_local6);
_local6._visible = true;
this.gui.setInfo(game.gd.text.place_cue_ball);
}
} else {
_local5 = 0;
while (_local5 < this.ballCount) {
var _local2 = this.balls[_local5];
_local2.vx = 0;
_local2.vy = 0;
_local2.movevec[0] = 0;
_local2.movevec[1] = 0;
_local2.movevecLen = 0;
_local2.originalMovevecLen = 0;
_local2.x = _local2.last_x;
_local2.y = _local2.last_y;
_local2._x = _local2.x;
_local2._y = _local2.y;
_local2._visible = true;
_local5++;
}
game.cue.setFocusBall();
}
};
this.restoreNineBall = function () {
var _local8 = game.table.bounds[0] + ((game.table.bounds[2] - game.table.bounds[0]) / 4);
var _local9 = game.table.bounds[0] + 26;
var _local7 = [game.table.bounds[1] + ((game.table.bounds[3] - game.table.bounds[1]) / 2)];
_local7[1] = _local7[0] + 25;
_local7[2] = _local7[0] - 25;
if (game.gameOver) {
return(undefined);
}
game.table.forceToRail(9);
var _local2 = game.table.removeFromHiddenPocket(9);
wr("restoreNineBall(), got ball:", _local2.no);
if (_local2 != null) {
var _local6 = 0;
while (_local6 < _local7.length) {
y = _local7[_local6];
_local2.y = y;
var _local5 = _local8;
while (_local5 > _local9) {
_local2.x = _local5;
var _local4 = 676;
j = 0;
while (j < this.balls.length) {
var _local3 = this.balls[j];
_local4 = Math.min(_local4, ((_local2.x - _local3.x) * (_local2.x - _local3.x)) + ((_local2.y - _local3.y) * (_local2.y - _local3.y)));
j++;
}
if (_local4 > 625) {
this.balls.push(_local2);
this.ballCount++;
this.ballsStill.push(_local2);
this.ballsStillCount++;
_local2.vx = 0;
_local2.vy = 0;
_local2.movevec[0] = 0;
_local2.movevec[1] = 0;
_local2.movevecLen = 0;
_local2.originalMovevecLen = 0;
_local2._x = _local2.x;
_local2._y = _local2.y;
_local2._visible = true;
return(true);
}
_local5--;
}
_local6++;
}
}
return(false);
};
this.removeBall = function (ball) {
wr("removeBall()", ball.no);
game.evaluateEvent({action:"ball sunk", value:ball.no, holeno:ball.holeno});
game.table.addToCage(ball);
var _local2 = 0;
while (_local2 < this.ballCount) {
if (this.balls[_local2] == ball) {
this.balls.splice(_local2, 1);
this.ballCount--;
break;
}
_local2++;
}
_local2 = this.ballsMoving.length - 1;
while (_local2 >= 0) {
if (this.ballsMoving[_local2] == ball) {
this.ballsMoving[_local2].moving = false;
this.ballsMoving.splice(_local2, 1);
this.ballsMovingCount--;
return(undefined);
}
_local2--;
}
_local2 = this.ballsStill.length - 1;
while (_local2 >= 0) {
if (this.ballsStill[_local2] == ball) {
this.ballsStill.splice(_local2, 1);
this.ballsStillCount--;
return(undefined);
}
_local2--;
}
};
this.shoot = function () {
var _local2 = 0;
while (_local2 < this.ballCount) {
this.balls[_local2].last_x = this.balls[_local2].x;
this.balls[_local2].last_y = this.balls[_local2].y;
if (this.balls[_local2].no == 0) {
var _local3 = this.balls[_local2];
var _local4 = Math.acos(_local3.vx / Math.sqrt((_local3.vx * _local3.vx) + (_local3.vy * _local3.vy)));
if (_local3.vy < 0) {
_local4 = -_local4;
}
_local3.anim_mc._rotation = _local4 * 57.3;
this.setBallMoving(this.balls[_local2]);
}
_local2++;
}
};
this.prepareShoot = function () {
this.firsthitdone = false;
if (game.netGame) {
this.opponentShotDone = false;
this.localShotDone = false;
this.netRailDone = false;
this.localRailDone = false;
this.shotDoneExecuted = false;
}
};
this.run = function () {
if (this.ballsMovingCount == 0) {
return(undefined);
}
var _local16;
var _local22 = 0;
var _local19 = false;
var _local13 = 0;
while (_local13 < this.ballsMovingCount) {
var _local2 = this.ballsMoving[_local13];
_local2.movevec[0] = _local2.vx;
_local2.movevec[1] = _local2.vy;
_local2.movevecLen = Math.sqrt((_local2.vx * _local2.vx) + (_local2.vy * _local2.vy));
_local2.originalMovevecLen = _local2.movevecLen;
_local13++;
}
_local13 = 0;
while (_local13 < this.ballsStillCount) {
var _local2 = this.ballsStill[_local13];
_local2.movevec[0] = 0;
_local2.movevec[1] = 0;
_local2.movevecLen = 0;
_local2.originalMovevecLen = 0;
_local13++;
}
do {
_local16 = false;
game.physics.resetCollisionData();
_local13 = 0;
while (_local13 < this.ballsMovingCount) {
var _local2 = this.ballsMoving[_local13];
var _local4 = _local13 + 1;
while (_local4 < this.ballsMovingCount) {
var _local10 = this.ballsMoving[_local4];
game.physics.collideBounce(_local2, _local10);
_local4++;
}
_local4 = 0;
while (_local4 < this.ballsStillCount) {
var _local10 = this.ballsStill[_local4];
game.physics.collideBounce(_local2, _local10);
_local4++;
}
var _local8 = false;
if ((_local2.y + _local2.movevec[1]) < 91.4) {
_local8 = true;
_local4 = 0;
while (_local4 < game.table.walls[0].length) {
game.physics.checkLineCollide(_local2, game.table.walls[0][_local4]);
_local4++;
}
_local4 = 0;
while (_local4 < game.table.wallpoints[0].length) {
game.physics.checkCollide_125_05(_local2, game.table.wallpoints[0][_local4], _local2.movevec, _local2.movevecLen);
_local4++;
}
}
if ((_local2.x + _local2.movevec[0]) > 660.189) {
_local8 = true;
_local4 = 0;
while (_local4 < game.table.walls[1].length) {
game.physics.checkLineCollide(_local2, game.table.walls[1][_local4]);
_local4++;
}
_local4 = 0;
while (_local4 < game.table.wallpoints[1].length) {
game.physics.checkCollide_125_05(_local2, game.table.wallpoints[1][_local4], _local2.movevec, _local2.movevecLen);
_local4++;
}
}
if ((_local2.y + _local2.movevec[1]) > 328.401) {
_local8 = true;
_local4 = 0;
while (_local4 < game.table.walls[2].length) {
game.physics.checkLineCollide(_local2, game.table.walls[2][_local4]);
_local4++;
}
_local4 = 0;
while (_local4 < game.table.wallpoints[2].length) {
game.physics.checkCollide_125_05(_local2, game.table.wallpoints[2][_local4], _local2.movevec, _local2.movevecLen);
_local4++;
}
}
if ((_local2.x + _local2.movevec[0]) < 173.189) {
_local8 = true;
_local4 = 0;
while (_local4 < game.table.walls[3].length) {
game.physics.checkLineCollide(_local2, game.table.walls[3][_local4]);
_local4++;
}
_local4 = 0;
while (_local4 < game.table.wallpoints[3].length) {
game.physics.checkCollide_125_05(_local2, game.table.wallpoints[3][_local4], _local2.movevec, _local2.movevecLen);
_local4++;
}
}
if (_local8) {
_local4 = game.table.holes.length - 1;
while (_local4 >= 0) {
if (game.physics.checkCollide_125_2(_local2, game.table.holes[_local4], _local2.movevec, _local2.movevecLen)) {
_local2.holeno = _local4;
}
_local4--;
}
}
_local13++;
}
var _local11 = game.physics.getCollisionData();
if (_local11) {
_local16 = true;
var _local3 = _local11.ball;
var _local6 = _local11.targetBall;
if (!_local6) {
game.physics.bounceLine();
var _local12 = Math.acos(_local3.vx / _local3.originalMovevecLen);
if (_local3.movevec[1] < 0) {
_local12 = -_local12;
}
_local3.anim_mc._rotation = _local12 * 57.3;
game.evaluateEvent({action:"hit wall"});
var _local17 = Math.min(100, _local3.originalMovevecLen * 4);
soundFx.play("wallhit1.wav", false, _local17);
} else if (_local6.type == "ball") {
game.physics.executeBounce();
var _local12 = Math.acos(_local3.vx / _local3.originalMovevecLen);
if (_local3.movevec[1] < 0) {
_local12 = -_local12;
}
_local3.anim_mc._rotation = _local12 * 57.3;
_local12 = Math.acos(_local6.vx / _local6.originalMovevecLen);
if (_local6.vy < 0) {
_local12 = -_local12;
}
_local6.anim_mc._rotation = _local12 * 57.3;
if (!this.firsthitdone) {
game.evaluateEvent({action:"hit first ball", value:_local6.no});
this.firsthitdone = true;
}
if (!_local19) {
var _local17 = Math.min(100, _local11.impactspeed * 3);
soundFx.play("ballhit0.wav", false, _local17);
_local19 = true;
}
} else if (_local6.type == "wallpoint") {
game.physics.executeBounce();
game.evaluateEvent({action:"hit wall"});
var _local12 = Math.acos(_local3.vx / _local3.originalMovevecLen);
if (_local3.movevec[1] < 0) {
_local12 = -_local12;
}
_local3.anim_mc._rotation = _local12 * 57.3;
var _local17 = Math.min(100, _local3.originalMovevecLen * 4);
soundFx.play("wallhit1.wav", false, _local17);
} else {
this.ballKillList.push(_local3);
}
if (_local6.radius < 1) {
_local6.vx = 0;
_local6.vy = 0;
}
var _local9 = game.physics.shortestHit;
var _local5;
_local13 = 0;
while (_local13 < this.ballsMovingCount) {
if ((_local3 != this.ballsMoving[_local13]) && (_local6 != this.ballsMoving[_local13])) {
_local5 = this.ballsMoving[_local13];
_local5.x = _local5.x + (_local5.movevec[0] * _local9);
_local5.y = _local5.y + (_local5.movevec[1] * _local9);
_local5.movevec[0] = _local5.movevec[0] * (1 - _local9);
_local5.movevec[1] = _local5.movevec[1] * (1 - _local9);
_local5.movevecLen = _local5.movevecLen * (1 - _local9);
}
_local13++;
}
}
_local13 = this.ballKillList.length - 1;
while (_local13 >= 0) {
this.removeBall(this.ballKillList[_local13]);
this.ballKillList.splice(_local13, 1);
_local13--;
}
_local22++;
} while (_local16);
_local13 = 0;
while (_local13 < this.ballsMovingCount) {
this.ballsMoving[_local13].x = this.ballsMoving[_local13].x + this.ballsMoving[_local13].movevec[0];
this.ballsMoving[_local13].y = this.ballsMoving[_local13].y + this.ballsMoving[_local13].movevec[1];
this.ballsMoving[_local13].frame = this.ballsMoving[_local13].frame + this.ballsMoving[_local13].movevecLen;
this.ballsMoving[_local13].anim_mc.gotoAndStop(Math.round((this.ballsMoving[_local13].frame / 1.23) & 31) + 1);
_local13++;
}
_local13 = 0;
while (_local13 < this.ballsMovingCount) {
var _local7 = this.ballsMoving[_local13];
if ((_local7.vx != 0) || (_local7.vy != 0)) {
var _local14 = Math.sqrt((_local7.vx * _local7.vx) + (_local7.vy * _local7.vy));
var _local18 = Math.max(0, (_local14 * damp) - damp2);
var _local15 = _local18 / _local14;
_local7.vx = _local7.vx * _local15;
_local7.vy = _local7.vy * _local15;
} else {
this.setBallStill(_local7);
}
_local7._x = _local7.x;
_local7._y = _local7.y;
_local13++;
}
if (this.ballsMovingCount == 0) {
if (game.netGame) {
wr("localShotDone");
var _local23 = 0;
if (game.player_local == game.player_current) {
game.player_current.timer.stopTimer();
_local23 = game.player_current.timer.getSecondsLeft();
}
game.player_current.absorb("GSD", _local23);
this.localShotDone = true;
if (this.opponentShotDone) {
this.shotDone();
} else {
game.gui.setInfo(game.gd.text.waiting_for_opponent);
}
} else {
this.shotDone();
}
}
};
this.shotDone = function () {
if (game.netGame) {
if ((!this.netRailDone) && (!game.table.cageOrRailActive())) {
this.localRailIsDone();
return(undefined);
}
if (!(this.netRailDone && (this.localRailDone))) {
return(undefined);
}
}
this.shotDoneExecuted = true;
game.evaluateEvent({action:"shot done"});
if (game.netGame && (game.getSwitchedPlayers())) {
game.switchPlayers();
}
var _local2 = false;
if (game.netGame) {
if (!this.restoreBallList) {
_local2 = game.updateHoleSelector();
}
game.player_current.timer.startTimer();
}
wr("shotDone()");
if (game.getGameFinsished()) {
game.evaluateEvent({action:"shot bonus"});
game.evaluateEvent({action:"time bonus", value:game.getSecondsLeft()});
game.setGameOver();
}
if (((!game.gameOver) && (!this.restoreBallList)) && (_local2 == false)) {
game.cue.setFocusBall();
} else if (this.restoreBallList.length > 0) {
if (!game.table.cageOrRailActive()) {
if (game.netGame) {
this.localRailIsDone();
} else {
this.railIsDone();
}
}
}
};
this.netShotDone = function (t) {
wr("netShotDone()");
if (game.netGame && (game.player_net == game.player_current)) {
game.player_current.timer.stopTimer();
game.player_current.timer.setSecondsLeft(t);
wr("got time left:", t);
}
this.opponentShotDone = true;
if (this.localShotDone) {
game.gui.setInfo("");
this.shotDone();
}
};
this.create8ballSprites = function () {
var _local3 = new Array(16);
var _local6 = [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15];
var _local12 = random.rangeFromSeed(0, 6);
var _local13 = random.rangeFromSeed(7, 13);
var _local11 = _local6[_local12];
var _local10 = _local6[_local13];
_local6.splice(_local13, 1);
_local6.splice(_local12, 1);
var _local9 = 0;
var _local8 = 0;
var _local5 = -1;
var _local4;
var _local2 = 0;
while (_local2 < _local3.length) {
if (_local2 == 0) {
_local3[_local2] = this.createBallSprite(0);
_local3[_local2].x = game.table.bounds[0] + (((game.table.bounds[2] - game.table.bounds[0]) * 6) / 8);
_local3[_local2].y = game.table.bounds[1] + ((game.table.bounds[3] - game.table.bounds[1]) / 2);
_local3[_local2].no = 0;
this.cueBall = _local3[_local2];
} else {
if (_local2 == 5) {
_local4 = 8;
} else if (_local2 == 11) {
_local4 = _local11;
} else if (_local2 == 14) {
_local4 = _local10;
} else {
var _local7 = random.rangeFromSeed(0, _local6.length - 1);
_local4 = _local6[_local7];
_local6.splice(_local7, 1);
}
_local3[_local2] = this.createBallSprite(_local4);
_local3[_local2].x = (game.table.bounds[0] + ((game.table.bounds[2] - game.table.bounds[0]) / 3)) - (22.52 * _local9);
_local3[_local2].y = (game.table.bounds[1] + ((game.table.bounds[3] - game.table.bounds[1]) / 2)) + (26.01 * (_local5 - (_local8 / 2)));
_local3[_local2].no = _local4;
}
_local5 = _local5 + 1;
if (_local5 > _local8) {
_local8 = _local8 + 1;
_local5 = 0;
_local9 = _local9 + 1;
}
_local3[_local2]._x = _local3[_local2].x;
_local3[_local2]._y = _local3[_local2].y;
_local3[_local2].x = _local3[_local2].x + ((random.floatFromSeed() / 2) - 0.5);
_local3[_local2].y = _local3[_local2].y + ((random.floatFromSeed() / 2) - 0.5);
_local2++;
}
return(_local3);
};
this.create9ballSprites = function () {
var _local3 = new Array(10);
var _local9 = [2, 3, 4, 5, 6, 7, 8];
var _local7;
var _local5 = 0;
var _local6 = 0;
var _local4 = -1;
var _local2 = 0;
while (_local2 < _local3.length) {
if (_local2 == 0) {
_local3[_local2] = this.createBallSprite(0);
_local3[_local2].x = game.table.bounds[0] + (((game.table.bounds[2] - game.table.bounds[0]) * 6) / 8);
_local3[_local2].y = game.table.bounds[1] + ((game.table.bounds[3] - game.table.bounds[1]) / 2);
_local3[_local2].no = 0;
this.cueBall = _local3[_local2];
} else {
if (_local2 == 1) {
_local7 = _local2;
} else if (_local2 == 5) {
_local7 = 9;
} else {
var _local8 = random.rangeFromSeed(0, _local9.length - 1);
_local7 = _local9[_local8];
_local9.splice(_local8, 1);
}
_local3[_local2] = this.createBallSprite(_local7);
_local3[_local2].x = (game.table.bounds[0] + ((game.table.bounds[2] - game.table.bounds[0]) / 3)) - (22.52 * _local5);
_local3[_local2].y = (game.table.bounds[1] + ((game.table.bounds[3] - game.table.bounds[1]) / 2)) + (26.01 * (_local4 - (_local6 / 2)));
_local3[_local2].no = _local7;
}
_local4 = _local4 + 1;
if (_local5 > 1) {
if (_local4 > _local6) {
_local4 = 0;
_local6 = 3 - _local5;
_local5 = _local5 + 1;
}
} else if (_local4 > _local6) {
_local6 = _local6 + 1;
_local4 = 0;
_local5 = _local5 + 1;
}
_local3[_local2]._x = _local3[_local2].x;
_local3[_local2]._y = _local3[_local2].y;
_local3[_local2].x = _local3[_local2].x + ((random.floatFromSeed() / 2) - 0.5);
_local3[_local2].y = _local3[_local2].y + ((random.floatFromSeed() / 2) - 0.5);
_local2++;
}
return(_local3);
};
this.createXballSprites = function () {
var _local3 = new Array(10);
var _local4 = [[87.813, 109.624], [535.482, 286.173], [491.518, 94.362], [510.698, 75.181], [529.879, 56], [316.407, 65.373], [296.689, 45.655], [54.448, 286.604], [58.095, 59.906], [158.095, 159.906]];
var _local5;
var _local2 = 0;
while (_local2 < _local3.length) {
if (_local2 == 0) {
_local3[_local2] = this.createBallSprite(0);
_local3[_local2].x = game.table.bounds[0] + (((game.table.bounds[2] - game.table.bounds[0]) * 6) / 8);
_local3[_local2].y = game.table.bounds[1] + ((game.table.bounds[3] - game.table.bounds[1]) / 2);
_local3[_local2].no = 0;
this.cueBall = _local3[_local2];
} else {
_local3[_local2] = this.createBallSprite(_local2);
_local3[_local2].x = game.table.offset_x + _local4[_local2 - 1][0];
_local3[_local2].y = game.table.offset_y + _local4[_local2 - 1][1];
_local3[_local2].no = _local2;
}
currentRowLength = currentRowLength + 1;
if (currentRow > 1) {
if (currentRowLength > lastRowLength) {
currentRowLength = 0;
lastRowLength = 3 - currentRow;
currentRow = currentRow + 1;
}
} else if (currentRowLength > lastRowLength) {
lastRowLength = lastRowLength + 1;
currentRowLength = 0;
currentRow = currentRow + 1;
}
_local3[_local2]._x = _local3[_local2].x;
_local3[_local2]._y = _local3[_local2].y;
_local3[_local2].x = _local3[_local2].x + ((random.floatFromSeed() / 2) - 0.25);
_local3[_local2].y = _local3[_local2].y + ((random.floatFromSeed() / 2) - 0.25);
_local2++;
}
return(_local3);
};
this.destroyBallSprites = function () {
var _local1 = 0;
while (_local1 < 10) {
sprites.removeGroup("gb_" + _local1);
_local1++;
}
};
this.createBallSprite = function (no) {
var _local1 = "gb_" + no;
var _local2 = sprites.createGroup({x:0, y:0, group:_local1});
var _local3 = sprites.create({x:0, y:0, member:"ball_" + no, group:_local1});
var _local7 = sprites.create({x:0, y:0, member:"BallShade", group:_local1});
_local2.anim_mc = _local3.member_mc;
return(_local2);
};
this.kill = function () {
events.stopIt(this);
};
}
function Cue() {
this.maxPower = 70;
this.maxSpace = 40;
this.ballSize = 25;
this.active = false;
this.m_down = false;
this.spin = new Spin({parent:this});
this.initialize = function (ball, refObj) {
this.ballObjRef = refObj;
this.active = false;
this.m_down = false;
this.aim_vect = [0, 0];
this.aim_vect_len = 0;
this.hilitenext = sprites.create({member:"ball_white_hilite", x:0, y:0, alpha:0});
this.hilitenext.toFront();
this.hilitenext.fader = new Pulsate({sprite:this.hilitenext});
this.cueSprite = sprites.create({member:"cue_gfx", x:0, y:0, alpha:0});
this.cueSprite.toFront();
this.cueSprite.member_mc.gotoAndStop(1);
this.helpBall = sprites.create({member:"helpball", x:0, y:0, visible:false, alpha:40});
this.helpLine1 = sprites.create({member:"helpline", x:0, y:0, visible:false, alpha:40});
this.helpLine2 = sprites.create({member:"helpline", x:0, y:0, visible:false, alpha:40});
this.helpLine3 = sprites.create({member:"helpline", x:0, y:0, visible:false, alpha:40});
this.helpBall.toFront();
this.helpLine1.toFront();
this.helpLine2.toFront();
this.helpLine3.toFront();
this.helpLine1.member_mc._x = (this.ballSize / 2) + 4;
this.helpLine2.member_mc._x = this.ballSize / 2;
this.pm = new PowerMeter();
this.pm.initialize(this.maxPower);
this.cueBall = ball;
events.runIt(this);
this.spinx = 0;
this.spiny = 0;
};
this.setupNewLevel = function (pos) {
this.setFocusBall();
};
this.setFocusBall = function () {
this.cueSprite.member_mc._x = (this.ballSize / 2) + 4;
this.cueSprite._x = this.cueBall._x;
this.cueSprite._y = this.cueBall._y;
this.cueSprite._alpha = 100;
this.cueSprite.alphaval = 100;
this.helpLine1._x = this.cueBall._x;
this.helpLine1._y = this.cueBall._y;
if (game.player_current.playerType == "local") {
this.run = this.aim;
}
if (game.netGame) {
if (game.player_current.playerType == "local") {
this.setNormal();
this.enable();
this.spin.enable();
} else {
this.setGhost();
this.disable();
this.spin.disable();
}
} else {
this.enable();
this.spin.enable();
}
this.active = true;
this.pm.update(-1);
this.spin.spinReset();
this.fixFocusBall();
};
this.fixFocusBall = function () {
var _local3 = game.findNextLegalBall();
var _local2 = 0;
while (_local2 < game.ballz.balls.length) {
if (game.ballz.balls[_local2].no == _local3) {
this.hilitenext._x = game.ballz.balls[_local2]._x;
this.hilitenext._y = game.ballz.balls[_local2]._y;
this.hilitenext.fader.start();
break;
}
_local2++;
}
};
this.run = function () {
};
this.aim = function () {
var _local4 = _root._xmouse - this.cueSprite._x;
var _local3 = _root._ymouse - this.cueSprite._y;
var _local5 = Math.sqrt((_local4 * _local4) + (_local3 * _local3));
if (_local5 != 0) {
_local4 = _local4 / _local5;
_local3 = _local3 / _local5;
this.v = Math.acos(_local4);
if (_local3 < 0) {
this.v = -this.v;
}
var _local6 = (this.v * 360) / (Math.PI*2);
this.updateLines(_local6);
if (game.netGame && (!this.spin.active)) {
game.player_local.absorb("GCP", this.v);
}
}
if (game.keys.isHit("space")) {
this.run = this.aim_fine;
}
};
this.draw_aim = function (x, y) {
var _local2 = Math.sqrt((x * x) + (y * y));
if (_local2 != 0) {
x = x / _local2;
y = y / _local2;
this.v = Math.acos(x);
if (y < 0) {
this.v = -this.v;
}
var _local3 = (this.v * 360) / (Math.PI*2);
this.updateLines(_local3);
}
};
this.aim_fine = function () {
if (game.keys.isDown("left")) {
this.v = this.v - 0.0025;
var _local2 = (this.v * 360) / (Math.PI*2);
this.updateLines(_local2);
if (game.netGame) {
game.player_local.absorb("GCP", this.v);
}
} else if (game.keys.isDown("right")) {
this.v = this.v + 0.0025;
var _local2 = (this.v * 360) / (Math.PI*2);
this.updateLines(_local2);
if (game.netGame) {
game.player_local.absorb("GCP", this.v);
}
} else if (game.keys.isDown("down")) {
this.v = this.v - 0.01;
var _local2 = (this.v * 360) / (Math.PI*2);
this.updateLines(_local2);
if (game.netGame) {
game.player_local.absorb("GCP", this.v);
}
} else if (game.keys.isDown("up")) {
this.v = this.v + 0.01;
var _local2 = (this.v * 360) / (Math.PI*2);
this.updateLines(_local2);
if (game.netGame) {
game.player_local.absorb("GCP", this.v);
}
}
if (game.keys.isHit("space")) {
this.run = this.aim;
}
};
this.netAim = function (v) {
if (this.active) {
this.v = v;
var _local2 = (this.v * 360) / (Math.PI*2);
this.updateLines(_local2);
}
};
this.updateLines = function (rot) {
if (this.lastRot == rot) {
return(undefined);
}
this.lastRot = rot;
this.cueSprite._rotation = rot;
this.cueBall.vx = (-Math.cos(this.v)) * this.maxPower;
this.cueBall.vy = (-Math.sin(this.v)) * this.maxPower;
game.physics.resetCollisionData();
this.aim_vect[0] = (-Math.cos(this.v)) * game.table.diagonal;
this.aim_vect[1] = (-Math.sin(this.v)) * game.table.diagonal;
this.aim_vect_len = Math.sqrt((this.aim_vect[0] * this.aim_vect[0]) + (this.aim_vect[1] * this.aim_vect[1]));
var _local2 = 0;
while (_local2 < game.ballz.ballCount) {
if (game.ballz.balls[_local2].no != 0) {
game.physics.checkCollide_25(this.cueBall, game.ballz.balls[_local2], this.aim_vect, this.aim_vect_len);
}
_local2++;
}
var _local6 = false;
this.cueBall.movevec[0] = this.aim_vect[0];
this.cueBall.movevec[1] = this.aim_vect[1];
this.cueBall.movevecLen = this.aim_vect_len;
if ((this.cueBall.y + this.cueBall.movevec[1]) < game.table.boundsMinusRadius[1]) {
_local6 = true;
var _local3 = 0;
while (_local3 < game.table.walls[0].length) {
game.physics.checkLineCollide(this.cueBall, game.table.walls[0][_local3]);
_local3++;
}
_local3 = 0;
while (_local3 < game.table.wallpoints[0].length) {
game.physics.checkCollide_125_05(this.cueBall, game.table.wallpoints[0][_local3], this.aim_vect, this.aim_vect_len);
_local3++;
}
}
if ((this.cueBall.x + this.cueBall.movevec[0]) > game.table.boundsMinusRadius[2]) {
_local6 = true;
var _local3 = 0;
while (_local3 < game.table.walls[1].length) {
game.physics.checkLineCollide(this.cueBall, game.table.walls[1][_local3]);
_local3++;
}
_local3 = 0;
while (_local3 < game.table.wallpoints[1].length) {
game.physics.checkCollide_125_05(this.cueBall, game.table.wallpoints[1][_local3], this.aim_vect, this.aim_vect_len);
_local3++;
}
}
if ((this.cueBall.y + this.cueBall.movevec[1]) > game.table.boundsMinusRadius[3]) {
_local6 = true;
var _local3 = 0;
while (_local3 < game.table.walls[2].length) {
game.physics.checkLineCollide(this.cueBall, game.table.walls[2][_local3]);
_local3++;
}
_local3 = 0;
while (_local3 < game.table.wallpoints[2].length) {
game.physics.checkCollide_125_05(this.cueBall, game.table.wallpoints[2][_local3], this.aim_vect, this.aim_vect_len);
_local3++;
}
}
if ((this.cueBall.x + this.cueBall.movevec[0]) < game.table.boundsMinusRadius[0]) {
_local6 = true;
var _local3 = 0;
while (_local3 < game.table.walls[3].length) {
game.physics.checkLineCollide(this.cueBall, game.table.walls[3][_local3]);
_local3++;
}
_local3 = 0;
while (_local3 < game.table.wallpoints[3].length) {
game.physics.checkCollide_125_05(this.cueBall, game.table.wallpoints[3][_local3], this.aim_vect, this.aim_vect_len);
_local3++;
}
}
if (_local6) {
var _local3 = game.table.holes.length - 1;
while (_local3 >= 0) {
game.physics.checkCollide_125_2(this.cueBall, game.table.holes[_local3], this.aim_vect, this.aim_vect_len);
_local3--;
}
}
var _local4 = game.physics.getCollisionData();
if (!_local4) {
this.helpBall._visible = false;
this.helpLine1._visible = false;
this.helpLine2._visible = false;
this.helpLine3._visible = false;
return(undefined);
}
var _local13 = _local4.distance;
if (_local13 <= (this.ballSize + 4)) {
this.helpLine1._visible = false;
} else {
this.helpLine1.member_mc._width = (_local13 - this.ballSize) - 4;
this.helpLine1._rotation = rot - 180;
this.helpLine1._visible = true;
}
this.helpBall._x = this.cueBall.x + _local4.mvx;
this.helpBall._y = this.cueBall.y + _local4.mvy;
this.helpBall._visible = true;
if (_local4.targetBall.radius > 5) {
var _local15 = this.cueBall.x;
var _local14 = this.cueBall.y;
this.cueBall.x = this.cueBall.x + _local4.mvx;
this.cueBall.y = this.cueBall.y + _local4.mvy;
var _local5 = _local4.targetBall;
game.physics.bounce(this.cueBall, _local5);
var _local10 = this.cueBall.vx;
var _local8 = this.cueBall.vy;
var _local9 = _local5.vx;
var _local7 = _local5.vy;
this.cueBall.x = _local15;
this.cueBall.y = _local14;
_local5.vx = 0;
_local5.vy = 0;
this.helpLine2._x = this.cueBall.x + _local4.mvx;
this.helpLine2._y = this.cueBall.y + _local4.mvy;
this.helpLine3._x = _local5.x;
this.helpLine3._y = _local5.y;
var _local11 = Math.sqrt((_local10 * _local10) + (_local8 * _local8));
var v = Math.acos(_local10 / _local11);
if ((_local8 / _local11) < 0) {
v = -v;
}
this.helpLine2._rotation = (v * 360) / (Math.PI*2);
this.helpLine2.member_mc._width = _local11 / 2;
_local11 = Math.sqrt((_local9 * _local9) + (_local7 * _local7));
var v = Math.acos(_local9 / _local11);
if ((_local7 / _local11) < 0) {
v = -v;
}
this.helpLine3._rotation = (v * 360) / (Math.PI*2);
this.helpLine3.member_mc._width = _local11 / 2;
this.helpLine2._visible = true;
this.helpLine3._visible = true;
} else {
this.helpLine2._visible = false;
this.helpLine3._visible = false;
}
};
this.set_power = function () {
var _local4 = "" + (_root._xmouse - this.mouse_x);
var _local3 = "" + (_root._ymouse - this.mouse_y);
if (game.netGame) {
game.player_local.absorb("GPS", (_local4 + ",") + _local3);
}
this.draw_power(parseFloat(_local4), parseFloat(_local3));
};
this.draw_power = function (dx, dy) {
dx = dx * Math.cos(this.v);
dy = dy * Math.sin(this.v);
this.power = Math.max(0, dx + dy);
this.power = Math.min(this.maxPower, this.power);
this.cueSprite._x = this.cueBall._x + (Math.min(this.maxSpace, this.power) * Math.cos(this.v));
this.cueSprite._y = this.cueBall._y + (Math.min(this.maxSpace, this.power) * Math.sin(this.v));
this.pm.update(this.power);
};
this.mousedPressed = function () {
if (this.spin.active) {
return(undefined);
}
if (this.active && (game.player_current.playerType == "local")) {
this.m_down = true;
this.mouse_x = _root._xmouse;
this.mouse_y = _root._ymouse;
this.run = this.set_power;
game.player_local.absorb("GPI", 0);
this.helpBall._visible = false;
this.helpLine1._visible = false;
this.helpLine2._visible = false;
this.helpLine3._visible = false;
}
};
this.netMousePressed = function () {
this.m_down = true;
this.helpBall._visible = false;
this.helpLine1._visible = false;
this.helpLine2._visible = false;
this.helpLine3._visible = false;
};
this.mousedReleased = function () {
if (this.spin.active) {
return(undefined);
}
if (this.active && (this.m_down)) {
if (this.power == 0) {
if (game.player_current.playerType == "local") {
this.run = this.aim;
} else {
this.draw_power(0, 0);
}
} else {
this.active = false;
this.cueSpeed = 1;
this.animPower = Math.min(this.maxSpace, this.power);
this.run = this.animateShot;
this.disable();
this.spin.disable();
}
this.m_down = false;
this.sendShoot();
var _local2 = "" + this.v;
var _local4 = "" + this.spinx;
var _local3 = "" + this.spiny;
var power = ("" + this.power);
this.v = parseFloat(_local2);
this.spinx = parseFloat(_local4);
this.spiny = parseFloat(_local3);
this.power = parseFloat(power);
game.ballz.prepareShoot();
}
};
this.animateShot = function () {
this.cueSpeed = this.cueSpeed * 1.3;
this.animPower = this.animPower - this.cueSpeed;
this.animPower = Math.max(-5, this.animPower);
this.cueSprite._x = this.cueBall._x + (this.animPower * Math.cos(this.v));
this.cueSprite._y = this.cueBall._y + (this.animPower * Math.sin(this.v));
if (this.animPower <= -5) {
this.shoot();
this.animPower = this.animPower / 2;
this.cueSpeed = this.cueSpeed / 4;
this.run = this.fadeOutCue;
}
};
this.sendShoot = function () {
if (game.player_current.playerType == "local") {
var _local2 = (((((("" + this.v) + ",") + this.spinx) + ",") + this.spiny) + ",") + this.power;
game.player_local.absorb("GCS", _local2);
game.player_current.timer.stopRoundSec();
}
};
this.netShoot = function (_data) {
var _local2 = _data.split(",");
wr("netShoot()", _local2[0], _local2[3], _local2[1], _local2[2]);
this.v = _local2[0];
this.spinx = _local2[1];
this.spiny = _local2[2];
this.power = _local2[3];
this.netAim(this.v);
this.pm.update(this.power);
this.spin.setSpinDot(this.spinx, this.spiny);
this.helpBall._visible = false;
this.helpLine1._visible = false;
this.helpLine2._visible = false;
this.helpLine3._visible = false;
this.mousedReleased();
};
this.shoot = function () {
wr("localShoot()", this.v, this.power, this.spinx, this.spiny);
wr("this.power:", typeof(this.power), "this.v", typeof(this.v));
var _local2 = (((((((("" + game.getFrameNo()) + ",") + this.v) + ",") + this.spinx) + ",") + this.spiny) + ",") + this.power;
game.evaluateEvent({action:"shoot", value:_local2});
this.animPower = this.animPower - 1;
var _local3 = (this.power * 100) / this.maxPower;
this.power = this.power / 2;
this.cueBall.vx = (-Math.cos(this.v)) * this.power;
this.cueBall.vy = (-Math.sin(this.v)) * this.power;
this.cueBall.spinx = (this.spinx * this.power) / 2;
this.cueBall.spiny = (this.spiny * this.power) / 2;
this.ballObjRef.shoot(this.cueBall);
this.hilitenext.fader.stop();
soundFx.play("cuehit0.wav", false, _local3);
};
this.fadeOutCue = function () {
if (this.cueSprite.alphaval <= 0) {
this.run = function () {
};
} else {
this.cueSprite.alphaval = this.cueSprite.alphaval - 14;
this.cueSprite.alphaval = Math.max(0, this.cueSprite.alphaval);
this.cueSprite._alpha = this.cueSprite.alphaval;
}
this.cueSpeed = this.cueSpeed * 0.5;
this.animPower = this.animPower - this.cueSpeed;
this.cueSprite._x = this.cueSprite._x - (this.animPower * Math.cos(this.v));
this.cueSprite._y = this.cueSprite._y - (this.animPower * Math.sin(this.v));
};
this.setSpinValue = function (x, y) {
this.spinx = x;
this.spiny = y;
};
this.setGhost = function () {
this.cueSprite.member_mc.gotoAndStop(2);
};
this.setNormal = function () {
this.cueSprite.member_mc.gotoAndStop(1);
};
this.enable = function () {
_root.main_bg_placeholder.onPress = function () {
game.cue.mousedPressed();
};
_root.main_bg_placeholder.onRelease = function () {
game.cue.mousedReleased();
};
_root.main_bg_placeholder.onReleaseOutside = function () {
game.cue.mousedReleased();
};
_root.main_bg_placeholder.useHandCursor = false;
};
this.disable = function () {
delete _root.main_bg_placeholder.onPress;
delete _root.main_bg_placeholder.onRelease;
delete _root.main_bg_placeholder.onReleaseOutside;
};
this.halt = function () {
this.active = false;
events.stopIt(this);
this.disable();
this.spin.disable();
};
this.kill = function () {
events.stopIt(this);
this.pm.kill();
sprites.remove(this.hilitenext);
sprites.remove(this.cueSprite);
sprites.remove(this.helpBall);
sprites.remove(this.helpLine1);
sprites.remove(this.helpLine2);
sprites.remove(this.helpLine3);
};
}
function Spin(props) {
this.active = false;
if (game.netGame) {
this.origx = 158;
this.origy = 420;
} else {
this.origx = 58;
this.origy = 375;
}
this.radius = 27;
this.hitspot = sprites.create({member:"aim_ball", x:this.origx, y:this.origy});
this.hitspot.toLevel(5);
this.hitspot.parent = this;
this.hitspot._alpha = 0;
this.spindot = sprites.create({member:"spin_dot", x:this.origx, y:this.origy});
this.spindot.toLevel(5);
this.parent = props.parent;
this.dragUpdate = function (x, y) {
var _local3 = x - this.origx;
var _local4 = y - this.origy;
if (_local3 == 0) {
_local3 = 1E-7;
}
var _local10 = Math.sqrt((_local3 * _local3) + (_local4 * _local4));
if (_local10 > this.radius) {
var _local7 = Math.abs(_local4 / _local3);
var _local9 = Math.sqrt((this.radius * this.radius) / (1 + (_local7 * _local7)));
var _local8 = _local7 * _local9;
if (_local3 < 0) {
_local9 = -_local9;
}
if (_local4 < 0) {
_local8 = -_local8;
}
_local9 = _local9 + this.origx;
_local8 = _local8 + this.origy;
} else {
var _local9 = _root._xmouse;
var _local8 = _root._ymouse;
}
this.spindot._x = _local9;
this.spindot._y = _local8;
var _local6 = (_local9 - this.origx) / this.radius;
var _local5 = (_local8 - this.origy) / this.radius;
_local6 = parseFloat("" + _local6);
_local5 = parseFloat("" + _local5);
if (game.netGame) {
game.player_local.absorb("GSP", (("" + _local6) + ",") + _local5);
}
this.parent.setSpinValue(_local6, _local5);
};
this.setSpinDot = function (x, y) {
this.spindot._x = (x * this.radius) + this.origx;
this.spindot._y = (y * this.radius) + this.origy;
};
this.spinReset = function () {
this.spindot._x = this.origx;
this.spindot._y = this.origy;
this.parent.setSpinValue(0, 0);
};
this.run = function () {
this.dragUpdate(_root._xmouse, _root._ymouse);
};
this.enable = function () {
this.hitspot.onRollOver = function () {
this.parent.active = true;
};
this.hitspot.onRollOut = function () {
this.parent.active = false;
};
this.hitspot.onPress = function () {
events.runIt(this.parent);
this.parent.dragUpdate(_root._xmouse, _root._ymouse);
};
this.hitspot.onRelease = function () {
events.stopIt(this.parent);
if (game.netGame) {
game.player_local.absorbSend();
}
};
this.hitspot.onReleaseOutside = function () {
events.stopIt(this.parent);
if (game.netGame) {
game.player_local.absorbSend();
}
this.parent.active = false;
};
};
this.disable = function () {
events.stopIt(this);
this.active = false;
delete this.hitspot.onRollOver;
delete this.hitspot.onRollOut;
delete this.hitspot.onPress;
delete this.hitspot.onRelease;
delete this.hitspot.onReleaseOutside;
};
}
function Hand() {
this.active = false;
this.mysprite = sprites.create({member:"handwithglove", visible:false});
this.mysprite.toLevel(5);
this.mysprite.member_mc.gotoAndStop(1);
this.mysprite.useHandCursor = false;
this.mysprite.parent = this;
this.min_x = 0;
this.padding = 0;
this.stringpos_x = "0";
this.stringpos_y = "0";
this.collision = false;
this.crossActive = false;
this.initialize = function (ball) {
this.grabBall(ball, ball._x);
};
this.grabBall = function (ball, min_x) {
if (this.active) {
return(undefined);
}
var _local4 = game.findNextLegalBall();
var _local3 = 0;
while (_local3 < game.ballz.balls.length) {
if (game.ballz.balls[_local3].no == _local4) {
game.cue.hilitenext._x = game.ballz.balls[_local3]._x;
game.cue.hilitenext._y = game.ballz.balls[_local3]._y;
game.cue.hilitenext.fader.start();
break;
}
_local3++;
}
this.ballref = ball;
this.padding = this.ballref.radius + 7;
if (typeof(min_x) != "number") {
this.min_x = game.table.bounds[0] + this.padding;
} else {
this.min_x = min_x;
}
var _local6 = _root._xmouse;
var _local5 = _root._ymouse;
if (game.netGame) {
this.sendMove(_local6, _local5);
}
this.moveUpdate();
this.mysprite._visible = true;
this.mysprite._alpha = 60;
this.active = true;
if (game.player_current.playerType == "local") {
Mouse.hide();
this.onMouseDown = function () {
};
this.onMouseMove = function () {
};
this.onMouseUp = function () {
this.placeBall();
};
events.runIt(this);
Mouse.addListener(this);
}
};
this.run = function () {
var _local4 = _root._xmouse;
var _local3 = _root._ymouse;
if (game.netGame) {
this.sendMove(_local4, _local3);
}
this.moveUpdate(_local4, _local3);
};
this.sendMove = function (px, py) {
game.player_current.absorb("GHP", (("" + px) + ",") + py);
};
this.moveUpdate = function (px, py) {
var _local7 = false;
if (px < this.min_x) {
px = this.min_x;
_local7 = true;
} else if (px > (game.table.bounds[2] - this.padding)) {
px = game.table.bounds[2] - this.padding;
_local7 = true;
}
if (py < (game.table.bounds[1] + this.padding)) {
py = game.table.bounds[1] + this.padding;
_local7 = true;
} else if (py > (game.table.bounds[3] - this.padding)) {
py = game.table.bounds[3] - this.padding;
_local7 = true;
}
var _local4;
var _local3;
this.collision = false;
var _local2 = 0;
while (_local2 < game.ballz.ballCount) {
if (game.ballz.balls[_local2].no != 0) {
_local4 = game.ballz.balls[_local2].x - px;
_local3 = game.ballz.balls[_local2].y - py;
if (((_local4 * _local4) + (_local3 * _local3)) < 676) {
this.collision = true;
break;
}
}
_local2++;
}
if (this.collision) {
this.showCross();
} else {
this.hideCross();
}
this.convertAndSetPositions(px, py);
if (game.player_current.playerType == "local") {
if (_local7) {
Mouse.show();
} else {
Mouse.hide();
}
}
};
this.convertAndSetPositions = function (px, py) {
this.stringpos_x = "" + px;
this.stringpos_y = "" + py;
px = parseFloat(this.stringpos_x);
py = parseFloat(this.stringpos_y);
this.mysprite._x = px;
this.mysprite._y = py;
this.ballref._x = px;
this.ballref._y = py;
this.ballref.x = px;
this.ballref.y = py;
};
this.netPlace = function (_data) {
var _local2 = _data.split(",");
this.convertAndSetPositions(_local2[0], _local2[1]);
this.hideCross();
this.collision = false;
this.placeBall();
};
this.placeBall = function () {
if (!this.active) {
return(undefined);
}
if (this.collision) {
return(undefined);
}
var _local2 = false;
this.mysprite._visible = false;
this.active = false;
if (game.netGame && (game.player_current.playerType == "local")) {
game.player_current.absorb("GHS", (this.stringpos_x + ",") + this.stringpos_y);
game.gui.setInfo("");
_local2 = game.updateHoleSelector();
}
wr("place ball()", this.ballref.x, this.ballref.y);
game.evaluateEvent({action:"place ball", value:(("" + this.stringpos_x) + ",") + this.stringpos_y});
events.stopIt(this);
Mouse.removeListener(this);
Mouse.show();
if ((!game.netGame) || (_local2 == false)) {
game.cue.setFocusBall();
}
};
this.showCross = function () {
if (this.crossActive) {
return(undefined);
}
this.crossActive = true;
this.mysprite.member_mc.gotoAndStop(2);
this.ballref._visible = false;
};
this.hideCross = function () {
if (!this.crossActive) {
return(undefined);
}
this.crossActive = false;
this.mysprite.member_mc.gotoAndStop(1);
this.ballref._visible = true;
};
this.kill = function () {
events.stopIt(this);
Mouse.removeListener(this);
sprites.remove(this.mysprite);
};
}
function PowerMeter() {
this.spritelist = [];
this.pmballs = 21;
this.posx = 266;
this.posy = 30;
this.spacing = 15;
this.maxpower = 0;
this.lastval = 0;
var nballs;
this.initialize = function (_maxpower) {
this.maxpower = _maxpower;
var _local2 = 0;
while (_local2 < this.pmballs) {
this.spritelist.push(sprites.create({member:"power_dot", x:this.posx + (this.spacing * _local2), y:this.posy, visible:false}));
_local2++;
}
};
this.update = function (_val) {
if (this.lastval == _val) {
return(undefined);
}
this.lastval = _val;
if (_val <= 0) {
nballs = 0;
} else {
nballs = Math.round(((_val / this.maxpower) * this.pmballs) + 0.5);
}
var _local2 = 0;
while (_local2 < this.pmballs) {
this.spritelist[_local2]._visible = _local2 < nballs;
_local2++;
}
};
this.kill = function () {
var _local2 = 0;
while (_local2 < this.pmballs) {
sprites.remove(this.spritelist[_local2]);
_local2++;
}
this.pmballs = null;
};
}
function Pulsate(props) {
this.running = false;
this.sinv = [1, 2, 4, 7, 10, 14, 18, 22, 28, 33, 39, 44, 50, 56, 62, 67, 73, 78, 82, 87, 90, 94, 96, 98, 99, 100, 100, 99, 98, 96, 93, 90, 86, 82, 77, 72, 66, 61, 55, 49, 43, 37, 32, 27, 22, 17, 13, 9, 6, 4, 2, 0];
this.sinlen = this.sinv.length;
this.sinpos = 0;
this.mysprite = props.sprite;
this.start = function () {
if (this.running) {
return(undefined);
}
this.running = true;
this.sinpos = 0;
events.runIt(this);
};
this.stop = function () {
if (!this.running) {
return(undefined);
}
this.running = false;
this.mysprite._alpha = 0;
events.stopIt(this);
};
this.run = function () {
this.mysprite._alpha = this.sinv[this.sinpos++];
if (this.sinpos == this.sinlen) {
this.sinpos = 0;
}
};
}
function SlideInOut(props) {
this.mysprite = props.sprite;
this.orig_x = this.mysprite._x;
this.orig_y = this.mysprite._y;
this.curr_x = this.orig_x;
this.curr_y = this.orig_y;
this.target_x = ((typeof(props.x) == "number") ? (props.x) : (this.curr_x));
this.target_y = ((typeof(props.y) == "number") ? (props.y) : (this.curr_y));
this.callback = props.callback;
this.done = false;
this.running = false;
this.nFrames = props.nFrames || 10;
this.wait = props.wait || 0;
this.run = function () {
this.runner();
};
this.setRunner = function () {
if (this.delay > 0) {
this.runner = this.doDelay;
} else if (this.mode == "in") {
this.runner = this.slideIn;
} else {
this.runner = this.slideOut;
}
};
this.doDelay = function () {
if (this.delay <= 0) {
this.setRunner();
}
this.delay--;
};
this.slideIn = function () {
if (this.done) {
this.stop();
return(undefined);
}
this.v = Math.min(this.v + (Math.PI / (this.nFrames * 2)), (Math.PI/2));
if (this.move_x) {
this.curr_x = this.orig_x + (Math.sin(this.v) * (this.target_x - this.orig_x));
this.mysprite._x = this.curr_x;
}
if (this.move_y) {
this.curr_y = this.orig_y + (Math.sin(this.v) * (this.target_y - this.orig_y));
this.mysprite._y = this.curr_y;
}
if (this.v >= (Math.PI/2)) {
this.done = true;
}
};
this.slideOut = function () {
if (this.done) {
this.stop();
return(undefined);
}
this.v = Math.min(this.v + (Math.PI / (this.nFrames * 2)), (Math.PI/2));
var _local2 = Math.sin(this.v + 4.71238898038469) + 1;
_local2 = _local2 * _local2;
if (this.move_x) {
this.curr_x = this.target_x + (_local2 * (this.orig_x - this.target_x));
this.mysprite._x = this.curr_x;
}
if (this.move_y) {
this.curr_y = this.target_y + (_local2 * (this.orig_y - this.target_y));
this.mysprite._y = this.curr_y;
}
if (this.v >= (Math.PI/2)) {
this.done = true;
}
};
this.reset = function () {
this.move_x = this.orig_x != this.target_x;
this.move_y = this.orig_y != this.target_y;
this.v = 0;
};
this.start = function (mode, delay) {
this.mode = mode;
this.delay = (delay ? (delay) : 0);
this.done = false;
this.reset();
this.setRunner();
if (!this.running) {
events.runIt(this);
this.running = true;
}
};
this.stop = function () {
if (!this.running) {
return(undefined);
}
events.stopIt(this);
this.running = false;
if (this.callback) {
this.callback();
this.callback = null;
}
};
this.reset();
}
function Logger() {
var theLog = new Array();
this.logEvent = function (data) {
theLog.push(data);
};
this.getLog = function () {
return(theLog);
};
}
function Game() {
function prepareStart() {
self.gameOver = false;
self.gd = prepare_gamedata(gameData);
_root.mc_intro.onRelease = undefined;
if (game.gd.relaxMode == "true") {
var _local2 = _root.main_bg_placeholder;
_local2.text_2._visible = false;
_local2.text_tag_2._visible = false;
}
random.setSeed(self.gd.randomseed);
if (game.gd.relaxMode == "true") {
if (game.roundNo == 0) {
scoreObj = new Score();
log = new Logger();
}
} else {
scoreObj = new Score();
log = new Logger();
}
self.physics = new Physics();
self.table = new Table();
self.table.init();
self.cue = new Cue();
if (game.gd.relaxMode == "true") {
if (game.roundNo == 0) {
self.gui = new Gui();
self.gui.init(self.gd);
} else {
self.callStart();
}
} else {
self.gui = new Gui();
self.gui.init(self.gd);
}
}
function start() {
fscommand ("gameStart");
self.evaluateEvent({action:"version", value:game_version});
self.ballz = new Ballz();
self.ballz.init("9ball");
self.cue.initialize(self.ballz.cueBall, self.ballz);
if (game.roundNo == 0) {
self.gui.addBonus(2000);
}
scoreObj.roundReset();
self.gui.swapNextBall(1);
self.hand = new Hand();
self.hand.initialize(self.ballz.cueBall);
self.keys = new Keys();
self.keys.init();
timeLeft = new String();
timeLeft.startTime = getTimer();
timeLeft.secondsLeft = 0;
timeLeft.frameNo = 0;
events.runIt(self);
game.roundNo++;
}
var self = this;
var scoreObj;
var log;
var timeLeft;
var fps_status;
this.bounds = [0, 0, Stage.width, Stage.height];
this.player_current = {playerType:"local"};
this.roundNo = 0;
this.netGame = false;
this.initialize = function () {
var _local2 = new Object();
_local2.run = function () {
if (gameData != undefined) {
events.stopIt(this);
game.callDelayedPrepare();
}
};
events.runIt(_local2);
};
this.callPrepare = function () {
prepareStart();
};
this.callStart = function () {
start();
};
this.callDelayedPrepare = function () {
_root.mc_outro.gotoAndStop(2);
_root.mc_outro._visible = false;
_root.mc_intro.gotoAndStop(2);
_root.mc_intro.area_checkbox._visible = false;
_root.mc_intro.area_signup._visible = false;
_root.mc_intro.checkbox._visible = false;
_root.mc_intro.area_playagain._visible = false;
_root.mc_intro.note._visible = false;
_root.mc_intro.playlabel._visible = true;
_root.mc_intro.onRelease = function () {
_root.mc_intro._visible = false;
prepareStart();
};
};
this.run = function () {
var _local2 = getTimer();
if (this.gameOver) {
return(undefined);
}
this.time_countdown(_local2);
};
this.time_countdown = function (timenow) {
timeLeft.frameNo++;
var _local2 = Math.max(0, Math.round(this.gd.duration - ((timenow - timeLeft.startTime) / 1000)));
timeLeft.secondsLeft = _local2;
if (self.gd.relaxMode == "true") {
return(undefined);
}
if (_local2 == 0) {
this.setGameOver("timeup");
}
var _local3 = this.time_format_str(_local2);
if (timeLeft.current != _local3) {
this.gui.setTime(_local3);
timeLeft.current = _local3;
if (_local2 <= 10) {
soundFx.play("ticking.wav");
}
}
};
this.getSecondsLeft = function () {
return(timeLeft.secondsLeft);
};
this.getFrameNo = function () {
return(timeLeft.frameNo);
};
this.time_format_str = function (t) {
var _local2 = String(Math.floor(t / 60) + ":");
t = t % 60;
_local2 = _local2 + ((t < 10) ? ("0" + t) : (t));
return(_local2);
};
this.fps_status = function (timenow) {
fps_status.frameCnt++;
if ((timenow - fps_status.lastTime) > 500) {
_root.fps_txt.text = fps_status.frameCnt * 2;
fps_status.lastTime = timenow;
fps_status.frameCnt = 0;
}
};
this.setGameOver = function (reason) {
if (this.gameOver) {
return(undefined);
}
this.gameOver = true;
this.ballz.kill();
this.cue.kill();
if ((reason == "endbutton") || (reason == "timeup")) {
this.clearShotBonus();
this.gui.showGameOver();
} else if (self.gd.relaxMode != "true") {
new Delay(function () {
game.gui.showGameOver();
}, 25);
}
if (self.gd.relaxMode == "true") {
if (scoreObj.getShotBonus() > 0) {
new Delay(function () {
prepareStart();
}, 25);
} else {
new Delay(function () {
game.gui.showGameOver();
}, 25);
new Delay(function () {
game.generateMagicBall();
}, (this.gd.postdelay * 25) + 25);
}
} else {
new Delay(function () {
game.generateMagicBall();
}, (this.gd.postdelay * 25) + 25);
}
};
this.getScore = function () {
return(scoreObj.getScore());
};
this.getFinalScore = function () {
return(scoreObj.getFinalScore());
};
this.getGameFinsished = function () {
return(scoreObj.getGameFinsished());
};
this.getShotBonus = function () {
return(scoreObj.getShotBonus());
};
this.getTimeBonus = function () {
return(scoreObj.getTimeBonus());
};
this.getGameScore = function () {
return(scoreObj.getGameScore());
};
this.findNextLegalBall = function () {
return(scoreObj.findNextLegalBall());
};
this.evaluateEvent = function (props) {
log.logEvent(props);
return(scoreObj.evaluateEvent(props));
};
this.clearShotBonus = function () {
scoreObj.clearShotBonus();
};
this.ballClearToPutOnRail = function (ballno) {
return(scoreObj.ballClearToPutOnRail(ballno));
};
this.generateMagicBall = function () {
if (self.gd.relaxMode == "true") {
var _local2 = Math.max(0, scoreObj.getScore());
fscommand ("gameOver", "" + _local2);
} else {
_root.mc_intro.onRelease = undefined;
_root.mc_intro.swapDepths(10480);
_root.mc_intro.removeMovieClip();
_root.mc_outro.swapDepths(10481);
_root.mc_outro._visible = true;
_root.mc_outro.area_checkbox._visible = true;
_root.mc_outro.area_signup._visible = true;
_root.mc_outro.checkbox._visible = true;
_root.mc_outro.area_playagain._visible = true;
_root.mc_outro.note._visible = true;
_root.mc_outro.playlabel._visible = false;
_root.mc_outro.area_checkbox.onRelease = function () {
_root.mc_outro.checkbox._visible = !_root.mc_outro.checkbox._visible;
};
_root.mc_outro.area_signup.onRelease = function () {
if (_root.mc_outro.checkbox._visible) {
game.doExit(1);
}
};
_root.mc_outro.area_playagain.onRelease = function () {
game.doExit(2);
};
}
};
this.doExit = function (exitValue) {
var _local3 = new Score();
var _local2 = log.getLog();
var _local1 = 0;
while (_local1 < _local2.length) {
_local3.evaluateEvent(_local2[_local1]);
_local1++;
}
var _local4 = Math.max(0, _local3.getScore());
gameResult = _local4;
if (exitValue == 2) {
flash.external.ExternalInterface.call("gameOver", "" + _local4);
}
if (exitValue == 1) {
flash.external.ExternalInterface.call("gameSignup");
}
};
}
function Keys() {
this.keyDownArray = new Object();
this.keyDownArray.left = false;
this.keyDownArray.right = false;
this.keyDownArray.up = false;
this.keyDownArray.down = false;
this.keyDownArray.space = false;
this.keyChangeArray = new Object();
this.keyChangeArray.left = false;
this.keyChangeArray.right = false;
this.keyChangeArray.up = false;
this.keyChangeArray.down = false;
this.keyChangeArray.space = false;
this.init = function () {
events.runIt(this);
};
this.isDown = function (key) {
return(this.keyDownArray[key]);
};
this.isHit = function (key) {
return(this.keyDownArray[key] && (this.keyChangeArray[key]));
};
this.isChanged = function (key) {
return(this.keyChangeArray[key]);
};
this.run = function () {
this.keyChangeArray.right = this.keyDownArray.right != Key.isDown(39);
this.keyDownArray.right = Key.isDown(39);
this.keyChangeArray.left = this.keyDownArray.left != Key.isDown(37);
this.keyDownArray.left = Key.isDown(37);
this.keyChangeArray.up = this.keyDownArray.up != Key.isDown(38);
this.keyDownArray.up = Key.isDown(38);
this.keyChangeArray.down = this.keyDownArray.down != Key.isDown(40);
this.keyDownArray.down = Key.isDown(40);
this.keyChangeArray.space = this.keyDownArray.space != Key.isDown(32);
this.keyDownArray.space = Key.isDown(32);
};
}
function startup() {
if (_gameStarted) {
return(undefined);
}
_gameStarted = true;
_root.scrollRect = new flash.geom.Rectangle(0, 0, 752, 440);
game = new Game("PoolKing");
game.initialize();
}
sprites = new Sprites();
events = new Events();
soundFx = new SoundFx();
random = new Random();
var dev_mode = true;
var game_version = 1.05;
if (dev_mode) {
gameData = "<gamedata relaxMode=\"false\" duration=\"300\" randomseed=\"4711\" postdelay=\"5\"><text id=\"shot_bonus\">SHOT BONUS</text><text id=\"next\">NEXT</text><text id=\"score\">SCORE</text><text id=\"instruction_header\">INSTRUCTIONS</text><text id=\"final_score\">FINAL SCORE</text><text id=\"game_over\">GAME OVER</text><text id=\"end_game\">END GAME</text><text id=\"time_left\">TIME LEFT</text><text id=\"start\">START</text><text id=\"spin\">SPIN</text><text id=\"instruction_text\">Play according to standard 9-ball rules. With each shot the cue ball has to first make contact with the lowest numbered ball on the table, which will be highlighted. You complete the game when you have sunk the 9-ball. Using as few shots as possible improves your score. Rotate the mouse to control the cue stick and aim. The ball trajectory outline helps you to perfect your aim. Press down the left mouse button and pull back on your mouse to add strength to your shot. Release the button to shoot. You can also use the keyboard to finetune your aim. Press down spacebar after aiming the cue, then use the left and right arrow keys to finetune aim before adding the strength.</text><text id=\"time_bonus\">TIME BONUS</text></gamedata>";
}
Stage.showMenu = false;
Stage.scaleMode = "noScale";
stop();
startup();
Symbol 362 MovieClip [mc_intro_outro] Frame 1
stop();