Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.13 KB | None | 0 0
  1. -- Checks
  2. -- SIMPLE MENU
  3. if not SimpleMenu then
  4. SimpleMenu = class()
  5.  
  6. function SimpleMenu:init(title, message, options)
  7. self.dialog_data = { title = title, text = message, button_list = {},
  8. id = tostring(math.random(0,0xFFFFFFFF)) }
  9. self.visible = false
  10. for _,opt in ipairs(options) do
  11. local elem = {}
  12. elem.text = opt.text
  13. opt.data = opt.data or nil
  14. opt.callback = opt.callback or nil
  15. elem.callback_func = callback(self, self, "_do_callback",
  16. { data = opt.data,
  17. callback = opt.callback})
  18. elem.cancel_button = opt.is_cancel_button or false
  19. if opt.is_focused_button then
  20. self.dialog_data.focus_button = #self.dialog_data.button_list+1
  21. end
  22. table.insert(self.dialog_data.button_list, elem)
  23. end
  24. return self
  25. end
  26.  
  27. function SimpleMenu:_do_callback(info)
  28. if info.callback then
  29. if info.data then
  30. info.callback(info.data)
  31. else
  32. info.callback()
  33. end
  34. end
  35. self.visible = false
  36. end
  37.  
  38. function SimpleMenu:show()
  39. if self.visible then
  40. return
  41. end
  42. self.visible = true
  43. managers.system_menu:show(self.dialog_data)
  44. end
  45.  
  46. function SimpleMenu:hide()
  47. if self.visible then
  48. managers.system_menu:close(self.dialog_data.id)
  49. self.visible = false
  50. return
  51. end
  52. end
  53. end
  54.  
  55. patched_update_input = patched_update_input or function (self, t, dt )
  56. if self._data.no_buttons then
  57. return
  58. end
  59.  
  60. local dir, move_time
  61. local move = self._controller:get_input_axis( "menu_move" )
  62.  
  63. if( self._controller:get_input_bool( "menu_down" )) then
  64. dir = 1
  65. elseif( self._controller:get_input_bool( "menu_up" )) then
  66. dir = -1
  67. end
  68.  
  69. if dir == nil then
  70. if move.y > self.MOVE_AXIS_LIMIT then
  71. dir = 1
  72. elseif move.y < -self.MOVE_AXIS_LIMIT then
  73. dir = -1
  74. end
  75. end
  76.  
  77. if dir ~= nil then
  78. if( ( self._move_button_dir == dir ) and self._move_button_time and ( t < self._move_button_time + self.MOVE_AXIS_DELAY ) ) then
  79. move_time = self._move_button_time or t
  80. else
  81. self._panel_script:change_focus_button( dir )
  82. move_time = t
  83. end
  84. end
  85.  
  86. self._move_button_dir = dir
  87. self._move_button_time = move_time
  88.  
  89. local scroll = self._controller:get_input_axis( "menu_scroll" )
  90. -- local sdir
  91. if( scroll.y > self.MOVE_AXIS_LIMIT ) then
  92. self._panel_script:scroll_up()
  93. -- sdir = 1
  94. elseif( scroll.y < -self.MOVE_AXIS_LIMIT ) then
  95. self._panel_script:scroll_down()
  96. -- sdir = -1
  97. end
  98. end
  99. managers.system_menu.DIALOG_CLASS.update_input = patched_update_input
  100. managers.system_menu.GENERIC_DIALOG_CLASS.update_input = patched_update_input
  101. -- FUNCTIONS ----------------------------------------------------------------------------------------------------------
  102. -- IS PLAYING CHECK
  103. function isPlaying()
  104. if not BaseNetworkHandler then return false end
  105. return BaseNetworkHandler._gamestate_filter.any_ingame_playing[ game_state_machine:last_queued_state_name() ]
  106. end
  107. -- INGAME CHECK
  108. function inGame()
  109. if not game_state_machine then return false end
  110. return string.find(game_state_machine:current_state_name(), "game")
  111. end
  112. -- SHOW MENU FUNCTION
  113. show_menu = show_menu or function(menu)
  114. menu:show()
  115. end
  116. -- BACK FUNCTION
  117. root_menu = root_menu or function()
  118. rootmenu:show()
  119. end
  120. -- INGAME FUNCTIONS ------
  121. -- SPAWN RANDOM GAGE PACKAGE
  122. SpawnGagePackage = SpawnGagePackage or function(id) --Don't pass any argument for random package
  123. if isHost() then
  124. function tweak_data.gage_assignment:get_num_assignment_units() --Patches limit on spawning units. World:spawn_unit somehow obey this value.
  125. return 9999
  126. end
  127. local id_table = {
  128. Idstring("units/pd2_dlc_gage_jobs/pickups/gen_pku_gage_green/gen_pku_gage_green"),
  129. Idstring("units/pd2_dlc_gage_jobs/pickups/gen_pku_gage_yellow/gen_pku_gage_yellow"),
  130. Idstring("units/pd2_dlc_gage_jobs/pickups/gen_pku_gage_red/gen_pku_gage_red"),
  131. Idstring("units/pd2_dlc_gage_jobs/pickups/gen_pku_gage_blue/gen_pku_gage_blue"),
  132. Idstring("units/pd2_dlc_gage_jobs/pickups/gen_pku_gage_purple/gen_pku_gage_purple"),
  133. }
  134. local pos = get_crosshair_pos()
  135. local rot = Rotation(managers.player:local_player():movement():m_head_rot():yaw(),0,0)
  136. if not pos or not rot then
  137. return
  138. end
  139. World:spawn_unit(id_table[id or math.random(1,5)], pos, rot )
  140. else
  141. show_mid_text("...dummy :\)", "This is a host only", 1.0 )
  142. end
  143. end
  144. --SPAWN BAG
  145. function ServerSpawnBag(name, zipline_unit)
  146. if not alive (managers.player:player_unit()) then return end
  147. local camera_ext = managers.player:player_unit():camera()
  148. local carry_data = tweak_data.carry[ name ]
  149. local dye_initiated = carry_data.dye_initiated
  150. local has_dye_pack = carry_data.has_dye_pack
  151. local dye_value_multiplier = carry_data.dye_value_multiplier
  152. if Network:is_client() then
  153. managers.network:session():send_to_host("server_drop_carry", name, carry_data.multiplier, carry_data.dye_initiated, carry_data.has_dye_pack, carry_data.dye_value_multiplier, camera_ext:position(), camera_ext:rotation(), camera_ext:forward(), Vector3(0, 0, 0), zipline_unit)
  154. else
  155. managers.player:server_drop_carry(name, carry_data.multiplier, carry_data.dye_initiated, carry_data.has_dye_pack, carry_data.dye_value_multiplier, camera_ext:position(), camera_ext:rotation(), camera_ext:forward(), Vector3(0, 0, 0), zipline_unit, managers.network:session():local_peer():id())
  156. end
  157. end
  158. --GIVE SELF BAG
  159. function GiveBag(name, zipline_unit)
  160. if not alive (managers.player:player_unit()) then return end
  161. local carry_data = tweak_data.carry[ name ]
  162. local dye_initiated = carry_data.dye_initiated
  163. local has_dye_pack = carry_data.has_dye_pack
  164. local dye_value_multiplier = carry_data.dye_value_multiplier
  165. if Network:is_client() then
  166. managers.network:session():send_to_host("set_carry", name, carry_data.multiplier, carry_data.dye_initiated, carry_data.has_dye_pack, carry_data.dye_value_multiplier, zipline_unit)
  167. else
  168. managers.player:set_carry(name, carry_data.multiplier, carry_data.dye_initiated, carry_data.has_dye_pack, carry_data.dye_value_multiplier, zipline_unit, managers.network:session():local_peer():id())
  169. end
  170. end
  171. -- SET SPAWN
  172. setspawn0 = function()
  173. _spawn_type = 0
  174. end
  175. setspawn1 = function(menu)
  176. _spawn_type = 1
  177. menu:show()
  178. end
  179. setspawn2 = function(menu)
  180. _spawn_type = 2
  181. menu:show()
  182. end
  183. setspawn3 = function(menu)
  184. _spawn_type = 3
  185. menu:show()
  186. end
  187. setspawn4 = function()
  188. _spawn_type = 4
  189. end
  190. setspawn = function(item)
  191. _spawn_item = item
  192. end
  193. chemset = function()
  194. managers.player:add_special( { name = "hydrogen_chloride", silent = true, amount = 1 } )
  195. managers.player:add_special( { name = "caustic_soda", silent = true, amount = 1 } )
  196. managers.player:add_special( { name = "acid", silent = true, amount = 1 } )
  197. end
  198. -- OUTGAME FUNCTIONS ------
  199. -- GIVE ITEMS
  200. function giveitems( argumentTable )
  201. local itype = argumentTable["type"]
  202. local times = argumentTable["times"]
  203.  
  204. local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
  205. local skip = { masks = {"character_locked"}, materials = {"plastic"}, colors = {"nothing"}, textures = {"no_color_full_material","no_color_no_material"} }
  206. if not times then times = 1 end
  207. if type(itype) == "table" then types = itype end
  208. if itype == "all" or type(itype) == "table" then
  209. for i = 1, #types do giveitems({ ["type"] = types[i], ["times"] = times }) end
  210. return
  211. end
  212. for i=1, times do
  213. for mat_id,_ in pairs(tweak_data.blackmarket[itype]) do
  214. if not in_table(skip[itype], mat_id) then
  215. local global_value = "normal"
  216. if _.global_value then
  217. global_value = _.global_value
  218. elseif _.infamous then
  219. global_value = "infamous"
  220. elseif _.dlcs or _.dlc then
  221. local dlcs = _.dlcs or {}
  222. if _.dlc then table.insert( dlcs, _.dlc ) end
  223. global_value = dlcs[ math.random( #dlcs ) ]
  224. end
  225. if _.unlocked == false then _.unlocked = true end
  226. managers.blackmarket:add_to_inventory(global_value, itype, mat_id, false)
  227. end
  228. end
  229. end
  230. end
  231. -- CLEAR ITEMS
  232. function clearitems( argumentTable )
  233. local itype = argumentTable["type"]
  234. local globalval = argumentTable["globalval"]
  235.  
  236. local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
  237. if not globalval then globalval = "all" end
  238. if type(itype) == "table" then types = itype end
  239. if itype == "all" or type(itype) == "table" then
  240. --for i = 1, #types do clearitems(types[i], globalval) end return
  241. for i = 1, #types do clearitems({ ["type"] = types[i], ["globalval"] = globalval }) end
  242.  
  243. end
  244. for global_value, categories in pairs( Global.blackmarket_manager.inventory ) do
  245. if (globalval == "all" or globalval == global_value) and categories[itype] then
  246. for id,amount in pairs( categories[itype] ) do
  247. -- Global.blackmarket_manager.inventory[global_value][itype][id] = 0
  248. Global.blackmarket_manager.inventory[global_value][itype][id] = nil
  249. end
  250. end
  251. end
  252. end
  253. -- UNLOCK ITEMS
  254. function unlockitems( itype )
  255. local types = {"weapon_mods", "masks", "materials", "textures", "colors", "weapons"}
  256. if type(itype) == "table" then types = itype end
  257. if itype == "all" or type(itype) == "table" then
  258. --for i = 1, #types do unlockitems(types[i]) end
  259. for i = 1, #types do unlockitems({ ["type"] = types[i] }) end
  260.  
  261. return
  262. end
  263. if itype == "weapons" then
  264. for wep_id,_ in pairs(tweak_data.upgrades.definitions) do
  265. if _.category == "weapon" and not string.find(wep_id, "_primary") and not string.find(wep_id, "_secondary") then
  266. if not managers.upgrades:aquired(wep_id) then managers.upgrades:aquire(wep_id) end
  267. end
  268. end
  269. else
  270. for mat_id,_ in pairs(tweak_data.blackmarket[itype]) do
  271. if _.unlocked == false then _.unlocked = true end
  272. end
  273. end
  274. end
  275. -- UNLOCK MASK SLOTS
  276. unlockmaskslots = unlockmaskslots or function()
  277. for i = 1, 300 do Global.blackmarket_manager.unlocked_mask_slots[i] = true
  278. end
  279. end
  280. -- UNLOCK PRIMARY WEAPON SLOTS
  281. unlockprimslot = unlockprimslot or function()
  282. for i = 1, 300 do
  283. Global.blackmarket_manager.unlocked_weapon_slots.primaries[i] = true
  284. end
  285. end
  286. -- UNLOCK SECONDARY WEAPON SLOTS
  287. unlocksecslot = unlocksecslot or function()
  288. for i = 1, 300 do
  289. Global.blackmarket_manager.unlocked_weapon_slots.secondaries[i] = true
  290. end
  291. end
  292. -- UNLOCK ALL WEAPON SLOTS
  293. unlockweaponslot = unlockweaponslot or function()
  294. for i = 1, 300 do
  295. Global.blackmarket_manager.unlocked_weapon_slots.primaries[i] = true
  296. Global.blackmarket_manager.unlocked_weapon_slots.secondaries[i] = true
  297. end
  298. end
  299. -- UNLOCK ALL
  300. unlockallstuff = unlockallstuff or function()
  301. unlockweaponslot() -- ALL WEAPONS SLOTS UNLOCKED (36)
  302. unlockmaskslots() -- ALL MASK SLOTS UNLOCKED (36)
  303. unlockitems("weapons") -- ALL WEAPONS UNLOCKED
  304. end
  305. -- CLEAR "!"
  306. remexclmark = remexclmark or function()
  307. Global.blackmarket_manager.new_drops = {}
  308. end
  309. -- MENUS ---------------------------------------------------------------------------------------------------------------
  310. -- OUTGAME MENUS ------
  311. -- ADD ITEMS
  312. items = {
  313. { text = "Add 1 of all weapon mods", callback = giveitems, data = { ["type"] = "weapon_mods", ["times"] = nil}},
  314. { text = "Add 5 of all weapon mods", callback = giveitems, data = { ["type"] = "weapon_mods", ["times"] = 5}},
  315. {},
  316. { text = "Add 1 of all materials", callback = giveitems, data = { ["type"] = "materials", ["times"] = nil}},
  317. { text = "Add 5 of all materials", callback = giveitems, data = { ["type"] = "materials", ["times"] = 5}},
  318. {},
  319. { text = "Add 1 of all patterns", callback = giveitems, data = { ["type"] = "textures", ["times"] = nil}},
  320. { text = "Add 5 of all patterns", callback = giveitems, data = { ["type"] = "textures", ["times"] = 5}},
  321. {},
  322. { text = "Add 1 of all colors", callback = giveitems, data = { ["type"] = "colors", ["times"] = nil}},
  323. { text = "Add 5 of all colors", callback = giveitems, data = { ["type"] = "colors", ["times"] = 5}},
  324. {},
  325. { text = "Add 1 of all masks", callback = giveitems, data = { ["type"] = "masks", ["times"] = nil}},
  326. { text = "Add 5 of all masks", callback = giveitems, data = { ["type"] = "masks", ["times"] = 5}},
  327. {},
  328. { text = "Add 1 of everything", callback = giveitems, data = { ["type"] = "all", ["times"] = nil}},
  329. { text = "Add 5 of everything", callback = giveitems, data = { ["type"] = "all", ["times"] = 5}},
  330. {},
  331. { text = "Back", callback = root_menu },
  332. { text = "Exit", is_cancel_button = true},
  333. }
  334. invitems = SimpleMenu:new("INVENTORY TOOLS: ADD ITEMS", "PICK A CARD!",items)
  335. -- REMOVE ITEMS
  336. remove = {
  337. { text = "--!! CLEAR INVENTORY !!--", callback = clearitems, data = { ["type"] = "all", ["globalval"] = "all"}},
  338. {},
  339. { text = "Remove all weapon mods", callback = clearitems, data = { ["type"] = "weapon_mods", ["globalval"] = "all"}},
  340. { text = "Remove all materials", callback = clearitems, data = { ["type"] = "materials", ["globalval"] = "all"}},
  341. { text = "Remove all patterns", callback = clearitems, data = { ["type"] = "textures", ["globalval"] = "all"}},
  342. { text = "Remove all colors", callback = clearitems, data = { ["type"] = "colors", ["globalval"] = "all"}},
  343. { text = "Remove all masks", callback = clearitems, data = { ["type"] = "masks", ["globalval"] = "all"}},
  344. {},
  345. { text = "Back", callback = root_menu },
  346. { text = "Exit", is_cancel_button = true},
  347. }
  348. invremove = SimpleMenu:new("INVENTORY TOOLS: REMOVE ITEMS", "DUMPSTERS: NOT JUST FOR BODIES!",remove)
  349. -- UNLOCK ITEMS
  350. unlock = {
  351. { text = "Unlock everything", callback = unlockallstuff },
  352. {},
  353. { text = "Unlock all primary weapon slots", callback = unlockprimslot },
  354. { text = "Unlock all secondary weapon slots", callback = unlocksecslot },
  355. { text = "Unlock all weapon slots", callback = unlockweaponslot },
  356. { text = "Unlock all mask slots", callback = unlockmaskslots },
  357. { text = "Unlock all weapons", callback = unlockitems, data = "weapons" },
  358. {},
  359. { text = "Back", callback = root_menu },
  360. { text = "Exit", is_cancel_button = true},
  361. }
  362. invunlock = SimpleMenu:new("INVENTORY TOOLS: UNLOCK STUFF", "YOU EARNED IT!",unlock)
  363. -- INGAME MENUS ------
  364. -- SELF ITEM MENU
  365. getitem = {
  366. { text = "Get a keycard", callback = setspawn, data = "bank_manager_key" },
  367. { text = "Get a key", callback = setspawn, data = "chavez_key" },
  368. { text = "Get a crowbar", callback = setspawn, data = "crowbar" },
  369. {},
  370. { text = "Get a plank", callback = setspawn, data = "planks" },
  371. { text = "Get a thermal paste", callback = setspawn, data = "thermite_paste" },
  372. { text = "Get a thermite", callback = setspawn, data = "thermite" },
  373. { text = "Get a gas can", callback = setspawn, data = "gas" },
  374. {},
  375. { text = "Get a Rats chem set", callback = chemset },
  376. { text = "Get a hydrogen chloride", callback = setspawn, data = "hydrogen_chloride" },
  377. { text = "Get a caustic soda", callback = setspawn, data = "caustic_soda" },
  378. { text = "Get a muriatic acid", callback = setspawn, data = "acid" },
  379. {},
  380. { text = "Exit", is_cancel_button = true, callback = setspawn0 },
  381. }
  382. selfitemmenu = SimpleMenu:new("GET AN ITEM MENU", "IT'S JUST WHAT I NEEDED!", getitem)
  383. -- BAG MENU
  384. baglist = {
  385. { text = "Get a thermal drill", callback = setspawn, data = "lance_bag" },
  386. {},
  387. { text = "Get a turret weapon part", callback = setspawn, data = "turret" },
  388. { text = "Get a turret shell bag", callback = setspawn, data = "ammo" },
  389. { text = "Get a gold bag", callback = setspawn, data = "gold" },
  390. { text = "Get a money bag", callback = setspawn, data = "money" },
  391. { text = "Get a weapon bag", callback = setspawn, data = "weapon" },
  392. { text = "Get a coke bag", callback = setspawn, data = "coke" },
  393. { text = "Get a meth bag", callback = setspawn, data = "meth" },
  394. { text = "Get a jewelry bag", callback = setspawn, data = "diamonds" },
  395. { text = "Get a painting", callback = setspawn, data = "painting" },
  396. { text = "Get a server", callback = setspawn, data = "circuit" },
  397. { text = "Get an artifact", callback = setspawn, data = "artifact_statue" },
  398. { text = "Get a samurai suit", callback = setspawn, data = "samurai_suit" },
  399. {},
  400. { text = "Exit", is_cancel_button = true, callback = setspawn0 },
  401. }
  402. getbagmenu = SimpleMenu:new("GET A BAG MENU", "THIS IS MINE!", baglist)
  403. spawnbagmenu = SimpleMenu:new("SPAWN A BAG MENU", "IT WAS PROBABLY THERE THE WHOLE TIME.", baglist)
  404. --ROOT MENU OUTGAME --
  405. rootinv = {
  406. {},
  407. { text = "--!! Remove new item exclamation mark !!--", callback = remexclmark },
  408. {},
  409. { text = "Add inventory items", callback = show_menu, data = invitems },
  410. { text = "Remove inventory items", callback = show_menu, data = invremove },
  411. { text = "Unlock inventory items", callback = show_menu, data = invunlock },
  412. {},
  413. { text = "Exit", is_cancel_button = true},
  414. }
  415. rootmenu = SimpleMenu:new("INVENTORY TOOLS", "THE RIGHT TOOL FOR THE JOB.", rootinv)
  416. --ROOT MENU INGAME --
  417. rootinvg = {
  418. {},
  419. { text = "Get an item", callback = setspawn1, data = selfitemmenu },
  420. { text = "Get a bag", callback = setspawn2, data = getbagmenu },
  421. { text = "Spawn a bag", callback = setspawn3, data = spawnbagmenu },
  422. { text = "Spawn a Gage Package", callback = setspawn4 },
  423. {},
  424. { text = "Exit", is_cancel_button = true, callback = setspawn0 },
  425. }
  426. rootmenug = SimpleMenu:new("INVENTORY TOOLS", "MAKE YOUR CHOICE! PRESS INSERT TO GET IT!", rootinvg)
  427.  
  428. -- InGame/isPlaying Check for Menu
  429. if not inGame() and not isPlaying() then
  430. rootmenu:show()
  431. else
  432. rootmenug:show()
  433. if not _invrunning then
  434. _spawn_type = 0
  435. _spawn_item = 0
  436. _invrunning = true end
  437. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement