Advertisement
Guest User

Untitled

a guest
Oct 7th, 2013
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 76.43 KB | None | 0 0
  1. package boxhead.game
  2. {
  3. import MMOcha.server.*;
  4. import MMOcha.utils.*;
  5. import boxhead.events.*;
  6. import boxhead.sounds.*;
  7. import boxhead.ui.*;
  8. import boxhead.ui.score.*;
  9. import boxhead.ui.screen.*;
  10. import boxhead.ui.weaponSlider.*;
  11. import boxhead.world.*;
  12. import boxhead.world.thing.*;
  13. import boxhead.world.thing.bounty.*;
  14. import boxhead.world.thing.character.*;
  15. import boxhead.world.thing.obstacle.deployable.*;
  16. import boxhead.world.weapon.*;
  17. import flash.display.*;
  18. import flash.events.*;
  19. import flash.external.*;
  20. import flash.utils.*;
  21.  
  22. public class Game extends Sprite
  23. {
  24. protected var scheduledProcess:int;
  25. protected var weaponSlider:WeaponSlider;
  26. protected var MAX_FLOOD:int = 3;
  27. protected var lastPing:int = 0;
  28. protected var localPlayer:LocalPlayer;
  29. protected var secondTimer:Timer;
  30. protected var forcePositionUpdate:Boolean = false;
  31. protected var existingDeployablesString:String;
  32. protected var gui:GUI;
  33. protected var checkProcessTimer:Timer;
  34. protected var gameMessageOutQueue:Array;
  35. protected var participated:Boolean = false;
  36. protected var pingQueueIndex:int = 0;
  37. protected var gameSummary:GameSummary;
  38. protected var canvas:BitmapData;
  39. protected var map:Map;
  40. protected var floodWarningGiven:Boolean = false;
  41. protected var scoreBoard:ScoreBoard;
  42. protected var roundTime:int = -1;
  43. protected var sentMoveFlags:int = 0;
  44. protected var messageOutQueue:Array;
  45. protected var FLOOD_TIME:int = 2000;
  46. protected var mapRequest:DatabaseRequest;
  47. protected var remotePlayers:Array;
  48. protected var existingPickupsString:String;
  49. protected var frameCount:int;
  50. protected var canvasBitmap:Bitmap;
  51. protected var drawn:Boolean;
  52. protected var quickPlayProfile:QuickPlayProfile;
  53. protected var floodCount:int = 0;
  54. protected var guiVisible:Boolean = true;
  55. protected var disconnectionTimer:Timer;
  56. protected var messageOutTimes:Array;
  57. protected var forceRedraw:Boolean;
  58. protected var mapIndex:int;
  59. protected var mapLoadingScreen:MapLoadingScreen;
  60. protected var inputStack:Array;
  61. protected var processCount:int;
  62. protected var connection:MMOchaServer;
  63. protected var gameOver:Boolean = false;
  64. protected var floodTimer:Timer;
  65. protected var messageInQueue:Array;
  66. protected var sentMoveDirIndex:int = 0;
  67. protected var sentDirIndex:int = 0;
  68. static const ROUND_END_TIME:int = 30;
  69. static const UPGRADE1_ACTION:String = "1";
  70. static const M_CHAT:String = "c";
  71. static const DELIM:String = ";";
  72. static const M_PING_REQUEST:String = "?";
  73. static const ROUND_AD_TIME:int = 20;
  74. static const REFILL_ACTION:String = "0";
  75. static const UPGRADE2_ACTION:String = "2";
  76. static const ROUND_START_TIME:int = 620;
  77. static const BUY_ACTION:String = "0";
  78. static const M_PING_RESPONSE:String = "!";
  79. static const M_DEPLOYABLE_ACTIVATE:String = "a";
  80.  
  81. public function Game(param1:MMOchaUser, param2:QuickPlayProfile)
  82. {
  83. inputStack = new Array();
  84. canvas = new BitmapData(Constants.WINDOW.width, Constants.WINDOW.height, false, 0);
  85. canvasBitmap = new Bitmap(canvas, "auto", true);
  86. addChild(canvasBitmap);
  87. checkProcessTimer = new Timer(10);
  88. secondTimer = new Timer(1000);
  89. disconnectionTimer = new Timer(5000);
  90. floodTimer = new Timer(FLOOD_TIME);
  91. checkProcessTimer.addEventListener(TimerEvent.TIMER, checkProcess);
  92. secondTimer.addEventListener(TimerEvent.TIMER, second);
  93. floodTimer.addEventListener(TimerEvent.TIMER, floodTick);
  94. floodTimer.start();
  95. localPlayer = new LocalPlayer();
  96. localPlayer.user = param1;
  97. this.quickPlayProfile = param2;
  98. Console.dispatcher.addEventListener(ConsoleEvent.INPUT, consoleInput, false, 0, true);
  99. remotePlayers = new Array();
  100. gameMessageOutQueue = new Array();
  101. messageOutQueue = new Array();
  102. messageOutTimes = new Array();
  103. messageInQueue = new Array();
  104. addEventListener(Event.ENTER_FRAME, enterFrame);
  105. weaponSlider = new WeaponSlider();
  106. weaponSlider.addEventListener(WeaponSliderEvent.SELECT, handleWeaponSliderSelect);
  107. addChild(weaponSlider);
  108. if (!scoreBoard)
  109. {
  110. scoreBoard = new ScoreBoard();
  111. }
  112. return;
  113. }// end function
  114.  
  115. protected function pickupBountyItem(param1:Player, param2:BountyItem, param3:int) : void
  116. {
  117. var _loc_4:int = 0;
  118. map.removeBountyItem(param2);
  119. if (param1)
  120. {
  121. param1.bountyPoints = param1.bountyPoints + param3;
  122. param1.score = param1.score + param2.bounty;
  123. if (param1 == localPlayer)
  124. {
  125. SoundControl.playAreaSound(SoundList.KA_CHING, localPlayer.character.pos);
  126. _loc_4 = localPlayer.pickupMoney(param2.bounty);
  127. gui.setMoney(localPlayer.money);
  128. gui.setBountyPoints(localPlayer.bountyPoints);
  129. gui.addMoneyFloater(_loc_4, param2.renderOffset.add(map.cameraOffset));
  130. }
  131. updateScores();
  132. }
  133. return;
  134. }// end function
  135.  
  136. protected function characterFire(event:FireEvent) : void
  137. {
  138. var _loc_2:* = event.shot;
  139. var _loc_3:* = _loc_2.source as Character;
  140. var _loc_4:* = _loc_2.weapon;
  141. if (!_loc_3 || !_loc_4)
  142. {
  143. return;
  144. }
  145. map.executeShot(_loc_2);
  146. var _loc_5:* = _loc_2.angle * 180 / Math.PI;
  147. while (_loc_5 < 0)
  148. {
  149.  
  150. _loc_5 = _loc_5 + 360;
  151. }
  152. while (_loc_5 > 360)
  153. {
  154.  
  155. _loc_5 = _loc_5 - 360;
  156. }
  157. if (_loc_4.ammo)
  158. {
  159. if (_loc_4.ammo.count == 0)
  160. {
  161. gui.showWarning("OUT OF AMMO!", 2000);
  162. }
  163. else if (!_loc_4.ammoWarningGiven && _loc_4.ammo.count <= Math.max(1, _loc_4.ammo.max * 0.2))
  164. {
  165. _loc_4.ammoWarningGiven = true;
  166. gui.showWarning("LOW AMMO!", 3000);
  167. }
  168. }
  169. forcePositionUpdate = true;
  170. queueGameMessage("4" + StringFunctions.padInt(_loc_5, 3) + _loc_2.fireParam);
  171. return;
  172. }// end function
  173.  
  174. protected function showInitUI() : void
  175. {
  176. return;
  177. }// end function
  178.  
  179. protected function applyPremium(param1:int) : void
  180. {
  181. var _loc_2:* = localPlayer.character;
  182. if (!_loc_2)
  183. {
  184. return;
  185. }
  186. var _loc_3:* = localPlayer.user.premiums[param1];
  187. if (_loc_3.applied)
  188. {
  189. return;
  190. }
  191. _loc_3.applied = true;
  192. switch(param1)
  193. {
  194. case Premium.PISTOLS_ID:
  195. {
  196. upgradeWeapon(WeaponInfo.PISTOL_ID, WeaponInfo.AKIMBO_PISTOLS_ID);
  197. break;
  198. }
  199. case Premium.M16_ID:
  200. {
  201. upgradeWeapon(WeaponInfo.AK47_ID, WeaponInfo.M16_ID);
  202. break;
  203. }
  204. case Premium.RAILGUN_ID:
  205. {
  206. upgradeWeapon(WeaponInfo.MAGNUM_ID, WeaponInfo.RAILGUN_ID);
  207. break;
  208. }
  209. case Premium.ARMOR_ID:
  210. {
  211. _loc_2.armor = _loc_3.value;
  212. break;
  213. }
  214. case Premium.SHOES_ID:
  215. {
  216. _loc_2.speedMultiplier = _loc_3.value;
  217. break;
  218. }
  219. case Premium.WALLET_ID:
  220. {
  221. localPlayer.moneyMultiplier = _loc_3.value;
  222. break;
  223. }
  224. case Premium.RADAR_ID:
  225. {
  226. gui.numPointers = 1 + _loc_3.value;
  227. updateScores();
  228. break;
  229. }
  230. case Premium.GRENADES_ID:
  231. {
  232. addPremiumEquipment(WeaponInfo.GRENADE_THROWER_ID, _loc_3.value);
  233. break;
  234. }
  235. case Premium.CHARGE_PACKS_ID:
  236. {
  237. addPremiumEquipment(WeaponInfo.CHARGE_PACK_PLANTER_ID, _loc_3.value);
  238. break;
  239. }
  240. case Premium.CLAYMORES_ID:
  241. {
  242. addPremiumEquipment(WeaponInfo.CLAYMORE_PLANTER_ID, _loc_3.value);
  243. break;
  244. }
  245. case Premium.AIRSTRIKES_ID:
  246. {
  247. addPremiumEquipment(WeaponInfo.AIRSTRIKE_THROWER_ID, _loc_3.value);
  248. break;
  249. }
  250. case Premium.BARRELS_ID:
  251. {
  252. addPremiumEquipment(WeaponInfo.BARREL_PLANTER_ID, _loc_3.value);
  253. break;
  254. }
  255. case Premium.BARRICADES_ID:
  256. {
  257. addPremiumEquipment(WeaponInfo.BARRICADE_PLANTER_ID, _loc_3.value);
  258. break;
  259. }
  260. case Premium.SPY_SATELLITE_ID:
  261. {
  262. addPremiumEquipment(WeaponInfo.SPY_ID, _loc_3.value);
  263. break;
  264. }
  265. case Premium.MG_TURRET_ID:
  266. {
  267. addPremiumEquipment(WeaponInfo.TURRET_MG_PLANTER_ID, _loc_3.value);
  268. break;
  269. }
  270. case Premium.MORTAR_TURRET_ID:
  271. {
  272. addPremiumEquipment(WeaponInfo.TURRET_MORTAR_PLANTER_ID, _loc_3.value);
  273. break;
  274. }
  275. default:
  276. {
  277. break;
  278. }
  279. }
  280. return;
  281. }// end function
  282.  
  283. protected function getDeployableByIndex(param1:int) : Deployable
  284. {
  285. var _loc_3:Player = null;
  286. var _loc_2:* = localPlayer.getDeployableByID(param1);
  287. if (_loc_2)
  288. {
  289. return _loc_2;
  290. }
  291. for each (_loc_3 in remotePlayers)
  292. {
  293.  
  294. _loc_2 = _loc_3.getDeployableByID(param1);
  295. if (_loc_2)
  296. {
  297. return _loc_2;
  298. }
  299. }
  300. return null;
  301. }// end function
  302.  
  303. protected function showAdvertisement() : void
  304. {
  305. if (Constants.TEST_MODE)
  306. {
  307. }
  308. else
  309. {
  310. try
  311. {
  312. ExternalInterface.call("ShowAd");
  313. }
  314. catch (error:Error)
  315. {
  316. Debug.output("Could not show ad");
  317. }
  318. }
  319. return;
  320. }// end function
  321.  
  322. protected function handleKeyUp(event:KeyboardEvent) : void
  323. {
  324. var _loc_2:String = null;
  325. if (currentInput is IngameMenuScreen)
  326. {
  327. if (event.keyCode == Input.ESCAPE)
  328. {
  329. toggleMenu();
  330. }
  331. }
  332. else if (currentInput == gui)
  333. {
  334. if (event.keyCode == Input.ENTER)
  335. {
  336. _loc_2 = gui.getInput();
  337. if (_loc_2 && _loc_2.length && !floodWarningGiven)
  338. {
  339. if (floodCount >= MAX_FLOOD)
  340. {
  341. floodWarningGiven = true;
  342. }
  343. else if (connection.password && _loc_2.toLowerCase().indexOf(connection.password.toLowerCase()) >= 0)
  344. {
  345. gui.addChatMessage(localPlayer, "You can not send chat messages containing your password");
  346. }
  347. else
  348. {
  349. var _loc_4:* = floodCount + 1;
  350. floodCount = _loc_4;
  351. sendChatMessage(_loc_2);
  352. gui.addChatMessage(localPlayer, _loc_2);
  353. }
  354. }
  355. gui.closeInput();
  356. freeInput(gui);
  357. }
  358. else if (event.keyCode == Input.ESCAPE)
  359. {
  360. gui.closeInput();
  361. freeInput(gui);
  362. }
  363. }
  364. else if (currentInput == null)
  365. {
  366. if (event.keyCode == Input.ESCAPE)
  367. {
  368. toggleMenu();
  369. }
  370. else if (event.keyCode == Input.ENTER)
  371. {
  372. captureInput(gui);
  373. gui.openInput();
  374. }
  375. }
  376. return;
  377. }// end function
  378.  
  379. protected function handleMapReceived(event:DatabaseEvent) : void
  380. {
  381. if (!mapRequest)
  382. {
  383. return;
  384. }
  385. mapRequest.removeEventListener(DatabaseEvent.GET_MAP, handleMapReceived);
  386. mapRequest = null;
  387. var _loc_2:* = MapInfo.mapList[mapIndex];
  388. if (event.error)
  389. {
  390. Debug.error("Could not retrieve map data. for map: " + _loc_2.name + " (" + _loc_2.slot + "). Retrying...");
  391. getMap();
  392. return;
  393. }
  394. _loc_2.mapString = event.data.map.data.toString();
  395. var _loc_3:* = _loc_2.create();
  396. if (_loc_3)
  397. {
  398. loadMap(_loc_3);
  399. }
  400. else
  401. {
  402. Debug.error("Could not retrieve map data for map: " + _loc_2.name + " (" + _loc_2.slot + ")");
  403. }
  404. return;
  405. }// end function
  406.  
  407. protected function premiumsRefreshed(event:ServerEvent) : void
  408. {
  409. if (localPlayer.character)
  410. {
  411. applyLocalPremiums();
  412. }
  413. return;
  414. }// end function
  415.  
  416. public function dispose() : void
  417. {
  418. var _loc_1:RemotePlayer = null;
  419. if (localPlayer && localPlayer.character)
  420. {
  421. localPlayer.character.removeEventListener(FireEvent.FIRE, characterFire);
  422. localPlayer.character.removeEventListener(CharacterEvent.WEAPON_SWITCH, characterWeaponSwitch);
  423. localPlayer.character.removeEventListener(CharacterEvent.HURT, characterHurt);
  424. localPlayer.character.removeEventListener(CharacterEvent.RESPAWN, characterRespawn);
  425. }
  426. disableConnection();
  427. localPlayer.dispose();
  428. for each (_loc_1 in remotePlayers)
  429. {
  430.  
  431. _loc_1.dispose();
  432. }
  433. Console.dispatcher.removeEventListener(ConsoleEvent.INPUT, consoleInput);
  434. disconnectionTimer.removeEventListener(TimerEvent.TIMER, disconnectionTimeUp);
  435. disconnectionTimer.stop();
  436. checkProcessTimer.removeEventListener(TimerEvent.TIMER, checkProcess);
  437. checkProcessTimer.stop();
  438. secondTimer.removeEventListener(TimerEvent.TIMER, second);
  439. secondTimer.stop();
  440. floodTimer.removeEventListener(TimerEvent.TIMER, floodTick);
  441. floodTimer.stop();
  442. if (scoreBoard)
  443. {
  444. scoreBoard.dispose();
  445. }
  446. weaponSlider.removeEventListener(WeaponSliderEvent.SELECT, handleWeaponSliderSelect);
  447. removeEventListener(Event.ENTER_FRAME, enterFrame);
  448. if (stage)
  449. {
  450. stage.removeEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
  451. stage.removeEventListener(KeyboardEvent.KEY_UP, handleKeyUp);
  452. }
  453. if (map)
  454. {
  455. map.removeEventListener(DeployableEvent.DAMAGE, deployableDamage);
  456. map.removeEventListener(DeployableEvent.ACTIVATE, deployableActivate);
  457. map.dispose();
  458. }
  459. canvas.dispose();
  460. gameOver = true;
  461. return;
  462. }// end function
  463.  
  464. protected function receiveServerMessage(event:ServerEvent) : void
  465. {
  466. switch(event.message.charAt(0))
  467. {
  468. case "r":
  469. {
  470. existingDeployablesString = event.message.substr(1);
  471. break;
  472. }
  473. case "s":
  474. {
  475. existingPickupsString = event.message.substr(1);
  476. break;
  477. }
  478. default:
  479. {
  480. messageInQueue.push(new QueuedMessage(QueuedMessage.SERVER_MESSAGE, null, event.message));
  481. break;
  482. break;
  483. }
  484. }
  485. return;
  486. }// end function
  487.  
  488. protected function getPlayerWeaponDamage(param1:Player, param2:int) : int
  489. {
  490. var _loc_3:* = param1.character;
  491. if (!_loc_3)
  492. {
  493. return 0;
  494. }
  495. var _loc_4:* = _loc_3.getWeaponByID(param2);
  496. if (!_loc_3.getWeaponByID(param2))
  497. {
  498. return 0;
  499. }
  500. return _loc_4.damage;
  501. }// end function
  502.  
  503. public function captureInput(param1:Object) : void
  504. {
  505. if (inputStack.length == 0)
  506. {
  507. localPlayer.clearInput();
  508. }
  509. var _loc_2:* = inputStack.indexOf(param1);
  510. if (_loc_2 == -1)
  511. {
  512. inputStack.push(param1);
  513. }
  514. return;
  515. }// end function
  516.  
  517. protected function createDeployableFromString(param1:String, param2:Boolean = true) : Deployable
  518. {
  519. var _loc_3:* = getPlayerByID(param1.substr(0, 3));
  520. if (!_loc_3)
  521. {
  522. Debug.error("Error: Deployable owner not found");
  523. return null;
  524. }
  525. var _loc_4:* = _loc_3.character;
  526. if (!_loc_3.character)
  527. {
  528. Debug.error("Error: Deployable owner not active");
  529. return null;
  530. }
  531. var _loc_5:* = getWeaponIDFromDeployableCode(param1.charAt(3));
  532. var _loc_6:* = _loc_4.getWeaponByID(_loc_5) as WeaponPlanter;
  533. if (!(_loc_4.getWeaponByID(_loc_5) as WeaponPlanter))
  534. {
  535. Debug.error("Error: Deployable owner does not own weapon");
  536. return null;
  537. }
  538. var _loc_7:* = stringToCellPos(param1.substr(6));
  539. var _loc_8:* = map.cellGrid.cellAtPos(_loc_7);
  540. if (map.cellGrid.cellAtPos(_loc_7).deployable)
  541. {
  542. map.removeDeployable(_loc_8.deployable);
  543. }
  544. var _loc_9:* = _loc_6.createDeployable(_loc_7.x, _loc_7.y);
  545. _loc_6.createDeployable(_loc_7.x, _loc_7.y).index = parseInt(param1.substr(4, 2));
  546. _loc_4.owner.addDeployable(_loc_9);
  547. map.plantDeployable(_loc_9, param2);
  548. return _loc_9;
  549. }// end function
  550.  
  551. protected function getPlayerByID(param1:String) : Player
  552. {
  553. var _loc_2:RemotePlayer = null;
  554. if (localPlayer.id == param1)
  555. {
  556. return localPlayer;
  557. }
  558. for each (_loc_2 in remotePlayers)
  559. {
  560.  
  561. if (_loc_2.id == param1)
  562. {
  563. return _loc_2;
  564. }
  565. }
  566. return null;
  567. }// end function
  568.  
  569. protected function resetUI() : void
  570. {
  571. return;
  572. }// end function
  573.  
  574. protected function getMap() : void
  575. {
  576. var _loc_1:* = MapInfo.mapList[mapIndex];
  577. mapRequest = new DatabaseRequest(DatabaseRequest.GET_MAP, MapInfo.BOUNTY_ACCOUNT, null, null, "" + _loc_1.slot);
  578. mapRequest.addEventListener(DatabaseEvent.GET_MAP, handleMapReceived);
  579. return;
  580. }// end function
  581.  
  582. protected function applyQuickPlayProfile() : void
  583. {
  584. return;
  585. }// end function
  586.  
  587. protected function processServerMessage(param1:String) : void
  588. {
  589. var _loc_3:Player = null;
  590. var _loc_4:Deployable = null;
  591. var _loc_5:HasOwner = null;
  592. var _loc_6:int = 0;
  593. var _loc_2:* = param1.charAt(0);
  594. param1 = param1.substr(1);
  595. switch(_loc_2)
  596. {
  597. case "R":
  598. {
  599. endGame(param1);
  600. break;
  601. }
  602. case "n":
  603. {
  604. _loc_4 = createDeployableFromString(param1);
  605. break;
  606. }
  607. case "o":
  608. {
  609. _loc_4 = getDeployableByIndex(parseInt(param1.substr(0, 2)));
  610. if (_loc_4)
  611. {
  612. if (param1.length >= 5)
  613. {
  614. _loc_5 = getPlayerByID(param1.substr(2, 3)).character;
  615. _loc_6 = 0;
  616. }
  617. else
  618. {
  619. _loc_6 = parseInt(param1.substr(2));
  620. }
  621. if (_loc_6 > 0)
  622. {
  623. _loc_4.setHealth(_loc_6);
  624. }
  625. else
  626. {
  627. if (!_loc_5)
  628. {
  629. _loc_5 = _loc_4;
  630. }
  631. _loc_4.owner.removeDeployable(_loc_4);
  632. map.deployableDeath(_loc_4, _loc_5);
  633. }
  634. }
  635. else
  636. {
  637. Debug.error("Deployable index not found");
  638. }
  639. break;
  640. }
  641. default:
  642. {
  643. break;
  644. }
  645. }
  646. return;
  647. }// end function
  648.  
  649. protected function setRoundTime(param1:int) : void
  650. {
  651. roundTime = param1;
  652. if (param1 > ROUND_END_TIME)
  653. {
  654. participated = true;
  655. }
  656. return;
  657. }// end function
  658.  
  659. protected function processLocalPlayer() : void
  660. {
  661. localPlayer.process();
  662. if (!currentInput)
  663. {
  664. localPlayer.processInput();
  665. }
  666. if (Constants.TEST_MODE && remotePlayers.length && localPlayer.localCharacter)
  667. {
  668. localPlayer.localCharacter.unlag(remotePlayers[0].ping);
  669. Debug.drawCircle(localPlayer.localCharacter.fireHit.pos.x, localPlayer.localCharacter.fireHit.pos.y, localPlayer.localCharacter.fireHit.radius, 65535);
  670. localPlayer.localCharacter.unlag(0);
  671. }
  672. return;
  673. }// end function
  674.  
  675. protected function characterWeaponSwitch(event:CharacterEvent) : void
  676. {
  677. queueWeapon(event.weaponID);
  678. return;
  679. }// end function
  680.  
  681. protected function setupConnection() : void
  682. {
  683. connection.addEventListener(ServerEvent.HANDSHAKE, peerJoined);
  684. connection.addEventListener(ServerEvent.DISCONNECTED, disconnected);
  685. connection.addEventListener(ServerEvent.PEER_DISCONNECTED, peerDisconnected);
  686. connection.addEventListener(ServerEvent.MESSAGE, receiveMessage);
  687. connection.addEventListener(ServerEvent.PLAYER_MESSAGE, receivePlayerMessage);
  688. connection.addEventListener(ServerEvent.SERVER_MESSAGE, receiveServerMessage);
  689. connection.addEventListener(ServerEvent.GLOBAL_MESSAGE, receiveGlobalMessage);
  690. connection.addEventListener(ServerEvent.ROOM_INFO, receiveRoomInfo);
  691. connection.addEventListener(ServerEvent.ROUND_TIME, receiveRoundTime);
  692. connection.addEventListener(ServerEvent.MOST_WANTED_CHANGE, receiveMostWantedStatus);
  693. connection.addEventListener(ServerEvent.PEER_PREMIUMS, peerPremiums);
  694. connection.addEventListener(ServerEvent.PREMIUMS_REFRESHED, premiumsRefreshed);
  695. return;
  696. }// end function
  697.  
  698. protected function checkProcess(event:TimerEvent) : void
  699. {
  700. Time.current = getTimer();
  701. if (Time.current >= scheduledProcess && !forceRedraw)
  702. {
  703. process();
  704. scheduledProcess = scheduledProcess + Constants.PROCESS_INTERVAL;
  705. var _loc_3:* = processCount + 1;
  706. processCount = _loc_3;
  707. Time.lastProcess = Time.current;
  708. }
  709. else
  710. {
  711. if (!drawn)
  712. {
  713. draw();
  714. var _loc_3:* = frameCount + 1;
  715. frameCount = _loc_3;
  716. drawn = true;
  717. Time.lastRender = Time.current;
  718. }
  719. forceRedraw = false;
  720. }
  721. return;
  722. }// end function
  723.  
  724. protected function disconnected(event:ServerEvent) : void
  725. {
  726. checkProcessTimer.stop();
  727. disableConnection();
  728. gui.showWarning("Connection Lost", 99999);
  729. if (map && canvas)
  730. {
  731. draw();
  732. }
  733. disconnectionTimer.addEventListener(TimerEvent.TIMER, disconnectionTimeUp);
  734. disconnectionTimer.start();
  735. return;
  736. }// end function
  737.  
  738. public function draw() : void
  739. {
  740. var camPosition:Position;
  741. if (gameOver || !canvas || !map)
  742. {
  743. return;
  744. }
  745. Debug.clear();
  746. canvas.lock();
  747. try
  748. {
  749. camPosition = localPlayer.getCameraPosition();
  750. if (!camPosition)
  751. {
  752. camPosition = new Position(map.width / 2, map.height / 2);
  753. }
  754. map.focus(camPosition);
  755. map.draw(canvas);
  756. if (localPlayer.spyMode)
  757. {
  758. localPlayer.spyCam.drawScanLines(canvas);
  759. map.drawOutlines(canvas);
  760. }
  761. drawOverheads();
  762. drawGUI();
  763. }
  764. catch (e:Error)
  765. {
  766. Debug.error("Draw Error: " + e.message);
  767. }
  768. canvas.unlock();
  769. return;
  770. }// end function
  771.  
  772. protected function quit() : void
  773. {
  774. if (checkProcessTimer)
  775. {
  776. checkProcessTimer.stop();
  777. }
  778. disableConnection();
  779. dispatchEvent(new ScreenEvent(ScreenEvent.CLOSE));
  780. return;
  781. }// end function
  782.  
  783. protected function updateScores() : void
  784. {
  785. gui.updateLeaderboard(remotePlayers.concat(localPlayer));
  786. if (scoreBoard && scoreBoard.parent)
  787. {
  788. scoreBoard.update(remotePlayers.concat(localPlayer));
  789. }
  790. return;
  791. }// end function
  792.  
  793. protected function peerJoined(event:ServerEvent) : void
  794. {
  795. var _loc_3:Object = null;
  796. var _loc_4:Weapon = null;
  797. var _loc_5:int = 0;
  798. var _loc_2:* = new RemotePlayer();
  799. _loc_2.user = event.info as MMOchaUser;
  800. if (!_loc_2.user.name || _loc_2.user.name.length == 0)
  801. {
  802. _loc_2.user.name = QuickPlayProfile.generateName(_loc_2.user);
  803. }
  804. remotePlayers.push(_loc_2);
  805. gui.addMessage(_loc_2.name + " joined the game", false, true);
  806. _loc_2.score = _loc_2.user.handShake.score;
  807. _loc_2.kills = _loc_2.user.handShake.kills;
  808. _loc_2.deaths = _loc_2.user.handShake.deaths;
  809. _loc_2.bountyPoints = _loc_2.user.handShake.bountyPoints;
  810. _loc_2.team = _loc_2.user.handShake.team;
  811. _loc_2.createCharacter();
  812. _loc_2.character.active = false;
  813. _loc_2.character.pickupRemoteWeapons();
  814. _loc_2.character.selectWeaponByID(_loc_2.user.handShake.weaponID, false);
  815. _loc_2.character.setHealth(_loc_2.user.handShake.hp, false);
  816. if (map)
  817. {
  818. map.addCharacter(_loc_2.character);
  819. }
  820. for each (_loc_3 in _loc_2.user.handShake.upgrades)
  821. {
  822.  
  823. _loc_4 = _loc_2.character.getWeaponByID(_loc_3.weaponID);
  824. _loc_5 = _loc_3.flags;
  825. if (_loc_4)
  826. {
  827. if ((_loc_5 == 1 || _loc_5 == 3) && _loc_4.upgrade1)
  828. {
  829. _loc_4.upgrade1.buy();
  830. }
  831. if ((_loc_5 == 2 || _loc_5 == 3) && _loc_4.upgrade2)
  832. {
  833. _loc_4.upgrade2.buy();
  834. }
  835. }
  836. }
  837. pingPlayer(_loc_2);
  838. _loc_2.user.handShake = null;
  839. forcePositionUpdate = true;
  840. updateScores();
  841. return;
  842. }// end function
  843.  
  844. protected function respawnLocalCharacter() : void
  845. {
  846. var _loc_1:* = localPlayer.character;
  847. if (!_loc_1)
  848. {
  849. return;
  850. }
  851. map.spawnCharacter(_loc_1);
  852. queueGameMessage("8" + cellPosToString(_loc_1.pos));
  853. return;
  854. }// end function
  855.  
  856. protected function handleKeyDown(event:KeyboardEvent) : void
  857. {
  858. if (currentInput == gui)
  859. {
  860. if (event.keyCode == Input.BACKSPACE)
  861. {
  862. gui.deleteInput();
  863. }
  864. else
  865. {
  866. gui.appendInput(event.charCode);
  867. }
  868. }
  869. return;
  870. }// end function
  871.  
  872. protected function processRemotePlayers() : void
  873. {
  874. var _loc_2:Player = null;
  875. var _loc_3:QueuedMessage = null;
  876. var _loc_4:Player = null;
  877. if (Time.current > lastPing + Constants.PING_CYCLE_INTERVAL)
  878. {
  879. _loc_2 = remotePlayers[pingQueueIndex];
  880. if (_loc_2)
  881. {
  882. if (Time.current - _loc_2.lastPing > Constants.PING_INTERVAL)
  883. {
  884. pingPlayer(_loc_2);
  885. pingQueueIndex = (pingQueueIndex + 1) % remotePlayers.length;
  886. }
  887. }
  888. else
  889. {
  890. pingQueueIndex = (pingQueueIndex + 1) % remotePlayers.length;
  891. }
  892. }
  893. var _loc_1:int = 0;
  894. while (_loc_1 < messageInQueue.length)
  895. {
  896.  
  897. _loc_3 = messageInQueue[_loc_1];
  898. _loc_4 = getPlayerByID(_loc_3.source);
  899. switch(_loc_3.type)
  900. {
  901. case QueuedMessage.CHAT_BUNDLE:
  902. {
  903. if (_loc_4)
  904. {
  905. processBundle(_loc_4, _loc_3.message);
  906. }
  907. break;
  908. }
  909. case QueuedMessage.PLAYER_MESSAGE:
  910. {
  911. if (_loc_4)
  912. {
  913. processPlayerMessage(_loc_4, _loc_3.message);
  914. }
  915. break;
  916. }
  917. case QueuedMessage.SERVER_MESSAGE:
  918. {
  919. processServerMessage(_loc_3.message);
  920. break;
  921. }
  922. default:
  923. {
  924. break;
  925. }
  926. }
  927. _loc_1++;
  928. }
  929. messageInQueue = [];
  930. return;
  931. }// end function
  932.  
  933. protected function drawGUI() : void
  934. {
  935. if (guiVisible)
  936. {
  937. if (!guiShouldBeVisible())
  938. {
  939. hideGUI();
  940. }
  941. }
  942. else if (guiShouldBeVisible())
  943. {
  944. showGUI();
  945. }
  946. if (!guiVisible)
  947. {
  948. return;
  949. }
  950. gui.draw(canvas, map.focusPosition);
  951. return;
  952. }// end function
  953.  
  954. protected function disconnectionTimeUp(event:TimerEvent) : void
  955. {
  956. disconnectionTimer.removeEventListener(TimerEvent.TIMER, disconnectionTimeUp);
  957. disconnectionTimer.stop();
  958. dispatchEvent(new ScreenEvent(ScreenEvent.DISCONNECTED));
  959. return;
  960. }// end function
  961.  
  962. protected function receiveRoomInfo(event:ServerEvent) : void
  963. {
  964. var _loc_2:MapInfo = null;
  965. var _loc_3:Map = null;
  966. setRoundTime(event.info.roundTime);
  967. if (!map && !mapRequest)
  968. {
  969. mapIndex = event.info.mapID;
  970. _loc_2 = MapInfo.mapList[mapIndex];
  971. if (!_loc_2)
  972. {
  973. Debug.error("Bad map index: " + mapIndex);
  974. }
  975. else
  976. {
  977. _loc_3 = _loc_2.create();
  978. if (_loc_3)
  979. {
  980. loadMap(_loc_3);
  981. setRoundTime(event.info.roundTime);
  982. }
  983. else
  984. {
  985. getMap();
  986. }
  987. }
  988. }
  989. return;
  990. }// end function
  991.  
  992. protected function drawOverheads() : void
  993. {
  994. var _loc_3:Thing = null;
  995. var _loc_4:int = 0;
  996. var _loc_5:Thing = null;
  997. var _loc_6:PlayerCharacter = null;
  998. var _loc_1:* = map.characters.concat(map.turrets);
  999. var _loc_2:int = 1;
  1000. while (_loc_2 < _loc_1.length)
  1001. {
  1002.  
  1003. _loc_3 = _loc_1[_loc_2];
  1004. _loc_4 = _loc_2 - 1;
  1005. while (_loc_4 >= 0)
  1006. {
  1007.  
  1008. _loc_5 = _loc_1[_loc_4];
  1009. if (_loc_3.depth < _loc_5.depth)
  1010. {
  1011. _loc_1[(_loc_4 + 1)] = _loc_5;
  1012. _loc_1[_loc_4] = _loc_3;
  1013. }
  1014. else
  1015. {
  1016. break;
  1017. }
  1018. _loc_4 = _loc_4 - 1;
  1019. }
  1020. _loc_2++;
  1021. }
  1022. for each (_loc_3 in _loc_1)
  1023. {
  1024.  
  1025. _loc_6 = _loc_3 as PlayerCharacter;
  1026. if (_loc_6 && (!_loc_6.active || _loc_6.dead))
  1027. {
  1028. continue;
  1029. }
  1030. _loc_3.drawOverhead(canvas, map.cameraOffset);
  1031. }
  1032. return;
  1033. }// end function
  1034.  
  1035. protected function processMap() : void
  1036. {
  1037. map.process();
  1038. return;
  1039. }// end function
  1040.  
  1041. protected function process() : void
  1042. {
  1043. var players:Array;
  1044. if (mapLoadingScreen && mapLoadingScreen.alpha < 1)
  1045. {
  1046. mapLoadingScreen.alpha = Math.max(0, mapLoadingScreen.alpha - 0.05);
  1047. if (mapLoadingScreen.alpha == 0)
  1048. {
  1049. removeMapLoadingScreen();
  1050. }
  1051. }
  1052. if (!map)
  1053. {
  1054. return;
  1055. }
  1056. if (gameSummary)
  1057. {
  1058. players = remotePlayers.concat();
  1059. if (participated)
  1060. {
  1061. players.push(localPlayer);
  1062. }
  1063. gameSummary.refreshScores(players);
  1064. }
  1065. if (gameOver)
  1066. {
  1067. Input.update();
  1068. return;
  1069. }
  1070. if (localPlayer.localCharacter)
  1071. {
  1072. localPlayer.localCharacter.unlag(0);
  1073. }
  1074. try
  1075. {
  1076. processLocalPlayer();
  1077. }
  1078. catch (e:Error)
  1079. {
  1080. Debug.error("Local Player Error: " + e.message);
  1081. try
  1082. {
  1083. }
  1084. processRemotePlayers();
  1085. }
  1086. catch (e:Error)
  1087. {
  1088. Debug.error("Remote Player Error: " + e.message);
  1089. try
  1090. {
  1091. }
  1092. processAI();
  1093. }
  1094. catch (e:Error)
  1095. {
  1096. Debug.error("AI Error: " + e.message);
  1097. try
  1098. {
  1099. }
  1100. processMap();
  1101. }
  1102. catch (e:Error)
  1103. {
  1104. Debug.error("Map Error: " + e.message);
  1105. }
  1106. if (localPlayer.character)
  1107. {
  1108. weaponSlider.update(localPlayer.character.currentWeapon);
  1109. checkBountyCrates();
  1110. }
  1111. if (Input.isDown(Input.SCORES_KEY))
  1112. {
  1113. if (Input.newPress(Input.SCORES_KEY))
  1114. {
  1115. addChild(scoreBoard);
  1116. }
  1117. scoreBoard.update(remotePlayers.concat(localPlayer));
  1118. }
  1119. else if (scoreBoard.parent && localPlayer.team)
  1120. {
  1121. scoreBoard.parent.removeChild(scoreBoard);
  1122. }
  1123. Input.update();
  1124. if (localPlayer.character && localPlayer.character.active)
  1125. {
  1126. sendUpdate();
  1127. }
  1128. return;
  1129. }// end function
  1130.  
  1131. public function start(param1:MMOchaServer) : void
  1132. {
  1133. this.connection = param1;
  1134. setupConnection();
  1135. Time.current = getTimer();
  1136. Time.lastRender = Time.current;
  1137. Time.lastProcess = Time.current;
  1138. scheduledProcess = Time.current;
  1139. processCount = 0;
  1140. frameCount = 0;
  1141. newGame();
  1142. return;
  1143. }// end function
  1144.  
  1145. protected function clearLocalPremiums() : void
  1146. {
  1147. var _loc_1:int = 0;
  1148. var _loc_2:Premium = null;
  1149. for each (_loc_1 in Premium.VALID_PREMIUMS)
  1150. {
  1151.  
  1152. _loc_2 = localPlayer.user.premiums[_loc_1];
  1153. _loc_2.applied = false;
  1154. }
  1155. return;
  1156. }// end function
  1157.  
  1158. protected function enterFrame(event:Event) : void
  1159. {
  1160. drawn = false;
  1161. return;
  1162. }// end function
  1163.  
  1164. protected function sendUpdate() : void
  1165. {
  1166. var _loc_1:String = null;
  1167. var _loc_5:String = null;
  1168. var _loc_2:* = localPlayer.character;
  1169. var _loc_3:int = 0;
  1170. if (_loc_2.collided)
  1171. {
  1172. _loc_3 = _loc_3 + 1;
  1173. }
  1174. var _loc_4:int = 0;
  1175. if (_loc_2.moveDir)
  1176. {
  1177. _loc_4 = _loc_2.moveDir.index + 1;
  1178. }
  1179. if (forcePositionUpdate || _loc_2.collided || _loc_3 != sentMoveFlags || _loc_4 != sentMoveDirIndex || _loc_2.dir.index != sentDirIndex)
  1180. {
  1181. _loc_1 = "1" + posToString(_loc_2.pos) + _loc_4 + "" + _loc_2.dir.index + "" + _loc_3;
  1182. connection.sendGameMessage(_loc_1);
  1183. sentMoveDirIndex = _loc_4;
  1184. sentDirIndex = _loc_2.dir.index;
  1185. sentMoveFlags = _loc_3;
  1186. }
  1187. while (gameMessageOutQueue.length > 0)
  1188. {
  1189.  
  1190. _loc_5 = gameMessageOutQueue.shift();
  1191. connection.sendGameMessage(_loc_5);
  1192. }
  1193. if (messageOutQueue.length)
  1194. {
  1195. _loc_1 = "";
  1196. while (messageOutQueue.length)
  1197. {
  1198.  
  1199. _loc_1 = _loc_1 + (messageOutQueue.shift() + DELIM);
  1200. }
  1201. connection.sendMessage(_loc_1);
  1202. messageOutTimes.push({time:Time.current, message:_loc_1});
  1203. }
  1204. forcePositionUpdate = false;
  1205. return;
  1206. }// end function
  1207.  
  1208. protected function upgradeWeapon(param1:int, param2:int) : void
  1209. {
  1210. var _loc_3:* = localPlayer.character;
  1211. var _loc_4:* = _loc_3.getWeaponByID(param1);
  1212. if (!_loc_3.getWeaponByID(param1))
  1213. {
  1214. return;
  1215. }
  1216. var _loc_5:* = getPremiumWeapon(param2);
  1217. _loc_3.pickupWeapon(_loc_5);
  1218. if (_loc_3.currentWeapon && _loc_3.currentWeapon.weaponID == param1)
  1219. {
  1220. _loc_3.selectWeaponByID(param2, true);
  1221. }
  1222. _loc_3.dropWeaponByID(param1);
  1223. weaponSlider.updateWeaponList(_loc_3.getWeaponBanks());
  1224. return;
  1225. }// end function
  1226.  
  1227. protected function removeMapLoadingScreen() : void
  1228. {
  1229. if (!mapLoadingScreen)
  1230. {
  1231. return;
  1232. }
  1233. if (mapLoadingScreen.parent)
  1234. {
  1235. mapLoadingScreen.parent.removeChild(mapLoadingScreen);
  1236. }
  1237. mapLoadingScreen.removeEventListener(ScreenEvent.MENU, handleLoadingQuit);
  1238. mapLoadingScreen.dispose();
  1239. mapLoadingScreen = null;
  1240. return;
  1241. }// end function
  1242.  
  1243. protected function guiShouldBeVisible() : Boolean
  1244. {
  1245. if (scoreBoard && scoreBoard.parent)
  1246. {
  1247. return false;
  1248. }
  1249. if (gameSummary && gameSummary.parent)
  1250. {
  1251. return false;
  1252. }
  1253. return true;
  1254. }// end function
  1255.  
  1256. protected function second(event:TimerEvent = null) : void
  1257. {
  1258. var _loc_3:* = roundTime - 1;
  1259. roundTime = _loc_3;
  1260. if (roundTime % 20 == 0)
  1261. {
  1262. connection.requestRoundTime();
  1263. }
  1264. if (roundTime == ROUND_START_TIME)
  1265. {
  1266. SoundControl.playUISound(SoundList.GAME_START);
  1267. }
  1268. if (gameOver)
  1269. {
  1270. if (roundTime == ROUND_AD_TIME)
  1271. {
  1272. showAdvertisement();
  1273. }
  1274. if (gameSummary)
  1275. {
  1276. gameSummary.setCountDown(Math.max(0, roundTime));
  1277. }
  1278. if (roundTime <= 0 || roundTime > ROUND_END_TIME)
  1279. {
  1280. newGame();
  1281. }
  1282. return;
  1283. }
  1284. gui.updateFPS(frameCount);
  1285. gui.updateTime(Math.max(0, roundTime - ROUND_END_TIME));
  1286. forceRedraw = true;
  1287. frameCount = 0;
  1288. processCount = 0;
  1289. return;
  1290. }// end function
  1291.  
  1292. protected function peerPremiums(event:ServerEvent) : void
  1293. {
  1294. var _loc_2:* = getPlayerByID(event.source);
  1295. var _loc_3:* = _loc_2.user.premiums[Premium.SHOES_ID];
  1296. _loc_3.owned = true;
  1297. if (_loc_2.character)
  1298. {
  1299. _loc_2.character.speedMultiplier = _loc_3.value;
  1300. }
  1301. return;
  1302. }// end function
  1303.  
  1304. protected function getRemotePlayerByID(param1:String) : RemotePlayer
  1305. {
  1306. var _loc_2:RemotePlayer = null;
  1307. if (localPlayer.id == param1)
  1308. {
  1309. return null;
  1310. }
  1311. for each (_loc_2 in remotePlayers)
  1312. {
  1313.  
  1314. if (_loc_2.id == param1)
  1315. {
  1316. return _loc_2;
  1317. }
  1318. }
  1319. return null;
  1320. }// end function
  1321.  
  1322. protected function deployableDamage(event:DeployableEvent) : void
  1323. {
  1324. queueGameMessage("o" + StringFunctions.padInt(event.deployable.index, 2) + event.source.owner.id + StringFunctions.padInt(event.value, 2));
  1325. return;
  1326. }// end function
  1327.  
  1328. protected function queueWeapon(param1:int) : void
  1329. {
  1330. queueGameMessage("0q" + StringFunctions.padInt(param1, 2));
  1331. return;
  1332. }// end function
  1333.  
  1334. protected function createBountyItemsFromString(param1:String, param2:Character = null) : void
  1335. {
  1336. var _loc_3:Position = null;
  1337. var _loc_4:Position = null;
  1338. var _loc_5:int = 0;
  1339. var _loc_6:BountyItem = null;
  1340. if (param2)
  1341. {
  1342. _loc_3 = param2.pos.clone();
  1343. }
  1344. while (param1.length >= 13)
  1345. {
  1346.  
  1347. _loc_4 = stringToPos(param1.substr(3, 10));
  1348. _loc_5 = parseInt(param1.charAt(0));
  1349. _loc_6 = new BountyCrate(_loc_5, _loc_4);
  1350. if (_loc_3)
  1351. {
  1352. _loc_6.animateFrom(_loc_3);
  1353. }
  1354. _loc_6.index = parseInt(param1.substr(1, 2));
  1355. map.removeBountyItemByIndex(_loc_6.index);
  1356. map.addBountyItem(_loc_6);
  1357. param1 = param1.substr(13);
  1358. }
  1359. return;
  1360. }// end function
  1361.  
  1362. protected function hideGUI() : void
  1363. {
  1364. guiVisible = false;
  1365. if (weaponSlider.parent)
  1366. {
  1367. weaponSlider.parent.removeChild(weaponSlider);
  1368. }
  1369. return;
  1370. }// end function
  1371.  
  1372. protected function endGame(param1:String) : void
  1373. {
  1374. if (gameOver)
  1375. {
  1376. return;
  1377. }
  1378. if (scoreBoard.parent)
  1379. {
  1380. scoreBoard.parent.removeChild(scoreBoard);
  1381. }
  1382. gameSummary = new GameSummary();
  1383. var _loc_2:* = remotePlayers.concat();
  1384. if (participated)
  1385. {
  1386. _loc_2.push(localPlayer);
  1387. }
  1388. gameSummary.displaySummary(_loc_2, param1);
  1389. addChild(gameSummary);
  1390. hideGUI();
  1391. SoundControl.playUISound(SoundList.END_ROUND);
  1392. localPlayer.user.stats.kills = localPlayer.user.stats.kills + localPlayer.kills;
  1393. localPlayer.user.stats.deaths = localPlayer.user.stats.deaths + localPlayer.deaths;
  1394. localPlayer.user.stats.bountyPoints = localPlayer.user.stats.bountyPoints + localPlayer.bountyPoints;
  1395. if (localPlayer == gameSummary.winner)
  1396. {
  1397. var _loc_3:* = localPlayer.user.stats;
  1398. var _loc_4:* = localPlayer.user.stats.wins + 1;
  1399. _loc_3.wins = _loc_4;
  1400. }
  1401. else
  1402. {
  1403. var _loc_3:* = localPlayer.user.stats;
  1404. var _loc_4:* = localPlayer.user.stats.losses + 1;
  1405. _loc_3.losses = _loc_4;
  1406. }
  1407. draw();
  1408. localPlayer.exitSpyMode();
  1409. SoundControl.stopAllAreaSounds();
  1410. gameOver = true;
  1411. return;
  1412. }// end function
  1413.  
  1414. protected function handleLoadingQuit(event:ScreenEvent) : void
  1415. {
  1416. removeMapLoadingScreen();
  1417. quit();
  1418. return;
  1419. }// end function
  1420.  
  1421. protected function receiveMessage(event:ServerEvent) : void
  1422. {
  1423. var _loc_2:Object = null;
  1424. var _loc_3:int = 0;
  1425. var _loc_4:int = 0;
  1426. var _loc_5:RemotePlayer = null;
  1427. if (event.source == localPlayer.id)
  1428. {
  1429. if (messageOutTimes.length)
  1430. {
  1431. _loc_2 = messageOutTimes.shift();
  1432. _loc_3 = _loc_2.time;
  1433. _loc_4 = getTimer() - _loc_3;
  1434. }
  1435. return;
  1436. }
  1437. if (event.message == M_PING_REQUEST)
  1438. {
  1439. connection.sendPrivate(M_PING_RESPONSE, event.source);
  1440. return;
  1441. }
  1442. if (event.message == M_PING_RESPONSE)
  1443. {
  1444. _loc_5 = getRemotePlayerByID(event.source);
  1445. if (_loc_5)
  1446. {
  1447. _loc_5.pingReceived();
  1448. }
  1449. return;
  1450. }
  1451. messageInQueue.push(new QueuedMessage(QueuedMessage.CHAT_BUNDLE, event.source, event.message));
  1452. return;
  1453. }// end function
  1454.  
  1455. protected function loadMap(param1:Map) : void
  1456. {
  1457. var _loc_2:int = 0;
  1458. var _loc_3:PlayerCharacter = null;
  1459. var _loc_4:RemotePlayer = null;
  1460. var _loc_5:Premium = null;
  1461. var _loc_6:String = null;
  1462. var _loc_7:Deployable = null;
  1463. this.map = param1;
  1464. param1.addCamera(localPlayer.spyCam);
  1465. param1.addEventListener(DeployableEvent.DAMAGE, deployableDamage);
  1466. param1.addEventListener(DeployableEvent.ACTIVATE, deployableActivate);
  1467. resetUI();
  1468. for each (_loc_4 in remotePlayers)
  1469. {
  1470.  
  1471. if (!_loc_4.character)
  1472. {
  1473. _loc_4.createCharacter();
  1474. _loc_3 = _loc_4.character;
  1475. _loc_4.character.active = false;
  1476. _loc_4.character.pickupRemoteWeapons();
  1477. _loc_5 = _loc_4.user.premiums[Premium.SHOES_ID];
  1478. if (_loc_5.owned)
  1479. {
  1480. _loc_4.character.speedMultiplier = _loc_5.value;
  1481. }
  1482. }
  1483. param1.addCharacter(_loc_4.character);
  1484. }
  1485. _loc_3 = localPlayer.character;
  1486. if (_loc_3)
  1487. {
  1488. _loc_3.removeEventListener(FireEvent.FIRE, characterFire);
  1489. _loc_3.removeEventListener(CharacterEvent.WEAPON_SWITCH, characterWeaponSwitch);
  1490. _loc_3.removeEventListener(CharacterEvent.HURT, characterHurt);
  1491. _loc_3.removeEventListener(CharacterEvent.RESPAWN, characterRespawn);
  1492. }
  1493. localPlayer.createCharacter();
  1494. _loc_3 = localPlayer.character;
  1495. _loc_3.addEventListener(FireEvent.FIRE, characterFire);
  1496. _loc_3.addEventListener(CharacterEvent.WEAPON_SWITCH, characterWeaponSwitch);
  1497. _loc_3.addEventListener(CharacterEvent.HURT, characterHurt);
  1498. _loc_3.addEventListener(CharacterEvent.RESPAWN, characterRespawn);
  1499. _loc_3.active = false;
  1500. applyQuickPlayProfile();
  1501. param1.addCharacter(_loc_3);
  1502. clearLocalPremiums();
  1503. applyLocalPremiums();
  1504. _loc_3.animate();
  1505. if (existingDeployablesString)
  1506. {
  1507. _loc_6 = existingDeployablesString;
  1508. while (_loc_6.length >= 14)
  1509. {
  1510.  
  1511. _loc_7 = createDeployableFromString(_loc_6.substr(0, 12), false);
  1512. if (_loc_7)
  1513. {
  1514. _loc_7.setHealth(parseInt(_loc_6.substr(12, 2)));
  1515. }
  1516. _loc_6 = _loc_6.substr(14);
  1517. }
  1518. }
  1519. existingDeployablesString = null;
  1520. if (existingPickupsString)
  1521. {
  1522. createBountyItemsFromString(existingPickupsString);
  1523. }
  1524. existingPickupsString = null;
  1525. weaponSlider.clear();
  1526. weaponSlider.updateWeaponList(_loc_3.getWeaponBanks());
  1527. updateScores();
  1528. checkProcessTimer.start();
  1529. secondTimer.start();
  1530. if (stage)
  1531. {
  1532. stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown, false, 0, true);
  1533. stage.addEventListener(KeyboardEvent.KEY_UP, handleKeyUp, false, 0, true);
  1534. }
  1535. process();
  1536. draw();
  1537. if (mapLoadingScreen)
  1538. {
  1539. mapLoadingScreen.alpha = 0.95;
  1540. }
  1541. return;
  1542. }// end function
  1543.  
  1544. protected function receiveMostWantedStatus(event:ServerEvent) : void
  1545. {
  1546. updateScores();
  1547. return;
  1548. }// end function
  1549.  
  1550. protected function newGame() : void
  1551. {
  1552. var _loc_1:RemotePlayer = null;
  1553. if (gameSummary)
  1554. {
  1555. gameSummary.dispose();
  1556. if (gameSummary.parent)
  1557. {
  1558. gameSummary.parent.removeChild(gameSummary);
  1559. }
  1560. gameSummary = null;
  1561. }
  1562. SoundControl.stopAllAreaSounds();
  1563. if (roundTime != -1)
  1564. {
  1565. gameOver = false;
  1566. }
  1567. for each (_loc_1 in remotePlayers)
  1568. {
  1569.  
  1570. _loc_1.removeCharacter();
  1571. _loc_1.newRound();
  1572. }
  1573. localPlayer.newRound();
  1574. gui.setMoney(localPlayer.money);
  1575. gui.setBountyPoints(localPlayer.bountyPoints);
  1576. if (map)
  1577. {
  1578. map.removeEventListener(DeployableEvent.DAMAGE, deployableDamage);
  1579. map.removeEventListener(DeployableEvent.ACTIVATE, deployableActivate);
  1580. map.dispose();
  1581. map = null;
  1582. }
  1583. checkProcessTimer.stop();
  1584. secondTimer.stop();
  1585. if (stage)
  1586. {
  1587. stage.removeEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
  1588. stage.removeEventListener(KeyboardEvent.KEY_UP, handleKeyUp);
  1589. }
  1590. connection.requestRoomInfo(connection.room);
  1591. showInitUI();
  1592. if (mapLoadingScreen)
  1593. {
  1594. removeMapLoadingScreen();
  1595. }
  1596. mapLoadingScreen = new MapLoadingScreen();
  1597. mapLoadingScreen.addEventListener(ScreenEvent.MENU, handleLoadingQuit);
  1598. addChild(mapLoadingScreen);
  1599. return;
  1600. }// end function
  1601.  
  1602. protected function consoleInput(event:ConsoleEvent) : void
  1603. {
  1604. if (!event.command)
  1605. {
  1606. return;
  1607. }
  1608. switch(event.command.toLowerCase())
  1609. {
  1610. case "exit":
  1611. case "quit":
  1612. {
  1613. quit();
  1614. break;
  1615. }
  1616. default:
  1617. {
  1618. break;
  1619. }
  1620. }
  1621. return;
  1622. }// end function
  1623.  
  1624. protected function getPremiumWeapon(param1:int) : Weapon
  1625. {
  1626. return WeaponInfo.lookup(param1).create();
  1627. }// end function
  1628.  
  1629. protected function queueMessage(param1:String) : void
  1630. {
  1631. messageOutQueue.push(param1);
  1632. return;
  1633. }// end function
  1634.  
  1635. protected function floodTick(event:TimerEvent) : void
  1636. {
  1637. if (floodCount > 0)
  1638. {
  1639. var _loc_3:* = floodCount - 1;
  1640. floodCount = _loc_3;
  1641. if (floodCount == 0)
  1642. {
  1643. floodWarningGiven = false;
  1644. }
  1645. }
  1646. return;
  1647. }// end function
  1648.  
  1649. protected function peerDisconnected(event:ServerEvent) : void
  1650. {
  1651. var _loc_3:int = 0;
  1652. var _loc_4:Deployable = null;
  1653. var _loc_2:* = getRemotePlayerByID(event.source);
  1654. if (!_loc_2)
  1655. {
  1656. return;
  1657. }
  1658. if (map && _loc_2.character)
  1659. {
  1660. map.removeCharacter(_loc_2.character);
  1661. }
  1662. for each (_loc_4 in _loc_2.getDeployables())
  1663. {
  1664.  
  1665. map.removeDeployable(_loc_4);
  1666. }
  1667. _loc_3 = remotePlayers.length - 1;
  1668. while (_loc_3 >= 0)
  1669. {
  1670.  
  1671. if (remotePlayers[_loc_3] == _loc_2)
  1672. {
  1673. gui.addMessage(_loc_2.name + " left the game", false, true);
  1674. remotePlayers.splice(_loc_3, 1);
  1675. break;
  1676. }
  1677. _loc_3 = _loc_3 - 1;
  1678. }
  1679. updateScores();
  1680. return;
  1681. }// end function
  1682.  
  1683. public function freeInput(param1:Object) : void
  1684. {
  1685. var _loc_2:* = inputStack.indexOf(param1);
  1686. if (_loc_2 >= 0)
  1687. {
  1688. inputStack.splice(_loc_2, 1);
  1689. }
  1690. return;
  1691. }// end function
  1692.  
  1693. protected function handleWeaponSliderSelect(event:WeaponSliderEvent) : void
  1694. {
  1695. var _loc_2:* = event.weapon;
  1696. var _loc_3:* = localPlayer.character;
  1697. if (!_loc_2 || !_loc_3 || _loc_2 == _loc_3.currentWeapon)
  1698. {
  1699. return;
  1700. }
  1701. _loc_3.selectWeaponByID(_loc_2.weaponID);
  1702. return;
  1703. }// end function
  1704.  
  1705. public function getDeployable(param1:Player, param2:int) : Deployable
  1706. {
  1707. return param1.getDeployableByID(param2);
  1708. }// end function
  1709.  
  1710. protected function addPremiumEquipment(param1:int, param2:int) : void
  1711. {
  1712. var _loc_3:* = localPlayer.character;
  1713. var _loc_4:* = _loc_3.getWeaponByID(param1);
  1714. if (_loc_3.getWeaponByID(param1))
  1715. {
  1716. if (_loc_4.ammo)
  1717. {
  1718. _loc_4.ammo.setCount(param2);
  1719. }
  1720. }
  1721. else
  1722. {
  1723. _loc_4 = getPremiumWeapon(param1);
  1724. if (_loc_4.ammo)
  1725. {
  1726. _loc_4.ammo.setCount(param2);
  1727. }
  1728. _loc_3.pickupWeapon(_loc_4);
  1729. }
  1730. weaponSlider.updateWeaponList(_loc_3.getWeaponBanks());
  1731. return;
  1732. }// end function
  1733.  
  1734. protected function receiveGlobalMessage(event:ServerEvent) : void
  1735. {
  1736. var _loc_2:* = event.message;
  1737. if (_loc_2 && _loc_2.length > 0)
  1738. {
  1739. gui.showGlobal(_loc_2);
  1740. }
  1741. return;
  1742. }// end function
  1743.  
  1744. protected function characterDeath(param1:LocalCharacter, param2:HasOwner, param3:int) : void
  1745. {
  1746. gui.addKillMessage(param2.owner, param1.owner, param3);
  1747. gui.showWarning("You will respawn in: [seconds]", param1.respawnTime);
  1748. forcePositionUpdate = true;
  1749. return;
  1750. }// end function
  1751.  
  1752. protected function processPlayerMessage(param1:Player, param2:String) : void
  1753. {
  1754. var _loc_3:Position = null;
  1755. var _loc_4:Direction = null;
  1756. var _loc_5:int = 0;
  1757. var _loc_6:Weapon = null;
  1758. var _loc_9:int = 0;
  1759. var _loc_10:Direction = null;
  1760. var _loc_11:uint = 0;
  1761. var _loc_12:Boolean = false;
  1762. var _loc_13:int = 0;
  1763. var _loc_14:Player = null;
  1764. var _loc_15:int = 0;
  1765. var _loc_16:int = 0;
  1766. var _loc_17:BountyItem = null;
  1767. var _loc_18:Number = NaN;
  1768. var _loc_19:int = 0;
  1769. var _loc_20:Shot = null;
  1770. var _loc_7:* = param1.isLocal;
  1771. var _loc_8:* = param1.character;
  1772. switch(param2.charAt(0))
  1773. {
  1774. case "0":
  1775. {
  1776. switch(param2.charAt(1))
  1777. {
  1778. case "k":
  1779. {
  1780. if (_loc_7)
  1781. {
  1782. break;
  1783. }
  1784. param1.team = parseInt(param2.substr(2));
  1785. updateScores();
  1786. break;
  1787. }
  1788. case "q":
  1789. {
  1790. if (_loc_7)
  1791. {
  1792. break;
  1793. }
  1794. _loc_8.selectWeaponByID(parseInt(param2.substr(2)));
  1795. break;
  1796. }
  1797. case "l":
  1798. {
  1799. if (_loc_7)
  1800. {
  1801. break;
  1802. }
  1803. _loc_5 = parseInt(param2.substr(2, 2));
  1804. _loc_6 = _loc_8.getWeaponByID(_loc_5);
  1805. if (_loc_6)
  1806. {
  1807. switch(param2.charAt(4))
  1808. {
  1809. case BUY_ACTION:
  1810. {
  1811. break;
  1812. }
  1813. case UPGRADE1_ACTION:
  1814. {
  1815. _loc_6.upgrade1.buy();
  1816. break;
  1817. }
  1818. case UPGRADE2_ACTION:
  1819. {
  1820. _loc_6.upgrade2.buy();
  1821. break;
  1822. }
  1823. default:
  1824. {
  1825. break;
  1826. }
  1827. }
  1828. }
  1829. break;
  1830. }
  1831. default:
  1832. {
  1833. break;
  1834. }
  1835. }
  1836. break;
  1837. }
  1838. case "1":
  1839. {
  1840. if (_loc_7)
  1841. {
  1842. break;
  1843. }
  1844. _loc_3 = stringToPos(param2.substr(1, 10));
  1845. _loc_9 = parseInt(param2.charAt(11));
  1846. _loc_10 = null;
  1847. if (_loc_9 > 0)
  1848. {
  1849. _loc_10 = Direction.list[(_loc_9 - 1)];
  1850. }
  1851. _loc_4 = Direction.list[parseInt(param2.charAt(12))];
  1852. _loc_11 = parseInt(param2.charAt(13));
  1853. _loc_8.moving = _loc_10 != null;
  1854. _loc_8.strafing = true;
  1855. _loc_12 = (_loc_11 & 1) > 0;
  1856. if (_loc_12 || !_loc_10 || _loc_8.moveDir != _loc_10)
  1857. {
  1858. _loc_8.pos.copy(_loc_3);
  1859. }
  1860. if (_loc_10 != null && _loc_10 != _loc_8.moveDir)
  1861. {
  1862. _loc_8.applySmoothing();
  1863. }
  1864. _loc_8.moveDir = _loc_10;
  1865. _loc_8.dir = _loc_4;
  1866. _loc_8.firePos.copy(_loc_3);
  1867. _loc_8.updateWeapons();
  1868. if (!_loc_8.active)
  1869. {
  1870. _loc_8.active = true;
  1871. updateScores();
  1872. }
  1873. break;
  1874. }
  1875. case "4":
  1876. {
  1877. if (_loc_7)
  1878. {
  1879. break;
  1880. }
  1881. if (_loc_8.currentWeapon)
  1882. {
  1883. localPlayer.localCharacter.unlag(param1.ping);
  1884. _loc_18 = Math.PI / 180 * parseInt(param2.substr(1, 3));
  1885. _loc_19 = parseInt(param2.substr(4));
  1886. _loc_20 = _loc_8.currentWeapon.shoot(_loc_18, _loc_19);
  1887. map.executeShot(_loc_20);
  1888. }
  1889. break;
  1890. }
  1891. case "6":
  1892. {
  1893. if (_loc_7)
  1894. {
  1895. break;
  1896. }
  1897. _loc_13 = parseInt(param2.substr(1));
  1898. if (_loc_13 > 0)
  1899. {
  1900. map.addBlood(_loc_8, _loc_8.hp - _loc_13);
  1901. _loc_8.setHealth(_loc_13);
  1902. }
  1903. break;
  1904. }
  1905. case "7":
  1906. {
  1907. _loc_14 = getPlayerByID(param2.substr(1, 3));
  1908. if (!_loc_7 || !_loc_8.dead)
  1909. {
  1910. map.addBlood(_loc_8, _loc_8.hp);
  1911. _loc_8.setHealth(0);
  1912. _loc_5 = parseInt(param2.substr(4, 2));
  1913. gui.addKillMessage(_loc_14, param1, _loc_5);
  1914. }
  1915. var _loc_21:* = param1;
  1916. var _loc_22:* = param1.deaths + 1;
  1917. _loc_21.deaths = _loc_22;
  1918. if (_loc_14 != param1)
  1919. {
  1920. var _loc_21:* = _loc_14;
  1921. var _loc_22:* = _loc_14.kills + 1;
  1922. _loc_21.kills = _loc_22;
  1923. }
  1924. updateScores();
  1925. createBountyItemsFromString(param2.substr(6), param1.character);
  1926. break;
  1927. }
  1928. case "8":
  1929. {
  1930. if (_loc_7)
  1931. {
  1932. break;
  1933. }
  1934. _loc_3 = stringToCellPos(param2.substr(1, 6));
  1935. _loc_3.x = _loc_3.x + 0.5;
  1936. _loc_3.y = _loc_3.y + 0.5;
  1937. _loc_8.pos.copy(_loc_3);
  1938. _loc_8.respawn();
  1939. _loc_8.moveDir = null;
  1940. if (!_loc_8.active)
  1941. {
  1942. _loc_8.active = true;
  1943. updateScores();
  1944. }
  1945. break;
  1946. }
  1947. case "m":
  1948. {
  1949. _loc_15 = parseInt(param2.substr(1, 2));
  1950. _loc_16 = parseInt(param2.substr(3));
  1951. _loc_17 = map.getBountyItemByIndex(_loc_15);
  1952. if (_loc_17)
  1953. {
  1954. pickupBountyItem(param1, _loc_17, _loc_16);
  1955. }
  1956. break;
  1957. }
  1958. default:
  1959. {
  1960. break;
  1961. }
  1962. }
  1963. return;
  1964. }// end function
  1965.  
  1966. protected function get currentInput() : Object
  1967. {
  1968. if (!inputStack || inputStack.length == 0)
  1969. {
  1970. return null;
  1971. }
  1972. return inputStack[(inputStack.length - 1)];
  1973. }// end function
  1974.  
  1975. protected function receivePlayerMessage(event:ServerEvent) : void
  1976. {
  1977. messageInQueue.push(new QueuedMessage(QueuedMessage.PLAYER_MESSAGE, event.source, event.message));
  1978. return;
  1979. }// end function
  1980.  
  1981. protected function toggleMenu() : void
  1982. {
  1983. dispatchEvent(new ScreenEvent(ScreenEvent.MENU));
  1984. return;
  1985. }// end function
  1986.  
  1987. protected function deployableActivate(event:DeployableEvent) : void
  1988. {
  1989. var _loc_2:* = M_DEPLOYABLE_ACTIVATE + event.deployable.index;
  1990. queueMessage(_loc_2);
  1991. return;
  1992. }// end function
  1993.  
  1994. protected function processAI() : void
  1995. {
  1996. return;
  1997. }// end function
  1998.  
  1999. protected function receiveRoundTime(event:ServerEvent) : void
  2000. {
  2001. setRoundTime(int(event.info));
  2002. return;
  2003. }// end function
  2004.  
  2005. protected function characterHurt(event:CharacterEvent) : void
  2006. {
  2007. var _loc_2:* = event.target as LocalCharacter;
  2008. if (!_loc_2)
  2009. {
  2010. return;
  2011. }
  2012. map.addScreenShake(new ScreenShake(_loc_2.pos, 1.5, 200));
  2013. if (_loc_2.dead)
  2014. {
  2015. characterDeath(_loc_2, event.source, event.weaponID);
  2016. }
  2017. queueGameMessage("6" + event.source.owner.id + StringFunctions.padInt(event.weaponID, 2) + StringFunctions.padInt(event.damage, 2));
  2018. return;
  2019. }// end function
  2020.  
  2021. protected function characterRespawn(event:CharacterEvent) : void
  2022. {
  2023. respawnLocalCharacter();
  2024. return;
  2025. }// end function
  2026.  
  2027. protected function queueGameMessage(param1:String) : void
  2028. {
  2029. gameMessageOutQueue.push(param1);
  2030. return;
  2031. }// end function
  2032.  
  2033. protected function processBundle(param1:Player, param2:String) : void
  2034. {
  2035. var _loc_3:int = 0;
  2036. var _loc_6:String = null;
  2037. var _loc_7:String = null;
  2038. var _loc_8:String = null;
  2039. var _loc_9:int = 0;
  2040. var _loc_10:Deployable = null;
  2041. var _loc_4:* = param2.split(DELIM);
  2042. var _loc_5:Array = [];
  2043. for each (_loc_6 in _loc_4)
  2044. {
  2045.  
  2046. _loc_8 = _loc_6.charAt(0);
  2047. switch(_loc_8)
  2048. {
  2049. case M_DEPLOYABLE_ACTIVATE:
  2050. {
  2051. _loc_5.push(_loc_6.substr(1));
  2052. break;
  2053. }
  2054. case M_CHAT:
  2055. {
  2056. gui.addChatMessage(param1, LanguageFilter.filter(_loc_6.substr(1)));
  2057. break;
  2058. }
  2059. default:
  2060. {
  2061. break;
  2062. }
  2063. }
  2064. }
  2065. for each (_loc_7 in _loc_5)
  2066. {
  2067.  
  2068. _loc_9 = parseInt(_loc_7);
  2069. _loc_10 = getDeployable(param1, _loc_9);
  2070. if (_loc_10)
  2071. {
  2072. _loc_10.activate();
  2073. }
  2074. }
  2075. return;
  2076. }// end function
  2077.  
  2078. protected function disableConnection() : void
  2079. {
  2080. connection.removeEventListener(ServerEvent.HANDSHAKE, peerJoined);
  2081. connection.removeEventListener(ServerEvent.DISCONNECTED, disconnected);
  2082. connection.removeEventListener(ServerEvent.PEER_DISCONNECTED, peerDisconnected);
  2083. connection.removeEventListener(ServerEvent.MESSAGE, receiveMessage);
  2084. connection.removeEventListener(ServerEvent.PLAYER_MESSAGE, receivePlayerMessage);
  2085. connection.removeEventListener(ServerEvent.SERVER_MESSAGE, receiveServerMessage);
  2086. connection.removeEventListener(ServerEvent.GLOBAL_MESSAGE, receiveGlobalMessage);
  2087. connection.removeEventListener(ServerEvent.ROOM_INFO, receiveRoomInfo);
  2088. connection.removeEventListener(ServerEvent.ROUND_TIME, receiveRoundTime);
  2089. connection.removeEventListener(ServerEvent.MOST_WANTED_CHANGE, receiveMostWantedStatus);
  2090. connection.removeEventListener(ServerEvent.PEER_PREMIUMS, peerPremiums);
  2091. connection.removeEventListener(ServerEvent.PREMIUMS_REFRESHED, premiumsRefreshed);
  2092. return;
  2093. }// end function
  2094.  
  2095. protected function checkBountyCrates() : void
  2096. {
  2097. var _loc_3:BountyItem = null;
  2098. var _loc_1:* = localPlayer.character;
  2099. if (!_loc_1 || !_loc_1.active || _loc_1.dead)
  2100. {
  2101. return;
  2102. }
  2103. var _loc_2:* = map.bountyItems.length - 1;
  2104. while (_loc_2 >= 0)
  2105. {
  2106.  
  2107. _loc_3 = map.bountyItems[_loc_2];
  2108. if (_loc_3.checkRange(_loc_1))
  2109. {
  2110. map.claimBountyItem(_loc_3);
  2111. queueGameMessage("0m" + StringFunctions.padInt(_loc_3.index, 2));
  2112. }
  2113. _loc_2 = _loc_2 - 1;
  2114. }
  2115. return;
  2116. }// end function
  2117.  
  2118. protected function applyLocalPremiums() : void
  2119. {
  2120. var _loc_1:int = 0;
  2121. for each (_loc_1 in Premium.VALID_PREMIUMS)
  2122. {
  2123.  
  2124. if (localPlayer.premiumOwned(_loc_1))
  2125. {
  2126. applyPremium(_loc_1);
  2127. }
  2128. }
  2129. return;
  2130. }// end function
  2131.  
  2132. protected function pingPlayer(param1:Player) : void
  2133. {
  2134. lastPing = Time.current;
  2135. param1.pingSent();
  2136. connection.sendPrivate(M_PING_REQUEST, param1.id);
  2137. return;
  2138. }// end function
  2139.  
  2140. protected function showGUI() : void
  2141. {
  2142. guiVisible = true;
  2143. addChild(weaponSlider);
  2144. return;
  2145. }// end function
  2146.  
  2147. protected function sendChatMessage(param1:String) : void
  2148. {
  2149. queueMessage(M_CHAT + param1);
  2150. return;
  2151. }// end function
  2152.  
  2153. static function stringToCellPos(param1:String) : Position
  2154. {
  2155. return new Position(parseInt(param1.substr(0, 3)), parseInt(param1.substr(3, 3)));
  2156. }// end function
  2157.  
  2158. static function stringToPos(param1:String) : Position
  2159. {
  2160. return new Position(parseInt(param1.substr(0, 5)) / 100, parseInt(param1.substr(5, 5)) / 100);
  2161. }// end function
  2162.  
  2163. static function posToString(param1:Position) : String
  2164. {
  2165. return StringFunctions.padInt(int(param1.x * 100), 5) + StringFunctions.padInt(int(param1.y * 100), 5);
  2166. }// end function
  2167.  
  2168. static function getWeaponIDFromDeployableCode(param1:String) : int
  2169. {
  2170. switch(param1)
  2171. {
  2172. case "0":
  2173. default:
  2174. {
  2175. return WeaponInfo.BARREL_PLANTER_ID;
  2176. }
  2177. case "2":
  2178. {
  2179. return WeaponInfo.BARRICADE_PLANTER_ID;
  2180. }
  2181. case "3":
  2182. {
  2183. return WeaponInfo.CHARGE_PACK_PLANTER_ID;
  2184. }
  2185. case "4":
  2186. {
  2187. return WeaponInfo.CLAYMORE_PLANTER_ID;
  2188. }
  2189. case "5":
  2190. {
  2191. return WeaponInfo.TURRET_MG_PLANTER_ID;
  2192. }
  2193. case :
  2194. {
  2195. return WeaponInfo.TURRET_MORTAR_PLANTER_ID;
  2196. break;
  2197. }
  2198. }
  2199. }// end function
  2200.  
  2201. static function cellPosToString(param1:Position) : String
  2202. {
  2203. return StringFunctions.padInt(int(param1.x), 3) + StringFunctions.padInt(int(param1.y), 3);
  2204. }// end function
  2205.  
  2206. }
  2207. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement