View difference between Paste ID: gdZX5KJr and QP2GWCa3
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
		tfm.exec.movePlayer(p,0,0,false,operation[math.random(#operation)],operation[math.random(#operation)],true)
145
		data[p].health=data[p].health-10
146
		tfm.exec.displayParticle(1,x,y,0.2,0,0.2,0,nil)
147
		tfm.exec.displayParticle(1,x,y,0.4,0,0.4,0,nil)
148
		tfm.exec.displayParticle(1,x,y,0.6,0,0.6,0,nil)
149
		tfm.exec.displayParticle(1,x,y,0.8,0,0.8,0,nil)
150
		tfm.exec.displayParticle(1,x,y,1,0,1,0,nil)
151
		tfm.exec.displayParticle(1,x,y-10,0.2,0,0.2,0,nil)
152
		tfm.exec.displayParticle(1,x,y-10,0.4,0,0.4,0,nil)
153
		tfm.exec.displayParticle(1,x,y-10,0.6,0,0.6,0,nil)
154
		tfm.exec.displayParticle(1,x,y-10,0.8,0,0.8,0,nil)
155
		tfm.exec.displayParticle(1,x,y-10,1,0,1,0,nil)
156
		tfm.exec.displayParticle(1,x,y+10,0.2,0,0.2,0,nil)
157
		tfm.exec.displayParticle(1,x,y+10,0.4,0,0.4,0,nli)
158
		tfm.exec.displayParticle(1,x,y+10,0.6,0,0.6,0,nil)
159
		tfm.exec.displayParticle(1,x,y+10,0.8,0,0.8,0,nil)
160
		tfm.exec.displayParticle(1,x,y+10,1,0,1,0,nil)
161
	end
162
	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
163
		tfm.exec.movePlayer(n,0,0,false,operation[math.random(#operation)],operation[math.random(#operation)],true)
164
		data[p].health=data[p].health-10
165
		tfm.exec.displayParticle(1,x,y,-0.2,0,-0.2,0,nil)
166
		tfm.exec.displayParticle(1,x,y,-0.4,0,-0.4,0,nil)
167
		tfm.exec.displayParticle(1,x,y,-0.6,0,-0.6,0,nil)
168
		tfm.exec.displayParticle(1,x,y,-0.8,0,-0.8,0,nil)
169
		tfm.exec.displayParticle(1,x,y,-1,0,-1,0,nil)
170
		tfm.exec.displayParticle(1,x,y-10,-0.2,0,-0.2,0,nil)
171
		tfm.exec.displayParticle(1,x,y-10,-0.4,0,-0.4,0,nil)
172
		tfm.exec.displayParticle(1,x,y-10,-0.6,0,-0.6,0,nil)
173
		tfm.exec.displayParticle(1,x,y-10,-0.8,0,-0.8,0,nil)
174
		tfm.exec.displayParticle(1,x,y-10,-1,0,-1,0,nil)
175
		tfm.exec.displayParticle(1,x,y+10,-0.2,0,-0.2,0,nil)
176
		tfm.exec.displayParticle(1,x,y+10,-0.4,0,-0.4,0,nli)
177
		tfm.exec.displayParticle(1,x,y+10,-0.6,0,-0.6,0,nil)
178
		tfm.exec.displayParticle(1,x,y+10,-0.8,0,-0.8,0,nil)
179
		tfm.exec.displayParticle(1,x,y+10,-1,0,-1,0,nil)
180
	end
181
  if data[p].health<1 then
182
    tfm.exec.killPlayer(p)
183
  end
184
end
185
operation={-110,110}
186
function nearProtector(n,p,x,y)
187
	if not (n==p) and data[p].health>0 and data[n].health>0 then
188
		tfm.exec.displayParticle(13,x,y,-0.2,0.1,-0.2,0.1,nil)
189
		tfm.exec.displayParticle(13,x,y,-0.4,0,-0.4,0,nil)
190
		tfm.exec.displayParticle(13,x,y,-0.6,0,-0.6,0,nil)
191
		tfm.exec.displayParticle(3,x,y,-0.8,0,-0.8,0,nil)
192
		tfm.exec.displayParticle(3,x,y,-8,0,-1,0,nil)
193
		tfm.exec.displayParticle(3,x,y-10,-0.2,0.1,-0.2,0.1,nil)
194
		tfm.exec.displayParticle(13,x,y-10,-0.4,0,-0.4,0,nil)
195
		tfm.exec.displayParticle(13,x,y-10,-0.6,0,-0.6,0,nil)
196
		tfm.exec.displayParticle(13,x,y-10,-0.8,0,-0.8,0,nil)
197
		tfm.exec.displayParticle(13,x,y-10,-1,0,-1,0,nil)
198
		tfm.exec.displayParticle(13,x,y+10,-0.2,0.1,-0.2,0.1,nil)
199
		tfm.exec.displayParticle(13,x,y+10,-0.4,0,-0.4,0,nli)
200
		tfm.exec.displayParticle(13,x,y+10,-0.6,0,-0.6,0,nil)
201
		tfm.exec.displayParticle(13,x,y+10,-0.8,-0.1,-0.8,-0.1,nil)
202
		tfm.exec.displayParticle(13,x,y+10,-1,0,-1,0,nil)
203
		tfm.exec.displayParticle(13,x,y,0.2,0,0.2,0,nil)
204
		tfm.exec.displayParticle(13,x,y,0.4,0,0.4,0,nil)
205
		tfm.exec.displayParticle(13,x,y,0.6,0,0.6,0,nil)
206
		tfm.exec.displayParticle(13,x,y,0.8,0,0.8,0,nil)
207
		tfm.exec.displayParticle(13,x,y,1,0,1,0,nil)
208
		tfm.exec.displayParticle(13,x,y-10,0.2,0.1,0.2,0.1,nil)
209
		tfm.exec.displayParticle(13,x,y-10,0.4,0,0.4,0,nil)
210
		tfm.exec.displayParticle(13,x,y-10,0.6,0,0.6,0,nil)
211
		tfm.exec.displayParticle(13,x,y-10,0.8,0,0.8,0,nil)
212
		tfm.exec.displayParticle(13,x,y-10,1,0,1,0,nil)
213
		tfm.exec.displayParticle(13,x,y+10,0.2,0,0.2,0,nil)
214
		tfm.exec.displayParticle(13,x,y+10,0.4,0,0.4,0,nli)
215
		tfm.exec.displayParticle(13,x,y+10,0.6,0,0.6,0,nil)
216
		tfm.exec.displayParticle(3,x,y+10,0.8,0,0.8,0,nil)
217
		tfm.exec.displayParticle(3,x,y+10,8,0,1,0,nil)
218
	end
219
	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
220
		data[n].health=data[n].health-10
221
		tfm.exec.movePlayer(n,0,0,false,operation[math.random(#operation)],operation[math.random(#operation)],true)
222
	end
223
		if data[n].health<1 then
224
    		tfm.exec.killPlayer(n)
225
  	end
226
end
227
228
for n,player in pairs(tfm.get.room.playerList) do
229
  bindKeyboard(n)
230
  setLang(n)
231
  insertName(n)
232
  setData(n)
233
  showMenu(n)
234
end
235
chooseRole()
236
for n,player in pairs(tfm.get.room.playerList) do
237
  identifyBomber(n)
238
end
239
function allInfo(n)
240
  bindKeyboard(n)
241
  setLang(n)
242
  insertName(n)
243
  setData(n)
244
  showMenu(n)
245
  identifyBomber(n)
246
end
247
function eventNewGame()
248
	players={}
249
	for n,player in pairs(tfm.get.room.playerList) do
250
		insertName(n)
251
	end
252
		chooseRole()
253
	countAlive()
254
  removeWinner()
255
	for n,player in pairs(tfm.get.room.playerList) do
256
		identifyBomber(n)
257
		data[n].health=100
258
	end
259
end
260
function eventTextAreaCallback(txt, n, a)
261
	if a=="Menu" then
262
  	showMenu(n)
263
  elseif a=="menu2" then
264
  	showMenu2(n)
265
  elseif a=="Help" then
266
  	displayTab(n,text[n].help,text[n].help2)
267
  elseif a=="close" then
268
  	close(n)
269
  elseif a=="Profile" then
270
  	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)
271
  elseif a=="Powerups" then
272
    displayTab(n,"<J>"..text[n].powerup1.."\n\n<J>"..text[n].powerup2,text[n].powerups2)
273
  end
274
end
275
function eventNewPlayer(n)
276
  allInfo(n)
277
end
278
function eventLoop(time,timeRemaining)
279
	for n,player in pairs(tfm.get.room.playerList) do
280
    data[n].spawn=data[n].spawn+0.5
281
		showHealth(n)
282
	end
283
	if timeRemaining<=0 then
284
    tfm.exec.newGame(maps[math.random(#maps)])
285
  end
286
end
287
288
function eventKeyboard(n, k, d, x, y)
289
	if k==32 and data[n].role==0 and data[n].spawn>0 then
290
		nearBomber(n,x,y,player)
291
		data[n].spawn=-1
292
  elseif k==32 and data[n].role==1 and data[n].spawn>0 then
293
    data[n].spawn=-1.5
294
		player=player
295
		for n in pairs(tfm.get.room.playerList) do
296
      		nearProtector(n,player,tfm.get.room.playerList[player].x,tfm.get.room.playerList[player].y)
297
		end
298
  elseif k==3 and data[n].spawn>0 then
299
    data[n].spawn=-2
300
		player=player
301
    bigJump(n,x,y)
302
	end
303
end
304
function eventPlayerDied(n)
305
	win(n)
306
	countAlive()
307
	data[n].health=0
308
	if data[n].role==1 then
309
		for n,player in pairs(tfm.get.room.playerList) do
310
        ui.addTextArea(20, "", n, 262, 172, 268, 66, 0x331f15, 0x331f15, 1, true)
311
        ui.addTextArea(30, "", n, 262, 191, 4, 26, 0x6b4231, 0x6b4231, 1, true)
312
        ui.addTextArea(50, "", n, 300, 172, 198, 4, 0x6b4231, 0x6b4231, 1, true)
313
      	ui.addTextArea(40, "", n, 526, 192, 4, 26, 0x6b4231, 0x6b4231, 1, true)
314
        ui.addTextArea(60, "", n, 300, 234, 198, 4, 0x6b4231, 0x6b4231, 1, true)
315
        ui.addTextArea(19, "<p align='center'><font size='20'><VP>"..text[n].protector_Wins, n, 270, 182, 252, 44, 0x1b262b, 0x131c21, 1, true)
316
      	tfm.exec.setGameTime(5,true)
317
		end
318
	end
319
end
320
321
function eventMouse(playerName,x,y)
322
	print("<VP>X</VP><N>:</N><J> "..x.."</J><VP> Y</VP><N>:</N><J> "..y)
323
end
324
system.bindMouse("Fuzzyfirsdog#0000", true)
325
function eventPlayerGetCheese(n)
326
	win(n)
327
	if data[n].role==1 then
328
		data[n].wins=data[n].wins+1
329
		data[n].wins_Bomber=data[n].wins_Bomber+1
330
		tfm.exec.setGameTime(10,true)
331
		for n,player in pairs(tfm.get.room.playerList) do
332
    		ui.addTextArea(20, "", n, 262, 172, 268, 66, 0x331f15, 0x331f15, 1, true)
333
    		ui.addTextArea(30, "", n, 262, 191, 4, 26, 0x6b4231, 0x6b4231, 1, true)
334
    		ui.addTextArea(50, "", n, 300, 172, 198, 4, 0x6b4231, 0x6b4231, 1, true)
335
    		ui.addTextArea(40, "", n, 526, 192, 4, 26, 0x6b4231, 0x6b4231, 1, true)
336
    		ui.addTextArea(60, "", n, 300, 234, 198, 4, 0x6b4231, 0x6b4231, 1, true)
337
    		ui.addTextArea(19, "<p align='center'><font size='20'><R>"..text[n].bomber_Wins, n, 270, 182, 252, 44, 0x1b262b, 0x131c21, 1, true)
338
			if not (data[n].role==1) then
339
				tfm.exec.killPlayer(n)
340
			end
341
		end
342
	end
343
end