View difference between Paste ID: QP2GWCa3 and qr6rkTjJ
SHOW: | | - or go back to the newest paste.
1
tfm.exec.setGameTime(3,true)
2
roles={0,1}
3
maps={7489629}
4
data={}
5
text={}
6
lang={}
7
players={}
8
alive=0
9
lang.en={
10
	menu="Menu",
11
  profile2="Profile",
12
  help2="Help",
13
  help="In #bombdeliver the goal of the game is for protectors to catch the mouse with the bomb before the mouse gets to the hole. The mouse with the bomb can use attacks to shield off protectors.",
14
  wins="Total Wins",
15
  wins_Bomber="Wins As Bomber",
16
  wins_Protector="Wins As Protector",
17
  close="Close",
18
	health=100,
19
  bomber_Wins="Bomber Wins!",
20
  protector_Wins="Protectors Win!",
21
  powerups2="Powerups",
22
  powerup1="[Normal Attack]</J> Is activated by pressing space. Only works for Protectors when they are near the bomber, but works for Bombers at any time.",
23
  powerup2="[Mega Jump]</J> Is activated by the down arrow."
24
}
25
for _, s in next, {'AutoTimeLeft', 'PhysicalConsumables', 'AfkDeath', 'AutoShaman', 'AutoNewGame'} do
26
    tfm.exec['disable' .. s]()
27
end
28
function particles(x,y)
29
  tfm.exec.displayParticle(9,x,y+10,-0.4,0.1,0.2,0.3,nil)
30
  tfm.exec.displayParticle(9,x,y+10,-0.6,0.2,0.6,0.2,nil)
31
  tfm.exec.displayParticle(9,x,y+10,-0.8,0.3,0.8,0.1,nil)
32
  tfm.exec.displayParticle(9,x,y+10,0.4,0.4,-0.4,0.3,nil)
33
  tfm.exec.displayParticle(9,x,y+10,0.6,0.5,-0.6,0.2,nil)
34
  tfm.exec.displayParticle(9,x,y+10,0.8,0.6,-0.8,0.1,nil)
35
end
36
function bigJump(n,x,y)
37
  tfm.exec.movePlayer(n,0,0,false,0,-80,true)
38
  tfm.exec.displayParticle(3,x-5,y+10,-0.8,0,0,0,n)
39
  tfm.exec.displayParticle(3,x+5,y+10,0.8,0,0,0,n)
40
  tfm.exec.displayParticle(3,x-10,y+10,-1.7,0,0,0,n)
41
  tfm.exec.displayParticle(3,x+10,y+10,1.7,0,0,0,n)
42
  particles(x,y)
43
end
44
function identifyBomber(n)
45
  if data[n].role==0 then
46
  	tfm.exec.setNameColor(n,0x00FF00)
47
		tfm.exec.movePlayer(n,1023,432,false,0,50,false)
48
  elseif data[n].role==1 then
49
    tfm.exec.setNameColor(n,0xFF0000)
50
  end
51
end
52
function countAlive()
53
	alive=0
54
	for n,player in pairs(tfm.get.room.playerList) do
55
		if tfm.get.room.playerList[n].isDead==false then
56
			alive=alive+1
57
		end
58
  end
59
end
60
function removeWinner()
61
	ui.removeTextArea(20,nil)
62
  ui.removeTextArea(30,nil)
63
  ui.removeTextArea(40,nil)
64
  ui.removeTextArea(50,nil)
65
  ui.removeTextArea(60,nil)
66
  ui.removeTextArea(19,nil)
67
end
68
	
69
function win(n)
70
	for n,player in pairs(tfm.get.room.playerList) do
71
		if tfm.get.room.playerList[n].isDead==false and data[n].role==0 then
72
73
        	data[n].wins=data[n].wins+1
74
			data[n].wins_Protector=data[n].wins_Protector+1
75
		end
76
	end
77
end
78
function insertName(n)
79
	table.insert(players,n)
80
end
81
function setLang(n)
82
	text[n]=lang[tfm.get.room.playerList[n].community] or lang.en
83
end
84
function setData(n)
85
	data[n]=
86
  {
87
		wins=0,
88
    role=0,
89
    health=100,
90
		spawn=1,
91
    wins_Protector=0,
92
    wins_Bomber=0
93
  }
94
end
95
function chooseRole()
96
  for n,player in pairs(tfm.get.room.playerList) do
97
		data[n].role=0
98
	end
