Advertisement
Altamurenza

Bully SE/AE: Open Auditorium Mod

May 19th, 2022 (edited)
633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.50 KB | None | 0 0
  1. -- OPEN AUDITORIUM
  2. -- AUTHOR   : ALTAMURENZA
  3.  
  4.  
  5. --[[
  6.     Created         : 21/08/2021
  7.     Last Modified   : 19/05/2022
  8.    
  9.    
  10.     - SCRIPT INFORMATION -
  11.    
  12.     I'm sorry for being lazy to make a full comment on this script.
  13.     I'll just provide some notable informations you need to know.
  14.    
  15.     1) SETUP table vs FIELD table:
  16.         - SETUP     = How the mod prepares everything
  17.         - FIELD     = How the mod goes (rule & scope)
  18.    
  19.     2) FIELD.SMOOTH_CLEANUP condition
  20.         FIELD.SMOOTH_CLEANUP will make NPCs exit the auditorium once the maximum event time being reached.
  21.         It will happen if you don't leave the auditorium after 6 pm (according to SETUP.EVENT).
  22.         If you exit the auditorium before the time limit, the NPCs will just disappear like a normal day in Bully.
  23.    
  24.     The rest of them should be easy to understand.
  25.    
  26.    
  27.     - AUTHOR'S POLICY -
  28.    
  29.     You can edit any part of this mod and play it privately.
  30.     However, you cannot upload it as a compiled script or source code.
  31.     It simply because i would never give permission to do so.
  32.    
  33.     Everything that is not mentioned above is allowed, you don't have to ask me for a permission.
  34.    
  35.     Q: Can i publish a modified version of this?
  36.     A: No, that's obviously a copy. Too easy, like 5 minutes ready mod.
  37.    
  38.     Q: Can i use some resources from this script to my mod?
  39.     A: Yes, i'm eager to see your innovation, the community is eager to fresh content.
  40. ]]
  41.  
  42.  
  43. main = function()
  44.     AreaDisableCameraControlForTransition(true)
  45.     DATLoad("eventsAuditorium.DAT", 0)
  46.     DATLoad("SP_Auditorium.DAT", 0)
  47.     F_PreDATInit()
  48.     DATInit()
  49.     shared.gAreaDATFileLoaded[19] = true
  50.     shared.gAreaDataLoaded = true
  51.     CameraFade(1, 0)
  52.    
  53.     local HOUR, MINUTE = ClockGet()
  54.     local SETUP = {}
  55.    
  56.     SETUP.FLAG = false
  57.     SETUP.EVENT = (HOUR >= 12 and HOUR < 18) and true or false
  58.    
  59.     if not MissionActiveSpecific("3_01C") and not MissionActiveSpecific("1_09") then
  60.         if not SETUP.PROP then
  61.             if ChapterGet() == 2 and not IsMissionCompleated("3_01C") then
  62.                 AreaLoadSpecialEntities("nutcracker", true)
  63.                 AreaEnsureSpecialEntitiesAreCreated()
  64.             elseif IsMissionCompleated("1_03") and not IsMissionCompleated("1_09") then
  65.                 AreaLoadSpecialEntities("vote", true)
  66.                 AreaEnsureSpecialEntitiesAreCreated()
  67.             end
  68.            
  69.             SETUP.PROP = true
  70.         end
  71.        
  72.         if not SETUP.FLAG then
  73.             DATLoad("3_01C.DAT", 2)
  74.            
  75.             if ChapterGet() == 2 then
  76.                 DATLoad("ClassMusic.DAT", 2)
  77.                 DATInit()
  78.                
  79.                 if not IsMissionCompleated("3_01C") and SETUP.EVENT then
  80.                     SETUP.NPC = {}
  81.                    
  82.                     table.insert(SETUP.NPC, {"MSPETERS", 249, POINTLIST._3_01C_MSPETERS, "/Global/MGMusic/Animations/Teacher", "Act/Conv/MGMusic.act"})
  83.                     table.insert(SETUP.NPC, {"MELODY", IsMissionCompleated("3_01D") and 257 or 137, POINTLIST._3_01C_DANCER01, "/Global/3_01C/Flower", "Act/Conv/3_01C.act"})
  84.                     table.insert(SETUP.NPC, {"EUNICE", IsMissionCompleated("3_01D") and 256 or 74, POINTLIST._3_01C_DANCER02, "/Global/3_01C/Fairy", "Act/Conv/3_01C.act"})
  85.                     table.insert(SETUP.NPC, {"PEDRO", IsMissionCompleated("3_01D") and 258 or 69, POINTLIST._3_01C_DANCER03, "/Global/3_01C/Flower", "Act/Conv/3_01C.act"})
  86.                     table.insert(SETUP.NPC, {"PETER", IsMissionCompleated("3_01D") and 255 or 134, POINTLIST._3_01C_BAND02, "/Global/MGMusic/Animations/Gary/Sticks/Timpani", "Act/Conv/MGMusic.act"})
  87.                     if not IsMissionCompleated("3_01D") then
  88.                         table.insert(SETUP.NPC, {"CONSTANTINOS", 70, POINTLIST._3_01C_PLAYERSTART, "/Global/MGMusic/Animations/Jimmy/Sticks/xylophone", "Act/Conv/MGMusic.act"})
  89.                     end
  90.                    
  91.                     LoadActionTree("Act/Conv/MGMusic.act")
  92.                     LoadActionTree("Act/Conv/3_01C.act")
  93.                    
  94.                     WeaponRequestModel(439)
  95.                     WeaponRequestModel(443)
  96.                     WeaponRequestModel(444)
  97.                    
  98.                     for _, V in ipairs(SETUP.NPC) do
  99.                         if not PedIsValid(_G[V[1]]) then
  100.                             _G[V[1]] = PedCreatePoint(V[2], V[3])
  101.                             PedIgnoreStimuli(_G[V[1]], true)
  102.                             PedSetStationary(_G[V[1]], true)
  103.                            
  104.                             if V[1] == "PETER" then
  105.                                 SoundLoadBank("MINIGAME\\TIMPANI_01.bnk")
  106.                                 GeometryInstance("xmas_timpani", false, -762.71301269531, 308.60299682617, 77.249000549316)
  107.                                 GeometryInstance("xmas_timstick_l", false, -762.61901855469, 307.45700073242, 74.888999938965)
  108.                                 GeometryInstance("x_cowbell_2p", false, -762.73699951172, 307.45700073242, 74.888999938965)
  109.                                 PedSetActionNode(_G[V[1]], V[4], V[5])
  110.                                 Wait(10)
  111.                                 PedSetActionNode(_G[V[1]], "/Global/MGMusic/Animations/Gary/CustomIdle", "Act/Conv/MGMusic.act")
  112.                             elseif V[1] == "CONSTANTINOS" then
  113.                                 GeometryInstance("xmas_xylophone", false, -763.99597167969, 308.15399169922, 77.249000549316)
  114.                                 GeometryInstance("xmas_xylostick_r", false, -763.59899902344, 307.45700073242, 74.888999938965)
  115.                                 GeometryInstance("xmas_xylostick_l", false, -763.48101806641, 307.45700073242, 74.888999938965)
  116.                                 PedSetActionNode(_G[V[1]], V[4], V[5])
  117.                                 Wait(10)
  118.                                 PedSetActionNode(_G[V[1]], "/Global/MGMusic/Animations/Jimmy/CustomIdle", "Act/Conv/MGMusic.act")
  119.                             else
  120.                                 PedSetActionNode(_G[V[1]], V[4], V[5])
  121.                             end
  122.                         end
  123.                     end
  124.                    
  125.                     SETUP.ANIM = {
  126.                         "Drumming",
  127.                         "Pageant",
  128.                         "UBO",
  129.                         "NPC_Spectator",
  130.                     }
  131.                    
  132.                     for _, V in ipairs(SETUP.ANIM) do
  133.                         if HasAnimGroupLoaded(V) == false then
  134.                             LoadAnimationGroup(V)
  135.                         end
  136.                     end
  137.                 end
  138.             else
  139.                 if not IsMissionCompleated("1_09") and IsMissionCompleated("1_03") and SETUP.EVENT then
  140.                     DATLoad("1_09.DAT", 2)
  141.                     DATInit()
  142.                    
  143.                     SETUP.NPC = {}
  144.                    
  145.                     table.insert(SETUP.NPC, {"EARNEST", 10, POINTLIST._1_09_EARNEST})
  146.                     table.insert(SETUP.NPC, {"BEATRICE", 3, POINTLIST._1_09_SEATEDPOINTS, 1})
  147.                     table.insert(SETUP.NPC, {"FATTY", 5, POINTLIST._1_09_SEATEDPOINTS, 2})
  148.                     table.insert(SETUP.NPC, {"CORNELIUS", 9, POINTLIST._1_09_SEATEDPOINTS, 3})
  149.                     table.insert(SETUP.NPC, {"BUCKY", 8, POINTLIST._1_09_SEATEDPOINTS, 4})
  150.                     table.insert(SETUP.NPC, {"MELVIN", 6, POINTLIST._1_09_SEATEDPOINTS, 5})
  151.                    
  152.                     for _, V in ipairs(SETUP.NPC) do
  153.                         if not PedIsValid(_G[V[1]]) then
  154.                             _G[V[1]] = PedCreatePoint(V[2], V[3], V[4] or nil)
  155.                             PedIgnoreStimuli(_G[V[1]], true)
  156.                             PedIgnoreAttacks(_G[V[1]], true)
  157.                             PedSetMinHealth(_G[V[1]], 25)
  158.                            
  159.                             if V[1] == "EARNEST" then
  160.                                 PedSetFlag(_G[V[1]], 13, true)
  161.                                 PedSetActionNode(_G[V[1]], "/Global/NPC1_09/Speech", "Act/Anim/NPC1_09.act")
  162.                             else
  163.                                 PedSetActionNode(_G[V[1]], "/Global/1_09/CustomPedTree", "Act/Conv/1_09.act")
  164.                             end
  165.                         end
  166.                     end
  167.                    
  168.                     SETUP.ANIM = {
  169.                         "1_09_Candidate",
  170.                         "NPC_Mascot",
  171.                         "NIS_1_09",
  172.                         "IDLE_NERD_A",
  173.                         "Cheer_Nerd1",
  174.                     }
  175.                    
  176.                     for _, V in ipairs(SETUP.ANIM) do
  177.                         if HasAnimGroupLoaded(V) == false then
  178.                             LoadAnimationGroup(V)
  179.                         end
  180.                     end
  181.                 end
  182.             end
  183.            
  184.             SETUP.FLAG = true
  185.         end
  186.     end
  187.    
  188.     local FIELD = {}
  189.    
  190.     FIELD.VIOLATION = {
  191.         [1] = true, [2] = true, [4] = true, [7] = true, [9] = true,
  192.         [12] = true, [27] = true, [60] = true, [61] = true, [74] = true
  193.     }
  194.     FIELD.BREACH = function()
  195.         if PedInRectangle(gPlayer, -778.45, 306.26, -760.57, 319.52) then
  196.             if not FIELD.INTERRUPT then
  197.                 local BX, BY, BZ = PedGetOffsetInWorldCoords(gPlayer, 0, -1.5, 0)
  198.                 local RAT = PedCreateXYZ(136, BX, BY, BZ + 12)
  199.                 PedSetEffectedByGravity(RAT, false)
  200.                 PedSetStationary(RAT, true)
  201.                 PedSetAsleep(RAT, true)
  202.                 PedSetInvulnerable(RAT, true)
  203.                 PedMakeTargetable(RAT, false)
  204.                
  205.                 if PedInRectangle(RAT, -778.45, 306.26, -760.57, 319.52) then
  206.                     for _, OFFSET in ipairs({{0, 1.5, 0}, {-1.5, 0, 0}, {1.5, 0, 0}, {0, -2.5, 0}, {0, 2.5, 0}, {-2.5, 0, 0}, {2.5, 0, 0}}) do
  207.                         BX, BY, BZ = PedGetOffsetInWorldCoords(gPlayer, unpack(OFFSET))
  208.                         PedSetPosXYZ(RAT, BX, BY, BZ + 12)
  209.                        
  210.                         if not PedInRectangle(RAT, -778.45, 306.26, -760.57, 319.52) then
  211.                             break
  212.                         end
  213.                     end
  214.                 end
  215.                
  216.                 if PedInRectangle(RAT, -778.45, 306.26, -760.57, 319.52) then
  217.                     BX, BY, BZ = -769.54, 304.50, 76.40
  218.                 end
  219.                 PedDelete(RAT)
  220.                 PlayerLockButtonInputsExcept(7, true)
  221.                 PedMoveToXYZ(gPlayer, 0, BX, BY, BZ)
  222.                 CameraSetWidescreen(true)
  223.                
  224.                 FIELD.INTERRUPT, FIELD.INTERRUPT_MAX = GetTimer() + 2000, GetTimer() + 10000
  225.             else
  226.                 if FIELD.INTERRUPT < GetTimer() and FIELD.INTERRUPT_MAX < GetTimer() then
  227.                     PedMoveToXYZ(gPlayer, 0, -769.54, 304.50, 76.40)
  228.                 end
  229.             end
  230.         else
  231.             if FIELD.INTERRUPT then
  232.                 if FIELD.INTERRUPT < GetTimer() then
  233.                     CameraSetWidescreen(false)
  234.                     PlayerLockButtonInputsExcept(false)
  235.                    
  236.                     FIELD.INTERRUPT, FIELD.INTERRUPT_MAX = nil, nil
  237.                 end
  238.             end
  239.         end
  240.     end
  241.     FIELD.HIT = function()
  242.         if type(SETUP.NPC) == "table" then
  243.             for _, CONTENT in ipairs(SETUP.NPC) do
  244.                 if PedIsValid(_G[CONTENT[1]]) and PedMePlaying(_G[CONTENT[1]], "HitTree") and PedGetWhoHitMeLast(_G[CONTENT[1]]) == gPlayer then
  245.                     return true
  246.                 end
  247.             end
  248.         end
  249.        
  250.         return false
  251.     end
  252.    
  253.     AreaDisableCameraControlForTransition(false)
  254.     Wait(250)
  255.     CameraFade(500, 1)
  256.    
  257.     while AreaGetVisible() == 19 and not SystemShouldEndScript() do
  258.         Wait(0)
  259.        
  260.         HOUR, MINUTE = ClockGet()
  261.        
  262.         SETUP.EVENT = (HOUR >= 12 and HOUR < 18) and true or false
  263.        
  264.         if FIELD.KICK then
  265.             shared.storeTransition = {2, GetPointList(POINTLIST._3_01C_PLAYEREND)}
  266.             LaunchScript("AreaScripts/StoreTransition.lua")
  267.            
  268.             break
  269.         end
  270.        
  271.         if SETUP.EVENT then
  272.             if not FIELD.SMOOTH_CLEANUP then
  273.                 if PedIsValid(_G.MSPETERS) then
  274.                     if IsMissionCompleated("3_01D") then
  275.                         SoundPlayStream("MS_MusicClass_Carols01.rsm", 1.2)
  276.                     else
  277.                         SoundPlayStream("MS_XmasComeRudyLow.rsm", 1.2)
  278.                     end
  279.                    
  280.                     if PedIsValid(_G.PETER) and PedGetHealth(_G.PETER) > 0 then
  281.                         if not PETER_TIMER then
  282.                             PETER_TIMER = GetTimer() + math.random(1000, 2500)
  283.                         end
  284.                        
  285.                         if PETER_TIMER < GetTimer() then
  286.                             PedSetActionNode(_G.PETER, "/Global/MGMusic/Animations/Gary/Left/Timpani/Hit", "Act/Conv/MGMusic.act")
  287.                            
  288.                             local X, Y, Z = PlayerGetPosXYZ()
  289.                             local PX, PY, PZ = PedGetPosXYZ(_G.PETER)
  290.                            
  291.                             if math.abs(X - PX) + math.abs(Y - PY) + math.abs(Z - PZ) <= 7 then
  292.                                 SoundPlay2D("TIMPANI_LEFT_H")
  293.                             end
  294.                            
  295.                             PETER_TIMER = GetTimer() + math.random(1000, 2500)
  296.                         end
  297.                     end
  298.                    
  299.                     if PedIsValid(_G.CONSTANTINOS) and PedGetHealth(_G.CONSTANTINOS) > 0 then
  300.                         if not CONSTANTINOS_TIMER then
  301.                             CONSTANTINOS_TIMER = GetTimer() + math.random(700, 2500)
  302.                         end
  303.                        
  304.                         if CONSTANTINOS_TIMER < GetTimer() then
  305.                             local HAND = math.random(1, 2) == 1 and "Right" or "Left"
  306.                             PedSetActionNode(_G.CONSTANTINOS, "/Global/MGMusic/Animations/Jimmy/"..HAND.."/xylophone/Hit", "Act/Conv/MGMusic.act")
  307.                            
  308.                             CONSTANTINOS_TIMER = GetTimer() + math.random(1000, 2500)
  309.                         end
  310.                     end
  311.                    
  312.                     for _, S in pairs(FIELD.VIOLATION) do
  313.                         if (FIELD.HIT() or PedHasGeneratedStimulusOfType(gPlayer, S) or PedInRectangle(gPlayer, -778.45, 306.26, -760.57, 319.52)) and not FIELD.KICK then
  314.                             PedFaceXYZ(_G.MSPETERS, PlayerGetPosXYZ())
  315.                            
  316.                             SoundStopStream()
  317.                             PlayerSetControl(0)
  318.                             CameraSetWidescreen(true)
  319.                            
  320.                             local CSX, CSY, CSZ = PedGetOffsetInWorldCoords(_G.MSPETERS, 0, 2.5, 1)
  321.                             local CLX, CLY, CLZ = PedGetPosXYZ(_G.MSPETERS)
  322.                             CameraSetXYZ(CSX, CSY, CSZ, CLX, CLY, CLZ + 1)
  323.                            
  324.                             while PedMePlaying(_G.MSPETERS, "HitTree") do
  325.                                 Wait(0)
  326.                             end
  327.                            
  328.                             PedSetActionNode(_G.MSPETERS, "/Global/1_08/CafeteriaLady/Point/Point", "Act/Conv/1_08.act")
  329.                             SoundStopCurrentSpeechEvent(_G.MSPETERS)
  330.                             SoundPlayScriptedSpeechEvent(_G.MSPETERS, "DONT_HIT", 0, "xtralarge", false)
  331.                            
  332.                             while SoundSpeechPlaying(_G.MSPETERS) do
  333.                                 Wait(0)
  334.                             end
  335.                             Wait(1000)
  336.                            
  337.                             CameraFade(500, 0)
  338.                             Wait(501)
  339.                            
  340.                             FIELD.KICK = true
  341.                             break
  342.                         end
  343.                     end
  344.                 end
  345.                
  346.                 if PedIsValid(_G.EARNEST) then
  347.                     SoundStopStream()
  348.                    
  349.                     if not shared.EARNEST_SPEECH then
  350.                         shared.EARNEST_SPEECH = 0
  351.                     end
  352.                    
  353.                     if not EARNEST_TIMER then
  354.                         EARNEST_TIMER = GetTimer() + 1000
  355.                     end
  356.                    
  357.                     if not SoundSpeechPlaying(_G.EARNEST) and not PedIsPlaying(_G.EARNEST, "/Global/DodgeballGame/Anims/DejectedD", true) and not EARNEST_SPEECH_STOP and not EARNEST_SPEECH_FAIL then
  358.                         if EARNEST_TIMER < GetTimer() then
  359.                             shared.EARNEST_SPEECH = shared.EARNEST_SPEECH + 1 > 30 and 0 or shared.EARNEST_SPEECH + 1
  360.                            
  361.                             if math.random(0, 10) ~= 5 then
  362.                                 SoundPlayScriptedSpeechEvent(_G.EARNEST, "M_1_09", shared.EARNEST_SPEECH + 2, "xtralarge", true)
  363.                                
  364.                                 local CONVERTED_NUMBER
  365.                                 for I = 1, 9 do
  366.                                     if shared.EARNEST_SPEECH == I then
  367.                                         CONVERTED_NUMBER = "0"..I
  368.                                         break
  369.                                     end
  370.                                 end
  371.                                
  372.                                 PedSetActionNode(_G.EARNEST, "/Global/1_09/EarnestSpeech/"..(CONVERTED_NUMBER or shared.EARNEST_SPEECH), "Act/Conv/1_09.act")
  373.                             else
  374.                                 if HOUR < 17 then
  375.                                     EARNEST_SPEECH_FAIL = true
  376.                                 end
  377.                             end
  378.                            
  379.                             EARNEST_TIMER = GetTimer() + (EARNEST_SPEECH_FAIL and 3000 or 1000)
  380.                         end
  381.                     end
  382.                    
  383.                     if EARNEST_SPEECH_FAIL then
  384.                         if EARNEST_TIMER < GetTimer() then
  385.                             PedSetActionNode(_G.EARNEST, "/Global/DodgeballGame/Anims/DejectedD", "Act/Conv/DodgeballGame.act")
  386.                            
  387.                             shared.EARNEST_SPEECH = 0
  388.                             EARNEST_TIMER = GetTimer() + 8000
  389.                             EARNEST_SPEECH_FAIL = false
  390.                         end
  391.                     end
  392.                    
  393.                     for _, S in pairs(FIELD.VIOLATION) do
  394.                         if (FIELD.HIT() or PedHasGeneratedStimulusOfType(gPlayer, S) or PedInRectangle(gPlayer, -778.45, 306.26, -760.57, 319.52)) and not FIELD.KICK then
  395.                             EARNEST_SPEECH_STOP = true
  396.                             SoundStopCurrentSpeechEvent(_G.EARNEST)
  397.                             PedFaceXYZ(_G.EARNEST, PlayerGetPosXYZ())
  398.                            
  399.                             SoundStopStream()
  400.                             PlayerSetControl(0)
  401.                             CameraSetWidescreen(true)
  402.                            
  403.                             local CSX, CSY, CSZ = PedGetOffsetInWorldCoords(_G.EARNEST, 0, 2.5, 1)
  404.                             local CLX, CLY, CLZ = PedGetPosXYZ(_G.EARNEST)
  405.                             CameraSetXYZ(CSX, CSY, CSZ, CLX, CLY, CLZ + 1)
  406.                            
  407.                             while PedMePlaying(_G.EARNEST, "HitTree") do
  408.                                 Wait(0)
  409.                             end
  410.                            
  411.                             PedSetActionNode(_G.EARNEST, "/Global/1_08/CafeteriaLady/Point/Point", "Act/Conv/1_08.act")
  412.                             SoundStopCurrentSpeechEvent(_G.EARNEST)
  413.                             SoundPlayScriptedSpeechEvent(_G.EARNEST, "DONT_HIT", 0, "xtralarge", false)
  414.                            
  415.                             while SoundSpeechPlaying(_G.EARNEST) do
  416.                                 Wait(0)
  417.                             end
  418.                             Wait(1000)
  419.                            
  420.                             CameraFade(500, 0)
  421.                             Wait(501)
  422.                            
  423.                             FIELD.KICK = true
  424.                             break
  425.                         end
  426.                     end
  427.                 end
  428.                
  429.                 if not PedIsValid(_G.MSPETERS) and not PedIsValid(_G.EARNEST) then
  430.                     FIELD.BREACH()
  431.                 end
  432.             else
  433.                 FIELD.BREACH()
  434.             end
  435.         else
  436.             SoundStopStream()
  437.            
  438.             if PedIsValid(_G.MSPETERS) and not FIELD.SMOOTH_CLEANUP then
  439.                 for _, V in ipairs(SETUP.NPC) do
  440.                     if PedIsValid(_G[V[1]]) then
  441.                         PedIgnoreStimuli(_G[V[1]], false)
  442.                         PedSetStationary(_G[V[1]], false)
  443.                        
  444.                         if V[1] == "PETER" then
  445.                             PedSetActionNode(_G[V[1]], "/Global/MGMusic/Animations/Gary/Sticks/RemoveSticks", "Act/Conv/MGMusic.act")
  446.                         elseif V[1] == "CONSTANTINOS" then
  447.                             PedSetActionNode(_G[V[1]], "/Global/MGMusic/Animations/Jimmy/Sticks/RemoveSticks", "Act/Conv/MGMusic.act")
  448.                         end
  449.                        
  450.                         PedStop(_G[V[1]])
  451.                         PedSetActionNode(_G[V[1]], "/Global", "Act/Globals.act")
  452.                        
  453.                         PedSetAITree(_G[V[1]], "/Global/AI", "Act/AI/AI.act")
  454.                         PedMakeAmbient(_G[V[1]])
  455.                     end
  456.                 end
  457.                
  458.                 SoundPlayScriptedSpeechEvent(_G.MSPETERS, IsMissionCompleated("3_01D") and "CONGRATULATIONS" or "SEE_SOMETHING_CRAP", 0, "xtralarge", true)
  459.                
  460.                 FIELD.CLEANUP_TIMER = GetTimer() + math.random(5000, 10000)
  461.                 FIELD.SMOOTH_CLEANUP = true
  462.             end
  463.            
  464.             if PedIsValid(_G.EARNEST) and not FIELD.SMOOTH_CLEANUP then
  465.                 for _, V in ipairs(SETUP.NPC) do
  466.                     if PedIsValid(_G[V[1]]) then
  467.                         PedIgnoreStimuli(_G[V[1]], false)
  468.                         PedIgnoreAttacks(_G[V[1]], false)
  469.                         PedSetMinHealth(_G[V[1]], 0)
  470.                        
  471.                         if V[1] == "EARNEST" then
  472.                             SoundStopCurrentSpeechEvent(_G[V[1]])
  473.                             PedSetFlag(_G[V[1]], 13, false)
  474.                             PedSetActionNode(_G[V[1]], "/Global", "Act/Globals.act")
  475.                         else
  476.                             PedSetActionNode(_G[V[1]], "/Global/1_09/CustomPedTree/Break", "Act/Conv/1_09.act")
  477.                             local PFX, PFY, PFZ = PedGetOffsetInWorldCoords(_G[V[1]], 0, 1, 0)
  478.                             PedMoveToXYZ(_G[V[1]], 0, PFX, PFY, PFZ)
  479.                         end
  480.                        
  481.                         PedMakeAmbient(_G[V[1]])
  482.                     end
  483.                 end
  484.                
  485.                 SoundPlayScriptedSpeechEvent(_G.EARNEST, "M_1_09", 36, "xtralarge", true)
  486.                
  487.                 FIELD.CLEANUP_TIMER = GetTimer() + math.random(4000, 7000)
  488.                 FIELD.SMOOTH_CLEANUP = true
  489.             end
  490.            
  491.             if FIELD.SMOOTH_CLEANUP then
  492.                 if FIELD.CLEANUP_TIMER then
  493.                     if FIELD.CLEANUP_TIMER < GetTimer() then
  494.                         for _, V in ipairs(SETUP.NPC) do
  495.                             if PedIsValid(_G[V[1]]) and PedGetHealth(_G[V[1]]) > 0 then
  496.                                 PedMoveToXYZ(_G[V[1]], math.random(1, 3) == 2 and 1 or 0, -777.85, 288.00, 77.95)
  497.                             end
  498.                         end
  499.                        
  500.                         FIELD.CLEANUP_TIMER = nil
  501.                     end
  502.                 else
  503.                     for _, V in ipairs(SETUP.NPC) do
  504.                         if PedIsValid(_G[V[1]]) and PedIsInAreaXYZ(_G[V[1]], -777.85, 288.00, 77.95, 1.5) then
  505.                             PedDelete(_G[V[1]])
  506.                         end
  507.                     end
  508.                 end
  509.             end
  510.            
  511.             FIELD.BREACH()
  512.         end
  513.     end
  514.    
  515.     if SETUP.PROP then
  516.         if ChapterGet() == 2 and not IsMissionCompleated("3_01C") then
  517.             AreaLoadSpecialEntities("nutcracker", false)
  518.             AreaEnsureSpecialEntitiesAreCreated()
  519.         elseif IsMissionCompleated("1_03") and not IsMissionCompleated("1_09") then
  520.             AreaLoadSpecialEntities("vote", false)
  521.             AreaEnsureSpecialEntitiesAreCreated()
  522.         end
  523.        
  524.         SETUP.PROP = false
  525.     end
  526.    
  527.     if SETUP.FLAG then
  528.         DATUnload(2)
  529.        
  530.         if type(SETUP.NPC) == "table" then
  531.             for _, V in ipairs(SETUP.NPC) do
  532.                 if PedIsValid(_G[V[1]]) then
  533.                     PedDelete(_G[V[1]])
  534.                 end
  535.             end
  536.            
  537.             if ChapterGet() == 2 and not IsMissionCompleated("3_01C") then
  538.                 SoundUnLoadBank("MINIGAME\\TIMPANI_01.bnk")
  539.             end
  540.             SoundStopStream()
  541.            
  542.             if FIELD.KICK then
  543.                 PlayerSetControl(1)
  544.                
  545.                 EARNEST_SPEECH_STOP = false
  546.                 FIELD.KICK = false
  547.             end
  548.            
  549.             for _, V in ipairs(SETUP.ANIM) do
  550.                 if HasAnimGroupLoaded(V) then
  551.                     UnLoadAnimationGroup(V)
  552.                 end
  553.             end
  554.            
  555.             SETUP.NPC = nil
  556.             SETUP.ANIM = nil
  557.         end
  558.        
  559.         FIELD.SMOOTH_CLEANUP = false
  560.         SETUP.FLAG = false
  561.     end
  562.    
  563.     DATUnload(0)
  564.    
  565.     shared.gAreaDataLoaded = false
  566.     shared.gAreaDATFileLoaded[19] = false
  567.    
  568.     SETUP = nil
  569.     FIELD = nil
  570.    
  571.     collectgarbage()
  572. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement