Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package boxhead.game
- {
- import MMOcha.server.*;
- import MMOcha.utils.*;
- import boxhead.events.*;
- import boxhead.sounds.*;
- import boxhead.ui.*;
- import boxhead.ui.score.*;
- import boxhead.ui.screen.*;
- import boxhead.ui.weaponSlider.*;
- import boxhead.world.*;
- import boxhead.world.thing.*;
- import boxhead.world.thing.bounty.*;
- import boxhead.world.thing.character.*;
- import boxhead.world.thing.obstacle.deployable.*;
- import boxhead.world.weapon.*;
- import flash.display.*;
- import flash.events.*;
- import flash.external.*;
- import flash.utils.*;
- public class Game extends Sprite
- {
- protected var scheduledProcess:int;
- protected var weaponSlider:WeaponSlider;
- protected var MAX_FLOOD:int = 3;
- protected var lastPing:int = 0;
- protected var localPlayer:LocalPlayer;
- protected var secondTimer:Timer;
- protected var forcePositionUpdate:Boolean = false;
- protected var existingDeployablesString:String;
- protected var gui:GUI;
- protected var checkProcessTimer:Timer;
- protected var gameMessageOutQueue:Array;
- protected var participated:Boolean = false;
- protected var pingQueueIndex:int = 0;
- protected var gameSummary:GameSummary;
- protected var canvas:BitmapData;
- protected var map:Map;
- protected var floodWarningGiven:Boolean = false;
- protected var scoreBoard:ScoreBoard;
- protected var roundTime:int = -1;
- protected var sentMoveFlags:int = 0;
- protected var messageOutQueue:Array;
- protected var FLOOD_TIME:int = 2000;
- protected var mapRequest:DatabaseRequest;
- protected var remotePlayers:Array;
- protected var existingPickupsString:String;
- protected var frameCount:int;
- protected var canvasBitmap:Bitmap;
- protected var drawn:Boolean;
- protected var quickPlayProfile:QuickPlayProfile;
- protected var floodCount:int = 0;
- protected var guiVisible:Boolean = true;
- protected var disconnectionTimer:Timer;
- protected var messageOutTimes:Array;
- protected var forceRedraw:Boolean;
- protected var mapIndex:int;
- protected var mapLoadingScreen:MapLoadingScreen;
- protected var inputStack:Array;
- protected var processCount:int;
- protected var connection:MMOchaServer;
- protected var gameOver:Boolean = false;
- protected var floodTimer:Timer;
- protected var messageInQueue:Array;
- protected var sentMoveDirIndex:int = 0;
- protected var sentDirIndex:int = 0;
- static const ROUND_END_TIME:int = 30;
- static const UPGRADE1_ACTION:String = "1";
- static const M_CHAT:String = "c";
- static const DELIM:String = ";";
- static const M_PING_REQUEST:String = "?";
- static const ROUND_AD_TIME:int = 20;
- static const REFILL_ACTION:String = "0";
- static const UPGRADE2_ACTION:String = "2";
- static const ROUND_START_TIME:int = 620;
- static const BUY_ACTION:String = "0";
- static const M_PING_RESPONSE:String = "!";
- static const M_DEPLOYABLE_ACTIVATE:String = "a";
- public function Game(param1:MMOchaUser, param2:QuickPlayProfile)
- {
- inputStack = new Array();
- canvas = new BitmapData(Constants.WINDOW.width, Constants.WINDOW.height, false, 0);
- canvasBitmap = new Bitmap(canvas, "auto", true);
- addChild(canvasBitmap);
- checkProcessTimer = new Timer(10);
- secondTimer = new Timer(1000);
- disconnectionTimer = new Timer(5000);
- floodTimer = new Timer(FLOOD_TIME);
- checkProcessTimer.addEventListener(TimerEvent.TIMER, checkProcess);
- secondTimer.addEventListener(TimerEvent.TIMER, second);
- floodTimer.addEventListener(TimerEvent.TIMER, floodTick);
- floodTimer.start();
- localPlayer = new LocalPlayer();
- localPlayer.user = param1;
- this.quickPlayProfile = param2;
- Console.dispatcher.addEventListener(ConsoleEvent.INPUT, consoleInput, false, 0, true);
- remotePlayers = new Array();
- gameMessageOutQueue = new Array();
- messageOutQueue = new Array();
- messageOutTimes = new Array();
- messageInQueue = new Array();
- addEventListener(Event.ENTER_FRAME, enterFrame);
- weaponSlider = new WeaponSlider();
- weaponSlider.addEventListener(WeaponSliderEvent.SELECT, handleWeaponSliderSelect);
- addChild(weaponSlider);
- if (!scoreBoard)
- {
- scoreBoard = new ScoreBoard();
- }
- return;
- }// end function
- protected function pickupBountyItem(param1:Player, param2:BountyItem, param3:int) : void
- {
- var _loc_4:int = 0;
- map.removeBountyItem(param2);
- if (param1)
- {
- param1.bountyPoints = param1.bountyPoints + param3;
- param1.score = param1.score + param2.bounty;
- if (param1 == localPlayer)
- {
- SoundControl.playAreaSound(SoundList.KA_CHING, localPlayer.character.pos);
- _loc_4 = localPlayer.pickupMoney(param2.bounty);
- gui.setMoney(localPlayer.money);
- gui.setBountyPoints(localPlayer.bountyPoints);
- gui.addMoneyFloater(_loc_4, param2.renderOffset.add(map.cameraOffset));
- }
- updateScores();
- }
- return;
- }// end function
- protected function characterFire(event:FireEvent) : void
- {
- var _loc_2:* = event.shot;
- var _loc_3:* = _loc_2.source as Character;
- var _loc_4:* = _loc_2.weapon;
- if (!_loc_3 || !_loc_4)
- {
- return;
- }
- map.executeShot(_loc_2);
- var _loc_5:* = _loc_2.angle * 180 / Math.PI;
- while (_loc_5 < 0)
- {
- _loc_5 = _loc_5 + 360;
- }
- while (_loc_5 > 360)
- {
- _loc_5 = _loc_5 - 360;
- }
- if (_loc_4.ammo)
- {
- if (_loc_4.ammo.count == 0)
- {
- gui.showWarning("OUT OF AMMO!", 2000);
- }
- else if (!_loc_4.ammoWarningGiven && _loc_4.ammo.count <= Math.max(1, _loc_4.ammo.max * 0.2))
- {
- _loc_4.ammoWarningGiven = true;
- gui.showWarning("LOW AMMO!", 3000);
- }
- }
- forcePositionUpdate = true;
- queueGameMessage("4" + StringFunctions.padInt(_loc_5, 3) + _loc_2.fireParam);
- return;
- }// end function
- protected function showInitUI() : void
- {
- return;
- }// end function
- protected function applyPremium(param1:int) : void
- {
- var _loc_2:* = localPlayer.character;
- if (!_loc_2)
- {
- return;
- }
- var _loc_3:* = localPlayer.user.premiums[param1];
- if (_loc_3.applied)
- {
- return;
- }
- _loc_3.applied = true;
- switch(param1)
- {
- case Premium.PISTOLS_ID:
- {
- upgradeWeapon(WeaponInfo.PISTOL_ID, WeaponInfo.AKIMBO_PISTOLS_ID);
- break;
- }
- case Premium.M16_ID:
- {
- upgradeWeapon(WeaponInfo.AK47_ID, WeaponInfo.M16_ID);
- break;
- }
- case Premium.RAILGUN_ID:
- {
- upgradeWeapon(WeaponInfo.MAGNUM_ID, WeaponInfo.RAILGUN_ID);
- break;
- }
- case Premium.ARMOR_ID:
- {
- _loc_2.armor = _loc_3.value;
- break;
- }
- case Premium.SHOES_ID:
- {
- _loc_2.speedMultiplier = _loc_3.value;
- break;
- }
- case Premium.WALLET_ID:
- {
- localPlayer.moneyMultiplier = _loc_3.value;
- break;
- }
- case Premium.RADAR_ID:
- {
- gui.numPointers = 1 + _loc_3.value;
- updateScores();
- break;
- }
- case Premium.GRENADES_ID:
- {
- addPremiumEquipment(WeaponInfo.GRENADE_THROWER_ID, _loc_3.value);
- break;
- }
- case Premium.CHARGE_PACKS_ID:
- {
- addPremiumEquipment(WeaponInfo.CHARGE_PACK_PLANTER_ID, _loc_3.value);
- break;
- }
- case Premium.CLAYMORES_ID:
- {
- addPremiumEquipment(WeaponInfo.CLAYMORE_PLANTER_ID, _loc_3.value);
- break;
- }
- case Premium.AIRSTRIKES_ID:
- {
- addPremiumEquipment(WeaponInfo.AIRSTRIKE_THROWER_ID, _loc_3.value);
- break;
- }
- case Premium.BARRELS_ID:
- {
- addPremiumEquipment(WeaponInfo.BARREL_PLANTER_ID, _loc_3.value);
- break;
- }
- case Premium.BARRICADES_ID:
- {
- addPremiumEquipment(WeaponInfo.BARRICADE_PLANTER_ID, _loc_3.value);
- break;
- }
- case Premium.SPY_SATELLITE_ID:
- {
- addPremiumEquipment(WeaponInfo.SPY_ID, _loc_3.value);
- break;
- }
- case Premium.MG_TURRET_ID:
- {
- addPremiumEquipment(WeaponInfo.TURRET_MG_PLANTER_ID, _loc_3.value);
- break;
- }
- case Premium.MORTAR_TURRET_ID:
- {
- addPremiumEquipment(WeaponInfo.TURRET_MORTAR_PLANTER_ID, _loc_3.value);
- break;
- }
- default:
- {
- break;
- }
- }
- return;
- }// end function
- protected function getDeployableByIndex(param1:int) : Deployable
- {
- var _loc_3:Player = null;
- var _loc_2:* = localPlayer.getDeployableByID(param1);
- if (_loc_2)
- {
- return _loc_2;
- }
- for each (_loc_3 in remotePlayers)
- {
- _loc_2 = _loc_3.getDeployableByID(param1);
- if (_loc_2)
- {
- return _loc_2;
- }
- }
- return null;
- }// end function
- protected function showAdvertisement() : void
- {
- if (Constants.TEST_MODE)
- {
- }
- else
- {
- try
- {
- ExternalInterface.call("ShowAd");
- }
- catch (error:Error)
- {
- Debug.output("Could not show ad");
- }
- }
- return;
- }// end function
- protected function handleKeyUp(event:KeyboardEvent) : void
- {
- var _loc_2:String = null;
- if (currentInput is IngameMenuScreen)
- {
- if (event.keyCode == Input.ESCAPE)
- {
- toggleMenu();
- }
- }
- else if (currentInput == gui)
- {
- if (event.keyCode == Input.ENTER)
- {
- _loc_2 = gui.getInput();
- if (_loc_2 && _loc_2.length && !floodWarningGiven)
- {
- if (floodCount >= MAX_FLOOD)
- {
- floodWarningGiven = true;
- }
- else if (connection.password && _loc_2.toLowerCase().indexOf(connection.password.toLowerCase()) >= 0)
- {
- gui.addChatMessage(localPlayer, "You can not send chat messages containing your password");
- }
- else
- {
- var _loc_4:* = floodCount + 1;
- floodCount = _loc_4;
- sendChatMessage(_loc_2);
- gui.addChatMessage(localPlayer, _loc_2);
- }
- }
- gui.closeInput();
- freeInput(gui);
- }
- else if (event.keyCode == Input.ESCAPE)
- {
- gui.closeInput();
- freeInput(gui);
- }
- }
- else if (currentInput == null)
- {
- if (event.keyCode == Input.ESCAPE)
- {
- toggleMenu();
- }
- else if (event.keyCode == Input.ENTER)
- {
- captureInput(gui);
- gui.openInput();
- }
- }
- return;
- }// end function
- protected function handleMapReceived(event:DatabaseEvent) : void
- {
- if (!mapRequest)
- {
- return;
- }
- mapRequest.removeEventListener(DatabaseEvent.GET_MAP, handleMapReceived);
- mapRequest = null;
- var _loc_2:* = MapInfo.mapList[mapIndex];
- if (event.error)
- {
- Debug.error("Could not retrieve map data. for map: " + _loc_2.name + " (" + _loc_2.slot + "). Retrying...");
- getMap();
- return;
- }
- _loc_2.mapString = event.data.map.data.toString();
- var _loc_3:* = _loc_2.create();
- if (_loc_3)
- {
- loadMap(_loc_3);
- }
- else
- {
- Debug.error("Could not retrieve map data for map: " + _loc_2.name + " (" + _loc_2.slot + ")");
- }
- return;
- }// end function
- protected function premiumsRefreshed(event:ServerEvent) : void
- {
- if (localPlayer.character)
- {
- applyLocalPremiums();
- }
- return;
- }// end function
- public function dispose() : void
- {
- var _loc_1:RemotePlayer = null;
- if (localPlayer && localPlayer.character)
- {
- localPlayer.character.removeEventListener(FireEvent.FIRE, characterFire);
- localPlayer.character.removeEventListener(CharacterEvent.WEAPON_SWITCH, characterWeaponSwitch);
- localPlayer.character.removeEventListener(CharacterEvent.HURT, characterHurt);
- localPlayer.character.removeEventListener(CharacterEvent.RESPAWN, characterRespawn);
- }
- disableConnection();
- localPlayer.dispose();
- for each (_loc_1 in remotePlayers)
- {
- _loc_1.dispose();
- }
- Console.dispatcher.removeEventListener(ConsoleEvent.INPUT, consoleInput);
- disconnectionTimer.removeEventListener(TimerEvent.TIMER, disconnectionTimeUp);
- disconnectionTimer.stop();
- checkProcessTimer.removeEventListener(TimerEvent.TIMER, checkProcess);
- checkProcessTimer.stop();
- secondTimer.removeEventListener(TimerEvent.TIMER, second);
- secondTimer.stop();
- floodTimer.removeEventListener(TimerEvent.TIMER, floodTick);
- floodTimer.stop();
- if (scoreBoard)
- {
- scoreBoard.dispose();
- }
- weaponSlider.removeEventListener(WeaponSliderEvent.SELECT, handleWeaponSliderSelect);
- removeEventListener(Event.ENTER_FRAME, enterFrame);
- if (stage)
- {
- stage.removeEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
- stage.removeEventListener(KeyboardEvent.KEY_UP, handleKeyUp);
- }
- if (map)
- {
- map.removeEventListener(DeployableEvent.DAMAGE, deployableDamage);
- map.removeEventListener(DeployableEvent.ACTIVATE, deployableActivate);
- map.dispose();
- }
- canvas.dispose();
- gameOver = true;
- return;
- }// end function
- protected function receiveServerMessage(event:ServerEvent) : void
- {
- switch(event.message.charAt(0))
- {
- case "r":
- {
- existingDeployablesString = event.message.substr(1);
- break;
- }
- case "s":
- {
- existingPickupsString = event.message.substr(1);
- break;
- }
- default:
- {
- messageInQueue.push(new QueuedMessage(QueuedMessage.SERVER_MESSAGE, null, event.message));
- break;
- break;
- }
- }
- return;
- }// end function
- protected function getPlayerWeaponDamage(param1:Player, param2:int) : int
- {
- var _loc_3:* = param1.character;
- if (!_loc_3)
- {
- return 0;
- }
- var _loc_4:* = _loc_3.getWeaponByID(param2);
- if (!_loc_3.getWeaponByID(param2))
- {
- return 0;
- }
- return _loc_4.damage;
- }// end function
- public function captureInput(param1:Object) : void
- {
- if (inputStack.length == 0)
- {
- localPlayer.clearInput();
- }
- var _loc_2:* = inputStack.indexOf(param1);
- if (_loc_2 == -1)
- {
- inputStack.push(param1);
- }
- return;
- }// end function
- protected function createDeployableFromString(param1:String, param2:Boolean = true) : Deployable
- {
- var _loc_3:* = getPlayerByID(param1.substr(0, 3));
- if (!_loc_3)
- {
- Debug.error("Error: Deployable owner not found");
- return null;
- }
- var _loc_4:* = _loc_3.character;
- if (!_loc_3.character)
- {
- Debug.error("Error: Deployable owner not active");
- return null;
- }
- var _loc_5:* = getWeaponIDFromDeployableCode(param1.charAt(3));
- var _loc_6:* = _loc_4.getWeaponByID(_loc_5) as WeaponPlanter;
- if (!(_loc_4.getWeaponByID(_loc_5) as WeaponPlanter))
- {
- Debug.error("Error: Deployable owner does not own weapon");
- return null;
- }
- var _loc_7:* = stringToCellPos(param1.substr(6));
- var _loc_8:* = map.cellGrid.cellAtPos(_loc_7);
- if (map.cellGrid.cellAtPos(_loc_7).deployable)
- {
- map.removeDeployable(_loc_8.deployable);
- }
- var _loc_9:* = _loc_6.createDeployable(_loc_7.x, _loc_7.y);
- _loc_6.createDeployable(_loc_7.x, _loc_7.y).index = parseInt(param1.substr(4, 2));
- _loc_4.owner.addDeployable(_loc_9);
- map.plantDeployable(_loc_9, param2);
- return _loc_9;
- }// end function
- protected function getPlayerByID(param1:String) : Player
- {
- var _loc_2:RemotePlayer = null;
- if (localPlayer.id == param1)
- {
- return localPlayer;
- }
- for each (_loc_2 in remotePlayers)
- {
- if (_loc_2.id == param1)
- {
- return _loc_2;
- }
- }
- return null;
- }// end function
- protected function resetUI() : void
- {
- return;
- }// end function
- protected function getMap() : void
- {
- var _loc_1:* = MapInfo.mapList[mapIndex];
- mapRequest = new DatabaseRequest(DatabaseRequest.GET_MAP, MapInfo.BOUNTY_ACCOUNT, null, null, "" + _loc_1.slot);
- mapRequest.addEventListener(DatabaseEvent.GET_MAP, handleMapReceived);
- return;
- }// end function
- protected function applyQuickPlayProfile() : void
- {
- return;
- }// end function
- protected function processServerMessage(param1:String) : void
- {
- var _loc_3:Player = null;
- var _loc_4:Deployable = null;
- var _loc_5:HasOwner = null;
- var _loc_6:int = 0;
- var _loc_2:* = param1.charAt(0);
- param1 = param1.substr(1);
- switch(_loc_2)
- {
- case "R":
- {
- endGame(param1);
- break;
- }
- case "n":
- {
- _loc_4 = createDeployableFromString(param1);
- break;
- }
- case "o":
- {
- _loc_4 = getDeployableByIndex(parseInt(param1.substr(0, 2)));
- if (_loc_4)
- {
- if (param1.length >= 5)
- {
- _loc_5 = getPlayerByID(param1.substr(2, 3)).character;
- _loc_6 = 0;
- }
- else
- {
- _loc_6 = parseInt(param1.substr(2));
- }
- if (_loc_6 > 0)
- {
- _loc_4.setHealth(_loc_6);
- }
- else
- {
- if (!_loc_5)
- {
- _loc_5 = _loc_4;
- }
- _loc_4.owner.removeDeployable(_loc_4);
- map.deployableDeath(_loc_4, _loc_5);
- }
- }
- else
- {
- Debug.error("Deployable index not found");
- }
- break;
- }
- default:
- {
- break;
- }
- }
- return;
- }// end function
- protected function setRoundTime(param1:int) : void
- {
- roundTime = param1;
- if (param1 > ROUND_END_TIME)
- {
- participated = true;
- }
- return;
- }// end function
- protected function processLocalPlayer() : void
- {
- localPlayer.process();
- if (!currentInput)
- {
- localPlayer.processInput();
- }
- if (Constants.TEST_MODE && remotePlayers.length && localPlayer.localCharacter)
- {
- localPlayer.localCharacter.unlag(remotePlayers[0].ping);
- Debug.drawCircle(localPlayer.localCharacter.fireHit.pos.x, localPlayer.localCharacter.fireHit.pos.y, localPlayer.localCharacter.fireHit.radius, 65535);
- localPlayer.localCharacter.unlag(0);
- }
- return;
- }// end function
- protected function characterWeaponSwitch(event:CharacterEvent) : void
- {
- queueWeapon(event.weaponID);
- return;
- }// end function
- protected function setupConnection() : void
- {
- connection.addEventListener(ServerEvent.HANDSHAKE, peerJoined);
- connection.addEventListener(ServerEvent.DISCONNECTED, disconnected);
- connection.addEventListener(ServerEvent.PEER_DISCONNECTED, peerDisconnected);
- connection.addEventListener(ServerEvent.MESSAGE, receiveMessage);
- connection.addEventListener(ServerEvent.PLAYER_MESSAGE, receivePlayerMessage);
- connection.addEventListener(ServerEvent.SERVER_MESSAGE, receiveServerMessage);
- connection.addEventListener(ServerEvent.GLOBAL_MESSAGE, receiveGlobalMessage);
- connection.addEventListener(ServerEvent.ROOM_INFO, receiveRoomInfo);
- connection.addEventListener(ServerEvent.ROUND_TIME, receiveRoundTime);
- connection.addEventListener(ServerEvent.MOST_WANTED_CHANGE, receiveMostWantedStatus);
- connection.addEventListener(ServerEvent.PEER_PREMIUMS, peerPremiums);
- connection.addEventListener(ServerEvent.PREMIUMS_REFRESHED, premiumsRefreshed);
- return;
- }// end function
- protected function checkProcess(event:TimerEvent) : void
- {
- Time.current = getTimer();
- if (Time.current >= scheduledProcess && !forceRedraw)
- {
- process();
- scheduledProcess = scheduledProcess + Constants.PROCESS_INTERVAL;
- var _loc_3:* = processCount + 1;
- processCount = _loc_3;
- Time.lastProcess = Time.current;
- }
- else
- {
- if (!drawn)
- {
- draw();
- var _loc_3:* = frameCount + 1;
- frameCount = _loc_3;
- drawn = true;
- Time.lastRender = Time.current;
- }
- forceRedraw = false;
- }
- return;
- }// end function
- protected function disconnected(event:ServerEvent) : void
- {
- checkProcessTimer.stop();
- disableConnection();
- gui.showWarning("Connection Lost", 99999);
- if (map && canvas)
- {
- draw();
- }
- disconnectionTimer.addEventListener(TimerEvent.TIMER, disconnectionTimeUp);
- disconnectionTimer.start();
- return;
- }// end function
- public function draw() : void
- {
- var camPosition:Position;
- if (gameOver || !canvas || !map)
- {
- return;
- }
- Debug.clear();
- canvas.lock();
- try
- {
- camPosition = localPlayer.getCameraPosition();
- if (!camPosition)
- {
- camPosition = new Position(map.width / 2, map.height / 2);
- }
- map.focus(camPosition);
- map.draw(canvas);
- if (localPlayer.spyMode)
- {
- localPlayer.spyCam.drawScanLines(canvas);
- map.drawOutlines(canvas);
- }
- drawOverheads();
- drawGUI();
- }
- catch (e:Error)
- {
- Debug.error("Draw Error: " + e.message);
- }
- canvas.unlock();
- return;
- }// end function
- protected function quit() : void
- {
- if (checkProcessTimer)
- {
- checkProcessTimer.stop();
- }
- disableConnection();
- dispatchEvent(new ScreenEvent(ScreenEvent.CLOSE));
- return;
- }// end function
- protected function updateScores() : void
- {
- gui.updateLeaderboard(remotePlayers.concat(localPlayer));
- if (scoreBoard && scoreBoard.parent)
- {
- scoreBoard.update(remotePlayers.concat(localPlayer));
- }
- return;
- }// end function
- protected function peerJoined(event:ServerEvent) : void
- {
- var _loc_3:Object = null;
- var _loc_4:Weapon = null;
- var _loc_5:int = 0;
- var _loc_2:* = new RemotePlayer();
- _loc_2.user = event.info as MMOchaUser;
- if (!_loc_2.user.name || _loc_2.user.name.length == 0)
- {
- _loc_2.user.name = QuickPlayProfile.generateName(_loc_2.user);
- }
- remotePlayers.push(_loc_2);
- gui.addMessage(_loc_2.name + " joined the game", false, true);
- _loc_2.score = _loc_2.user.handShake.score;
- _loc_2.kills = _loc_2.user.handShake.kills;
- _loc_2.deaths = _loc_2.user.handShake.deaths;
- _loc_2.bountyPoints = _loc_2.user.handShake.bountyPoints;
- _loc_2.team = _loc_2.user.handShake.team;
- _loc_2.createCharacter();
- _loc_2.character.active = false;
- _loc_2.character.pickupRemoteWeapons();
- _loc_2.character.selectWeaponByID(_loc_2.user.handShake.weaponID, false);
- _loc_2.character.setHealth(_loc_2.user.handShake.hp, false);
- if (map)
- {
- map.addCharacter(_loc_2.character);
- }
- for each (_loc_3 in _loc_2.user.handShake.upgrades)
- {
- _loc_4 = _loc_2.character.getWeaponByID(_loc_3.weaponID);
- _loc_5 = _loc_3.flags;
- if (_loc_4)
- {
- if ((_loc_5 == 1 || _loc_5 == 3) && _loc_4.upgrade1)
- {
- _loc_4.upgrade1.buy();
- }
- if ((_loc_5 == 2 || _loc_5 == 3) && _loc_4.upgrade2)
- {
- _loc_4.upgrade2.buy();
- }
- }
- }
- pingPlayer(_loc_2);
- _loc_2.user.handShake = null;
- forcePositionUpdate = true;
- updateScores();
- return;
- }// end function
- protected function respawnLocalCharacter() : void
- {
- var _loc_1:* = localPlayer.character;
- if (!_loc_1)
- {
- return;
- }
- map.spawnCharacter(_loc_1);
- queueGameMessage("8" + cellPosToString(_loc_1.pos));
- return;
- }// end function
- protected function handleKeyDown(event:KeyboardEvent) : void
- {
- if (currentInput == gui)
- {
- if (event.keyCode == Input.BACKSPACE)
- {
- gui.deleteInput();
- }
- else
- {
- gui.appendInput(event.charCode);
- }
- }
- return;
- }// end function
- protected function processRemotePlayers() : void
- {
- var _loc_2:Player = null;
- var _loc_3:QueuedMessage = null;
- var _loc_4:Player = null;
- if (Time.current > lastPing + Constants.PING_CYCLE_INTERVAL)
- {
- _loc_2 = remotePlayers[pingQueueIndex];
- if (_loc_2)
- {
- if (Time.current - _loc_2.lastPing > Constants.PING_INTERVAL)
- {
- pingPlayer(_loc_2);
- pingQueueIndex = (pingQueueIndex + 1) % remotePlayers.length;
- }
- }
- else
- {
- pingQueueIndex = (pingQueueIndex + 1) % remotePlayers.length;
- }
- }
- var _loc_1:int = 0;
- while (_loc_1 < messageInQueue.length)
- {
- _loc_3 = messageInQueue[_loc_1];
- _loc_4 = getPlayerByID(_loc_3.source);
- switch(_loc_3.type)
- {
- case QueuedMessage.CHAT_BUNDLE:
- {
- if (_loc_4)
- {
- processBundle(_loc_4, _loc_3.message);
- }
- break;
- }
- case QueuedMessage.PLAYER_MESSAGE:
- {
- if (_loc_4)
- {
- processPlayerMessage(_loc_4, _loc_3.message);
- }
- break;
- }
- case QueuedMessage.SERVER_MESSAGE:
- {
- processServerMessage(_loc_3.message);
- break;
- }
- default:
- {
- break;
- }
- }
- _loc_1++;
- }
- messageInQueue = [];
- return;
- }// end function
- protected function drawGUI() : void
- {
- if (guiVisible)
- {
- if (!guiShouldBeVisible())
- {
- hideGUI();
- }
- }
- else if (guiShouldBeVisible())
- {
- showGUI();
- }
- if (!guiVisible)
- {
- return;
- }
- gui.draw(canvas, map.focusPosition);
- return;
- }// end function
- protected function disconnectionTimeUp(event:TimerEvent) : void
- {
- disconnectionTimer.removeEventListener(TimerEvent.TIMER, disconnectionTimeUp);
- disconnectionTimer.stop();
- dispatchEvent(new ScreenEvent(ScreenEvent.DISCONNECTED));
- return;
- }// end function
- protected function receiveRoomInfo(event:ServerEvent) : void
- {
- var _loc_2:MapInfo = null;
- var _loc_3:Map = null;
- setRoundTime(event.info.roundTime);
- if (!map && !mapRequest)
- {
- mapIndex = event.info.mapID;
- _loc_2 = MapInfo.mapList[mapIndex];
- if (!_loc_2)
- {
- Debug.error("Bad map index: " + mapIndex);
- }
- else
- {
- _loc_3 = _loc_2.create();
- if (_loc_3)
- {
- loadMap(_loc_3);
- setRoundTime(event.info.roundTime);
- }
- else
- {
- getMap();
- }
- }
- }
- return;
- }// end function
- protected function drawOverheads() : void
- {
- var _loc_3:Thing = null;
- var _loc_4:int = 0;
- var _loc_5:Thing = null;
- var _loc_6:PlayerCharacter = null;
- var _loc_1:* = map.characters.concat(map.turrets);
- var _loc_2:int = 1;
- while (_loc_2 < _loc_1.length)
- {
- _loc_3 = _loc_1[_loc_2];
- _loc_4 = _loc_2 - 1;
- while (_loc_4 >= 0)
- {
- _loc_5 = _loc_1[_loc_4];
- if (_loc_3.depth < _loc_5.depth)
- {
- _loc_1[(_loc_4 + 1)] = _loc_5;
- _loc_1[_loc_4] = _loc_3;
- }
- else
- {
- break;
- }
- _loc_4 = _loc_4 - 1;
- }
- _loc_2++;
- }
- for each (_loc_3 in _loc_1)
- {
- _loc_6 = _loc_3 as PlayerCharacter;
- if (_loc_6 && (!_loc_6.active || _loc_6.dead))
- {
- continue;
- }
- _loc_3.drawOverhead(canvas, map.cameraOffset);
- }
- return;
- }// end function
- protected function processMap() : void
- {
- map.process();
- return;
- }// end function
- protected function process() : void
- {
- var players:Array;
- if (mapLoadingScreen && mapLoadingScreen.alpha < 1)
- {
- mapLoadingScreen.alpha = Math.max(0, mapLoadingScreen.alpha - 0.05);
- if (mapLoadingScreen.alpha == 0)
- {
- removeMapLoadingScreen();
- }
- }
- if (!map)
- {
- return;
- }
- if (gameSummary)
- {
- players = remotePlayers.concat();
- if (participated)
- {
- players.push(localPlayer);
- }
- gameSummary.refreshScores(players);
- }
- if (gameOver)
- {
- Input.update();
- return;
- }
- if (localPlayer.localCharacter)
- {
- localPlayer.localCharacter.unlag(0);
- }
- try
- {
- processLocalPlayer();
- }
- catch (e:Error)
- {
- Debug.error("Local Player Error: " + e.message);
- try
- {
- }
- processRemotePlayers();
- }
- catch (e:Error)
- {
- Debug.error("Remote Player Error: " + e.message);
- try
- {
- }
- processAI();
- }
- catch (e:Error)
- {
- Debug.error("AI Error: " + e.message);
- try
- {
- }
- processMap();
- }
- catch (e:Error)
- {
- Debug.error("Map Error: " + e.message);
- }
- if (localPlayer.character)
- {
- weaponSlider.update(localPlayer.character.currentWeapon);
- checkBountyCrates();
- }
- if (Input.isDown(Input.SCORES_KEY))
- {
- if (Input.newPress(Input.SCORES_KEY))
- {
- addChild(scoreBoard);
- }
- scoreBoard.update(remotePlayers.concat(localPlayer));
- }
- else if (scoreBoard.parent && localPlayer.team)
- {
- scoreBoard.parent.removeChild(scoreBoard);
- }
- Input.update();
- if (localPlayer.character && localPlayer.character.active)
- {
- sendUpdate();
- }
- return;
- }// end function
- public function start(param1:MMOchaServer) : void
- {
- this.connection = param1;
- setupConnection();
- Time.current = getTimer();
- Time.lastRender = Time.current;
- Time.lastProcess = Time.current;
- scheduledProcess = Time.current;
- processCount = 0;
- frameCount = 0;
- newGame();
- return;
- }// end function
- protected function clearLocalPremiums() : void
- {
- var _loc_1:int = 0;
- var _loc_2:Premium = null;
- for each (_loc_1 in Premium.VALID_PREMIUMS)
- {
- _loc_2 = localPlayer.user.premiums[_loc_1];
- _loc_2.applied = false;
- }
- return;
- }// end function
- protected function enterFrame(event:Event) : void
- {
- drawn = false;
- return;
- }// end function
- protected function sendUpdate() : void
- {
- var _loc_1:String = null;
- var _loc_5:String = null;
- var _loc_2:* = localPlayer.character;
- var _loc_3:int = 0;
- if (_loc_2.collided)
- {
- _loc_3 = _loc_3 + 1;
- }
- var _loc_4:int = 0;
- if (_loc_2.moveDir)
- {
- _loc_4 = _loc_2.moveDir.index + 1;
- }
- if (forcePositionUpdate || _loc_2.collided || _loc_3 != sentMoveFlags || _loc_4 != sentMoveDirIndex || _loc_2.dir.index != sentDirIndex)
- {
- _loc_1 = "1" + posToString(_loc_2.pos) + _loc_4 + "" + _loc_2.dir.index + "" + _loc_3;
- connection.sendGameMessage(_loc_1);
- sentMoveDirIndex = _loc_4;
- sentDirIndex = _loc_2.dir.index;
- sentMoveFlags = _loc_3;
- }
- while (gameMessageOutQueue.length > 0)
- {
- _loc_5 = gameMessageOutQueue.shift();
- connection.sendGameMessage(_loc_5);
- }
- if (messageOutQueue.length)
- {
- _loc_1 = "";
- while (messageOutQueue.length)
- {
- _loc_1 = _loc_1 + (messageOutQueue.shift() + DELIM);
- }
- connection.sendMessage(_loc_1);
- messageOutTimes.push({time:Time.current, message:_loc_1});
- }
- forcePositionUpdate = false;
- return;
- }// end function
- protected function upgradeWeapon(param1:int, param2:int) : void
- {
- var _loc_3:* = localPlayer.character;
- var _loc_4:* = _loc_3.getWeaponByID(param1);
- if (!_loc_3.getWeaponByID(param1))
- {
- return;
- }
- var _loc_5:* = getPremiumWeapon(param2);
- _loc_3.pickupWeapon(_loc_5);
- if (_loc_3.currentWeapon && _loc_3.currentWeapon.weaponID == param1)
- {
- _loc_3.selectWeaponByID(param2, true);
- }
- _loc_3.dropWeaponByID(param1);
- weaponSlider.updateWeaponList(_loc_3.getWeaponBanks());
- return;
- }// end function
- protected function removeMapLoadingScreen() : void
- {
- if (!mapLoadingScreen)
- {
- return;
- }
- if (mapLoadingScreen.parent)
- {
- mapLoadingScreen.parent.removeChild(mapLoadingScreen);
- }
- mapLoadingScreen.removeEventListener(ScreenEvent.MENU, handleLoadingQuit);
- mapLoadingScreen.dispose();
- mapLoadingScreen = null;
- return;
- }// end function
- protected function guiShouldBeVisible() : Boolean
- {
- if (scoreBoard && scoreBoard.parent)
- {
- return false;
- }
- if (gameSummary && gameSummary.parent)
- {
- return false;
- }
- return true;
- }// end function
- protected function second(event:TimerEvent = null) : void
- {
- var _loc_3:* = roundTime - 1;
- roundTime = _loc_3;
- if (roundTime % 20 == 0)
- {
- connection.requestRoundTime();
- }
- if (roundTime == ROUND_START_TIME)
- {
- SoundControl.playUISound(SoundList.GAME_START);
- }
- if (gameOver)
- {
- if (roundTime == ROUND_AD_TIME)
- {
- showAdvertisement();
- }
- if (gameSummary)
- {
- gameSummary.setCountDown(Math.max(0, roundTime));
- }
- if (roundTime <= 0 || roundTime > ROUND_END_TIME)
- {
- newGame();
- }
- return;
- }
- gui.updateFPS(frameCount);
- gui.updateTime(Math.max(0, roundTime - ROUND_END_TIME));
- forceRedraw = true;
- frameCount = 0;
- processCount = 0;
- return;
- }// end function
- protected function peerPremiums(event:ServerEvent) : void
- {
- var _loc_2:* = getPlayerByID(event.source);
- var _loc_3:* = _loc_2.user.premiums[Premium.SHOES_ID];
- _loc_3.owned = true;
- if (_loc_2.character)
- {
- _loc_2.character.speedMultiplier = _loc_3.value;
- }
- return;
- }// end function
- protected function getRemotePlayerByID(param1:String) : RemotePlayer
- {
- var _loc_2:RemotePlayer = null;
- if (localPlayer.id == param1)
- {
- return null;
- }
- for each (_loc_2 in remotePlayers)
- {
- if (_loc_2.id == param1)
- {
- return _loc_2;
- }
- }
- return null;
- }// end function
- protected function deployableDamage(event:DeployableEvent) : void
- {
- queueGameMessage("o" + StringFunctions.padInt(event.deployable.index, 2) + event.source.owner.id + StringFunctions.padInt(event.value, 2));
- return;
- }// end function
- protected function queueWeapon(param1:int) : void
- {
- queueGameMessage("0q" + StringFunctions.padInt(param1, 2));
- return;
- }// end function
- protected function createBountyItemsFromString(param1:String, param2:Character = null) : void
- {
- var _loc_3:Position = null;
- var _loc_4:Position = null;
- var _loc_5:int = 0;
- var _loc_6:BountyItem = null;
- if (param2)
- {
- _loc_3 = param2.pos.clone();
- }
- while (param1.length >= 13)
- {
- _loc_4 = stringToPos(param1.substr(3, 10));
- _loc_5 = parseInt(param1.charAt(0));
- _loc_6 = new BountyCrate(_loc_5, _loc_4);
- if (_loc_3)
- {
- _loc_6.animateFrom(_loc_3);
- }
- _loc_6.index = parseInt(param1.substr(1, 2));
- map.removeBountyItemByIndex(_loc_6.index);
- map.addBountyItem(_loc_6);
- param1 = param1.substr(13);
- }
- return;
- }// end function
- protected function hideGUI() : void
- {
- guiVisible = false;
- if (weaponSlider.parent)
- {
- weaponSlider.parent.removeChild(weaponSlider);
- }
- return;
- }// end function
- protected function endGame(param1:String) : void
- {
- if (gameOver)
- {
- return;
- }
- if (scoreBoard.parent)
- {
- scoreBoard.parent.removeChild(scoreBoard);
- }
- gameSummary = new GameSummary();
- var _loc_2:* = remotePlayers.concat();
- if (participated)
- {
- _loc_2.push(localPlayer);
- }
- gameSummary.displaySummary(_loc_2, param1);
- addChild(gameSummary);
- hideGUI();
- SoundControl.playUISound(SoundList.END_ROUND);
- localPlayer.user.stats.kills = localPlayer.user.stats.kills + localPlayer.kills;
- localPlayer.user.stats.deaths = localPlayer.user.stats.deaths + localPlayer.deaths;
- localPlayer.user.stats.bountyPoints = localPlayer.user.stats.bountyPoints + localPlayer.bountyPoints;
- if (localPlayer == gameSummary.winner)
- {
- var _loc_3:* = localPlayer.user.stats;
- var _loc_4:* = localPlayer.user.stats.wins + 1;
- _loc_3.wins = _loc_4;
- }
- else
- {
- var _loc_3:* = localPlayer.user.stats;
- var _loc_4:* = localPlayer.user.stats.losses + 1;
- _loc_3.losses = _loc_4;
- }
- draw();
- localPlayer.exitSpyMode();
- SoundControl.stopAllAreaSounds();
- gameOver = true;
- return;
- }// end function
- protected function handleLoadingQuit(event:ScreenEvent) : void
- {
- removeMapLoadingScreen();
- quit();
- return;
- }// end function
- protected function receiveMessage(event:ServerEvent) : void
- {
- var _loc_2:Object = null;
- var _loc_3:int = 0;
- var _loc_4:int = 0;
- var _loc_5:RemotePlayer = null;
- if (event.source == localPlayer.id)
- {
- if (messageOutTimes.length)
- {
- _loc_2 = messageOutTimes.shift();
- _loc_3 = _loc_2.time;
- _loc_4 = getTimer() - _loc_3;
- }
- return;
- }
- if (event.message == M_PING_REQUEST)
- {
- connection.sendPrivate(M_PING_RESPONSE, event.source);
- return;
- }
- if (event.message == M_PING_RESPONSE)
- {
- _loc_5 = getRemotePlayerByID(event.source);
- if (_loc_5)
- {
- _loc_5.pingReceived();
- }
- return;
- }
- messageInQueue.push(new QueuedMessage(QueuedMessage.CHAT_BUNDLE, event.source, event.message));
- return;
- }// end function
- protected function loadMap(param1:Map) : void
- {
- var _loc_2:int = 0;
- var _loc_3:PlayerCharacter = null;
- var _loc_4:RemotePlayer = null;
- var _loc_5:Premium = null;
- var _loc_6:String = null;
- var _loc_7:Deployable = null;
- this.map = param1;
- param1.addCamera(localPlayer.spyCam);
- param1.addEventListener(DeployableEvent.DAMAGE, deployableDamage);
- param1.addEventListener(DeployableEvent.ACTIVATE, deployableActivate);
- resetUI();
- for each (_loc_4 in remotePlayers)
- {
- if (!_loc_4.character)
- {
- _loc_4.createCharacter();
- _loc_3 = _loc_4.character;
- _loc_4.character.active = false;
- _loc_4.character.pickupRemoteWeapons();
- _loc_5 = _loc_4.user.premiums[Premium.SHOES_ID];
- if (_loc_5.owned)
- {
- _loc_4.character.speedMultiplier = _loc_5.value;
- }
- }
- param1.addCharacter(_loc_4.character);
- }
- _loc_3 = localPlayer.character;
- if (_loc_3)
- {
- _loc_3.removeEventListener(FireEvent.FIRE, characterFire);
- _loc_3.removeEventListener(CharacterEvent.WEAPON_SWITCH, characterWeaponSwitch);
- _loc_3.removeEventListener(CharacterEvent.HURT, characterHurt);
- _loc_3.removeEventListener(CharacterEvent.RESPAWN, characterRespawn);
- }
- localPlayer.createCharacter();
- _loc_3 = localPlayer.character;
- _loc_3.addEventListener(FireEvent.FIRE, characterFire);
- _loc_3.addEventListener(CharacterEvent.WEAPON_SWITCH, characterWeaponSwitch);
- _loc_3.addEventListener(CharacterEvent.HURT, characterHurt);
- _loc_3.addEventListener(CharacterEvent.RESPAWN, characterRespawn);
- _loc_3.active = false;
- applyQuickPlayProfile();
- param1.addCharacter(_loc_3);
- clearLocalPremiums();
- applyLocalPremiums();
- _loc_3.animate();
- if (existingDeployablesString)
- {
- _loc_6 = existingDeployablesString;
- while (_loc_6.length >= 14)
- {
- _loc_7 = createDeployableFromString(_loc_6.substr(0, 12), false);
- if (_loc_7)
- {
- _loc_7.setHealth(parseInt(_loc_6.substr(12, 2)));
- }
- _loc_6 = _loc_6.substr(14);
- }
- }
- existingDeployablesString = null;
- if (existingPickupsString)
- {
- createBountyItemsFromString(existingPickupsString);
- }
- existingPickupsString = null;
- weaponSlider.clear();
- weaponSlider.updateWeaponList(_loc_3.getWeaponBanks());
- updateScores();
- checkProcessTimer.start();
- secondTimer.start();
- if (stage)
- {
- stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown, false, 0, true);
- stage.addEventListener(KeyboardEvent.KEY_UP, handleKeyUp, false, 0, true);
- }
- process();
- draw();
- if (mapLoadingScreen)
- {
- mapLoadingScreen.alpha = 0.95;
- }
- return;
- }// end function
- protected function receiveMostWantedStatus(event:ServerEvent) : void
- {
- updateScores();
- return;
- }// end function
- protected function newGame() : void
- {
- var _loc_1:RemotePlayer = null;
- if (gameSummary)
- {
- gameSummary.dispose();
- if (gameSummary.parent)
- {
- gameSummary.parent.removeChild(gameSummary);
- }
- gameSummary = null;
- }
- SoundControl.stopAllAreaSounds();
- if (roundTime != -1)
- {
- gameOver = false;
- }
- for each (_loc_1 in remotePlayers)
- {
- _loc_1.removeCharacter();
- _loc_1.newRound();
- }
- localPlayer.newRound();
- gui.setMoney(localPlayer.money);
- gui.setBountyPoints(localPlayer.bountyPoints);
- if (map)
- {
- map.removeEventListener(DeployableEvent.DAMAGE, deployableDamage);
- map.removeEventListener(DeployableEvent.ACTIVATE, deployableActivate);
- map.dispose();
- map = null;
- }
- checkProcessTimer.stop();
- secondTimer.stop();
- if (stage)
- {
- stage.removeEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
- stage.removeEventListener(KeyboardEvent.KEY_UP, handleKeyUp);
- }
- connection.requestRoomInfo(connection.room);
- showInitUI();
- if (mapLoadingScreen)
- {
- removeMapLoadingScreen();
- }
- mapLoadingScreen = new MapLoadingScreen();
- mapLoadingScreen.addEventListener(ScreenEvent.MENU, handleLoadingQuit);
- addChild(mapLoadingScreen);
- return;
- }// end function
- protected function consoleInput(event:ConsoleEvent) : void
- {
- if (!event.command)
- {
- return;
- }
- switch(event.command.toLowerCase())
- {
- case "exit":
- case "quit":
- {
- quit();
- break;
- }
- default:
- {
- break;
- }
- }
- return;
- }// end function
- protected function getPremiumWeapon(param1:int) : Weapon
- {
- return WeaponInfo.lookup(param1).create();
- }// end function
- protected function queueMessage(param1:String) : void
- {
- messageOutQueue.push(param1);
- return;
- }// end function
- protected function floodTick(event:TimerEvent) : void
- {
- if (floodCount > 0)
- {
- var _loc_3:* = floodCount - 1;
- floodCount = _loc_3;
- if (floodCount == 0)
- {
- floodWarningGiven = false;
- }
- }
- return;
- }// end function
- protected function peerDisconnected(event:ServerEvent) : void
- {
- var _loc_3:int = 0;
- var _loc_4:Deployable = null;
- var _loc_2:* = getRemotePlayerByID(event.source);
- if (!_loc_2)
- {
- return;
- }
- if (map && _loc_2.character)
- {
- map.removeCharacter(_loc_2.character);
- }
- for each (_loc_4 in _loc_2.getDeployables())
- {
- map.removeDeployable(_loc_4);
- }
- _loc_3 = remotePlayers.length - 1;
- while (_loc_3 >= 0)
- {
- if (remotePlayers[_loc_3] == _loc_2)
- {
- gui.addMessage(_loc_2.name + " left the game", false, true);
- remotePlayers.splice(_loc_3, 1);
- break;
- }
- _loc_3 = _loc_3 - 1;
- }
- updateScores();
- return;
- }// end function
- public function freeInput(param1:Object) : void
- {
- var _loc_2:* = inputStack.indexOf(param1);
- if (_loc_2 >= 0)
- {
- inputStack.splice(_loc_2, 1);
- }
- return;
- }// end function
- protected function handleWeaponSliderSelect(event:WeaponSliderEvent) : void
- {
- var _loc_2:* = event.weapon;
- var _loc_3:* = localPlayer.character;
- if (!_loc_2 || !_loc_3 || _loc_2 == _loc_3.currentWeapon)
- {
- return;
- }
- _loc_3.selectWeaponByID(_loc_2.weaponID);
- return;
- }// end function
- public function getDeployable(param1:Player, param2:int) : Deployable
- {
- return param1.getDeployableByID(param2);
- }// end function
- protected function addPremiumEquipment(param1:int, param2:int) : void
- {
- var _loc_3:* = localPlayer.character;
- var _loc_4:* = _loc_3.getWeaponByID(param1);
- if (_loc_3.getWeaponByID(param1))
- {
- if (_loc_4.ammo)
- {
- _loc_4.ammo.setCount(param2);
- }
- }
- else
- {
- _loc_4 = getPremiumWeapon(param1);
- if (_loc_4.ammo)
- {
- _loc_4.ammo.setCount(param2);
- }
- _loc_3.pickupWeapon(_loc_4);
- }
- weaponSlider.updateWeaponList(_loc_3.getWeaponBanks());
- return;
- }// end function
- protected function receiveGlobalMessage(event:ServerEvent) : void
- {
- var _loc_2:* = event.message;
- if (_loc_2 && _loc_2.length > 0)
- {
- gui.showGlobal(_loc_2);
- }
- return;
- }// end function
- protected function characterDeath(param1:LocalCharacter, param2:HasOwner, param3:int) : void
- {
- gui.addKillMessage(param2.owner, param1.owner, param3);
- gui.showWarning("You will respawn in: [seconds]", param1.respawnTime);
- forcePositionUpdate = true;
- return;
- }// end function
- protected function processPlayerMessage(param1:Player, param2:String) : void
- {
- var _loc_3:Position = null;
- var _loc_4:Direction = null;
- var _loc_5:int = 0;
- var _loc_6:Weapon = null;
- var _loc_9:int = 0;
- var _loc_10:Direction = null;
- var _loc_11:uint = 0;
- var _loc_12:Boolean = false;
- var _loc_13:int = 0;
- var _loc_14:Player = null;
- var _loc_15:int = 0;
- var _loc_16:int = 0;
- var _loc_17:BountyItem = null;
- var _loc_18:Number = NaN;
- var _loc_19:int = 0;
- var _loc_20:Shot = null;
- var _loc_7:* = param1.isLocal;
- var _loc_8:* = param1.character;
- switch(param2.charAt(0))
- {
- case "0":
- {
- switch(param2.charAt(1))
- {
- case "k":
- {
- if (_loc_7)
- {
- break;
- }
- param1.team = parseInt(param2.substr(2));
- updateScores();
- break;
- }
- case "q":
- {
- if (_loc_7)
- {
- break;
- }
- _loc_8.selectWeaponByID(parseInt(param2.substr(2)));
- break;
- }
- case "l":
- {
- if (_loc_7)
- {
- break;
- }
- _loc_5 = parseInt(param2.substr(2, 2));
- _loc_6 = _loc_8.getWeaponByID(_loc_5);
- if (_loc_6)
- {
- switch(param2.charAt(4))
- {
- case BUY_ACTION:
- {
- break;
- }
- case UPGRADE1_ACTION:
- {
- _loc_6.upgrade1.buy();
- break;
- }
- case UPGRADE2_ACTION:
- {
- _loc_6.upgrade2.buy();
- break;
- }
- default:
- {
- break;
- }
- }
- }
- break;
- }
- default:
- {
- break;
- }
- }
- break;
- }
- case "1":
- {
- if (_loc_7)
- {
- break;
- }
- _loc_3 = stringToPos(param2.substr(1, 10));
- _loc_9 = parseInt(param2.charAt(11));
- _loc_10 = null;
- if (_loc_9 > 0)
- {
- _loc_10 = Direction.list[(_loc_9 - 1)];
- }
- _loc_4 = Direction.list[parseInt(param2.charAt(12))];
- _loc_11 = parseInt(param2.charAt(13));
- _loc_8.moving = _loc_10 != null;
- _loc_8.strafing = true;
- _loc_12 = (_loc_11 & 1) > 0;
- if (_loc_12 || !_loc_10 || _loc_8.moveDir != _loc_10)
- {
- _loc_8.pos.copy(_loc_3);
- }
- if (_loc_10 != null && _loc_10 != _loc_8.moveDir)
- {
- _loc_8.applySmoothing();
- }
- _loc_8.moveDir = _loc_10;
- _loc_8.dir = _loc_4;
- _loc_8.firePos.copy(_loc_3);
- _loc_8.updateWeapons();
- if (!_loc_8.active)
- {
- _loc_8.active = true;
- updateScores();
- }
- break;
- }
- case "4":
- {
- if (_loc_7)
- {
- break;
- }
- if (_loc_8.currentWeapon)
- {
- localPlayer.localCharacter.unlag(param1.ping);
- _loc_18 = Math.PI / 180 * parseInt(param2.substr(1, 3));
- _loc_19 = parseInt(param2.substr(4));
- _loc_20 = _loc_8.currentWeapon.shoot(_loc_18, _loc_19);
- map.executeShot(_loc_20);
- }
- break;
- }
- case "6":
- {
- if (_loc_7)
- {
- break;
- }
- _loc_13 = parseInt(param2.substr(1));
- if (_loc_13 > 0)
- {
- map.addBlood(_loc_8, _loc_8.hp - _loc_13);
- _loc_8.setHealth(_loc_13);
- }
- break;
- }
- case "7":
- {
- _loc_14 = getPlayerByID(param2.substr(1, 3));
- if (!_loc_7 || !_loc_8.dead)
- {
- map.addBlood(_loc_8, _loc_8.hp);
- _loc_8.setHealth(0);
- _loc_5 = parseInt(param2.substr(4, 2));
- gui.addKillMessage(_loc_14, param1, _loc_5);
- }
- var _loc_21:* = param1;
- var _loc_22:* = param1.deaths + 1;
- _loc_21.deaths = _loc_22;
- if (_loc_14 != param1)
- {
- var _loc_21:* = _loc_14;
- var _loc_22:* = _loc_14.kills + 1;
- _loc_21.kills = _loc_22;
- }
- updateScores();
- createBountyItemsFromString(param2.substr(6), param1.character);
- break;
- }
- case "8":
- {
- if (_loc_7)
- {
- break;
- }
- _loc_3 = stringToCellPos(param2.substr(1, 6));
- _loc_3.x = _loc_3.x + 0.5;
- _loc_3.y = _loc_3.y + 0.5;
- _loc_8.pos.copy(_loc_3);
- _loc_8.respawn();
- _loc_8.moveDir = null;
- if (!_loc_8.active)
- {
- _loc_8.active = true;
- updateScores();
- }
- break;
- }
- case "m":
- {
- _loc_15 = parseInt(param2.substr(1, 2));
- _loc_16 = parseInt(param2.substr(3));
- _loc_17 = map.getBountyItemByIndex(_loc_15);
- if (_loc_17)
- {
- pickupBountyItem(param1, _loc_17, _loc_16);
- }
- break;
- }
- default:
- {
- break;
- }
- }
- return;
- }// end function
- protected function get currentInput() : Object
- {
- if (!inputStack || inputStack.length == 0)
- {
- return null;
- }
- return inputStack[(inputStack.length - 1)];
- }// end function
- protected function receivePlayerMessage(event:ServerEvent) : void
- {
- messageInQueue.push(new QueuedMessage(QueuedMessage.PLAYER_MESSAGE, event.source, event.message));
- return;
- }// end function
- protected function toggleMenu() : void
- {
- dispatchEvent(new ScreenEvent(ScreenEvent.MENU));
- return;
- }// end function
- protected function deployableActivate(event:DeployableEvent) : void
- {
- var _loc_2:* = M_DEPLOYABLE_ACTIVATE + event.deployable.index;
- queueMessage(_loc_2);
- return;
- }// end function
- protected function processAI() : void
- {
- return;
- }// end function
- protected function receiveRoundTime(event:ServerEvent) : void
- {
- setRoundTime(int(event.info));
- return;
- }// end function
- protected function characterHurt(event:CharacterEvent) : void
- {
- var _loc_2:* = event.target as LocalCharacter;
- if (!_loc_2)
- {
- return;
- }
- map.addScreenShake(new ScreenShake(_loc_2.pos, 1.5, 200));
- if (_loc_2.dead)
- {
- characterDeath(_loc_2, event.source, event.weaponID);
- }
- queueGameMessage("6" + event.source.owner.id + StringFunctions.padInt(event.weaponID, 2) + StringFunctions.padInt(event.damage, 2));
- return;
- }// end function
- protected function characterRespawn(event:CharacterEvent) : void
- {
- respawnLocalCharacter();
- return;
- }// end function
- protected function queueGameMessage(param1:String) : void
- {
- gameMessageOutQueue.push(param1);
- return;
- }// end function
- protected function processBundle(param1:Player, param2:String) : void
- {
- var _loc_3:int = 0;
- var _loc_6:String = null;
- var _loc_7:String = null;
- var _loc_8:String = null;
- var _loc_9:int = 0;
- var _loc_10:Deployable = null;
- var _loc_4:* = param2.split(DELIM);
- var _loc_5:Array = [];
- for each (_loc_6 in _loc_4)
- {
- _loc_8 = _loc_6.charAt(0);
- switch(_loc_8)
- {
- case M_DEPLOYABLE_ACTIVATE:
- {
- _loc_5.push(_loc_6.substr(1));
- break;
- }
- case M_CHAT:
- {
- gui.addChatMessage(param1, LanguageFilter.filter(_loc_6.substr(1)));
- break;
- }
- default:
- {
- break;
- }
- }
- }
- for each (_loc_7 in _loc_5)
- {
- _loc_9 = parseInt(_loc_7);
- _loc_10 = getDeployable(param1, _loc_9);
- if (_loc_10)
- {
- _loc_10.activate();
- }
- }
- return;
- }// end function
- protected function disableConnection() : void
- {
- connection.removeEventListener(ServerEvent.HANDSHAKE, peerJoined);
- connection.removeEventListener(ServerEvent.DISCONNECTED, disconnected);
- connection.removeEventListener(ServerEvent.PEER_DISCONNECTED, peerDisconnected);
- connection.removeEventListener(ServerEvent.MESSAGE, receiveMessage);
- connection.removeEventListener(ServerEvent.PLAYER_MESSAGE, receivePlayerMessage);
- connection.removeEventListener(ServerEvent.SERVER_MESSAGE, receiveServerMessage);
- connection.removeEventListener(ServerEvent.GLOBAL_MESSAGE, receiveGlobalMessage);
- connection.removeEventListener(ServerEvent.ROOM_INFO, receiveRoomInfo);
- connection.removeEventListener(ServerEvent.ROUND_TIME, receiveRoundTime);
- connection.removeEventListener(ServerEvent.MOST_WANTED_CHANGE, receiveMostWantedStatus);
- connection.removeEventListener(ServerEvent.PEER_PREMIUMS, peerPremiums);
- connection.removeEventListener(ServerEvent.PREMIUMS_REFRESHED, premiumsRefreshed);
- return;
- }// end function
- protected function checkBountyCrates() : void
- {
- var _loc_3:BountyItem = null;
- var _loc_1:* = localPlayer.character;
- if (!_loc_1 || !_loc_1.active || _loc_1.dead)
- {
- return;
- }
- var _loc_2:* = map.bountyItems.length - 1;
- while (_loc_2 >= 0)
- {
- _loc_3 = map.bountyItems[_loc_2];
- if (_loc_3.checkRange(_loc_1))
- {
- map.claimBountyItem(_loc_3);
- queueGameMessage("0m" + StringFunctions.padInt(_loc_3.index, 2));
- }
- _loc_2 = _loc_2 - 1;
- }
- return;
- }// end function
- protected function applyLocalPremiums() : void
- {
- var _loc_1:int = 0;
- for each (_loc_1 in Premium.VALID_PREMIUMS)
- {
- if (localPlayer.premiumOwned(_loc_1))
- {
- applyPremium(_loc_1);
- }
- }
- return;
- }// end function
- protected function pingPlayer(param1:Player) : void
- {
- lastPing = Time.current;
- param1.pingSent();
- connection.sendPrivate(M_PING_REQUEST, param1.id);
- return;
- }// end function
- protected function showGUI() : void
- {
- guiVisible = true;
- addChild(weaponSlider);
- return;
- }// end function
- protected function sendChatMessage(param1:String) : void
- {
- queueMessage(M_CHAT + param1);
- return;
- }// end function
- static function stringToCellPos(param1:String) : Position
- {
- return new Position(parseInt(param1.substr(0, 3)), parseInt(param1.substr(3, 3)));
- }// end function
- static function stringToPos(param1:String) : Position
- {
- return new Position(parseInt(param1.substr(0, 5)) / 100, parseInt(param1.substr(5, 5)) / 100);
- }// end function
- static function posToString(param1:Position) : String
- {
- return StringFunctions.padInt(int(param1.x * 100), 5) + StringFunctions.padInt(int(param1.y * 100), 5);
- }// end function
- static function getWeaponIDFromDeployableCode(param1:String) : int
- {
- switch(param1)
- {
- case "0":
- default:
- {
- return WeaponInfo.BARREL_PLANTER_ID;
- }
- case "2":
- {
- return WeaponInfo.BARRICADE_PLANTER_ID;
- }
- case "3":
- {
- return WeaponInfo.CHARGE_PACK_PLANTER_ID;
- }
- case "4":
- {
- return WeaponInfo.CLAYMORE_PLANTER_ID;
- }
- case "5":
- {
- return WeaponInfo.TURRET_MG_PLANTER_ID;
- }
- case :
- {
- return WeaponInfo.TURRET_MORTAR_PLANTER_ID;
- break;
- }
- }
- }// end function
- static function cellPosToString(param1:Position) : String
- {
- return StringFunctions.padInt(int(param1.x), 3) + StringFunctions.padInt(int(param1.y), 3);
- }// end function
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement