DaBOSS54320

Bully LUA: Jimmy's Revenge Mission

Apr 1st, 2016
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.11 KB | None | 0 0
  1. -- JIMMY'S REVENGE 1.3
  2. -- PASTEBIN EXCLUSIVE BULLY MISSION (probably will post later on bully-board and/or bullymods)
  3. --[[ VERSION HISTORY
  4.   1.0: Initial release.
  5.   1.1: Changed the way the race time is shown, now it looks like M:SS instead of Mm SSs.
  6.   1.2: Changed method of setting unique model statuses, changed "Wow!" to "Holy shit!" in race comments.
  7.   1.3: Added skip feature to cutscene (press jump while loading).
  8. ]]
  9.  
  10. function main()
  11.   -- Make mission peds unique:
  12.   local modelStatus = {}
  13.   for i,model in {21,22,23,24,25,26,27,28,29,41,42,43,44,45} do
  14.     modelStatus[model] = PedGetUniqueModelStatus(model)
  15.     PedSetUniqueModelStatus(model,-1)
  16.   end
  17.  
  18.   -- Let game initialize:
  19.   Wait(500)
  20.  
  21.   -- Set attitude and respect:
  22.   for i,f in {1,2,3,4,5,6,11} do
  23.     PedSetTypeToTypeAttitude(f,13,4)
  24.     SetFactionRespect(f,100)
  25.   end
  26.  
  27.   -- Go outside:
  28.   local skip = false
  29.   TextPrintString("It's such a nice day, go outside.",3,1)
  30.   while AreaGetVisible() ~= 0 or AreaIsLoading() do
  31.     if IsButtonBeingPressed(8,0) and AreaIsLoading() then
  32.       skip = true
  33.     end
  34.     Wait(0)
  35.   end
  36.  
  37.   -- Play cutscene:
  38.   if skip then
  39.     PlayerSetControl(0)
  40.   else
  41.     PlayerSetWeapon(-1)
  42.     PlayerSetControl(0)
  43.     PlayerSetPosXYZ(234.1,-56.1,6.2)
  44.     PedMoveToXYZ(gPlayer,0,234.4,-67.7,6.2)
  45.     CameraSetActive(4)
  46.     CameraSetWidescreen(true)
  47.     CameraAllowChange(false)
  48.     repeat
  49.       local x,y,z = PlayerGetPosXYZ()
  50.       CameraSetXYZ(241,-69.6,10.2,x,y,z)
  51.       TextPrintString("It was just a normal day in Bullworth for young Hopkins...",0,1)
  52.       Wait(0)
  53.     until PedIsInAreaXYZ(gPlayer,234.4,-67.7,6.2,0.5)
  54.     TextPrintString("when suddenly...",1.5,1)
  55.     Wait(1500)
  56.     local johnny = PedCreateXYZ(23,220.4,-68.6,8.5)
  57.     PedSetPedToTypeAttitude(johnny,13,2)
  58.     PedSetInfiniteSprint(johnny,true)
  59.     TextPrintString("a wild Johnny appeared",3,1)
  60.     CameraSetXYZ(239.6,-75.1,11.3,220.4,-68.6,8.5)
  61.     Wait(3000)
  62.     PedMoveToXYZ(johnny,2,234.4,-67.7,6.2)
  63.     local attacked = false
  64.     repeat
  65.       local x,y,z = PedGetPosXYZ(johnny)
  66.       CameraSetXYZ(239.6,-75.1,11.3,x,y,z)
  67.       TextPrintString("and attacked!",0,1)
  68.       if not attacked and PedIsInAreaXYZ(johnny,234.4,-67.7,6.2,2) then
  69.         PedLockTarget(johnny,gPlayer)
  70.         PedSetActionNode(johnny,"/Global/Actions/Offense/RunningAttacks/RunningAttacksDirect","Act/Globals.act")
  71.         attacked = true
  72.       end
  73.       Wait(0)
  74.     until (attacked and not PedIsPlaying(johnny,"/Global/Actions/Offense/RunningAttacks/RunningAttacksDirect",true))
  75.     PedLockTarget(johnny,-1)
  76.     PedMoveToXYZ(johnny,2,271.5,-73,6)
  77.     CameraSetXYZ(227.7,-52.3,11.6,229.8,-54.4,11)
  78.     repeat
  79.       TextPrintString("...and got away.",0,1)
  80.       Wait(0)
  81.     until PedIsInAreaXYZ(johnny,271.5,-73,6,0.5)
  82.     PedDelete(johnny)
  83.     johnny = -1
  84.   end
  85.   PlayerFaceHeading(0.01403962076)
  86.   PlayerSetPosSimple(233.7,-63.4,6.2)
  87.   CameraSetXYZ(233.3,-62.7,7.8,234.8,-65.3,7.5)
  88.   TextPrintString("Jimmy must get revenge.",3,1)
  89.   Wait(3000)
  90.   CameraAllowChange(true)
  91.   CameraSetWidescreen(false)
  92.   CameraReset()
  93.   CameraReturnToPlayer()
  94.   PlayerSetControl(1)
  95.  
  96.   -- Go to the tenements:
  97.   TextPrintString("Search for Johnny in the Tenements",3,1)
  98.   blip = BlipAddXYZ(583.4,-472.4,4.5,0,1,1)
  99.   local raceStart = GetTimer()
  100.   local timeShown = false
  101.   while AreaGetVisible() ~= 36 do
  102.     if PedIsInAreaXYZ(gPlayer,583.4,-472.4,4.5,0.6) then
  103.       TextPrintString("Press \b to enter",0,2)
  104.       Wait(0)
  105.       if IsButtonBeingPressed(9,0) then
  106.         PlayerFaceHeading(0.007246047258)
  107.         PlayerSetPosXYZArea(-544.5,-49.5,31,36)
  108.         while AreaIsLoading() do
  109.           Wait(0)
  110.         end
  111.       end
  112.     elseif not timeShown and PedIsInAreaXYZ(gPlayer,583.4,-472.4,4.5,5) then
  113.       local seconds = (GetTimer() - raceStart)/1000
  114.       local comment,comments = "Fucking terrible.",{
  115.         {1,"You cheater."},
  116.         {5,"Unbelievable."},
  117.         {10,"10 seconds? Did you cheat mister?"},
  118.         {25,"How the fuck did you pull that off?"},
  119.         {30,"You are amazing."},
  120.         {35,"Insane time!"},
  121.         {40,"Fucking incredible!"},
  122.         {45,"Remarkable!"},
  123.         {50,"Holy shit!"},
  124.         {55,"Amazing!"},
  125.         {59,"Under a minute!"},
  126.         {60,"Great!"},
  127.         {65,"Pretty good."},
  128.         {70,"Decent."},
  129.         {75,"Not bad."},
  130.         {80,"Could be better."},
  131.         {85,"Needs some work."},
  132.         {90,"A bit slow."},
  133.         {100,"Pretty slow..."},
  134.         {120,"A bit embarassing."},
  135.         {150,"Awful."},
  136.         {180,"3 minutes? Really?"},
  137.         {200,"You should be ashamed."},
  138.         {300,"What the fuck were you doing?"},
  139.         {400,"...I don't even know what to say."},
  140.         {500,"Did you fucking ride a turtle here?"},
  141.         {600,"Great, you beat 10 minutes!\nFucking awful..."},
  142.       }
  143.       for i,v in ipairs(comments) do
  144.         if seconds <= v[1] then
  145.           comment = v[2]
  146.           break
  147.         end
  148.       end
  149.       local minutes = 0
  150.       while seconds > 60 do
  151.         seconds = seconds - 60
  152.         minutes = minutes + 1
  153.       end
  154.       seconds = string.format("%.0f",seconds)
  155.       if tonumber(seconds) < 10 then
  156.         seconds = "0"..seconds
  157.       end
  158.       TextPrintString("Time: "..minutes..":"..seconds.."\n\n"..comment,6,1)
  159.       timeShown = true
  160.     else
  161.       Wait(0)
  162.     end
  163.   end
  164.   BlipRemove(blip)
  165.  
  166.   -- Set greaser attitude and respect:
  167.   PedSetTypeToTypeAttitude(3,3,4)
  168.   PedSetTypeToTypeAttitude(3,4,4)
  169.   PedSetTypeToTypeAttitude(3,13,0)
  170.   PedSetTypeToTypeAttitude(4,4,4)
  171.   PedSetTypeToTypeAttitude(4,3,4)
  172.   PedSetTypeToTypeAttitude(4,13,0)
  173.   SetFactionRespect(3,0)
  174.   SetFactionRespect(4,0)
  175.  
  176.   -- Setup enemy room tables:
  177.   local rooms = {
  178.     --{{blip position},{enemy model,x,y,z},{enemy model,x,y,z},...}
  179.     {{-547.1,-42.3,31.0},{21,-550.0,-43.9,31.0},{24,-545.1,-38.6,31.0}},
  180.     {{-547.8,-20.6,31.0},{22,-542.7,-17.2,31.0},{26,-540.5,-27.3,31.3},{27,-546.5,-24.4,31.0}},
  181.     {{-534.2,-21.0,31.0},{28,-535.3,-26.4,31.0}},
  182.     {{-534.7,-42.9,31.0},{29,-537.3,-48.1,30.9},{41,-530.0,-43.2,30.8}},
  183.     {{-517.1,-44.0,31.0},{42,-508.4,-39.2,31.0},{43,-525.7,-48.1,31.0}},
  184.     {{-519.0,-21.2,31.0},{44,-525.9,-18.4,31.0},{45,-510.4,-22.5,31.0}}
  185.   }
  186.  
  187.   -- Setup enemy rooms:
  188.   for key,t in ipairs(rooms) do
  189.     t[1][4] = BlipAddXYZ(t[1][1],t[1][2],t[1][3],0,1)
  190.     local i = 2
  191.     while t[i] do
  192.       t[i][5] = PedCreateXYZ(t[i][1],t[i][2],t[i][3],t[i][4])
  193.       i = i + 1
  194.     end
  195.   end
  196.  
  197.   -- Clear rooms:
  198.   TextPrintString("This place is crawling with greasers! Clear all the rooms before confronting Johnny.",5,1)
  199.   local cleared
  200.   repeat
  201.     -- Set to be cleared (will be set to false if any peds are alive):
  202.     cleared = true
  203.    
  204.     -- Process each room:
  205.     for key,t in ipairs(rooms) do
  206.       -- Process room blip:
  207.       if t[1][4] then
  208.         local aggressed = false
  209.         local i = 2
  210.         while t[i] do
  211.           if not PedIsValid(t[i][5]) or PedIsDead(t[i][5]) or PedIsInCombat(t[i][5]) or PedHasAggressed(t[i][5]) then
  212.             aggressed = true
  213.             break
  214.           end
  215.           i = i + 1
  216.         end
  217.         if aggressed then
  218.           BlipRemove(t[1][4])
  219.           t[1][4] = nil
  220.           local i = 2
  221.           while t[i] do
  222.             if PedIsValid(t[i][5]) and not PedIsDead(t[i][5]) then
  223.               PedAttackPlayer(t[i][5],3)
  224.               AddBlipForChar(t[i][5],0,26,1)
  225.             end
  226.             i = i + 1
  227.           end
  228.         end
  229.       end
  230.      
  231.       -- Check if room is clear:
  232.       local i = 2
  233.       while cleared and t[i] do
  234.         if PedIsValid(t[i][5]) and not PedIsDead(t[i][5]) then
  235.           cleared = false
  236.           break
  237.         end
  238.         i = i + 1
  239.       end
  240.     end
  241.    
  242.     -- Wait:
  243.     Wait(0)
  244.   until cleared
  245.   rooms = nil
  246.  
  247.   -- Confront Johnny:
  248.   TextPrintString("Find Johnny",3,1)
  249.   johnny = PedCreateXYZ(23,-524.2,-32.4,35.7)
  250.   repeat
  251.     Wait(0)
  252.   until PedIsOnScreen(johnny)
  253.   PedAttackPlayer(johnny,3)
  254.   AddBlipForChar(johnny,0,26,4)
  255.   repeat
  256.     Wait(0)
  257.   until not PedIsValid(johnny) or PedIsDead(johnny)
  258.  
  259.   -- Mission succeed:
  260.   MissionSucceed()
  261.  
  262.   -- Restore original model status:
  263.   for model,status in modelStatus do
  264.     PedSetUniqueModelStatus(model,status)
  265.   end
  266.  
  267.   -- Keep the script running:
  268.   while true do
  269.     Wait(0)
  270.   end
  271. end
  272.  
  273. -- STimeCycle functions:
  274. F_AttendedClass = function()
  275.   if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
  276.     return
  277.   end
  278.   SetSkippedClass(false)
  279.   PlayerSetPunishmentPoints(0)
  280. end
  281.  
  282. F_MissedClass = function()
  283.   if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
  284.     return
  285.   end
  286.   SetSkippedClass(true)
  287.   StatAddToInt(166)
  288. end
  289.  
  290. F_AttendedCurfew = function()
  291.   if not PedInConversation(gPlayer) and not MissionActive() then
  292.     TextPrintString("You got home in time for curfew", 4)
  293.   end
  294. end
  295.  
  296. F_MissedCurfew = function()
  297.   if not PedInConversation(gPlayer) and not MissionActive() then
  298.     TextPrint("TM_TIRED5", 4, 2)
  299.   end
  300. end
  301.  
  302. F_StartClass = function()
  303.   if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
  304.     return
  305.   end
  306.   F_RingSchoolBell()
  307.   local l_6_0 = PlayerGetPunishmentPoints() + GetSkippingPunishment()
  308. end
  309.  
  310. F_EndClass = function()
  311.   if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
  312.     return
  313.   end
  314.   F_RingSchoolBell()
  315. end
  316.  
  317. F_StartMorning = function()
  318.   F_UpdateTimeCycle()
  319. end
  320.  
  321. F_EndMorning = function()
  322.   F_UpdateTimeCycle()
  323. end
  324.  
  325. F_StartLunch = function()
  326.   if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
  327.     F_UpdateTimeCycle()
  328.     return
  329.   end
  330.   F_UpdateTimeCycle()
  331. end
  332.  
  333. F_EndLunch = function()
  334.   F_UpdateTimeCycle()
  335. end
  336.  
  337. F_StartAfternoon = function()
  338.   F_UpdateTimeCycle()
  339. end
  340.  
  341. F_EndAfternoon = function()
  342.   F_UpdateTimeCycle()
  343. end
  344.  
  345. F_StartEvening = function()
  346.   F_UpdateTimeCycle()
  347. end
  348.  
  349. F_EndEvening = function()
  350.   F_UpdateTimeCycle()
  351. end
  352.  
  353. F_StartCurfew_SlightlyTired = function()
  354.   F_UpdateTimeCycle()
  355. end
  356.  
  357. F_StartCurfew_Tired = function()
  358.   F_UpdateTimeCycle()
  359. end
  360.  
  361. F_StartCurfew_MoreTired = function()
  362.   F_UpdateTimeCycle()
  363. end
  364.  
  365. F_StartCurfew_TooTired = function()
  366.   F_UpdateTimeCycle()
  367. end
  368.  
  369. F_EndCurfew_TooTired = function()
  370.   F_UpdateTimeCycle()
  371. end
  372.  
  373. F_EndTired = function()
  374.   F_UpdateTimeCycle()
  375. end
  376.  
  377. F_Nothing = function()
  378. end
  379.  
  380. F_ClassWarning = function()
  381.   if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
  382.     return
  383.   end
  384.   local l_23_0 = math.random(1, 2)
  385. end
  386.  
  387. F_UpdateTimeCycle = function()
  388.   if not IsMissionCompleated("1_B") then
  389.     local l_24_0 = GetCurrentDay(false)
  390.     if l_24_0 < 0 or l_24_0 > 2 then
  391.       SetCurrentDay(0)
  392.     end
  393.   end
  394.   F_UpdateCurfew()
  395. end
  396.  
  397. F_UpdateCurfew = function()
  398.   local l_25_0 = shared.gCurfewRules
  399.   if not l_25_0 then
  400.     l_25_0 = F_CurfewDefaultRules
  401.   end
  402.   l_25_0()
  403. end
  404.  
  405. F_CurfewDefaultRules = function()
  406.   local l_26_0 = ClockGet()
  407.   if l_26_0 >= 23 or l_26_0 < 7 then
  408.     shared.gCurfew = true
  409.   else
  410.     shared.gCurfew = false
  411.   end
  412. end
Advertisement
Add Comment
Please, Sign In to add comment