-
Notifications
You must be signed in to change notification settings - Fork 8
/
debug.js
107 lines (88 loc) · 3.51 KB
/
debug.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*global gs, console*/
/*global Item*/
/*global FACTION*/
/*jshint esversion: 6*/
'use strict';
var debug = {};
// SPAWN_NEXT_NPC:
// Use for testing each NPC in the game, one by one
// ************************************************************************************************
debug.spawnNextNPC = function () {
if (!this.nextNPCIndex) {
this.nextNPCIndex = 0;
}
if (this.nextNPCIndex < gs.npcTypeList.length) {
console.log(gs.debugNextNPCIndex);
gs.spawnNPCOrGroup({x: gs.pc.tileIndex.x + 1, y: gs.pc.tileIndex.y}, gs.npcTypeList[gs.debugNextNPCIndex].name);
gs.updateCharacterFrames();
gs.updateTileMapSprites();
gs.debugNextNPCIndex += 1;
}
else {
console.log('No more NPCs');
}
};
// CREATE_OBJECT:
// ************************************************************************************************
debug.createObject = function (typeName, tileIndex = {x: gs.pc.tileIndex.x + 1, y: gs.pc.tileIndex.y}) {
var obj;
obj = gs.createObject(tileIndex, typeName);
gs.updateTileMapSprites();
return obj;
};
// FLOOD_OBJECT:
// ************************************************************************************************
debug.floodObject = function () {
var tileIndex = gs.getNearestPassableIndex(gs.pc.tileIndex);
console.log(tileIndex.depth);
gs.debugCreateObject('Table', tileIndex);
gs.updateTileMapSprites();
};
// CREATE_PARTICLE_POOF
// ************************************************************************************************
debug.createParticlePoof = function() {
gs.createParticlePoof({x: gs.pc.tileIndex.x + 1, y: gs.pc.tileIndex.y});
};
// CREATE_NPC:
// Quick debug function for creating NPCs adjacent to the player
// Generally called from the console during testing and debugging
// ************************************************************************************************
debug.createNPC = function (typeName, flags) {
console.log('Creating NPC: ' + typeName);
gs.createNPC({x: gs.pc.tileIndex.x + 1, y: gs.pc.tileIndex.y}, typeName, flags);
gs.updateCharacterFrames();
gs.updateTileMapSprites();
};
// AGRO_ALL_NPCS:
// ************************************************************************************************
debug.agroAllNPCs = function () {
gs.characterList.forEach(function (npc) {
if (npc.isAlive && npc.faction === FACTION.HOSTILE) {
npc.agroPlayer();
}
}, this);
};
// ADD_ITEM:
// ************************************************************************************************
debug.addItem = function (typeName, flags) {
gs.pc.inventory.addItem(Item.createItem(typeName, flags));
};
// CREATE_FLOOR_ITEM:
// ************************************************************************************************
debug.createFloorItem = function (typeName, flags) {
var tileIndex = {x: gs.pc.tileIndex.x + 1, y: gs.pc.tileIndex.y};
gs.createFloorItem(tileIndex, Item.createItem(typeName, flags));
};
// CREATE_RANDOM_FLOOR_ITEM:
// ************************************************************************************************
debug.createRandomFloorItem = function (dropTableName) {
var tileIndex = {x: gs.pc.tileIndex.x + 1, y: gs.pc.tileIndex.y};
gs.createRandomFloorItem(tileIndex, dropTableName);
};
// SET_LEVEL:
// Use this to hack the players level
// ************************************************************************************************
debug.setPlayerLevel = function (level) {
gs.pc.level = level;
gs.pc.exp = gs.expPerLevel[gs.pc.level];
};