99
		player=players[math.random(#players)]
100
		data[player].role=1
101
		player=""..player
102
end
103
function bindKeyboard(n)
104
  for i=0,100 do
105
    tfm.exec.bindKeyboard(n,i,true,true)
106
  end
107
end
108
function showMenu(n)
109
	ui.addTextArea(0, "<p align='center'><font face='calibri'><a href='event:menu2'>"..text[n].menu, n, 10, 30, 42, 20, 0x000001, 0xFFFFFF, 1, true)
110
end
111
function showMenu2(n)
112
	ui.addTextArea(0, "<p align='center'><font face='calibri'><a href='event:Menu'>"..text[n].menu.." </a>| <a href='event:Help'>"..text[n].help2.."</a> | <a href='event:Profile'>"..text[n].profile2.."</a> | <a href='event:Powerups'>"..text[n].powerups2, n, 10, 30, 190, 20, 0x000001, 0xffffff, 1, true)
113
end
114
function showHealth(n)
115
  ui.addTextArea(-3, "", n, 319, 27, 100, 18, 0xffffff, 0xffffff, 1, true)
116
	ui.addTextArea(-1, "", n, 319, 27, data[n].health, 18, 0x1aff00, 0x1aff00, 1, true)
117
	ui.addTextArea(-2, "<p align='center'><b><font color='#000000'>"..data[n].health.."%", n, 345, 27, 54, 18, 0x324650, 0x000000, 0, true)
118
end
119
function displayTab(n,info,subject)
120
	ui.addTextArea(2, "", n, 262, 72, 360, 290, 0x331f15, 0x331f15, 1, true)
121
	ui.addTextArea(3, "", n, 262, 125, 4, 180, 0x6b4231, 0x6b4231, 1, true)
122
	ui.addTextArea(5, "", n, 295, 72, 290, 4, 0x6b4231, 0x6b4231, 1, true)
123
	ui.addTextArea(4, "", n, 618, 125, 4, 180, 0x6b4231, 0x6b4231, 1, true)
124
	ui.addTextArea(6, "", n, 295, 358, 295, 4, 0x6b4231, 0x6b4231, 1, true)
125
	ui.addTextArea(1, "<p align='center'><font face='calibri'><font size='17'><b>#BOMBDELIVER - "..subject.."</b></font></font><font size='14'>\n\n"..info, n, 271, 80, 342, 270, 0x1b262b, 0x131c21, 1, true)
126
	ui.addTextArea(7, "<p align='center'><font size='13'><a href='event:close'>"..text[n].close.."</a></font>", n, 272, 330, 339, 20, 0x324650, 0x324650, 1, true)
127
end
128
function profile(n,info)
129
	ui.addTextArea(2, "", n, 262, 72, 268, 290, 0x331f15, 0x331f15, 1, true)
130
	ui.addTextArea(3, "", n, 262, 120, 4, 180, 0x6b4231, 0x6b4231, 1, true)
131
	ui.addTextArea(5, "", n, 295, 72, 198, 4, 0x6b4231, 0x6b4231, 1, true)
132
	ui.addTextArea(4, "", n, 526, 120, 4, 180, 0x6b4231, 0x6b4231, 1, true)
133
	ui.addTextArea(6, "", n, 295, 358, 198, 4, 0x6b4231, 0x6b4231, 1, true)
134
	ui.addTextArea(1, "<p align='center'><font face='calibri'><font size='17'><b>"..n.."</b></font></font></p><font size='14'>\n<font face='calibri'>\n"..info, n, 270, 82, 252, 270, 0x1b262b, 0x131c21, 1, true)
135
	ui.addTextArea(7, "<p align='center'><font size='13'><a href='event:close'>"..text[n].close.."</a></font>", n, 272, 330, 248, 20, 0x324650, 0x324650, 1, true)
136
end
137
function close(n)
138
	for i=1,7 do
139
  	ui.removeTextArea(i,n)
140
  end
141
end
142
function nearBomber(n,x,y,p)
143
	if ((tfm.get.room.playerList[n].x<tfm.get.room.playerList[p].x+130 and tfm.get.room.playerList[n].x<tfm.get.room.playerList[p].x) and tfm.get.room.playerList[n].y<tfm.get.room.playerList[p].y+30 and tfm.get.room.playerList[n].y>tfm.get.room.playerList[p].y-30) and not (n==p) and data[p].health>0 and tfm.get.room.playerList[n].isFacingRight==true then
144
		data[p].health=data[p].health-10
145
		tfm.exec.displayParticle(1,x,y,0.2,0,0.2,0,nil)
146
		tfm.exec.displayParticle(1,x,y,0.4,0,0.4,0,nil)
147
		tfm.exec.displayParticle(1,x,y,0.6,0,0.6,0,nil)
148
		tfm.exec.displayParticle(1,x,y,0.8,0,0.8,0,nil)
149
		tfm.exec.displayParticle(1,x,y,1,0,1,0,nil)
150
		tfm.exec.displayParticle(1,x,y-10,0.2,0,0.2,0,nil)
151
		tfm.exec.displayParticle(1,x,y-10,0.4,0,0.4,0,nil)
152
		tfm.exec.displayParticle(1,x,y-10,0.6,0,0.6,0,nil)
153
		tfm.exec.displayParticle(1,x,y-10,0.8,0,0.8,0,nil)
154
		tfm.exec.displayParticle(1,x,y-10,1,0,1,0,nil)
155
		tfm.exec.displayParticle(1,x,y+10,0.2,0,0.2,0,nil)
156
		tfm.exec.displayParticle(1,x,y+10,0.4,0,0.4,0,nli)
157
		tfm.exec.displayParticle(1,x,y+10,0.6,0,0.6,0,nil)
158
		tfm.exec.displayParticle(1,x,y+10,0.8,0,0.8,0,nil)
159
		tfm.exec.displayParticle(1,x,y+10,1,0,1,0,nil)
160
	end
161
	if ((tfm.get.room.playerList[n].x>tfm.get.room.playerList[p].x-130 and tfm.get.room.playerList[n].x>tfm.get.room.playerList[p].x) and tfm.get.room.playerList[n].y<tfm.get.room.playerList[p].y+30 and tfm.get.room.playerList[n].y>tfm.get.room.playerList[p].y-30) and not (n==p) and data[p].health>0 and tfm.get.room.playerList[n].isFacingRight==false then
162
		data[p].health=data[p].health-10
163
		tfm.exec.displayParticle(1,x,y,-0.2,0,-0.2,0,nil)
164
		tfm.exec.displayParticle(1,x,y,-0.4,0,-0.4,0,nil)
165
		tfm.exec.displayParticle(1,x,y,-0.6,0,-0.6,0,nil)
166
		tfm.exec.displayParticle(1,x,y,-0.8,0,-0.8,0,nil)
167
		tfm.exec.displayParticle(1,x,y,-1,0,-1,0,nil)
168
		tfm.exec.displayParticle(1,x,y-10,-0.2,0,-0.2,0,nil)
169
		tfm.exec.displayParticle(1,x,y-10,-0.4,0,-0.4,0,nil)
170
		tfm.exec.displayParticle(1,x,y-10,-0.6,0,-0.6,0,nil)
171
		tfm.exec.displayParticle(1,x,y-10,-0.8,0,-0.8,0,nil)
172
		tfm.exec.displayParticle(1,x,y-10,-1,0,-1,0,nil)
173
		tfm.exec.displayParticle(1,x,y+10,-0.2,0,-0.2,0,nil)
174
		tfm.exec.displayParticle(1,x,y+10,-0.4,0,-0.4,0,nli)
175
		tfm.exec.displayParticle(1,x,y+10,-0.6,0,-0.6,0,nil)
176
		tfm.exec.displayParticle(1,x,y+10,-0.8,0,-0.8,0,nil)
177
		tfm.exec.displayParticle(1,x,y+10,-1,0,-1,0,nil)
178
	end
179
  if data[p].health<1 then
180
    tfm.exec.killPlayer(p)
181
  end
182
end
183
operation={-110,110}
184
function nearProtector(n,p,x,y)
185
	if not (n==p) and data[p].health>0 and data[n].health>0 then
186
		tfm.exec.displayParticle(13,x,y,-0.2,0.1,-0.2,0.1,nil)
187
		tfm.exec.displayParticle(13,x,y,-0.4,0,-0.4,0,nil)
188
		tfm.exec.displayParticle(13,x,y,-0.6,0,-0.6,0,nil)
189
		tfm.exec.displayParticle(3,x,y,-0.8,0,-0.8,0,nil)
190
		tfm.exec.displayParticle(3,x,y,-8,0,-1,0,nil)
191
		tfm.exec.displayParticle(3,x,y-10,-0.2,0.1,-0.2,0.1,nil)
192
		tfm.exec.displayParticle(13,x,y-10,-0.4,0,-0.4,0,nil)
193
		tfm.exec.displayParticle(13,x,y-10,-0.6,0,-0.6,0,nil)
194
		tfm.exec.displayParticle(13,x,y-10,-0.8,0,-0.8,0,nil)
195
		tfm.exec.displayParticle(13,x,y-10,-1,0,-1,0,nil)
196
		tfm.exec.displayParticle(13,x,y+10,-0.2,0.1,-0.2,0.1,nil)
197
		tfm.exec.displayParticle(13,x,y+10,-0.4,0,-0.4,0,nli)
198
		tfm.exec.displayParticle(13,x,y+10,-0.6,0,-0.6,0,nil)
199
		tfm.exec.displayParticle(13,x,y+10,-0.8,-0.1,-0.8,-0.1,nil)
200
		tfm.exec.displayParticle(13,x,y+10,-1,0,-1,0,nil)
201
		tfm.exec.displayParticle(13,x,y,0.2,0,0.2,0,nil)
202
		tfm.exec.displayParticle(13,x,y,0.4,0,0.4,0,nil)
203
		tfm.exec.displayParticle(13,x,y,0.6,0,0.6,0,nil)
204
		tfm.exec.displayParticle(13,x,y,0.8,0,0.8,0,nil)
205
		tfm.exec.displayParticle(13,x,y,1,0,1,0,nil)
206
		tfm.exec.displayParticle(13,x,y-10,0.2,0.1,0.2,0.1,nil)
207
		tfm.exec.displayParticle(13,x,y-10,0.4,0,0.4,0,nil)
208
		tfm.exec.displayParticle(13,x,y-10,0.6,0,0.6,0,nil)
209
		tfm.exec.displayParticle(13,x,y-10,0.8,0,0.8,0,nil)
210
		tfm.exec.displayParticle(13,x,y-10,1,0,1,0,nil)
211
		tfm.exec.displayParticle(13,x,y+10,0.2,0,0.2,0,nil)
212
		tfm.exec.displayParticle(13,x,y+10,0.4,0,0.4,0,nli)
213
		tfm.exec.displayParticle(13,x,y+10,0.6,0,0.6,0,nil)
214
		tfm.exec.displayParticle(3,x,y+10,0.8,0,0.8,0,nil)
215
		tfm.exec.displayParticle(3,x,y+10,8,0,1,0,nil)
216
	end
217
	if (tfm.get.room.playerList[n].x<tfm.get.room.playerList[p].x+50 and tfm.get.room.playerList[n].x>tfm.get.room.playerList[p].x-50 and tfm.get.room.playerList[n].y<tfm.get.room.playerList[p].y+30 and tfm.get.room.playerList[n].y>tfm.get.room.playerList[p].y-30) and not (n==p) and data[p].health>0 and data[n].health>0 then
218
		data[n].health=data[n].health-10
219
		tfm.exec.movePlayer(n,0,0,false,operation[math.random(#operation)],operation[math.random(#operation)],true)
220
	end
221
		if data[n].health<1 then
222
    		tfm.exec.killPlayer(n)
223
  	end
224
end
225
226
for n,player in pairs(tfm.get.room.playerList) do
227
  bindKeyboard(n)
228
  setLang(n)
229
  insertName(n)
230
  setData(n)
231
  showMenu(n)
232
end
233
chooseRole()
234
for n,player in pairs(tfm.get.room.playerList) do
235
  identifyBomber(n)
236
end
237
function allInfo(n)
238
  bindKeyboard(n)
239
  setLang(n)
240
  insertName(n)
241
  setData(n)
242
  showMenu(n)
243
  identifyBomber(n)
244
end
245
function eventNewGame()
246-
	chooseRole()
246+
	players={}
247
	for n,player in pairs(tfm.get.room.playerList) do
248
		insertName(n)
249
	end
250
		chooseRole()
251
	countAlive()
252
  removeWinner()
253
	for n,player in pairs(tfm.get.room.playerList) do
254
		identifyBomber(n)
255
		data[n].health=100
256
	end
257
end
258
function eventTextAreaCallback(txt, n, a)
259
	if a=="Menu" then
260
  	showMenu(n)
261
  elseif a=="menu2" then
262
  	showMenu2(n)
263
  elseif a=="Help" then
264
  	displayTab(n,text[n].help,text[n].help2)
265
  elseif a=="close" then
266
  	close(n)
267
  elseif a=="Profile" then
268
  	profile(n,text[n].wins..": <J>"..data[n].wins.."\n\n</J>"..text[n].wins_Bomber..": <J>"..data[n].wins_Bomber.."\n\n</J>"..text[n].wins_Protector..": <J>"..data[n].wins_Protector)
269
  elseif a=="Powerups" then
270
    displayTab(n,"<J>"..text[n].powerup1.."\n\n<J>"..text[n].powerup2,text[n].powerups2)
271
  end
272
end
273
function eventNewPlayer(n)
274
  allInfo(n)
275
end
276
function eventLoop(time,timeRemaining)
277
	for n,player in pairs(tfm.get.room.playerList) do
278
    data[n].spawn=data[n].spawn+0.5
279
		showHealth(n)
280
	end
281
	if timeRemaining<=0 then
282
    tfm.exec.newGame(maps[math.random(#maps)])
283
  end
284
end
285
286
function eventKeyboard(n, k, d, x, y)
287
	if k==32 and data[n].role==0 and data[n].spawn>0 then
288
		nearBomber(n,x,y,player)
289
		data[n].spawn=-1
290
  elseif k==32 and data[n].role==1 and data[n].spawn>0 then
291
    data[n].spawn=-1.5
292
		player=player
293
		for n in pairs(tfm.get.room.playerList) do
294
      		nearProtector(n,player,tfm.get.room.playerList[player].x,tfm.get.room.playerList[player].y)
295
		end
296
  elseif k==3 and data[n].spawn>0 then
297
    data[n].spawn=-2
298
		player=player
299
    bigJump(n,x,y)
300
	end
301
end
302
function eventPlayerDied(n)
303
	win(n)
304
	countAlive()
305
	data[n].health=0
306
	if data[n].role==1 then
307
		for n,player in pairs(tfm.get.room.playerList) do
308
        ui.addTextArea(20, "", n, 262, 172, 268, 66, 0x331f15, 0x331f15, 1, true)
309
        ui.addTextArea(30, "", n, 262, 191, 4, 26, 0x6b4231, 0x6b4231, 1, true)
310
        ui.addTextArea(50, "", n, 300, 172, 198, 4, 0x6b4231, 0x6b4231, 1, true)
311
      	ui.addTextArea(40, "", n, 526, 192, 4, 26, 0x6b4231, 0x6b4231, 1, true)
312
        ui.addTextArea(60, "", n, 300, 234, 198, 4, 0x6b4231, 0x6b4231, 1, true)
313
        ui.addTextArea(19, "<p align='center'><font size='20'><VP>"..text[n].protector_Wins, n, 270, 182, 252, 44, 0x1b262b, 0x131c21, 1, true)
314
      	tfm.exec.setGameTime(5,true)
315
		end
316
	end
317
end
318
319
function eventMouse(playerName,x,y)
320
	print("<VP>X</VP><N>:</N><J> "..x.."</J><VP> Y</VP><N>:</N><J> "..y)
321
end
322
system.bindMouse("Fuzzyfirsdog#0000", true)
323
function eventPlayerGetCheese(n)
324
	win(n)
325
	if data[n].role==1 then
326
		data[n].wins=data[n].wins+1
327
		data[n].wins_Bomber=data[n].wins_Bomber+1
328
		tfm.exec.setGameTime(10,true)
329
		for n,player in pairs(tfm.get.room.playerList) do
330
    		ui.addTextArea(20, "", n, 262, 172, 268, 66, 0x331f15, 0x331f15, 1, true)
331
    		ui.addTextArea(30, "", n, 262, 191, 4, 26, 0x6b4231, 0x6b4231, 1, true)
332
    		ui.addTextArea(50, "", n, 300, 172, 198, 4, 0x6b4231, 0x6b4231, 1, true)
333
    		ui.addTextArea(40, "", n, 526, 192, 4, 26, 0x6b4231, 0x6b4231, 1, true)
334
    		ui.addTextArea(60, "", n, 300, 234, 198, 4, 0x6b4231, 0x6b4231, 1, true)
335
    		ui.addTextArea(19, "<p align='center'><font size='20'><R>"..text[n].bomber_Wins, n, 270, 182, 252, 44, 0x1b262b, 0x131c21, 1, true)
336
			if not (data[n].role==1) then
337
				tfm.exec.killPlayer(n)
338
			end
339
		end
340
	end
341
end