Advertisement
Guest User

sc.MapModel override v2.0

a guest
Aug 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 69.98 KB | None | 0 0
  1. ig.module("game.feature").requires("game.main").defines(function() {
  2. sc.MapModel = ig.GameAddon.extend({
  3. observers: [],
  4. activeLandmarks: {},
  5. areas: null,
  6. areasVisited: {},
  7. currentPlayerArea: null,
  8. currentArea: null,
  9. currentPlayerFloor: 0,
  10. currentFloor: 0,
  11. currentMap: null,
  12. unknownArea: null,
  13. teleportEvent: null,
  14. _usedNames: [],
  15. init: function() {
  16. this.parent("MapModel");
  17. console.log("this is a console.log message!");
  18. ig.storage.register(this);
  19. window.wm && ig.database.register("areas", "AreaList", "Areas");
  20. this.initAreas();
  21. console.log("here are the areas registered in the game:", this.areas);
  22. ig.vars.registerVarAccessor("area", this, "VarAreaEditor");
  23. ig.vars.registerVarAccessor("location", this, "VarLocationEditor")
  24. },
  25. getTotalAreasFound: function(a) {
  26. var b = 0,
  27. c = 0,
  28. e;
  29. for (e in this.areas)
  30. if (this.areas[e].track) {
  31. this.areasVisited[e.toCamel()] && b++;
  32. c++
  33. } return a ? b / c : b
  34. },
  35. getTotalLandmarksFound: function(a) {
  36. var b = 0,
  37. c = 0,
  38. e;
  39. for (e in this.areas)
  40. for (var f in this.areas[e].landmarks)
  41. if (this.areas[e].track) {
  42. this.activeLandmarks[e] && this.activeLandmarks[e][f] && b++;
  43. c++
  44. } return a ? b / c : b
  45. },
  46. getTotalChestsFound: function(a) {
  47. var b = 0,
  48. c = 0,
  49. e;
  50. for (e in this.areas)
  51. if (this.areas[e].track) {
  52. var f =
  53. sc.stats.getMap("chests", e) || 0;
  54. f > this.areas[e].chests && (f = this.areas[e].chests);
  55. b = b + f;
  56. c = c + (this.areas[e].chests || 0)
  57. } return a ? b / c : b
  58. },
  59. getTotalChests: function() {
  60. var a = 0,
  61. b;
  62. for (b in this.areas) this.areas[b].track && (a = a + (this.areas[b].chests || 0));
  63. return a
  64. },
  65. hasAllAreasFound: function() {
  66. for (var a in this.areas)
  67. if (this.areas[a].track && !this.areasVisited[a.toCamel()]) return false;
  68. return true
  69. },
  70. getTotalLandmarksFoundInArea: function(a) {
  71. if (a = this.activeLandmarks[a]) {
  72. var b = 0,
  73. c;
  74. for (c in a) b++;
  75. return b || 0
  76. }
  77. },
  78. levelLoadStartOrder: 10,
  79. onLevelLoadStart: function(a) {
  80. this.currentMap = a.name.toKey("", "");
  81. a = a.attributes && a.attributes.area || "fallback";
  82. this.updateVisitedArea(a);
  83. var b = false;
  84. this.currentPlayerArea && this.currentPlayerArea.path != a ? b = true : this
  85. .currentPlayerArea || (b = true);
  86. if (b) {
  87. this.currentPlayerArea = new sc.AreaLoadable(a);
  88. this.currentPlayerArea.addLoadListener(this);
  89. this.currentArea = this.currentPlayerArea
  90. } else {
  91. this.currentArea = this.currentPlayerArea;
  92. this.onLoadableComplete()
  93. }
  94. },
  95. levelLoadedOrder: 150,
  96. onLevelLoaded: function() {
  97. var a =
  98. ig.game.entities,
  99. b = a.length;
  100. Math.seedrandomSeed(ig.game.mapName);
  101. this._usedNames.length = 0;
  102. for (var c = sc.quickmodel.names, e = 0, f = sc.NPC_GENDER.BOTH; b--;) {
  103. var g = a[b];
  104. if (g && g instanceof ig.ENTITY.NPC && !g.displayName && !g.character.data.name) {
  105. for (var f = sc.NPC_GENDER[g.character.data.gender] || sc.NPC_GENDER.BOTH, h = Math.floor(
  106. Math.randomSeed() * c.length), e = 0; !this.canUseGenderName(f, sc.NPC_GENDER[c[h]
  107. .gender]) || this._usedNames[h];) {
  108. h = Math.floor(Math.randomSeed() * c.length);
  109. e++;
  110. if (e >= 3) break
  111. }
  112. this._usedNames[h] =
  113. true;
  114. g.displayNameRandom = ig.LangLabel.getText(c[h].name)
  115. }
  116. }
  117. sc.Model.notifyObserver(sc.map, sc.MAP_EVENT.MAP_ENTERED)
  118. },
  119. canUseGenderName: function(a, b) {
  120. switch (b || 0) {
  121. case sc.NPC_GENDER.BOTH:
  122. return a == sc.NPC_GENDER.MALE || a == sc.NPC_GENDER.FEMALE;
  123. case sc.NPC_GENDER.MALE:
  124. return a == sc.NPC_GENDER.MALE;
  125. case sc.NPC_GENDER.FEMALE:
  126. return a == sc.NPC_GENDER.FEMALE
  127. }
  128. return false
  129. },
  130. onReset: function() {
  131. this.areasVisited = {};
  132. this.activeLandmarks = {}
  133. },
  134. onVarAccess: function(a, b) {
  135. if (b[0] == "area") {
  136. var c = b[1];
  137. if (this.areas[c]) switch (b[2]) {
  138. case "name":
  139. return ig.LangLabel.getText(this.areas[c].name);
  140. case "isCurrent":
  141. return this.currentPlayerArea && this.currentPlayerArea.path == c;
  142. case "isBoosted":
  143. return this.getAreaItemToggleState(sc.AREA_ITEM_TYPE.BOOSTER, c);
  144. case "chests":
  145. return (this.areas[c].chests || 0) + "";
  146. case "landmark":
  147. switch (b[3]) {
  148. case "name":
  149. return ig.LangLabel.getText(this.areas[c].landmarks[b[4]].name);
  150. case "active":
  151. return this.activeLandmarks[b[1]][b[4]] ? true : false
  152. }
  153. break;
  154. case "unlocked":
  155. return this.areasVisited[c.toCamel()] ? true : false
  156. }
  157. }
  158. if (b[0] == "location") switch (b[1]) {
  159. case "current":
  160. return this.currentPlayerArea &&
  161. this.currentPlayerArea.path;
  162. case "isMapDungeon":
  163. return this.isDungeon();
  164. case "isAreaDungon":
  165. return this.isDungeon(true)
  166. }
  167. throw Error("Unsupported var access path: " + a);
  168. },
  169. initAreas: function() {
  170. this.areas = ig.database.get("areas")
  171. },
  172. loadArea: function(a, b) {
  173. if (a == this.currentPlayerArea.path) {
  174. this.currentArea = this.currentPlayerArea;
  175. b.onLoadableComplete(true, this.currentArea)
  176. } else {
  177. this.currentArea = new sc.AreaLoadable(a);
  178. this.currentArea.addLoadListener(b)
  179. }
  180. },
  181. unloadCurrentArea: function() {
  182. if (this.currentArea.path !=
  183. this.currentPlayerArea.path) {
  184. this.currentArea.decreaseRef();
  185. this.currentArea = null
  186. }
  187. },
  188. updateVisitedArea: function(a) {
  189. if (!this.areasVisited[a.toCamel()]) {
  190. this.areas[a].track && sc.stats.addMap("exploration", "areas", 1);
  191. this.areasVisited[a.toCamel()] = {}
  192. }
  193. },
  194. undoVisitedArea: function(a, b) {
  195. if (this.areasVisited[a.toCamel()]) {
  196. this.areas[a].track && sc.stats.subMap("exploration", "areas", 1);
  197. delete this.areasVisited[a.toCamel()]
  198. }
  199. if (b)
  200. for (var c = b.data.floors, e = c.length; e--;)
  201. for (var f = c[e], g = f.maps.length; g--;) ig.vars.set("maps." +
  202. f.maps[g].path.toCamel().toPath("", ""), null)
  203. },
  204. validateCurrentPlayerFloor: function() {
  205. var a = this.currentPlayerArea.data;
  206. if (a) {
  207. var b = a.floors.length,
  208. c = 0,
  209. e = null,
  210. f = null;
  211. this.currentPlayerFloor = this.currentFloor = 0;
  212. for (var g = false; b--;) {
  213. e = a.floors[b];
  214. for (c = e.maps.length; c--;) {
  215. f = e.maps[c];
  216. g = f.path == this.currentMap;
  217. f.zMin && (g = g & ig.game.playerEntity.coll.level >= f.zMin);
  218. f.zMax && (g = g & ig.game.playerEntity.coll.level <= f.zMax);
  219. if (g) {
  220. this.currentFloor = this.currentPlayerFloor = e.level || 0;
  221. return
  222. }
  223. }
  224. }
  225. }
  226. },
  227. validateCurrentFloor: function() {
  228. var a =
  229. this.currentArea.data,
  230. b = a.floors.length,
  231. c = 0,
  232. e = null,
  233. f = null;
  234. this.currentFloor = 0;
  235. for (var g = a.defaultFloor == void 0 ? void 0 : a.defaultFloor, h = false; b--;) {
  236. e = a.floors[b];
  237. for (c = e.maps.length; c--;) {
  238. f = e.maps[c];
  239. h = ig.vars.get("maps." + f.path.toCamel().toPath("", ""));
  240. f.zMin && (h = h & ig.game.playerEntity.coll.level >= f.zMin);
  241. f.zMax && (h = h & ig.game.playerEntity.coll.level <= f.zMax);
  242. if (h) {
  243. if (g == void 0) {
  244. this.currentFloor = e.level || 0;
  245. return
  246. }
  247. if (g == e.level) {
  248. this.currentFloor = g;
  249. return
  250. }
  251. } else e.level == g && (g = void 0)
  252. }
  253. }
  254. },
  255. restore: function() {
  256. this.currentFloor =
  257. this.currentPlayerFloor;
  258. this.currentArea && this.currentPlayerArea && this.currentArea.path != this.currentPlayerArea
  259. .path && this.currentArea.decreaseRef();
  260. this.currentArea = this.currentPlayerArea
  261. },
  262. addLandmark: function(a, d, c) {
  263. if (!this.isLandmarkValid(a, d || this.currentPlayerArea.path)) throw Error(
  264. "invalid Landmark: " + a + "! Maybe missing entry in database?");
  265. d = d || this.currentPlayerArea.path;
  266. this.activeLandmarks[d] || (this.activeLandmarks[d] = {});
  267. if (!this.activeLandmarks[d][a] || !this.activeLandmarks[d][a].active) {
  268. if (this.activeLandmarks[d][a]) this.activeLandmarks[d][a].active =
  269. true;
  270. else {
  271. this.activeLandmarks[d][a] = {
  272. active: true
  273. };
  274. sc.stats.addMap("exploration", "landmarks", 1);
  275. sc.stats.addMap("exploration", d + "-landmarks", 1);
  276. sc.stats.setMap("exploration", "landmarksTotalRate", this.getTotalLandmarksFound(true));
  277. sc.menu.addLog({
  278. type: "LANDMARK",
  279. area: d,
  280. landmark: a
  281. })
  282. }
  283. b.landmark = a;
  284. b.area = d || this.currentPlayerArea.path;
  285. c && sc.options.get("update-landmark-style") != sc.UPDATE_LANDMARK_STYLE.NONE && ig.game
  286. .events.callEvent(this.getLandmarkEvent(c), ig.EventRunType.INTERRUPTABLE);
  287. sc.quests.onLandmarkEvent(d);
  288. sc.Model.notifyObserver(this, sc.MAP_EVENT.LANDMARK_ADDED, b)
  289. }
  290. },
  291. startTeleport: function(a) {
  292. this.teleportEvent = this.getTeleportEvent(a.path);
  293. sc.stats.addMap("player", "teleports", 1);
  294. sc.model.enterRunning();
  295. sc.Cutscene.startCutscene(this.teleportEvent)
  296. },
  297. getAreaType: function(a) {
  298. return sc.AREA_TYPE[this.areas[a].areaType]
  299. },
  300. isLandmarkValid: function(a, b) {
  301. var c = this.areas[b].landmarks;
  302. return c ? c[a] : false
  303. },
  304. getAreaItemId: function(a, b) {
  305. if (!b) {
  306. if (!this.currentPlayerArea) return -1;
  307. b = this.currentPlayerArea.path
  308. }
  309. var c =
  310. this.areas[b][a.areaField];
  311. return !c && c !== 0 ? -1 : c
  312. },
  313. getAreaItemType: function(a, b) {
  314. if (!b) {
  315. if (!this.currentPlayerArea) return null;
  316. b = this.currentPlayerArea.path
  317. }
  318. var c = this.areas[b],
  319. e;
  320. for (e in sc.AREA_ITEM_TYPE)
  321. if (a == c[sc.AREA_ITEM_TYPE[e].areaField]) return e
  322. },
  323. getAreaItemAmount: function(a, b) {
  324. var c = this.getAreaItemId(a, b);
  325. return c == -1 ? 0 : sc.model.player.getItemAmount(c)
  326. },
  327. getAreaItemToggleState: function(a, b) {
  328. var c = this.getAreaItemId(a, b);
  329. return c == -1 ? false : sc.model.player.getItemAmount(c) > 0 && sc.model.player
  330. .getToggleItemState(c)
  331. },
  332. isLandmarkActive: function(a, b, c) {
  333. if (b = b || this.currentPlayerArea && this.currentPlayerArea.path) {
  334. this.activeLandmarks[b] || (this.activeLandmarks[b] = {});
  335. return !this.activeLandmarks[b][a] ? false : c ? this.activeLandmarks[b][a].active ||
  336. false : this.activeLandmarks[b][a] || false
  337. }
  338. },
  339. setLandmarkActiveState: function(a, b, c) {
  340. (c = c || this.currentPlayerArea && this.currentPlayerArea.path) && this.activeLandmarks[c] &&
  341. this.activeLandmarks[c][a] && (this.activeLandmarks[c][a].active = b || false)
  342. },
  343. setAreaLandmarksActiveState: function(a,
  344. b) {
  345. var c = this.activeLandmarks[a];
  346. if (c)
  347. for (var e in c) c[e].active = b
  348. },
  349. isDungeon: function(a) {
  350. if (!this.currentPlayerArea) return false;
  351. if (!a)
  352. if (a = this.getMapDungeon(this.currentMap)) return a == sc.MAP_DUNGEON_OVERRIDE.DUNGEON;
  353. a = this.areas[this.currentPlayerArea.path];
  354. return sc.AREA_TYPE[a && a.areaType] == sc.AREA_TYPE.DUNGEON
  355. },
  356. hasAnyAreaUnlocked: function() {
  357. for (var a in this.areas)
  358. if (this.areas[a] && this.areas[a].track && this.areasVisited[a.toCamel()]) return true;
  359. return false
  360. },
  361. getUnlockedAreas: function() {
  362. var a = [],
  363. b;
  364. for (b in this.areas) this.areas[b] && (this.areas[b].track && this.areasVisited[b
  365. .toCamel()]) && a.push(b);
  366. return a
  367. },
  368. sortAreaList: function(a) {
  369. if (a) {
  370. a.sort(function(a, b) {
  371. return (this.areas[a].order || 0) - (this.areas[b].order || 0)
  372. }.bind(this));
  373. return a
  374. }
  375. },
  376. getLandmarkName: function(a, b) {
  377. var c = (b = this.areas[b]) && b.landmarks && b.landmarks[a] && b.landmarks[a].name;
  378. return c ? new ig.LangLabel(c) : "???"
  379. },
  380. getLandmark: function(a, b) {
  381. return this.areas[b].landmarks[a]
  382. },
  383. getCurrentAreaLandmark: function(a) {
  384. return this.areas[this.currentArea.path].landmarks[a]
  385. },
  386. getCurrentPlayerAreaName: function() {
  387. return new ig.LangLabel(this.areas[this.currentPlayerArea.path].name)
  388. },
  389. getCurrentAreaName: function() {
  390. return new ig.LangLabel(this.areas[this.currentArea.path].name)
  391. },
  392. getAreaOrder: function(a) {
  393. return this.areas[a] ? this.areas[a].order || 0 : 0
  394. },
  395. getAreaName: function(a, b) {
  396. if (!a) return "";
  397. var c = this.areas[a];
  398. return c ? new ig.LangLabel(b ? c.shortName ? c.shortName : c.name : c.name) : null
  399. },
  400. getCurrentMapName: function(a) {
  401. var b = this.getMapName(this.currentMap);
  402. return a && b == this.currentMap ?
  403. "???" : b
  404. },
  405. getMapName: function(a) {
  406. for (var b = this.currentArea.data.floors[this.getCurrentFloorIndex()].maps, c = b
  407. .length; c--;) {
  408. var e = b[c];
  409. if (e.path == a && e.name) return new ig.LangLabel(e.name)
  410. }
  411. return this.currentMap
  412. },
  413. getMapDungeon: function(a) {
  414. if (!this.currentArea || !this.currentArea.data) return null;
  415. var b = this.currentArea.data.floors[this.getCurrentFloorIndex()];
  416. if (!b) return null;
  417. for (var b = b.maps, c = b.length; c--;) {
  418. var e = b[c];
  419. if (e.path == a) return sc.MAP_DUNGEON_OVERRIDE[e.dungeon] || null
  420. }
  421. return null
  422. },
  423. getCurrentFloorIndex: function() {
  424. return this.currentFloor -
  425. this.currentArea.lowestFloor
  426. },
  427. getCurrentArea: function() {
  428. return this.currentArea ? this.currentArea.data : null
  429. },
  430. getLandmarkEvent: function(a) {
  431. return new ig.Event({
  432. steps: [{
  433. type: "SET_CAMERA_BETWEEN",
  434. entity1: a,
  435. entity2: ig.game.playerEntity,
  436. speed: "NORMAL",
  437. wait: true,
  438. transition: "EASE_OUT"
  439. }, {
  440. type: "WAIT",
  441. time: 1
  442. }, {
  443. type: "RESET_CAMERA",
  444. speed: "NORMAL",
  445. transition: "EASE_IN_OUT"
  446. }]
  447. })
  448. },
  449. getTeleportEvent: function(a) {
  450. var b = ig.game.playerEntity,
  451. c = [];
  452. c.push({
  453. type: "DO_ACTION",
  454. entity: ig.game.playerEntity,
  455. action: [{
  456. type: "SET_Z_GRAVITY_FACTOR",
  457. value: 0
  458. }, {
  459. type: "SET_Z_VEL",
  460. value: 0
  461. }, {
  462. type: "WAIT",
  463. time: 5
  464. }]
  465. });
  466. c.push({
  467. time: 0.2,
  468. ignoreSlowDown: false,
  469. type: "WAIT"
  470. });
  471. c.push({
  472. type: "SET_TELEPORT_COLOR",
  473. lighter: true,
  474. color: "white"
  475. });
  476. c.push({
  477. color: "white",
  478. alpha: 1,
  479. time: 1,
  480. lighter: true,
  481. type: "SET_OVERLAY"
  482. });
  483. c.push({
  484. type: "SET_CAMERA_TARGET",
  485. entity: b,
  486. speed: "NORMAL",
  487. transition: "EASE_IN_OUT",
  488. zoom: 1.5
  489. });
  490. c.push({
  491. time: 0.2,
  492. ignoreSlowDown: false,
  493. type: "WAIT"
  494. });
  495. c.push({
  496. type: "SHOW_EFFECT",
  497. entity: b,
  498. effect: {
  499. sheet: "teleport",
  500. name: "hideMapTeleport"
  501. }
  502. });
  503. for (b = sc.party.getPartySize(); b--;) {
  504. var e =
  505. sc.party.getPartyMemberEntityByIndex(b);
  506. c.push({
  507. type: "SHOW_EFFECT",
  508. entity: e,
  509. effect: {
  510. sheet: "teleport",
  511. name: "hideFast"
  512. }
  513. })
  514. }
  515. c.push({
  516. time: 1,
  517. ignoreSlowDown: false,
  518. type: "WAIT"
  519. });
  520. c.push({
  521. type: "TELEPORT",
  522. map: a,
  523. marker: "landmark"
  524. });
  525. c.push({
  526. time: 3,
  527. ignoreSlowDown: false,
  528. type: "WAIT"
  529. });
  530. a = new ig.Event({
  531. steps: c
  532. });
  533. a.addHint("SKIN_ALLOWED");
  534. return a
  535. },
  536. getVisitedArea: function(a) {
  537. return this.areasVisited[a.toCamel()]
  538. },
  539. getTeleport: function() {
  540. return this.teleportEvent
  541. },
  542. getCurrentChestCount: function() {
  543. return this.areas[this.currentArea.path].chests ||
  544. 0
  545. },
  546. getChestCount: function(a) {
  547. return this.areas[a].chests || 0
  548. },
  549. onStorageSave: function(a) {
  550. if (this.currentPlayerArea) {
  551. a.area = this.areas[this.currentPlayerArea.path].name;
  552. if (this.currentPlayerFloor != void 0)
  553. for (var b = this.currentPlayerArea.data.floors, c = b.length; c--;) {
  554. if (this.currentPlayerFloor == b[c].level) {
  555. a.floor = b[c].name ? ig.LangLabel.getText(b[c].name) : "";
  556. b = b[c].maps;
  557. for (c = b.length; c--;)
  558. if (b[c].path == this.currentMap && b[c].name) {
  559. a.specialMap = ig.LangLabel.getText(b[c].name);
  560. a.specialMap = b[c].name
  561. } break
  562. }
  563. } else a.floor =
  564. "???"
  565. } else {
  566. a.area = "???";
  567. a.floor = ""
  568. }
  569. a.visitedAreas = ig.copy(this.areasVisited);
  570. a.landmarks = ig.copy(this.activeLandmarks)
  571. },
  572. onStoragePreLoad: function(a) {
  573. this.areasVisited = a.visitedAreas || {};
  574. a = a.landmarks || {};
  575. this.activeLandmarks = {};
  576. var b, c;
  577. for (c in a) {
  578. b = 0;
  579. for (var e in a[c]) {
  580. this.activeLandmarks[c] || (this.activeLandmarks[c] = {});
  581. var f = a[c][e];
  582. if (!f || f.active === void 0) f = {
  583. active: true
  584. };
  585. this.activeLandmarks[c][e] = f;
  586. b++
  587. }
  588. sc.stats.setMap("exploration", c + "-landmarks", b)
  589. }
  590. sc.stats.setMap("exploration", "landmarksTotalRate",
  591. this.getTotalLandmarksFound(true));
  592. sc.stats.setMap("chests", "totalRate", sc.map.getTotalChestsFound(true))
  593. },
  594. onLoadableComplete: function() {
  595. this.validateCurrentPlayerFloor()
  596. }
  597. });
  598.  
  599. function b(a) {
  600. for (var b = h.length, c = 0; b--;)
  601. if (a.time >= h[b]) {
  602. c = b + 1;
  603. break
  604. } return c = Math.min(a.maxLevel, c)
  605. }
  606.  
  607. function a(a, b) {
  608. if (a[b] > 0) {
  609. a[b] = a[b] -
  610. ig.system.tick;
  611. a[b] <= 0 && (a[b] = 0)
  612. }
  613. }
  614.  
  615. Vec2.create();
  616. var d = {
  617. actionKey: "ATTACK_SPECIAL"
  618. },
  619. c = {
  620. actionKey: "THROW_SPECIAL"
  621. },
  622. e = {
  623. actionKey: "GUARD_SPECIAL"
  624. },
  625. f = {
  626. actionKey: "DASH_SPECIAL"
  627. },
  628. g = ["Neutral", "Heat", "Cold", "Shock", "Wave"],
  629. h = [0.25, 0.5, 1];
  630. sc.PLAYER_ZOOM = 1;
  631. var i = {
  632. thrown: false,
  633. melee: false,
  634. aim: false,
  635. autoThrow: false,
  636. attack: false,
  637. guard: false,
  638. charge: false,
  639. dashX: 0,
  640. dashY: 0,
  641. switchMode: false,
  642. relativeVel: 0,
  643. moveDir: Vec2.create()
  644. },
  645. j = {};
  646.  
  647. ig.ENTITY.Player = sc.PlayerBaseEntity.extend({
  648. skin: {
  649. appearanceFx: null,
  650. appearance: null,
  651. stepFx: null,
  652. auraFx: null,
  653. auraFxHandle: null,
  654. pet: null
  655. },
  656. proxies: null,
  657. model: null,
  658. state: 0,
  659. throwCounter: 0,
  660. attackCounter: 0,
  661. attackResetTimer: 0,
  662. throwDir: Vec2.create(),
  663. throwDirData: Vec2.create(),
  664. doAttack: false,
  665. lastMoveDir: Vec2.create(),
  666. dashCount: 0,
  667. dashAttackCount: 0,
  668. maxDash: 3,
  669. keepLastMoveDir: 0,
  670. moveDirStartedTimer: 0,
  671. jumpPoint: Vec2.create(),
  672. jumpForwardDir: Vec2.create(),
  673. idle: {
  674. timer: 0,
  675. actions: [],
  676. petAction: null
  677. },
  678. gui: {},
  679. cameraHandle: null,
  680. cameraTargets: [],
  681. mapStartPos: Vec3.create(),
  682. actionBlocked: {
  683. action: 0,
  684. charge: 0,
  685. dash: 0,
  686. reaim: 0,
  687. move: 0
  688. },
  689. combatStats: {
  690. lastTarget: null
  691. },
  692. dashDir: Vec2.create(),
  693. dashDirData: Vec2.create(),
  694. dashTimer: 0,
  695. dashBlock: 0,
  696. doEscapeTimer: 0,
  697. stunEscapeDash: false,
  698. dashPerfect: false,
  699. perfectGuardCooldown: 0,
  700. charging: {
  701. time: -1,
  702. cancelTime: 0,
  703. swapped: false,
  704. type: null,
  705. maxLevel: 0,
  706. fx: null,
  707. block: 0,
  708. msg: null,
  709. executeLevel: 0,
  710. prefDir: Vec2.create()
  711. },
  712. chargeThrowCharged: false,
  713. floating: false,
  714. recordInput: false,
  715. interactObject: null,
  716. explicitAimStart: 0,
  717. levelUpNotifier: null,
  718. itemConsumer: null,
  719. isPlayer: true,
  720. hidePets: false,
  721. init: function(a,
  722. b, c, d) {
  723. this.parent(a, b, c, d);
  724. this.levelUpNotifier = new sc.PlayerLevelNotifier;
  725. this.itemConsumer = new sc.ItemConsumption;
  726. if (sc.model) {
  727. this.model = sc.model.player;
  728. sc.Model.addObserver(this.model, this);
  729. sc.Model.addObserver(sc.model, this);
  730. this.initModel()
  731. }
  732. sc.Model.addObserver(sc.playerSkins, this);
  733. this.charging.fx = new sc.CombatCharge(this, true);
  734. sc.combat.addActiveCombatant(this)
  735. },
  736. initModel: function() {
  737. this.params = this.model.params;
  738. this.params.setCombatant(this);
  739. this.animSheet = this.animSheetReplace || this.model.animSheet;
  740. sc.Model.addObserver(this.params, this);
  741. this.initAnimations();
  742. this.copyModelSkills();
  743. this.updateModelStats(true);
  744. this.updateSkinStepFx();
  745. this.updateSkinAura();
  746. this.updateSkinPet(false);
  747. this.initIdleActions()
  748. },
  749. replaceAnimSheet: function(a) {
  750. this.animSheetReplace = a;
  751. this.updateAnimSheet()
  752. },
  753. initIdleActions: function() {
  754. this.idle.actions.length = 0;
  755. if (this.model.name == "Lea") {
  756. var a = sc.gameCode.isEnabled("caramelldansen") ? new ig.Action("PLAYER_IDLE", [{
  757. type: "SET_FACE",
  758. face: "SOUTH",
  759. rotate: true
  760. }, {
  761. type: "WAIT",
  762. time: 0.3
  763. },
  764. {
  765. type: "SHOW_EXTERN_ANIM",
  766. anim: {
  767. sheet: "player-poses",
  768. name: "caramelldansen"
  769. }
  770. }, {
  771. type: "WAIT",
  772. time: 5
  773. }, {
  774. type: "SHOW_ANIMATION",
  775. anim: "preIdle",
  776. wait: true
  777. }
  778. ], false, false) : new ig.Action("PLAYER_IDLE", [{
  779. type: "CHANGE_STAT_MAP_NUMBER",
  780. map: "misc",
  781. stat: "yawns",
  782. value: 1,
  783. changeType: "add"
  784. }, {
  785. type: "SET_FACE",
  786. face: "SOUTH_EAST",
  787. rotate: true
  788. }, {
  789. type: "SHOW_ANIMATION",
  790. anim: "idleStretch",
  791. wait: true
  792. }], false, false);
  793. this.idle.actions.push(a)
  794. }
  795. },
  796. doPetAction: function() {
  797. var a = [{
  798. x: 0,
  799. y: -7
  800. }, {
  801. x: 12,
  802. y: -1
  803. }, {
  804. x: -12,
  805. y: -1
  806. }, {
  807. x: 0,
  808. y: 7
  809. }],
  810. b = this.skin.pet;
  811. if (b.petSkin.petOffsets) a = b.petSkin.petOffsets;
  812. a = new ig.Action("PLAYER_IDLE", [{
  813. type: "SET_FACE_TO_ENTITY",
  814. entity: b,
  815. rotate: true
  816. }, {
  817. type: "WAIT",
  818. time: 0.4
  819. }, {
  820. type: "SET_COLL_TYPE",
  821. value: "IGNORE"
  822. }, {
  823. type: "SET_RELATIVE_SPEED",
  824. value: 0.3
  825. }, {
  826. type: "MOVE_TO_ENTITY_CLOSEST_OFFSET",
  827. entity: b,
  828. offsets: a,
  829. maxTime: 0.4,
  830. forceTime: true
  831. }, {
  832. type: "SET_FACE_TO_ENTITY",
  833. entity: b,
  834. rotate: false
  835. }, {
  836. type: "SHOW_ANIMATION",
  837. anim: "pet"
  838. }, {
  839. type: "WAIT",
  840. time: 1.5
  841. }, {
  842. type: "SHOW_ANIMATION",
  843. anim: "preIdle",
  844. wait: true
  845. }], false, false);
  846. b = new ig.Action("PLAYER_IDLE",
  847. [{
  848. type: "SHOW_ANIMATION",
  849. anim: "idle",
  850. viaWalkConfig: true
  851. }, {
  852. type: "SET_FACE_TO_ENTITY",
  853. entity: this,
  854. rotate: true
  855. }, {
  856. type: "SET_COLL_TYPE",
  857. value: "IGNORE"
  858. }, {
  859. type: "WAIT",
  860. time: 1
  861. }, {
  862. type: "SET_FACE_TO_ENTITY",
  863. entity: this,
  864. rotate: true
  865. }, {
  866. type: "WAIT",
  867. time: 1.2
  868. }, {
  869. type: "SHOW_EFFECT",
  870. effect: {
  871. sheet: "npc",
  872. name: "hearts"
  873. }
  874. }, {
  875. type: "JUMP",
  876. jumpHeight: "S",
  877. wait: true,
  878. ignoreSounds: true
  879. }, {
  880. type: "JUMP",
  881. jumpHeight: "S",
  882. wait: true,
  883. ignoreSounds: true
  884. }, {
  885. type: "JUMP",
  886. jumpHeight: "S",
  887. wait: true,
  888. ignoreSounds: true
  889. }], false, false);
  890. this.setAction(a);
  891. this.skin.pet.setAction(b)
  892. },
  893. updateAnimSheet: function(a) {
  894. var b = null;
  895. if ((!sc.model.isCutscene() || ig.game.events.hasBlockingEventCallHint("SKIN_ALLOWED")) && !ig
  896. .dreamFx.isActive()) {
  897. var c = sc.playerSkins.getCurrentSkin("Appearance");
  898. c && c.loaded && (b = c)
  899. }
  900. if (b != this.skin.appearance) {
  901. if (!a) {
  902. if (this.skin.appearanceFx) {
  903. this.skin.appearanceFx.setCallback(null);
  904. this.skin.appearanceFx.stop();
  905. this.skin.appearanceFx = null
  906. }
  907. b ? this.skin.appearanceFx = b.fx.spawnOnTarget("skinOn", this, {
  908. callback: this
  909. }) : this.skin.appearance.fx.spawnOnTarget("skinOff",
  910. this)
  911. }
  912. this.skin.appearance = b
  913. }
  914. if (this.animSheetReplace) this.animSheet = this.animSheetReplace;
  915. else {
  916. a = this.model.animSheet;
  917. if (this.skin.appearance && !this.skin.appearanceFx) a = this.skin.appearance.animSheet;
  918. this.animSheet = a
  919. }
  920. },
  921. updateSkinStepFx: function() {
  922. var a = sc.playerSkins.getCurrentSkin("StepEffect");
  923. this.skin.stepFx = a && a.loaded ? a.fx : null
  924. },
  925. updateSkinAura: function() {
  926. var a = sc.playerSkins.getCurrentSkin("Aura");
  927. this.skin.auraFx = a && a.loaded ? a.fx : null;
  928. this.skin.auraFxHandle && this.skin.auraFxHandle.stop();
  929. this.skin.auraFxHandle = null;
  930. if (this.skin.auraFx) {
  931. var a = "aura",
  932. b = g[this.model.currentElementMode];
  933. this.skin.auraFx.hasEffect(a + b) && (a = a + b);
  934. this.skin.auraFxHandle = this.skin.auraFx.spawnOnTarget(a, this, {
  935. duration: -1
  936. })
  937. }
  938. },
  939. updateSkinPet: function(a) {
  940. if (this.skin.pet) {
  941. this.skin.pet.remove();
  942. this.skin.pet = null
  943. }
  944. var b = sc.playerSkins.getCurrentSkin("Pet");
  945. if (b && b.loaded) this.skin.pet = ig.game.spawnEntity(sc.PlayerPetEntity, 0, 0, 0, {
  946. petSkin: b
  947. }, a || false)
  948. },
  949. onEffectEvent: function(a) {
  950. if (a == this.skin.appearanceFx && a.state >=
  951. ig.EFFECT_STATE.POST_LOOP) {
  952. this.skin.appearanceFx = null;
  953. this.updateAnimSheet()
  954. }
  955. },
  956. regenPvp: function(a) {
  957. this.parent(a);
  958. this.model.addElementLoad(-1E3)
  959. },
  960. updateModelStats: function(a) {
  961. this.regenFactor = this.params.getModifier("HP_REGEN");
  962. this.stunData.stunEscapeTime = 1.5;
  963. this.gui.crosshair && this.gui.crosshair.setBaseSpeedFactor(1 + this.params.getModifier(
  964. "AIM_SPEED"));
  965. if (this.params) this.params.criticalDmgFactor = 1.5 + this.params.getModifier(
  966. "CRITICAL_DMG");
  967. this.stunThreshold = this.params.getModifier("STUN_THRESHOLD");
  968. this.updateAnimSheet(a);
  969. this.configs.aiming.overwrite("maxVel", 100 * (1 + this.params.getModifier(
  970. "AIMING_MOVEMENT")));
  971. this.maxDash = Math.round(3 + this.params.getModifier("DASH_STEP"));
  972. this.spikeDmg.baseFactor = this.params.getModifier("SPIKE_DMG")
  973. },
  974. hasCameraTarget: function(a) {
  975. return this.cameraTargets.indexOf(a) != -1
  976. },
  977. addCameraTarget: function(a, b) {
  978. if (this.cameraTargets.indexOf(a) == -1) {
  979. this.cameraTargets.push(a);
  980. this._updateCameraHandle(b || "NORMAL")
  981. }
  982. },
  983. removeCameraTarget: function(a, b) {
  984. this.cameraTargets.erase(a);
  985. this._updateCameraHandle(b || "NORMAL")
  986. },
  987. removeAllCameraTargets: function(a) {
  988. this.cameraTargets.length = 0;
  989. this._updateCameraHandle(a || "NORMAL")
  990. },
  991. _updateCameraHandle: function(a) {
  992. var b = null;
  993. if (this.cameraTargets.length == 0) b = new ig.Camera.TargetHandle(new ig.Camera.EntityTarget(
  994. this), 0, 0);
  995. else {
  996. b = [this];
  997. b.push.apply(b, this.cameraTargets);
  998. b = new ig.Camera.TargetHandle(new ig.Camera.MultiEntityTarget(b, true), 0, 0)
  999. }
  1000. b.keepZoomFocusAligned = true;
  1001. sc.PLAYER_ZOOM != 1 && b.setZoom(sc.PLAYER_ZOOM, 0.1);
  1002. this.cameraHandle ?
  1003. ig.camera.replaceTarget(this.cameraHandle, b, a, KEY_SPLINES.EASE_IN_OUT) : ig.camera
  1004. .pushTarget(b, a, KEY_SPLINES.EASE_IN_OUT);
  1005. this.cameraHandle = b
  1006. },
  1007. onPlayerPlaced: function() {
  1008. if (ig.camera) {
  1009. for (; ig.camera.getTargetCount() > 0;) ig.camera.popTarget();
  1010. this._updateCameraHandle()
  1011. }
  1012. sc.party.onMapEnter();
  1013. Vec3.assign(this.respawn.pos, this.coll.pos);
  1014. Vec3.assign(this.mapStartPos, this.coll.pos);
  1015. this.skin.pet && this.skin.pet.resetStartPos()
  1016. },
  1017. onMoveEffect: function(a) {
  1018. a == "step" && sc.stats.addMap("player", "steps", 1);
  1019. this.skin.stepFx &&
  1020. this.skin.stepFx.hasEffect(a) && (a == "jump" ? this.skin.stepFx.spawnOnTarget("jump",
  1021. this, {
  1022. angle: Vec2.clockangle(this.face)
  1023. }) : this.skin.stepFx.spawnOnTarget(a, this));
  1024. sc.gameCode.isEnabled("speedlines") && (a == "step" ? ig.game.effects.speedlines
  1025. .spawnOnTarget("speedlinesWalk", this, {
  1026. duration: 0.2,
  1027. align: "CENTER"
  1028. }) : a == "dash" ? ig.game.effects.speedlines.spawnOnTarget("speedlinesDash", this, {
  1029. duration: 0.3,
  1030. align: "CENTER"
  1031. }) : a == "jump" && ig.game.effects.speedlines.spawnOnTarget("speedlinesJump", this, {
  1032. duration: 0.5,
  1033. align: "CENTER"
  1034. }))
  1035. },
  1036. setAction: function(a, b, c) {
  1037. this.coll.relativeVel = 1;
  1038. this.parent(a, b, c)
  1039. },
  1040. doCombatAction: function(a) {
  1041. this.doPlayerAction(a);
  1042. this.model.increaseActionHeat(sc.PLAYER_ACTION[a]);
  1043. this.actionBlocked.action = this.actionBlocked.charge = this.actionBlocked.move = this
  1044. .actionBlocked.reaim = this.actionBlocked.dash = 100;
  1045. sc.gameCode.isEnabled("speedlines") && ig.game.effects.speedlines.spawnOnTarget(
  1046. "speedlinesDash", this, {
  1047. duration: 0.3,
  1048. align: "CENTER"
  1049. })
  1050. },
  1051. setActionBlocked: function(a) {
  1052. this.actionBlocked.action = a.action;
  1053. this.actionBlocked.charge =
  1054. a.charge || a.action;
  1055. this.actionBlocked.dash = a.dash;
  1056. this.actionBlocked.reaim = a.reaim;
  1057. this.actionBlocked.move = a.move
  1058. },
  1059. clearActionBlocked: function() {
  1060. this.charging.executeLevel = 0;
  1061. this.actionBlocked.action = this.actionBlocked.move = this.actionBlocked.charge = this
  1062. .actionBlocked.reaim = this.actionBlocked.dash = 0
  1063. },
  1064. showChargeEffect: function(a) {
  1065. this.charging.fx.charge(this.model.currentElementMode, a);
  1066. this.params.notifySpConsume(sc.PLAYER_SP_COST[a - 1]);
  1067. this.cameraHandle.setZoom(sc.PLAYER_ZOOM + a * 0.5 / 3, 0.5, KEY_SPLINES.JUMPY);
  1068. if (a >= 2) {
  1069. a = new ig.ZoomBlurHandle(a == 2 ? "LIGHT" : "MEDIUM", 0.2, 0, 0.3);
  1070. ig.screenBlur.addZoom(a)
  1071. }
  1072. },
  1073. clearCharge: function() {
  1074. if (this.charging.time != -1) {
  1075. this.params.notifySpConsume(0);
  1076. this.charging.time = -1;
  1077. ig.slowMotion.clearNamed("playerCharge", 0);
  1078. this.gui.crosshair.setSpecial(false);
  1079. this.coll.time.animStatic = false;
  1080. this.charging.fx.stop();
  1081. this.cameraHandle.setZoom(sc.PLAYER_ZOOM, 0.5, KEY_SPLINES.EAST_IN_OUT)
  1082. }
  1083. },
  1084. onKill: function(a) {
  1085. this.clearCharge();
  1086. this.parent(a);
  1087. sc.Model.removeObserver(this.model, this);
  1088. sc.Model.removeObserver(sc.model,
  1089. this);
  1090. sc.Model.removeObserver(this.params, this);
  1091. sc.Model.removeObserver(sc.playerSkins, this);
  1092. sc.combat.removeActiveCombatant(this);
  1093. if (!a) {
  1094. a = ig.vars.get("stats.deaths") || 0;
  1095. ig.game.respawn();
  1096. ig.vars.set("stats.deaths", a + 1)
  1097. }
  1098. },
  1099. show: function() {
  1100. this.parent();
  1101. this.gui.crosshair = ig.game.spawnEntity(ig.ENTITY.Crosshair, 0, 0, 0, {
  1102. thrower: this,
  1103. controller: new sc.PlayerCrossHairController
  1104. });
  1105. this.updateModelStats()
  1106. },
  1107. getChargeType: function(a, b) {
  1108. return this.dashTimer > 0.33 ? f : a.guarding || sc.control.guarding() && Vec2.isZero(b
  1109. .moveDir) ?
  1110. this.model.getCore(sc.PLAYER_CORE.GUARD) ? e : d : sc.control.dashHold() ? f : this.state ==
  1111. 1 || (this.state == 2 || this.state == 5) && this.model.getCore(sc.PLAYER_CORE.THROWING) &&
  1112. sc.control.aiming() ? c : d
  1113. },
  1114. getCurrentChargeLevel: function() {
  1115. return this.charging.time <= 0 ? 0 : b(this.charging)
  1116. },
  1117. getMaxChargeLevel: function(a) {
  1118. for (var b = 0, a = a.actionKey; b < 3 && this.model.getAction(sc.PLAYER_ACTION[a + (b +
  1119. 1)]);) b++;
  1120. return b
  1121. },
  1122. startCharge: function(a) {
  1123. if (!this.model.getCore(sc.PLAYER_CORE.SPECIAL) || !this.model.getCore(sc.PLAYER_CORE
  1124. .CLOSE_COMBAT) &&
  1125. a == d) return false;
  1126. var b = this.getMaxChargeLevel(a),
  1127. e = this.model.params.getSp(),
  1128. f = 0;
  1129. e >= sc.PLAYER_SP_COST[2] ? f = 3 : e >= sc.PLAYER_SP_COST[1] ? f = 2 : e >= sc
  1130. .PLAYER_SP_COST[0] && (f = 1);
  1131. b = Math.min(b, f);
  1132. if (f == 0) {
  1133. if (!this.charging.msg || this.charging.msg.isFinished()) {
  1134. f = ig.lang.get("sc.gui.combat.no-sp");
  1135. this.charging.msg = new sc.SmallEntityBox(this, f, 0.5);
  1136. ig.gui.addGuiElement(this.charging.msg)
  1137. }
  1138. } else {
  1139. this.charging.msg && !this.charging.msg.isFinished() && this.charging.msg.remove();
  1140. this.charging.msg = null
  1141. }
  1142. if (b == 0) return false;
  1143. this.charging.maxLevel = b;
  1144. this.charging.type = a;
  1145. Vec2.assignC(this.charging.prefDir, 0, 0);
  1146. a == c ? this.quickStateSwitch(1) : a == d && this.quickStateSwitch(3);
  1147. return true
  1148. },
  1149. getChargeAction: function(a, b) {
  1150. for (var c = a.actionKey; b && !this.model.getAction(sc.PLAYER_ACTION[c + b]);) b--;
  1151. if (!b) return 0;
  1152. this.model.params.consumeSp(sc.PLAYER_SP_COST[b - 1]);
  1153. return c + b
  1154. },
  1155. quickStateSwitch: function(a) {
  1156. this.state = a;
  1157. if (a == 1) {
  1158. this.gui.crosshair.setActive(true);
  1159. this.setDefaultConfig(this.configs.aiming)
  1160. } else {
  1161. this.gui.crosshair.setActive(false);
  1162. this.setDefaultConfig(this.configs.normal)
  1163. }
  1164. },
  1165. isElementChangeBlocked: function() {
  1166. return this.isControlBlocked() || this.charging.time != -1
  1167. },
  1168. isControlBlocked: function() {
  1169. return this.hasStun() || this.params.isDefeated() || this.interactObject || this
  1170. .currentAction && this.currentAction.eventAction
  1171. },
  1172. update: function() {
  1173. this.playerTrack.lastPlayerAction = null;
  1174. for (var b = this.cameraTargets.length; b--;) {
  1175. var c = this.cameraTargets[b];
  1176. c._killed && this.removeCameraTarget(c)
  1177. }
  1178. if (this.attackResetTimer > 0) {
  1179. this.attackResetTimer = this.attackResetTimer -
  1180. ig.system.tick;
  1181. if (this.attackResetTimer <= 0) this.attackCounter = this.attackResetTimer = 0
  1182. }
  1183. if (this.perfectGuardCooldown > 0) {
  1184. this.perfectGuardCooldown = this.perfectGuardCooldown - ig.system.tick;
  1185. if (this.perfectGuardCooldown < 0) this.perfectGuardCooldown = 0
  1186. }
  1187. if (!sc.inputForcer.isBlocking()) {
  1188. a(this.actionBlocked, "charge");
  1189. a(this.actionBlocked, "action");
  1190. a(this.actionBlocked, "dash");
  1191. a(this.actionBlocked, "reaim");
  1192. a(this.actionBlocked, "move");
  1193. this.model.updateLoop(sc.combat.isInCombat(this));
  1194. if (this.explicitAimStart) {
  1195. this.explicitAimStart =
  1196. this.explicitAimStart - ig.system.actualTick;
  1197. if (this.explicitAimStart <= 0) this.explicitAimStart = 0
  1198. }
  1199. if (this.hasStun() && this.interactObject) {
  1200. this.interactObject.onInteractObjectDrop();
  1201. this.explicitAimStart = 0.05;
  1202. this.interactObject = null
  1203. }
  1204. b = this.gatherInput();
  1205. if (this.doEscapeTimer > 0) {
  1206. this.doEscapeTimer = this.doEscapeTimer - ig.system.tick;
  1207. if (this.doEscapeTimer <= 0 || this.params.isDefeated()) {
  1208. this.doEscapeTimer = 0;
  1209. Vec2.assignC(this.dashDir, 0, 0);
  1210. this.hitStable = sc.ATTACK_TYPE.LIGHT
  1211. } else if (this.damageTimer > 0 && this.damageTimer <=
  1212. 0.2) this.damageTimer = 1E-5
  1213. }
  1214. if (this.switchedMode) {
  1215. this.switchedMode = false;
  1216. sc.combat.showModeChange(this, this.model.currentElementMode);
  1217. this.updateSkinAura()
  1218. }
  1219. if (this.isControlBlocked()) {
  1220. this.clearCharge();
  1221. this.clearActionBlocked();
  1222. this.regenShield(false);
  1223. sc.combat.clearModeAura(this);
  1224. this.dashBlock = this.dashTimer = this.dashCount = 0;
  1225. this.hasStun() && this.stunData.time >= this.stunData.stunEscapeTime ? this.handleDash(j,
  1226. b, true, true) : this.hasStun() && this.damageTimer <= 0.2 ? this.handleDash(j, b,
  1227. true) : this.dashDir.x =
  1228. this.dashDir.y = 0;
  1229. this.attackResetTimer = this.attackCounter = 0;
  1230. b = this.currentAction && this.currentAction.eventAction ? 0 : 4;
  1231. if (this.state != b) {
  1232. this.state = b;
  1233. this.jumpingEnabled = false;
  1234. if (this.state == 0) {
  1235. this.setDefaultConfig(this.configs.normal);
  1236. this.defaultConfig.apply(this)
  1237. }
  1238. this.gui.crosshair.setActive(false);
  1239. Vec2.assignC(this.throwDir, 0, 0);
  1240. this.doAttack = false
  1241. }
  1242. this.parent()
  1243. } else {
  1244. if (this.model.hasLevelUp() && this.coll.pos.z == this.coll.baseZPos && sc.model
  1245. .isOutOfCombatDialogReady()) {
  1246. c = (c = (c = this.coll._collData &&
  1247. this.coll._collData.groundEntry) && c.parentColl || c) && c.entity;
  1248. (!c || !c.isDefeated || !c.isDefeated()) && this.levelUpNotifier.runLevelUpScene(this,
  1249. this.model)
  1250. }
  1251. if (this.currentAction && this.currentAction.name == "PLAYER_IDLE" && !Vec2.isZero(b
  1252. .moveDir)) {
  1253. this.cancelAction();
  1254. this.skin.pet && (this.skin.pet.currentAction && this.skin.pet.currentAction ==
  1255. "PLAYER_IDLE") && this.skin.pet.cancelAction()
  1256. }
  1257. this.currentAction || this.clearActionBlocked();
  1258. if (!this.jumping && this.coll.pos.z == this.coll.baseZPos) this.maxJumpHeight = -1;
  1259. this.handleDash(j, b);
  1260. this.handleGuard(j, b);
  1261. this.handleCharge(j, b);
  1262. this.handleStateChange(j, b);
  1263. if (this.dashTimer > 0) {
  1264. ig.game.firstUpdateLoop && sc.stats.addMap("player", "dashTime", ig.system.rawTick);
  1265. this.dashTimer = this.dashTimer - ig.system.tick;
  1266. if (this.dashTimer <= 0) {
  1267. this.dashTimer = 0;
  1268. this.gui.crosshair.setSpeedFactor(1);
  1269. !j.guarding && !j.isCharging && this.defaultConfig.apply(this)
  1270. }
  1271. } else {
  1272. this.dashCount = 0;
  1273. this.updatePlayerMovement(j, b)
  1274. }
  1275. if (this.state != 5 || j.startState == 5) this.gui.crosshair.active && (this.state !=
  1276. 2 || j.guarding) && !j.isCharging ? this.gui.crosshair.getDir(this.face) : ig.input
  1277. .currentDevice == ig.INPUT_DEVICES.KEYBOARD_AND_MOUSE && j.guarding && this.gui
  1278. .crosshair.getDir(this.face);
  1279. this.handleStateStart(j, b);
  1280. this.charging.executing = false;
  1281. !sc.model.isCutscene() && (this.state != 0 || !Vec2.isZero(this.coll.accelDir) || j
  1282. .guarding) ? sc.combat.showModeAura(this, this.model.currentElementMode) : sc.combat
  1283. .clearModeAura(this);
  1284. this.parent();
  1285. if (this.idle.timer > 0 && this.currentAnim == "idle" && !this.isControlBlocked() && !sc
  1286. .model.isCutscene() &&
  1287. !this.currentAction) {
  1288. this.idle.timer = this.idle.timer - ig.system.tick;
  1289. if (this.idle.timer <= 3.75 && this.skin.pet && ig.CollTools.getGroundDistance(this.skin
  1290. .pet.coll, this.coll) < 32 && Vec2.dot(this.skin.pet.face, this.face) <= 0 && this
  1291. .skin.pet.coll.pos.z == this.coll.pos.z) {
  1292. this.idle.timer = 0;
  1293. this.doPetAction()
  1294. } else if (this.idle.timer <= 0) {
  1295. b = this.idle.actions[Math.floor(this.idle.actions.length * Math.random())];
  1296. this.setAction(b)
  1297. }
  1298. } else this.idle.timer = 5 + Math.random() * 5
  1299. }
  1300. }
  1301. if (this.animSheet && this.animSheet.path === 'npc.mira') {
  1302. this.target = !this.target || this.target._killed ? null : this.target;
  1303. }
  1304. },
  1305. gatherInput: function() {
  1306. i.thrown = false;
  1307. i.melee =
  1308. false;
  1309. i.aimStart = false;
  1310. i.aim = false;
  1311. i.attack = false;
  1312. i.autoThrow = false;
  1313. i.charge = false;
  1314. i.dashX = 0;
  1315. i.dashY = 0;
  1316. i.guard = false;
  1317. i.relativeVel = this.coll.relativeVel;
  1318. Vec2.assign(i.moveDir, 0, 0);
  1319. if (ig.game.isControlBlocked()) {
  1320. this.explicitAimStart = 0.05;
  1321. return i
  1322. }
  1323. i.charge = sc.control.charge();
  1324. if (!ig.interact.isBlocked()) {
  1325. if (this.model.getCore(sc.PLAYER_CORE.THROWING)) {
  1326. i.aimStart = sc.control.aimStart();
  1327. i.aim = sc.control.aiming();
  1328. i.thrown = sc.control.thrown();
  1329. i.autoThrow = sc.control.autoThrown()
  1330. }
  1331. if (!this.floating && this.model.getCore(sc.PLAYER_CORE.CLOSE_COMBAT)) {
  1332. i.attack =
  1333. this.model.getCore(sc.PLAYER_CORE.THROWING) ? sc.control.attacking() : sc.control
  1334. .fullScreenAttacking();
  1335. i.melee = sc.control.melee()
  1336. }
  1337. }
  1338. if (this.model.getCore(sc.PLAYER_CORE.GUARD)) i.guard = sc.control.guarding();
  1339. i.relativeVel = !this.floating && this.model.getCore(sc.PLAYER_CORE.MOVE) ? sc.control
  1340. .moveDir(i.moveDir, this.coll.relativeVel) : 1;
  1341. if (Vec2.isZero(i.moveDir)) this.moveDirStartedTimer = 0;
  1342. else {
  1343. var a = Vec2.angle(i.moveDir, this.lastMoveDir);
  1344. if (!Vec2.isZero(this.lastMoveDir) && Math.abs(a) > Math.PI / 3) this.moveDirStartedTimer =
  1345. 0;
  1346. this.moveDirStartedTimer = this.moveDirStartedTimer + ig.system.actualTick
  1347. }
  1348. a = false;
  1349. if (this.charging.time >= 0 || sc.inputForcer.isSubmitted()) a = true;
  1350. i.aim && (a = true);
  1351. ig.input.currentDevice == ig.INPUT_DEVICES.KEYBOARD_AND_MOUSE && (a = true);
  1352. if (this.keepLastMoveDir <= 0 && !Vec2.equal(this.lastMoveDir, i.moveDir)) this
  1353. .keepLastMoveDir = 2 / 60;
  1354. if (this.keepLastMoveDir > 0) {
  1355. this.keepLastMoveDir = this.keepLastMoveDir - ig.system.actualTick;
  1356. if (!sc.inputForcer.isSubmitted() && this.keepLastMoveDir > 0 && (i.moveDir.x != 0 || i
  1357. .moveDir.y !=
  1358. 0)) {
  1359. if (i.moveDir.x == 0) i.moveDir.x = this.lastMoveDir.x;
  1360. if (i.moveDir.y == 0) i.moveDir.y = this.lastMoveDir.y
  1361. }
  1362. }
  1363. Vec2.assign(this.lastMoveDir, i.moveDir);
  1364. if (!this.jumping && sc.control.dashing() && this.dashBlock < 0.2 && (a || this
  1365. .moveDirStartedTimer > 0.05)) {
  1366. i.dashX = i.moveDir.x;
  1367. i.dashY = i.moveDir.y
  1368. }
  1369. return i
  1370. },
  1371. handleDash: function(a, b, c, d) {
  1372. if (this.dashBlock > 0) this.dashBlock = this.dashBlock - ig.system.tick;
  1373. if (!this.actionBlocked.dash && (b.dashX || b.dashY) && this.dashTimer <= 0.4 && this
  1374. .dashBlock <= 0) {
  1375. if (b.dashX) this.dashDir.x = b.dashX;
  1376. if (b.dashY) this.dashDir.y = b.dashY;
  1377. if (d) {
  1378. this.doEscapeTimer = 0.3;
  1379. this.hitStable = sc.ATTACK_TYPE.MASSIVE
  1380. }
  1381. }
  1382. a.redashReady = this.dashTimer <= (this.dashCount < this.maxDash ? 0.15 : 0.1);
  1383. if (c) a.redashReady = false;
  1384. if (!this.jumping && this.model.getCore(sc.PLAYER_CORE.DASH)) {
  1385. if ((this.dashDir.x != 0 || this.dashDir.y != 0) && a.redashReady) {
  1386. if (this.doEscapeTimer) {
  1387. this.doEscapeTimer = 0;
  1388. this.stunEscapeDash = true;
  1389. this.resetStunData();
  1390. this.hitStable = sc.ATTACK_TYPE.LIGHT;
  1391. sc.combat.showCombatMessage(this, sc.COMBAT_MSG_TYPE.STUN_CANCEL)
  1392. } else this.stunEscapeDash =
  1393. false;
  1394. this.startDash();
  1395. a.redashReady = false
  1396. }
  1397. } else {
  1398. this.dashCount = 0;
  1399. this.dashTimer = this.dashDir.x = this.dashDir.y = 0
  1400. }
  1401. },
  1402. handleGuard: function(a, b) {
  1403. var c = this.guard.damage < 1 && a.redashReady && !this.actionBlocked.action && (this.charging
  1404. .time == -1 || this.charging.type == e);
  1405. a.guarding = false;
  1406. var d = this.model.getAction(sc.PLAYER_ACTION.GUARD),
  1407. f = this.model.getAction(sc.PLAYER_ACTION.PERFECT_GUARD);
  1408. if (c)
  1409. if (b.guard) {
  1410. if (this.attackCounter && !this.attackResetTimer) this.attackResetTimer = 0.1;
  1411. if (this.currentAction != d && this.currentAction !=
  1412. f) {
  1413. this.dashTimer = 0;
  1414. if (this.perfectGuardCooldown > 0) this.setAction(d);
  1415. else {
  1416. this.setAction(f);
  1417. this.perfectGuardCooldown = 0.5
  1418. }
  1419. }
  1420. this.gui.crosshair.setSpeedFactor(0.25);
  1421. a.guarding = true;
  1422. ig.game.firstUpdateLoop && sc.stats.addMap("combat", "guardTime", ig.system.rawTick);
  1423. this.recordInput && ig.vars.add("playerVar.input.guardTime", ig.system.tick)
  1424. } else if (this.charging.time != -1 && this.charging.type == e) a.guarding = true;
  1425. else if (this.currentAction == d || this.currentAction == f) {
  1426. this.cancelAction();
  1427. this.gui.crosshair.setSpeedFactor(1)
  1428. }
  1429. this.regenShield(a.guarding)
  1430. },
  1431. handleCharge: function(a, c) {
  1432. if (this.charging.block > 0) {
  1433. this.charging.block = this.charging.block - ig.system.actualTick;
  1434. if (this.charging.block < 0) this.charging.block = 0
  1435. } else if (c.charge && this.charging.time == -1 && this.actionBlocked.charge != -1 && this
  1436. .actionBlocked.charge < 0.2) {
  1437. var d = this.getChargeType(a, c);
  1438. if (this.startCharge(d)) {
  1439. this.attackResetTimer = this.attackCounter = 0;
  1440. this.dashAttackCount = Math.min(this.maxDash, this.dashCount);
  1441. this.dashTimer = 0;
  1442. this.dashDir.x = this.dashDir.y = 0;
  1443. this.charging.swapped = false;
  1444. this.charging.time =
  1445. 0;
  1446. this.charging.cancelTime = 0
  1447. }
  1448. }
  1449. a.applyCharge = 0;
  1450. a.isCharging = false;
  1451. if (this.charging.time >= 0) {
  1452. a.isCharging = true;
  1453. if (!this.actionBlocked.charge) {
  1454. if (this.charging.time == 0) {
  1455. ig.slowMotion.add(0.1, 0.2, "playerCharge");
  1456. this.showChargeEffect(1);
  1457. this.gui.crosshair.setSpecial(true);
  1458. if (!a.guarding) {
  1459. this.currentAction && this.cancelAction();
  1460. this.doPlayerAction("CHARGING")
  1461. }
  1462. this.coll.time.animStatic = true;
  1463. this.gui.crosshair.active ? this.gui.crosshair.getDir(this.face) : Vec2.isZero(c
  1464. .moveDir) || Vec2.assign(this.face, c.moveDir)
  1465. }
  1466. Vec2.isZero(c.moveDir) ||
  1467. Vec2.assign(this.charging.prefDir, c.moveDir);
  1468. d = b(this.charging);
  1469. ig.game.firstUpdateLoop && sc.stats.addMap("combat", "charging", ig.system.rawTick);
  1470. if (!sc.autoControl.isActive() || !ig.slowMotion.hasSlowMotion("tutorialMsg")) this
  1471. .charging.time = this.charging.time + ig.system.actualTick;
  1472. if (!sc.autoControl.isActive()) this.charging.cancelTime = this.charging.cancelTime + ig
  1473. .system.actualTick;
  1474. if (this.charging.maxLevel < 3) this.charging.time = Math.min(this.charging.time, h[this
  1475. .charging.maxLevel] - 0.05);
  1476. var e = b(this.charging);
  1477. if (d >= 1 && e != d) {
  1478. this.charging.cancelTime = 0;
  1479. this.showChargeEffect(e)
  1480. }
  1481. }
  1482. if ((this.charging.cancelTime > 1 || !c.charge) && this.charging.time >= h[0]) {
  1483. a.applyCharge = b(this.charging);
  1484. a.isCharging = false;
  1485. this.clearCharge();
  1486. if (this.charging.cancelTime > 1) this.charging.block = 0.5
  1487. }
  1488. }
  1489. },
  1490. handleStateChange: function(a, b) {
  1491. a.startState = -1;
  1492. if (a.isCharging) {
  1493. if (!this.charging.swapped)
  1494. if (this.charging.type != e && a.guarding) {
  1495. this.charging.swapped = true;
  1496. this.startCharge(e)
  1497. } else if (this.charging.type != f && !a.guarding && this.charging.time <
  1498. 0.1 && sc.control.dashing() && !Vec2.isZero(b.moveDir)) {
  1499. this.charging.swapped = true;
  1500. this.startCharge(f)
  1501. } else if (this.charging.type == d && this.model.getCore(sc.PLAYER_CORE.THROWING) && sc
  1502. .control.chargeThrowSwap()) {
  1503. this.charging.swapped = true;
  1504. this.startCharge(c)
  1505. } else if (this.charging.type == c && sc.control.chargeAttackSwap()) {
  1506. this.charging.swapped = true;
  1507. this.startCharge(d)
  1508. }
  1509. } else {
  1510. if (this.state == 4) {
  1511. this.state = 0;
  1512. a.startState = this.state
  1513. }
  1514. if (a.applyCharge) {
  1515. this.state = 5;
  1516. if (this.charging.type == c) {
  1517. this.gui.crosshair.getThrowDir(this.throwDir);
  1518. this.gui.crosshair.setThrown()
  1519. }
  1520. a.startState = this.state
  1521. } else if (this.state == 0 && (b.attack || b.melee)) {
  1522. this.state = 3;
  1523. a.startState = this.state
  1524. } else if (this.state == 0 && (b.aimStart || !this.explicitAimStart && !this.dashTimer && b
  1525. .aim)) {
  1526. this.state = 1;
  1527. a.startState = this.state
  1528. } else if (this.state == 1)
  1529. if (b.thrown || b.autoThrow && (!this.dashTimer || a.redashReady)) {
  1530. this.gui.crosshair.getThrowDir(this.throwDir);
  1531. this.state = 2;
  1532. a.startState = this.state;
  1533. this.throwCharge = this.gui.crosshair.isThrowCharged();
  1534. this.gui.crosshair.setThrown();
  1535. this.gui.crosshair.setSpeedFactor(0.25)
  1536. } else {
  1537. if (!b.aim) {
  1538. this.state = 0;
  1539. a.startState = this.state
  1540. }
  1541. }
  1542. else if (this.state == 2 || this.state == 3 || this.state == 5) {
  1543. var g = b.thrown && this.actionBlocked.action >= 0 && this.actionBlocked.action < 0.2 || b
  1544. .autoThrow && !this.actionBlocked.action;
  1545. if (this.gui.crosshair.active && !this.doAttack && g) {
  1546. this.gui.crosshair.getThrowDir(this.throwDir);
  1547. this.throwCharge = this.gui.crosshair.isThrowCharged();
  1548. this.gui.crosshair.setThrown()
  1549. }
  1550. if ((b.attack || b.melee) && this.actionBlocked.action >= 0 && this.actionBlocked.action <
  1551. 0.2) this.doAttack = true;
  1552. if (!this.actionBlocked.action && !Vec2.isZero(this.throwDir)) {
  1553. this.state = 2;
  1554. a.startState = this.state
  1555. } else if (!this.actionBlocked.action && this.doAttack) {
  1556. this.state = 3;
  1557. a.startState = this.state
  1558. } else if (!this.currentAction || a.guarding || !this.actionBlocked.move && (b.moveDir
  1559. .x != 0 || b.moveDir.y != 0) || !this.actionBlocked.reaim && b.aim) {
  1560. if (this.attackCounter && !this.attackResetTimer) this.attackResetTimer = 0.1;
  1561. if (this.dashTimer <= 0 && !a.guarding) {
  1562. this.cancelAction();
  1563. this.clearActionBlocked()
  1564. }
  1565. if (b.aim) {
  1566. this.state =
  1567. 1;
  1568. a.startState = this.state
  1569. } else {
  1570. this.state = 0;
  1571. a.startState = this.state;
  1572. this.setCurrentAnim("preIdle", true, "idle")
  1573. }
  1574. }
  1575. }
  1576. }
  1577. },
  1578. updatePlayerMovement: function(a, b) {
  1579. if (a.guarding) {
  1580. this.state == 1 && ig.game.firstUpdateLoop && sc.stats.addMap("combat", "aiming", ig.system
  1581. .rawTick);
  1582. Vec2.assignC(this.coll.accelDir, 0, 0);
  1583. (b.moveDir.x || b.moveDir.y) && Vec2.assign(this.face, b.moveDir)
  1584. } else if (this.state == 0 || this.state == 1) {
  1585. this.state == 1 && ig.game.firstUpdateLoop && sc.stats.addMap("combat", "aiming", ig.system
  1586. .rawTick);
  1587. if (!this.currentAction ||
  1588. this.currentAction.parallelMove) {
  1589. Vec2.assign(this.coll.accelDir, b.moveDir);
  1590. this.coll.relativeVel = b.relativeVel
  1591. }
  1592. this.jumping && (Vec2.dot(this.coll.accelDir, this.jumpForwardDir) >= 0 && Vec2.distance(
  1593. this.coll.pos, this.jumpPoint) < 8 ? Vec2.add(this.coll.accelDir, this
  1594. .jumpForwardDir) : Vec2.assignC(this.jumpForwardDir, 0, 0))
  1595. } else this.jumping || Vec2.assignC(this.coll.accelDir, 0, 0)
  1596. },
  1597. handleStateStart: function(a, b) {
  1598. a.startState != -1 && this.cancelJump();
  1599. switch (a.startState) {
  1600. case 0:
  1601. this.recordInput && ig.vars.set("playerVar.input.aiming",
  1602. false);
  1603. this.setWalkAnims("normal");
  1604. this.setDefaultConfig(this.configs.normal);
  1605. this.gui.crosshair.setActive(false);
  1606. break;
  1607. case 1:
  1608. this.recordInput && ig.vars.set("playerVar.input.aiming", true);
  1609. this.explicitAimStart = 0;
  1610. this.setDefaultConfig(this.configs.aiming);
  1611. this.dashTimer <= 0 && (!this.jumping && !a.guarding) && this.setAction(this.model
  1612. .getAction(sc.PLAYER_ACTION.AIM_START));
  1613. this.setWalkAnims("aiming");
  1614. this.gui.crosshair.chargeActive = this.model.getCore(sc.PLAYER_CORE.CHARGE);
  1615. this.gui.crosshair.active || this.gui.crosshair.setActive(true);
  1616. this.gui.crosshair.setSpeedFactor(1);
  1617. break;
  1618. case 3:
  1619. this.recordInput && ig.vars.set("playerVar.input.aiming", false);
  1620. ig.input.currentDevice == ig.INPUT_DEVICES.KEYBOARD_AND_MOUSE && (this.model.getCore(sc
  1621. .PLAYER_CORE.THROWING) && sc.options.get("close-circle")) && this.gui.crosshair
  1622. .setCircleGlow();
  1623. this.attackCounter++;
  1624. this.attackResetTimer = 0;
  1625. var g;
  1626. if (this.attackCounter <= 3) g = this.attackCounter % 2 == 1 ? "ATTACK_REV" : "ATTACK";
  1627. else {
  1628. g = "ATTACK_FINISHER";
  1629. this.attackResetTimer = this.attackCounter = 0
  1630. }
  1631. ig.vars.add("playerVar.input.melee",
  1632. 1);
  1633. sc.stats.addMap("player", "close", 1);
  1634. this.dashAttackCount = Math.min(this.maxDash, this.dashCount);
  1635. this.charging.executeLevel = 0;
  1636. this.startCloseCombatAction(g, b);
  1637. break;
  1638. case 2:
  1639. if (this.recordInput) {
  1640. ig.vars.set("playerVar.input.aiming", false);
  1641. ig.vars.add("playerVar.input.thrown", 1)
  1642. }
  1643. this.throwCounter++;
  1644. if (this.animSheet && this.animSheet.path === 'npc.mira') {
  1645. g = this.throwCharge ? "THROW_CHARGED" : "THROW_NORMAL";
  1646. } else {
  1647. g = this.throwCounter % 2 == 0 ? this.throwCharge ? "THROW_CHARGED_REV" :
  1648. "THROW_NORMAL_REV" : this.throwCharge ? "THROW_CHARGED" : "THROW_NORMAL";
  1649. }
  1650. this.dashAttackCount = Math.min(this.maxDash, this.dashCount);
  1651. this.charging.executeLevel =
  1652. 0;
  1653. var temp = this.target;
  1654. if (this.animSheet && this.animSheet.path === 'npc.mira' && g === "THROW_CHARGED") {
  1655. this.target = null;
  1656. this.startThrowAction(g, b);
  1657. this.target = temp;
  1658. } else {
  1659. this.startThrowAction(g, b);
  1660. }
  1661. break;
  1662. case 5:
  1663. g = this.getChargeAction(this.charging.type, a.applyCharge);
  1664. if (sc.options.get("combat-art-name")) {
  1665. var h = this.model.getCombatArtName(sc.PLAYER_ACTION[g]);
  1666. if (h) {
  1667. h = new sc.SmallEntityBox(this, h.toString(), 1);
  1668. h.stopRumble();
  1669. ig.gui.addGuiElement(h)
  1670. }
  1671. }
  1672. this.charging.executeLevel = a.applyCharge;
  1673. sc.stats.addMap("combat", "specials", 1);
  1674. sc.stats.addMap("combat", "specials-" + this.model.currentElementMode + "-level-" + a
  1675. .applyCharge, 1);
  1676. if (this.charging.type == d) {
  1677. sc.stats.addMap("combat",
  1678. "specialsClose", 1);
  1679. Vec2.isZero(this.charging.prefDir) || Vec2.assign(this.face, this.charging.prefDir);
  1680. this.startCloseCombatAction(g, b)
  1681. } else if (this.charging.type == c) {
  1682. sc.stats.addMap("combat", "specialsThrow", 1);
  1683. this.startThrowAction(g, b)
  1684. } else if (this.charging.type == e) {
  1685. sc.stats.addMap("combat", "specialsGuard", 1);
  1686. this.doCombatAction(g)
  1687. } else if (this.charging.type == f) {
  1688. sc.stats.addMap("combat", "specialsDash", 1);
  1689. Vec2.isZero(this.charging.prefDir) || Vec2.assign(this.dashDirData, this.charging
  1690. .prefDir);
  1691. this.gui.crosshair.setActive(false);
  1692. this.setAttribute("dashDir", this.dashDirData);
  1693. this.doCombatAction(g)
  1694. }
  1695. }
  1696. },
  1697. startThrowAction: function(a, b) {
  1698. if (this.dashTimer > 0) this.dashBlock = 0.3;
  1699. this.dashTimer = 0;
  1700. Vec2.assign(this.face, this.throwDir);
  1701. this.coll.pos.z == this.coll.baseZPos ? this.setAttribute("dashDir", Vec2.assign(this
  1702. .dashDirData, b.moveDir)) : this.setAttribute("dashDir", Vec2.assignC(this.dashDirData, 0,
  1703. 0));
  1704. Vec2.assign(this.throwDirData, this.throwDir);
  1705. Vec2.assignC(this.throwDir, 0, 0);
  1706. this.doCombatAction(a)
  1707. },
  1708. startCloseCombatAction: function(a, b) {
  1709. if (this.attackCounter > 1 && this.animSheet && this.animSheet.path === 'npc.mira') {
  1710. b.melee = true;
  1711. a = "ATTACK_FINISHER";
  1712. this.attackResetTimer = this.attackCounter = 0;
  1713. }
  1714. if (this.dashTimer >
  1715. 0) this.dashBlock = 0.3;
  1716. this.dashTimer = 0;
  1717. this.doAttack = false;
  1718. this.gui.crosshair.setActive(false);
  1719. this.coll.pos.z == this.coll.baseZPos ? this.setAttribute("dashDir", Vec2.assign(this
  1720. .dashDirData, b.moveDir)) : this.setAttribute("dashDir", Vec2.assignC(this.dashDirData, 0,
  1721. 0));
  1722. Vec2.isZero(b.moveDir) || Vec2.assign(this.face, b.moveDir);
  1723. this.doCombatAction(a)
  1724. },
  1725. startDash: function() {
  1726. if (this.state == 3) {
  1727. this.recordInput && ig.vars.add("playerVar.input.attackDashCancel", 1);
  1728. sc.stats.addMap("player", "atkDashCancel", 1)
  1729. }
  1730. this.attackCounter =
  1731. 0;
  1732. this.dashCount++;
  1733. this.doAttack = this.dashPerfect = false;
  1734. Vec2.assignC(this.throwDir, 0, 0);
  1735. this.gui.crosshair.active || Vec2.assign(this.face, this.dashDir);
  1736. this.setAttribute("dashDir", Vec2.assign(this.dashDirData, this.dashDir));
  1737. this.dashDir.x = this.dashDir.y = 0;
  1738. if (this.charging.time >= 0) {
  1739. if (this.charging.time <= 0.2) return;
  1740. this.clearCharge();
  1741. this.charging.block = 0.5
  1742. }
  1743. if (this.state == 2) this.state = 1;
  1744. else if (this.state == 3) {
  1745. this.setWalkAnims("normal");
  1746. this.setDefaultConfig(this.configs.normal);
  1747. this.state = 0
  1748. }
  1749. if (this.dashCount <=
  1750. this.maxDash) {
  1751. sc.stats.addMap("player", "dash", 1);
  1752. sc.stats.addMap("player", "steps", 3)
  1753. }
  1754. this.clearActionBlocked();
  1755. this.gui.crosshair.reducePrecision(0.2);
  1756. this.gui.crosshair.setSpeedFactor(0.5);
  1757. this.jumpingEnabled = false;
  1758. this.dashTimer = 0.36;
  1759. this.onMoveEffect("dash");
  1760. var a = this.dashCount <= this.maxDash ? "DASH" : "DASH_SLOW";
  1761. this.playerTrack.lastPlayerAction = a;
  1762. this.doPlayerAction(a);
  1763. this.dashCount <= this.maxDash && sc.combat.showModeDash(this, this.model.currentElementMode)
  1764. },
  1765. deferredUpdate: function() {
  1766. if (this.interactObject &&
  1767. this.interactObject.onInteractObjectDeferredUpdate) this.interactObject
  1768. .onInteractObjectDeferredUpdate(this)
  1769. },
  1770. postActionUpdate: function() {
  1771. if (this.interactObject && this.interactObject.onInteractObjectPostActionUpdate) this
  1772. .interactObject.onInteractObjectPostActionUpdate()
  1773. },
  1774. cancelInteract: function() {
  1775. if (this.interactObject) {
  1776. this.interactObject = null;
  1777. if (sc.control.aiming()) this.explicitAimStart = 0.05
  1778. }
  1779. },
  1780. onPreDamageModification: function(a, b, c, d, e, f) {
  1781. this.recordInput && (f ? ig.vars.add("playerVar.input.shieldedHits",
  1782. 1) : ig.vars.add("playerVar.input.hits", 1));
  1783. if (f) {
  1784. sc.stats.addMap("combat", "shieldedHits", 1);
  1785. if (f == sc.SHIELD_RESULT.PERFECT) {
  1786. ig.vars.add("playerVar.input.perfectShield", 1);
  1787. sc.stats.addMap("combat", "perfectShield", 1);
  1788. if (this.params.getModifier("PERFECT_GUARD_RESET") >= 1) {
  1789. this.perfectGuardCooldown = 0;
  1790. for (b = this.shieldsConnections.length; b--;) this.shieldsConnections[b]
  1791. .resetPerfectGuardTime()
  1792. }
  1793. }
  1794. if (this.params.getModifier("GUARD_SP")) {
  1795. b = this.params.getModifier("GUARD_SP");
  1796. this.params.addSp(b * c.damageFactor *
  1797. (f == sc.SHIELD_RESULT.PERFECT ? 2 : 1))
  1798. }
  1799. } else sc.stats.addMap("combat", "damageHits", 1);
  1800. sc.arena.onPreDamageModification(e, f, a);
  1801. return false
  1802. },
  1803. onPlayerShieldBreak: function() {
  1804. sc.stats.addMap("combat", "shieldBreaks", 1);
  1805. this.state = 4;
  1806. this.cancelAction()
  1807. },
  1808. onPerfectDash: function() {
  1809. if (!this.dashPerfect) {
  1810. sc.stats.addMap("player", "perfectDash", 1);
  1811. sc.arena.onPerfectDodge();
  1812. this.dashPerfect = true
  1813. }
  1814. },
  1815. onDamageTaken: function(a, b) {
  1816. b != sc.SHIELD_RESULT.PERFECT && !sc.model.isCutscene() && sc.stats.addMap("combat",
  1817. "damageTaken",
  1818. a)
  1819. },
  1820. onHeal: function(a, b) {
  1821. sc.stats.addMap("combat", "healed", b)
  1822. },
  1823. onTargetHit: function(a, b, c, d) {
  1824. if (!ig.vars.get("playerVar.damageStatsIgnore")) {
  1825. sc.stats.addMap("combat", "damageGiven", c.damage);
  1826. sc.stats.setMapMax("combat", "maxDamage", c.damage)
  1827. }
  1828. this.combatStats.lastTarget = a;
  1829. if (this.animSheet && this.animSheet.path === 'npc.mira') {
  1830. this.target = a;
  1831. }
  1832. if (c.critical) {
  1833. sc.stats.addMap("combat", "critHits", 1);
  1834. b.ballDamage ? sc.stats.addMap("combat", "critHitsThrow", 1) : sc.stats.addMap("combat",
  1835. "critHitsClose", 1)
  1836. }
  1837. if (b.spFactor) {
  1838. b.ballDamage || sc.stats.addMap("player", "closeHits", 1);
  1839. this.model.onTargetHit(a,
  1840. b, c)
  1841. }
  1842. sc.arena.onTargetHit(b, c, d, a);
  1843. this.parent(a, b, c, d)
  1844. },
  1845. onJump: function(a, b) {
  1846. sc.stats.addMap("player", "jumps", 1);
  1847. this.maxJumpHeight = this.coll.pos.z + a;
  1848. Vec2.assign(this.jumpPoint, this.coll.pos);
  1849. a >= 16 ? Vec2.assign(this.jumpForwardDir, this.coll.accelDir) : Vec2.assignC(this
  1850. .jumpForwardDir, 0, 0);
  1851. this.parent(a, b)
  1852. },
  1853. onPhysicsSquish: function(a) {
  1854. if (a.squishRespawn) {
  1855. Vec3.assign(this.respawn.pos, this.mapStartPos);
  1856. this.quickFall(ig.TERRAIN.HOLE)
  1857. }
  1858. },
  1859. varsChanged: function() {
  1860. this.condition && this.condition.evaluate();
  1861. if (!this.floating && ig.vars.get("playerVar.staticFloat")) {
  1862. this.floating = true;
  1863. this.configs.normal.overwrite("floatHeight", 6);
  1864. this.configs.aiming.overwrite("floatHeight", 6);
  1865. this.setDefaultConfig(this.configs.normal)
  1866. } else if (this.floating && !ig.vars.get("playerVar.staticFloat")) {
  1867. this.floating = false;
  1868. this.configs.normal.clearOverwrite();
  1869. this.configs.aiming.clearOverwrite();
  1870. this.setDefaultConfig(this.configs.normal)
  1871. }
  1872. if (this.recordInput != ig.vars.get("playerVar.recordInput"))
  1873. if (this.recordInput = ig.vars.get("playerVar.recordInput")) {
  1874. ig.vars.set("playerVar.input.thrown",
  1875. 0);
  1876. ig.vars.set("playerVar.input.aiming", false);
  1877. ig.vars.set("playerVar.input.guardTime", 0);
  1878. ig.vars.set("playerVar.input.shieldedHits", 0);
  1879. ig.vars.set("playerVar.input.hits", 0);
  1880. ig.vars.set("playerVar.input.perfectShield", 0);
  1881. ig.vars.set("playerVar.input.attackDashCancel", 0);
  1882. ig.vars.set("playerVar.input.melee", 0)
  1883. }
  1884. },
  1885. modelChanged: function(a, b, c) {
  1886. if (a == this.params) b == sc.COMBAT_PARAM_MSG.STATS_CHANGED && this.updateModelStats();
  1887. else if (a == this.model)
  1888. if (b == sc.PLAYER_MSG.ELEMENT_MODE_CHANGE) {
  1889. this.copyModelSkills();
  1890. this.updateModelStats()
  1891. } else b == sc.PLAYER_MSG.CONFIG_CHANGED ? this.initModel() : b == sc.PLAYER_MSG
  1892. .STATS_CHANGED ? this.updateModelStats() : b == sc.PLAYER_MSG.ITEM_USED ? this
  1893. .itemConsumer.activateItemEffect(this, this.model, c) : b == sc.PLAYER_MSG.ITEM_TOGGLED &&
  1894. this.updateModelStats();
  1895. else a == sc.playerSkins ? c == "Appearance" ? this.updateAnimSheet() : c == "StepEffect" ?
  1896. this.updateSkinStepFx() : c == "Aura" ? this.updateSkinAura() : c == "Pet" && this
  1897. .updateSkinPet(true) : a == sc.model && b == sc.GAME_MODEL_MSG.STATE_CHANGED && this
  1898. .updateAnimSheet()
  1899. },
  1900. copyModelSkills: function() {
  1901. this.proxies = this.model.getBalls()
  1902. },
  1903. doQuickRespawn: function(a, b, c) {
  1904. (a == ig.TERRAIN.WATER || a == ig.TERRAIN.HOLE || a == ig.TERRAIN.COAL || a == ig.TERRAIN
  1905. .QUICKSAND || a == ig.TERRAIN.HIGHWAY) && sc.stats.addMap("player", "respawns", 1);
  1906. a == ig.TERRAIN.WATER ? sc.stats.addMap("player", "waterDeath", 1) : a == ig.TERRAIN.COAL ? sc
  1907. .stats.addMap("player", "coalDeath", 1) : a == ig.TERRAIN.QUICKSAND ? sc.stats.addMap(
  1908. "player", "sandDeath", 1) : a == ig.TERRAIN.HOLE ? sc.stats.addMap("player", "holeDeath",
  1909. 1) : a == ig.TERRAIN.HIGHWAY &&
  1910. sc.stats.addMap("player", "highwayDeath", 1);
  1911. this.parent(a, b, c)
  1912. },
  1913. onRespawnEnd: function() {
  1914. for (var a = ig.game.getOverlapEntities(this), b = a.length; b--;) {
  1915. var c = a[b];
  1916. (c instanceof ig.ENTITY.WavePushPullBlock || c instanceof ig.ENTITY.PushPullBlock) && c
  1917. .resetPos()
  1918. }
  1919. },
  1920. isThrowCharged: function() {
  1921. return this.gui.crosshair.isThrowCharged()
  1922. },
  1923. setOverrideBall: function(a) {
  1924. this.overrideBall = a
  1925. },
  1926. useItem: function(a) {
  1927. this.itemConsumer.runItemUseAction(this, this.model, a)
  1928. },
  1929. onVarAccess: function(a, b) {
  1930. return b[1] == "hasElementShield" ?
  1931. this.hasShield("elementOrbShield") : this.parent(a, b)
  1932. }
  1933. });
  1934. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement