RanggaBS

Social Talk

Jun 14th, 2022 (edited)
913
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.85 KB | None | 0 0
  1. if type(F_InitGarages) ~= "function" then
  2.     F_InitGarages = function()
  3.         DATLoad("Garages.DAT", 1)
  4.         GarageClearAll()
  5.         GarageAdd(TRIGGER._Garage_SchoolGrounds, POINTLIST._Garage_SchoolGrounds)
  6.         GarageAdd(TRIGGER._Garage_RichArea, POINTLIST._Garage_RichArea)
  7.         GarageAdd(TRIGGER._Garage_BusinessArea, POINTLIST._Garage_BusinessArea)
  8.         GarageAdd(TRIGGER._Garage_PoorArea, POINTLIST._Garage_PoorArea)
  9.     end
  10. end
  11.  
  12. shared.userDeviceIsPC = type(_G["ClassMusicSetPlayers"]) == "function"
  13.  
  14. if type(shared.mods) ~= "table" then
  15.     shared.mods = {}
  16. end
  17.  
  18. _G.T_SocialTalk = function()
  19.     while not SystemIsReady() do
  20.         Wait(0)
  21.     end
  22.     shared.mods.SocialTalk = {}
  23.  
  24.     -- Localization:
  25.     local rand = _G.math.random
  26.     local len = _G.table.getn
  27.  
  28.     local psan
  29.     psan = function(animPath, actFile)
  30.         PedSetAITree(gPlayer, "/Global/AI", "Act/AI/AI.act")
  31.         PedSetActionNode(gPlayer, animPath, actFile)
  32.         PedSetAITree(gPlayer, "/Global/PlayerAI", "Act/PlayerAI.act")
  33.     end
  34.     local spase = _G.SoundPlayAmbientSpeechEvent
  35.  
  36.     -- Load animations:
  37.     shared.mods.SocialTalk.AnimationGroup = {"Ambient", "Ambient2", "Ambient3", "SFAT_F", "SNERD_F", "SGEN_F", "SGIRL_F", "SBULL_F", "NPC_Chat_1", "NPC_Chat_2", "NPC_Chat_F"}
  38.     for _, v in ipairs(shared.mods.SocialTalk.AnimationGroup) do
  39.         LoadAnimationGroup(v)
  40.     end
  41.    
  42.     -- Setup:
  43.     shared.mods.SocialTalk.Animations = {
  44.         s = 1,
  45.         {"/Global/Ambient/Talking/Talking/FAT/SpeechAnims/Anims", "Act/Anim/Ambient.act"},
  46.         {"/Global/Ambient/Talking/Talking/NerdMale/SpeechAnims/Anims", "Act/Anim/Ambient.act"},
  47.         {"/Global/Ambient/Talking/Talking/Male/SpeechAnims/Anims", "Act/Anim/Ambient.act"},
  48.         --{"/Global/Ambient/Talking/Talking/Male2/AGR1/Anims", "Act/Anim/Ambient.act"},             -- Doesn't work to Player, only NPC.
  49.         {"/Global/Ambient/Talking/Talking/Male2/AGR2/Anims", "Act/Anim/Ambient.act"},
  50.         {"/Global/Ambient/Talking/Talking/GEN/SpeechAnims/Anims", "Act/Anim/Ambient.act"},
  51.         {"/Global/Ambient/Talking/Talking", "Act/Anim/Ambient.act"},
  52.        
  53.         {"/Global/Ambient/Talking/Talking/Female/SpeechAnims/Anims", "Act/Anim/Ambient.act"},
  54.         {"/Global/Ambient/Talking/Talking/Female2/AGRF/Anims", "Act/Anim/Ambient.act"},
  55.     }
  56.     local anims = shared.mods.SocialTalk.Animations
  57.     shared.mods.SocialTalk.Speech = {
  58.         npc = {
  59.             s = 1,
  60.             "CONVERSATION_CONTINUATION",
  61.             "CONVERSATION_GOSSIP",
  62.             "CONVERSATION_GOSSIP_CHAPTER_1",
  63.             "CONVERSATION_GOSSIP_CHAPTER_2",
  64.             "CONVERSATION_GOSSIP_CHAPTER_3",
  65.             "CONVERSATION_GOSSIP_CHAPTER_4",
  66.             "CONVERSATION_GOSSIP_CHAPTER_5",
  67.             "CONVERSATION_GOSSIP_CHAPTER_6",
  68.             "CONVERSATION_GOSSIP_PRIVATE",
  69.             "CONVERSATION_GOSSIP_REPLY",
  70.             "CONVERSATION_NEGATIVE_PERSONAL",
  71.             "CONVERSATION_NEGATIVE_REPLY",
  72.             "CONVERSATION_NEGATIVE_STATEMENT",
  73.             "CONVERSATION_PARTING",
  74.             "CONVERSATION_POSITIVE_PERSONAL",
  75.             "CONVERSATION_POSITIVE_REPLY",
  76.             "CONVERSATION_QUESTION",
  77.             "CONVERSATION_QUESTION_REPLY",
  78.             "CONVERSATION_QUESTION_RESPONSE",
  79.             "CONVERSATION_START",
  80.             "CONVERSATION_END",
  81.         },
  82.         player = {
  83.             s = 1,
  84.             "PLAYER_AFFIRMATIVE",
  85.             "PLAYER_APOLOGY_AUTHORITY_GOOD",
  86.             "PLAYER_APOLOGY_SMOOTH",
  87.             "PLAYER_EXCUSE",
  88.             "PLAYER_IDLE",
  89.             "PLAYER_IDLE_CLASS",
  90.             "PLAYER_IDLE_RAIN",
  91.             "PLAYER_IDLE_SHIVER",
  92.             "PLAYER_IDLE_TIRED",
  93.             "PLAYER_IDLE_WINTER",
  94.             "PLAYER_OFFICE",
  95.  
  96.             "PLAYER_APOLOGY_GIRL",
  97.             "PLAYER_FLIRT_GOOD",
  98.             "PLAYER_FLIRT_POOR"
  99.         }
  100.     }
  101.     local speech = shared.mods.SocialTalk.Speech
  102.  
  103.     local girlsFaction = {
  104.         [1] = true,
  105.         [2] = true,
  106.         [3] = true,
  107.         [4] = true,
  108.         [5] = true,
  109.         [6] = true
  110.     }
  111.  
  112.     local target
  113.  
  114.     while true do
  115.         Wait(0)
  116.         --[[if not PedIsModel(gPlayer, 0) and not PedIsDoingTask(gPlayer, "/Global/PlayerAI", true) then
  117.             PedSetAITree(gPlayer, "/Global/PlayerAI", "Act/PlayerAI.act")
  118.         end]]
  119.         target = PedGetTargetPed(gPlayer)
  120.         -- Change model:
  121.         --[[if shared.userDeviceIsPC then
  122.             if IsButtonPressed(8, 0) and IsButtonBeingPressed(11, 0) then
  123.                 PlayerSwapModel(rand(2) == 1 and "player" or (rand(2) == 1 and "PRGirl_Pinky" or "GN_Littleblkboy"))
  124.                 --PedSetActionTree(gPlayer, "/Global/Player", "Act/Player.act")
  125.                 --PedSetAITree(gPlayer, "/Global/PlayerAI", "Act/PlayerAI.act")
  126.             end
  127.         else
  128.             if IsButtonHeld(8, 0) and IsButtonBeingPressed(6, 0) then
  129.                 PlayerSwapModel(rand(2) == 1 and "player" or (rand(2) == 1 and "PRGirl_Pinky" or "GN_Littleblkboy"))
  130.                 --PedSetActionTree(gPlayer, "/Global/Player", "Act/Player.act")
  131.                 --PedSetAITree(gPlayer, "/Global/PlayerAI", "Act/PlayerAI.act")
  132.             end
  133.         end]]
  134.         if (PedMePlaying(gPlayer, "Default_KEY") or PedMePlaying(gPlayer, "Talking")) and PedIsValid(target) and not PedIsInCombat(target) and PedIsSocializing(target) and (PedMePlaying(target, "Default_KEY") or PedMePlaying(target, "Talking") or SoundSpeechPlaying(target, "SUCKING_UP")) and PedGetTargetPed(target) == gPlayer and IsButtonBeingPressed(7, 0) then
  135.             Wait(1)
  136.             PedSetWantsToSocializeWithPed(target, gPlayer)
  137.             if PedIsModel(gPlayer, 0) then
  138.                 if SoundSpeechPlaying(gPlayer, "PLAYER_GREET_GENERIC") or rand(3) < 3 then
  139.                     SoundStopCurrentSpeechEvent(gPlayer)
  140.                 end
  141.                 if PedIsFemale(target) then
  142.                     if girlsFaction[PedGetFaction(target)] then
  143.                         anims.s = rand(len(anims)-2)
  144.                         psan(anims[anims.s][1], anims[anims.s][2])
  145.                         speech.player.s = rand(len(speech.player))
  146.                         spase(gPlayer, speech.player[speech.player.s])
  147.                     else
  148.                         anims.s = rand(len(anims)-2)
  149.                         psan(anims[anims.s][1], anims[anims.s][2])
  150.                         speech.player.s = rand(len(speech.player)-3)
  151.                         spase(gPlayer, speech.player[speech.player.s])
  152.                     end
  153.                 else
  154.                     anims.s = rand(len(anims)-2)
  155.                     psan(anims[anims.s][1], anims[anims.s][2])
  156.                     speech.player.s = rand(len(speech.player)-3)
  157.                     spase(gPlayer, speech.player[speech.player.s])
  158.                 end
  159.             else
  160.                 if PedIsFemale(gPlayer) then
  161.                     anims.s = rand(len(anims)-2, len(anims))
  162.                     psan(anims[anims.s][1], anims[anims.s][2])
  163.                     speech.npc.s = rand(len(speech.npc)-1)
  164.                     spase(gPlayer, speech.npc[speech.npc.s])
  165.                 else
  166.                     anims.s = rand(len(anims)-2)
  167.                     psan(anims[anims.s][1], anims[anims.s][2])
  168.                     speech.npc.s = rand(len(speech.npc)-1)
  169.                     spase(gPlayer, speech.npc[speech.npc.s])
  170.                 end
  171.             end
  172.             Wait(rand(2) == 1 and rand(0, 200) or rand(500, 1500))
  173.             anims.s = PedIsFemale(target) and rand(len(anims)-2, len(anims)) or rand(len(anims)-2)
  174.             --PedSetTaskNode(target, "/Global/AI/Reactions/Stimuli/Response/RespondGreet/GreetSocial", "Act/AI/AI.act")
  175.             PedSocialKeepAlive(target)
  176.             PedFaceObject(target, gPlayer, 2)
  177.             PedSetActionNode(target, anims[anims.s][1], anims[anims.s][2])
  178.             speech.npc.s = rand(len(speech.npc)-1)
  179.             spase(target, speech.npc[speech.npc.s])
  180.             if rand(6) == 1 then
  181.                 spase(target, speech.npc[len(speech.npc)])
  182.                 PedStopSocializing(target)
  183.                 PedSetTaskNode(target, "/Global/AI", "Act/AI/AI.act")
  184.                 PedWander(target)
  185.             end
  186.         end
  187.     end
  188. end
  189.  
  190. shared.mods.TALKING.mainThread = CreateThread("T_SocialTalk")
Add Comment
Please, Sign In to add comment