Advertisement
Guest User

F6 - Mastermind menu fix

a guest
Feb 8th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.55 KB | None | 0 0
  1. -- EVIL MASTERMIND DUOMENU SCRIPT
  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.  
  102. ------------------------------
  103. ------ GLOBAL SETTINGS -------
  104. ------------------------------
  105. -- SHOW MENU
  106. show_menu = show_menu or function(menu)
  107.     menu:show()
  108. end
  109. -- CALL MENU
  110. function openmenu(menu)
  111.     menu:show()
  112. end
  113. function inGame()
  114.   if not game_state_machine then return false end
  115.   return string.find(game_state_machine:current_state_name(), "game")
  116. end
  117. function show_mid_text( msg, msg_title, show_secs )
  118.     if managers and managers.hud then
  119.     managers.hud:present_mid_text( { text = msg, title = msg_title, time = show_secs } )
  120.     end
  121. end
  122.  
  123. ----------------------
  124. -- OUTGAME SETTINGS --
  125. ----------------------
  126. if not inGame() then
  127. end
  128. ---------------------------
  129. ---- INGAME SETTINGS ------
  130. ---------------------------
  131. if inGame() and managers.platform:presence() == "Playing" then
  132. ---------------------------
  133. -- BACKUP FOR NORMALIZER --
  134. ---------------------------
  135. if not _cableTie then _cableTie = PlayerManager.remove_special
  136. end
  137. if not _useMessiah then _useMessiah = PlayerDamage.consume_messiah_charge
  138. end
  139. if not _gotMessiah then _gotMessiah = PlayerDamage.got_messiah_charges
  140. end
  141. if not _dBaguse then _dBaguse = DoctorBagBase._take
  142. end
  143. if not _infPager then _infPager = GroupAIStateBase.on_successful_alarm_pager_bluff
  144. end
  145. if not _PlyUpgVal then _PlyUpgVal = PlayerManager.upgrade_value
  146. end
  147. if not _onIntimidated then _onIntimidated = CopLogicIdle.on_intimidated
  148. end
  149. if not _onIIntimidated then _onIIntimidated = CopLogicIntimidated.on_intimidated
  150. end
  151. if not _onSniperEnter then _onSniperEnter = CopLogicSniper.enter
  152. end
  153. if not _civDeduct then _civDeduct = MoneyManager.get_civilian_deduction
  154. end
  155. if not _civKilled then _civKilled = MoneyManager.civilian_killed
  156. end
  157.  
  158. ---------------------
  159. ---- FUNCTIONS ------
  160. ---------------------
  161. -- INFINITE CABLE TIES (normalizable)
  162. infcable = infcable or function()
  163.     function PlayerManager:remove_special( name )
  164.     end
  165. end
  166. -- INFINITE MESSIAH CHARGES ((SELF-REVIVE) normalizable)
  167. infmessiah = infmessiah or function()
  168.     function PlayerDamage:consume_messiah_charge() return true
  169.     end
  170. end
  171. -- UNLOCK MESSIAH CHARGES SKILL ((SELF-REVIVE) normalizable)
  172. unlmessiah = unlmessiah or function()
  173.     function PlayerDamage:got_messiah_charges() return true
  174.     end
  175. end
  176. -- INFINITE DOCTOR BAG USES (normalizable)
  177. infdocbag = infdocbag or function()
  178.     function DoctorBagBase:_take( unit )
  179.     unit:character_damage():recover_health() -- replenish()
  180.     return 0
  181.     end
  182. end
  183. -- ALLOW INFINITE PAGERS (normalizable)
  184. infpager = infpager or function()
  185.     function GroupAIStateBase:on_successful_alarm_pager_bluff()
  186.     end
  187. end
  188. -- NO CASH PENALTY FOR KILLING CIVILIANS (normalizable)
  189. frekillz = frekillz or function()
  190.     function MoneyManager.get_civilian_deduction()
  191.     return 0
  192.     end
  193.         function MoneyManager.civilian_killed()
  194.         return
  195.         end
  196. end
  197. -- 3 CONVERTS (normalizable)
  198. infconvert2 = infconvert2 or function()
  199.     function PlayerManager:upgrade_value( category, upgrade, default )
  200.         if category == "player" and upgrade == "convert_enemies" then
  201.             return true
  202.         elseif category == "player" and upgrade == "convert_enemies_max_minions" then
  203.             return 3
  204.         elseif category == "player" and upgrade == "convert_enemies_health_multiplier" then  
  205.             return 0.25
  206.         elseif category == "player" and upgrade == "convert_enemies_damage_multiplier" then
  207.             return 2.5
  208.         else
  209.             return _PlyUpgVal(self, category, upgrade, default)
  210.         end
  211.     end
  212. end
  213. -- INSTANT INTIMIDATIONS (normalizable)
  214. infintim = infintim or function()
  215.     function CopLogicIdle.on_intimidated( data, amount, aggressor_unit )
  216.         if aggressor_unit == managers.player:player_unit() then
  217.             CopLogicIdle._surrender( data, amount )
  218.             return true
  219.         else
  220.             return _onIntimidated(data, amount, aggressor_unit)
  221.         end
  222.     end
  223. CopLogicAttack.on_intimidated = CopLogicIdle.on_intimidated
  224. CopLogicArrest.on_intimidated = CopLogicIdle.on_intimidated
  225. CopLogicSniper.on_intimidated = CopLogicIdle.on_intimidated
  226. -- SHIELD LOGIC
  227. CopBrain._logic_variants.shield.intimidated = CopLogicIntimidated
  228.     function CopLogicIntimidated.on_intimidated( data, amount, aggressor_unit )
  229.     -- If shield we skip animations, go straight to conversion & spawn a new shield since it was destroyed during intimidation
  230.     if data.unit:base()._tweak_table == "shield" then
  231.         CopLogicIntimidated._do_tied( data, aggressor_unit )
  232.         CopInventory._chk_spawn_shield( data.unit:inventory(), nil )
  233.     else
  234.         _onIIntimidated(data, amount, aggressor_unit)
  235.     end
  236.  
  237.  
  238. -- PROPER SNIPER ((100% ACCURACY, NO SPREAD) normalizable)
  239. CopBrain._logic_variants.sniper = clone( CopBrain._logic_variants.security )
  240. CopBrain._logic_variants.sniper.attack = CopLogicSniper
  241.     function CopLogicSniper.enter( data, new_logic_name, enter_params )
  242.         if data.unit:brain()._logic_data and data.unit:brain()._logic_data.objective and data.unit:brain()._logic_data.objective.type == "follow" then
  243.             data.char_tweak.weapon[ data.unit:inventory():equipped_unit():base():weapon_tweak_data().usage ] = tweak_data.character.presets.weapon.sniper.m4
  244.             data.char_tweak.weapon[ data.unit:inventory():equipped_unit():base():weapon_tweak_data().usage ].spread = 0
  245.             -- Get dat 100% accuracy
  246.             for distance=1, 3 do
  247.                 for interpolate=1,2 do
  248.                     data.char_tweak.weapon[ data.unit:inventory():equipped_unit():base():weapon_tweak_data().usage ].FALLOFF[distance].acc[interpolate] = 1
  249.                 end
  250.             end
  251.         end
  252.     _onSniperEnter(data, new_logic_name, enter_params)
  253.     end
  254. end
  255. end
  256.  
  257. gagballcloakers = gagballcloakers or function()
  258. dofiles("trainer/assets/stfucloaker.lua")
  259. end
  260. -----------------------
  261. -- ACTIVATE MMCHEATS --
  262. -----------------------
  263. mastermindset = mastermindset or function()
  264.     infcable()
  265.     infmessiah()
  266.     unlmessiah()
  267.     infdocbag()
  268.     infpager()
  269.     infconvert2()
  270.     infintim()
  271.     frekillz()
  272.         show_mid_text("..now go do your evil deeds", "Evil mastermind", 2 )
  273. end
  274.  
  275. ------------------------------
  276. --P---- MENU CONTENT ------C--
  277. ------------------------------
  278. -- ROOT MENU INGAME
  279. masopt = masopt or {
  280. { text = "Exit", is_cancel_button = true},
  281. {},
  282. { text = "Cloaker VLF repeater", callback = gagballcloakers },
  283. {},
  284. { text = "Activate evil mastermind", callback = mastermindset },
  285. }
  286. -- ROOT MENU OUTGAME
  287. if not mastermindmenu then
  288.     mastermindmenu = mastermindmenu or SimpleMenu:new("Evil Mastermind", ".. have you been bad today?", masopt)
  289. end
  290. -- SHOW MASTERMIND INGAME MENU
  291. if inGame() and managers.platform:presence() == "Playing" then
  292.     mastermindmenu:show()
  293.     else
  294.     end
  295. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement