-
Notifications
You must be signed in to change notification settings - Fork 4
/
everything-must-die.js
136 lines (119 loc) · 3.53 KB
/
everything-must-die.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
everythingMustDie = {};
emdTranslations = {
'nl-NL': ["Padmeubilair vernielen", "Bezoekers opblazen"],
'ko-KR': ["보도 기물 전부 파괴하기", "손님 폭발시키기"],
'es-ES': ["Destruir muebles del camino", "Explotar visitantes"],
'eo-ZZ': ["Detrui meblojn de trotuaroj", "Eksplodigi gastojn"],
'it-IT': ["Distruggi decorazioni percorso", "Fai esplodere visitatori"],
'hu-HU': ["Bútorok tönkretétele az utakon", "Vendégek felrobbantása"],
'pt-BR': ["Destruir móveis no caminho", "Explodir visitantes"],
'de-DE': ["Wegobjekte zerstören", "Gäste sprengen"],
'zh-TW': ["毀壞道路上的設施", "引爆遊客"],
'ca-ES': ["Destrueix el mobiliari dels camins", "Fes explotar els visitants"],
'zh-CN': ["摧毁道路上的物品", "炸掉游客"],
};
function emdGetTranslation(id, fallback)
{
var language = context.configuration.get("general.language");
if (emdTranslations.hasOwnProperty(language) && id < emdTranslations[language].length)
{
return emdTranslations[language][id];
}
return fallback;
}
// #3526: Make vandalism
var destroyPathFurnitureGA = function(isExecuting, args)
{
if (isExecuting)
{
for (var y = 0; y < map.size.y; y++) {
for (var x = 0; x < map.size.x; x++) {
var tile = map.getTile(x, y);
for (var i = 0; i < tile.numElements; i++) {
var element = tile.getElement(i);
if (element.type === 'footpath') {
element.isAdditionBroken = true;
}
}
}
}
}
return {
cost: 0,
expenditureType: "landscaping",
position: {
x: -1,
y: -1,
z: 0
}
}
}
var destroyPathFurniture = function()
{
context.executeAction("emd-destroy-path-furniture", {}, function() {});
}
// Exact replication of the EXPLODE!!! cheat.
var explodeGA = function(isExecuting, args)
{
if (isExecuting)
{
for (var i = 0; i < map.numEntities; i++)
{
var entity = map.getEntity(i);
if (!entity)
{
continue;
}
var entityIsGuest = entity.type === 'peep' && entity.peepType === "guest";
if (entityIsGuest && context.getRandom(0, 6) === 0)
{
entity.setFlag("explode", true);
}
}
}
return {
cost: 0,
expenditureType: "landscaping",
position: {
x: -1,
y: -1,
z: 0
}
}
}
var explode = function()
{
context.executeAction("emd-explode-guests", {}, function() {});
}
var main = function()
{
context.registerAction(
"emd-destroy-path-furniture",
function(args) {
return destroyPathFurnitureGA(false, args);
},
function(args) {
return destroyPathFurnitureGA(true, args);
}
);
context.registerAction(
"emd-explode-guests",
function(args) {
return explodeGA(false, args);
},
function(args) {
return explodeGA(true, args);
}
);
ui.registerMenuItem(emdGetTranslation(0, "Destroy path furniture"), destroyPathFurniture);
ui.registerMenuItem(emdGetTranslation(1, "Explode guests"), explode);
};
registerPlugin({
name: 'Everything must die',
version: '0.1.0',
authors: ['Gymnasiast'],
licence: 'MIT',
type: 'remote',
targetApiVersion: 0,
main: main
});