News: Welcome back to Bullworth! If you haven't already, you will need to reset your password..


Poll

how to add npc fighting style

_
1 (100%)
_
0 (0%)

Total Members Voted: 1

Author Topic: Question / how to add npc fighting style  (Read 2640 times)

0 Members and 1 Guest are viewing this topic.

Offline Ordinarypeople

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Question / how to add npc fighting style
« on: October 11, 2022, 09:30:29 AM »
Can you help me?, I just started modding 
« Last Edit: October 11, 2022, 09:32:49 AM by Ordinarypeople »

Offline Altamurenza

  • Full Member
  • ***
  • Posts: 118
  • Gender: Male
  • I love cheat, unique, realistic, & expansion mod.
    • View Profile
Re: Question / how to add npc fighting style
« Reply #1 on: October 12, 2022, 11:48:20 PM »
Welcome to the board, there are not much activities here tbh.

If you are new, you may want to learn how to compile Lua script first before jump to anything else. Make a simple new 'Text Document' and name the file as STimeCycle.lua, copy everything from the given example below and try to compile it with LuaC.
Code: [Select]
-- the double hyphen ('--') is a comment section used by developer to explain something without interfering the actual script.
main = function()
    -- (1) wait for the game loading.
    while not SystemIsReady() or AreaIsLoading() do
        Wait(0)
    end
   
    -- (2) load a light setup of animation groups, this is required because we involved in animation modding.
    local GROUP = {
        'Authority','Boxing','Russell','Nemesis','B_Striker','CV_Female','CV_Male','DO_Edgar','DO_Grap','DO_StrikeCombo',
        'DO_Striker','F_Adult','F_BULLY','F_Douts','F_Girls','F_Greas','F_Jocks','F_Nerds','F_OldPeds','F_Pref','F_Preps',
        'G_Grappler','G_Johnny','G_Striker','Grap','J_Damon','J_Grappler','J_Melee','J_Ranged','J_Striker','LE_Orderly','N_Ranged',
        'N_Striker','N_Striker_A','N_Striker_B','P_Grappler','P_Striker','PunchBag','Qped','Rat_Ped','Russell_Pbomb','Straf_Dout',
        'Straf_Fat','Straf_Female','Straf_Male','Straf_Nerd','Straf_Prep','Straf_Savage','Straf_Wrest','TE_Female','MINI_React',
    }
    for _, ANIM in ipairs(GROUP) do
        if not HasAnimGroupLoaded(ANIM) then
            LoadAnimationGroup(ANIM)
        end
    end
   
    -- (3) modders usually make their own setup in here, after the game has loaded and before the main loop running.
   
    -- loop.
    while true do
        Wait(0)
       
        -- (4) main loop, this will run forever till you quit the game or crash.
       
       
        -- print a text, so you know that your script is actually working.
        TextPrintString('It works!', 1, 1)
    end
end

Once you succeed and your brain has stimulated a little bit of dopamine, I would simply recommend you to read these following documentations if you had considerable amount of time to spend 'cause they are simply useful for your further career in our Bully modding scene. Just skip them already if you don't want to or don't have time to read. (comeback later)
- Lua 5.0 Reference Manual
- Doc's Bully LUA wiki (a bit outdated)
- Function's / Mission scripting tutorial

Now, we have skipped dozens of Lua introductions, the function you were looking for is PedSetActionTree. The function itself has three arguments which are Ped (number), Animation Node (string), and Animation File (string). PedSetActionTree(Ped, Animation Node, Animation File).

Example:
Code: [Select]
PedSetActionTree(gPlayer, '/Global/Nemesis', 'Act/Anim/Nemesis.act')

Ped in the most cases are referring to variable that has pedestrian number, gPlayer is a variable that refers to our playable character which is actually equal to 0 (fixed number). Unlike the player, NPC has randomly generated number by the game and they don't have variables like gPlayer by default. The Animation Node and Animation File are codes, they are quite specific, so you can literally copy those from any other source code.

Since NPC's variable is not defined in the first place, you can either define them by targeting with a function called PedGetTargetPed or define all of them with PedFindInAreaXYZ. Both functions have some sort of differences one to another, PedGetTargetPed will return a pedestrian number based on your lock-on target, instead PedFindInAreaXYZ will return every single pedestrian number in certain distances.

1) Using PedGetTargetPed

This function only has one argument which is Ped, as mentioned before, we technically don't even know any NPC's pedestrian number, so we used this function in the ancient days to get pedestrian number with player targeting mechanism. In other words, gPlayer is the only option to use if you want to get NPC's pedestrian number.

Remember the given example script above? Yes. Copy these following lines and paste it below "-- (4) main loop, ..." because the code needs to be executed continuously without a hitch. Any "hitch" will prevent us from achieving our purpose here. Anyway, we'll talk about hitch later (perhaps, in another topic).

Code: [Select]
-- get target pedestrian number.
local TARGET = PedGetTargetPed(gPlayer)

-- check if pedestrian number is a valid ped.
if PedIsValid(TARGET) then
    -- press Zoom Out to change NPC fighting style.
    if IsButtonBeingPressed(3, 0) then
        PedSetActionTree(TARGET, '/Global/Nemesis', 'Act/Anim/Nemesis.act')
    end
end

HOW TO CHANGE FIGHTING STYLE IN THE GAME:
Approach any NPC, lock-on them, and press Zoom Out to change their fighting style.

2) Using PedFindInAreaXYZ

This function has four arguments in total, they are X, Y, Z, and Distance. X, Y, and Z are simply coordinates that you probably had learn it in school and Distance is a certain range of area that you want to cover with. In most cases, modders were likely to ignore the XYZ part by filling the arguments with 0, 0, 0 because they knew that the most important part of this function is the Distance. They usually put 999999 values which means every pedestrian is covered by that wide range.

However, as I have explained the differences before, this function returns every single pedestrian number, so we have to put them on a table and use "for loop" in order to retrieve every single NPC's pedestrian number in there. In simple term, "for loop" will automatically do 'task' of the organized structures (ex: alphabetical order which is A - Z) without having to do the tasks one by one.

Same as the previous function, copy these following lines and paste it below "-- (4) main loop, ...".

Code: [Select]
-- get player coordinates
local X, Y, Z = PlayerGetPosXYZ()

-- for loop and PedFindInAreaXYZ in a table.
for INDEX, PED in ({PedFindInAreaXYZ(X, Y, Z, 999999)}) do
    if PedIsValid(PED) then
       
        -- press Zoom Out to change every pedestrian fighting style (including the player).
        if IsButtonBeingPressed(3, 0) then
            PedSetActionTree(PED, '/Global/Nemesis', 'Act/Anim/Nemesis.act')
        end
    end
end

HOW TO CHANGE FIGHTING STYLE IN THE GAME:
You just have to press Zoom Out to change fighting styles of every single spawned living creature.

Good luck with that.

Offline Ordinarypeople

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Question / how to add npc fighting style
« Reply #2 on: October 13, 2022, 12:15:57 AM »
Thank you for all your explanations, I will try what you convey.

Can you explain to me about this :

https://bully-board.com/index.php?topic=22279.msg380365#msg380365

This mod I've been looking for for a long time, I've tried to make it but the mod doesn't work, I've copied everything he wrote but it still doesn't work.

 

Offline Altamurenza

  • Full Member
  • ***
  • Posts: 118
  • Gender: Male
  • I love cheat, unique, realistic, & expansion mod.
    • View Profile
Re: Question / how to add npc fighting style
« Reply #3 on: October 13, 2022, 07:41:02 AM »
https://bully-board.com/index.php?topic=22279.msg380365#msg380365

The mod used an ancient method to get every NPC's pedestrian number, but I must admit that it was very creative way to retrieve pedestrian numbers by snowballing one NPC to another with interactions. Nowadays, we can simply use PedFindInAreaXYZ to get them all as I explained before.

Offline Ordinarypeople

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Question / how to add npc fighting style
« Reply #4 on: October 13, 2022, 04:37:44 PM »
Can you give me a lua example of this?

I'm very happy with this

and can you see my file here:

-- Main function:
function main()
    -- Waiting for the game's appearing:
    while not SystemIsReady() or AreaIsLoading() do
        Wait(0)
    end
    LoadAnim()
    while true do
        Wait(0)
        MyMod()
    end
end

local F_Peds = {}


LoopFunctions = function()
repeat
CheckForPeds()
Wait(80)
until not Alive
end


CheckForPeds = function()
local P_H_P_L = PedGetWhoHitMeLast(gPlayer)
local P_T_P = PedGetTargetPed(gPlayer)
if PedIsValid(P_T_P) and PedGetHealth(P_T_P) > 1 then
if OnlyOnePedInstance(P_T_P) then
RegisterPed(P_T_P)
end
elseif PedIsValid(P_H_P_L) and PedGetHealth(P_H_P_L) > 1 then
if OnlyOnePedInstance(P_H_P_L) then
RegisterPed(P_H_P_L)
end
end

for i = 1,table.getn(F_Peds) do
if PedIsValid(F_Peds) then
local F_H_P_L = PedGetWhoHitMeLast(F_Peds)
local F_T_P = PedGetTargetPed(F_Peds)

if PedIsValid(F_T_P) and PedGetHealth(F_T_P) > 1 then
if OnlyOnePedInstance(F_T_P) and F_T_P ~= gPlayer then
RegisterPed(F_T_P)
end
end

if PedIsValid(F_H_P_L) and PedGetHealth(F_H_P_L) > 1 then
if OnlyOnePedInstance(F_H_P_L) and F_H_P_L ~= gPlayer then
RegisterPed(F_H_P_L)
end
end

end
end

end


OnlyOnePedInstance = function(PedToCheck)
local Match = false

for i = 1,table.getn(F_Peds) do
 if PedToCheck == F_Peds then
  Match = true
 end
end

if Match then
return false
else
return true
end

end

RegisterPed = function(Ped)
table.insert(F_Peds,Ped)
end


CheckPeds = function()
for i = 1,table.getn(F_Peds) do
 if not PedIsValid(F_Peds) or PedIsDead(F_Peds) then
  table.remove(F_Peds,i)
 end
end
end

CyclePeds = function()
for i = 1,table.getn(F_Peds) do
  FactionAndNameBased(F_Peds)
end
end

FactionAndNameBased = function(FI_Ped)
local FI_Ped_F = PedGetFaction(FI_Ped)
local FI_Ped_N = PedGetName(FI_Ped)
local RDNM_1 = math.random(1100)
local RDNM_2 = math.random(1100)
local RDNM_3 = math.random(1100)
local RDNM_4 = math.random(1100)
local RDNM_5 = math.random(1200)
local RDNM_6 = math.random(1200)
local RDNM_7 = math.random(1300)
local RDNM_8 = math.random(1300)
local RDNM_9 = math.random(1400)
local RDNM_10 = math.random(1400)



if PedIsValid(FI_Ped) and PedGetHealth(FI_Ped) > 1 then
if PedIsInCombat(FI_Ped) then
if PedGetGrappleTargetPed(FI_Ped) < 0 then


-----------------
--Name based-----
-----------------

elseif RDNM_1 == RDNM_2 and FI_Ped_N == "N_Peanut" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/G_Johnny/Offense/Special/SpecialActions/Grapples/Dash", "Act/Anim/G_Johnny.act")

elseif RDNM_3 == RDNM_4 and FI_Ped_N == "N_Peanut" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/Nemesis/Offense/Medium/Strikes/HeavyAttacks/JackieKick", "Act/Anim/Nemesis.act")


elseif RDNM_5 == RDNM_6 and FI_Ped_N == "N_Peanut" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/Nemesis/Offense/Short/Strikes/LightAttacks/JAB/HeavyAttacks/SuperUppercut", "Act/Anim/Nemesis.act")


elseif RDNM_1 == RDNM_2 and FI_Ped_N == "N_Ricky" then
PedSetActionNode(FI_Ped, "/Global/G_Johnny/Offense/Special/SpecialActions/Grapples/Dash", "Act/Anim/G_Johnny.act")


elseif RDNM_3 == RDNM_4 and FI_Ped_N == "N_Ricky" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 2 then
PedSetActionNode(FI_Ped, "/Global/Nemesis/Offense/Medium/Strikes/HeavyAttacks/JackieKick", "Act/Anim/Nemesis.act")


elseif RDNM_5 == RDNM_6 and FI_Ped_N == "N_Ricky" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/Nemesis/Offense/Short/Strikes/LightAttacks/JAB/HeavyAttacks/SuperUppercut", "Act/Anim/Nemesis.act")


elseif RDNM_1 == RDNM_2 and FI_Ped_N == "N_Gary" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/Nemesis/Offense/Short/Strikes/HeavyAttacks/HeavyPunch1", "Act/Anim/Nemesis.act")


elseif RDNM_3 == RDNM_4 and FI_Ped_N == "N_Gary" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 2 then
PedSetActionNode(FI_Ped, "/Global/Nemesis/Offense/Medium/Strikes/HeavyAttacks/JackieKick", "Act/Anim/Nemesis.act")


elseif RDNM_5 == RDNM_6 and FI_Ped_N == "N_Gary" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/BOSS_Darby/Offense/Short/Grapples/HeavyAttacks/Catch_Throw", "Act/Anim/BOSS_Darby.act")


elseif RDNM_7 == RDNM_8 and FI_Ped_N == "N_Gary" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/Nemesis/Offense/Short/Strikes/LightAttacks/JAB/HeavyAttacks/SuperUppercut", "Act/Anim/Nemesis.act")


elseif RDNM_9 == RDNM_10 and FI_Ped_N == "N_Gary" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/Russell_102/Offense/Short/Medium/RisingAttacks", "Act/Anim/Russell_102.act")


elseif RDNM_1 == RDNM_2 and FI_Ped_N == "N_Russell" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/Russell_102/Offense/Short/Medium/RisingAttacks", "Act/Anim/Russell_102.act")


elseif RDNM_3 == RDNM_4 and FI_Ped_N == "N_Russell" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/BOSS_Russell/Offense/Special/Invincible/HeadButt/HeadButt_AnticStart/", "Act/Anim/BOSS_Russell.act")


elseif RDNM_5 == RDNM_6 and FI_Ped_N == "N_Russell" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/BOSS_Russell/Offense/Medium/Strikes/Unblockable/DoubleAxeHandle", "Act/Anim/BOSS_Russell.act")


elseif RDNM_7 == RDNM_8 and FI_Ped_N == "N_Russell" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/Nemesis/Offense/Short/Strikes/LightAttacks/JAB/HeavyAttacks/SuperUppercut", "Act/Anim/Nemesis.act")


elseif RDNM_1 == RDNM_2 and FI_Ped_N == "N_Troy" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/Russell_102/Offense/Short/Medium/RisingAttacks", "Act/Anim/Russell_102.act")


elseif RDNM_3 == RDNM_4 and FI_Ped_N == "N_Troy" and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/BOSS_Russell/Offense/Medium/Strikes/Unblockable/DoubleAxeHandle", "Act/Anim/BOSS_Russell.act")



-----------------
--Faction based--
-----------------



elseif RDNM_1 == RDNM_2 and FI_Ped_F == 2 then
PedSetActionNode(FI_Ped, "/Global/J_Damon/Offense/SpecialStart/StartRun", "Act/Anim/J_Damon.act")


elseif RDNM_1 == RDNM_2 and FI_Ped_F == 5 and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/BOSS_Darby/Offense/Short/Grapples/HeavyAttacks/Catch_Throw", "Act/Anim/BOSS_Darby.act")


elseif RDNM_3 == RDNM_4 and FI_Ped_F == 5 and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/Nemesis/Offense/Short/Strikes/LightAttacks/JAB/HeavyAttacks/SuperUppercut/Knee", "Act/Anim/Nemesis.act")


elseif RDNM_1 == RDNM_2 and FI_Ped_F == 3 and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/Nemesis/Offense/Short/Strikes/LightAttacks/JAB/HeavyAttacks/SuperUppercut", "Act/Anim/Nemesis.act")


elseif RDNM_3 == RDNM_4 and FI_Ped_F == 3 and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 2 then
PedSetActionNode(FI_Ped, "/Global/Nemesis/Offense/Medium/Strikes/HeavyAttacks/JackieKick", "Act/Anim/Nemesis.act")


elseif RDNM_5 == RDNM_6 and FI_Ped_F == 3 and DistanceBetweenPeds2D(PedGetTargetPed(FI_Ped), FI_Ped) <= 1.5 then
PedSetActionNode(FI_Ped, "/Global/Nemesis/Offense/Short/Strikes/HeavyAttacks/HeavyPunch1", "Act/Anim/Nemesis.act")


elseif RDNM_1 == RDNM_2 and FI_Ped_F == 1 and PedGetWeapon(FI_Ped) == 305 then
PedSetActionNode(FI_Ped, "/Global/N_Earnest/Offense/FireSpudGun", "Act/Anim/N_Earnest.act")


elseif RDNM_3 == RDNM_4 and FI_Ped_F == 1 and PedGetWeapon(FI_Ped) == 307 then
PedSetActionNode(FI_Ped, "/Global/N_Earnest/Offense/ThrowBombs", "Act/Anim/N_Earnest.act")


elseif RDNM_5 == RDNM_6 and FI_Ped_F == 1 and PedGetWeapon(FI_Ped) == 301 then
PedSetActionNode(FI_Ped, "/Global/N_Earnest/Offense/ThrowBombs", "Act/Anim/N_Earnest.act")


end
end
end

end


main = function()
 
  LoadAnimationGroup("Authority")
  LoadAnimationGroup("Boxing")
  LoadAnimationGroup("Earnest")
  LoadAnimationGroup("B_Striker")
  LoadAnimationGroup("CV_Female")
  LoadAnimationGroup("CV_Male")
  LoadAnimationGroup("DO_Edgar")
  LoadAnimationGroup("DO_Grap")
  LoadAnimationGroup("DO_StrikeCombo")
  LoadAnimationGroup("DO_Striker")
  LoadAnimationGroup("F_Adult")
  LoadAnimationGroup("F_BULLY")
  LoadAnimationGroup("F_Crazy")
  LoadAnimationGroup("F_Douts")
  LoadAnimationGroup("F_Girls")
  LoadAnimationGroup("F_Greas")
  LoadAnimationGroup("F_Jocks")
  LoadAnimationGroup("F_Nerds")
  LoadAnimationGroup("F_OldPeds")
  LoadAnimationGroup("F_Pref")
  LoadAnimationGroup("F_Preps")
  LoadAnimationGroup("G_Grappler")
  LoadAnimationGroup("G_Johnny")
  LoadAnimationGroup("G_Striker")
  LoadAnimationGroup("J_Damon")
  LoadAnimationGroup("J_Grappler")
  LoadAnimationGroup("J_Melee")
  LoadAnimationGroup("J_Ranged")
  LoadAnimationGroup("J_Striker")
  LoadAnimationGroup("Nemesis")
  LoadAnimationGroup("N_Ranged")
  LoadAnimationGroup("N_Striker")
  LoadAnimationGroup("N_Striker_A")
  LoadAnimationGroup("N_Striker_B")
  LoadAnimationGroup("P_Grappler")
  LoadAnimationGroup("P_Striker")
  LoadAnimationGroup("Russell")
  LoadAnimationGroup("Russell_Pbomb")
  LoadAnimationGroup("Straf_Dout")
  LoadAnimationGroup("Straf_Fat")
  LoadAnimationGroup("Straf_Female")
  LoadAnimationGroup("Straf_Male")
  LoadAnimationGroup("Straf_Nerd")
  LoadAnimationGroup("Straf_Prep")
  LoadAnimationGroup("Straf_Savage")
  LoadAnimationGroup("Straf_Wrest")
  LoadAnimationGroup("TE_Female")
 
  CreateThread("LoopFunctions")
  --DisablePunishmentSystem(true)
  repeat
  CheckPeds()
  CyclePeds()
    Wait(10)
  until not Alive
end
 
F_AttendedClass = function()
  if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
    return
  end
  SetSkippedClass(false)
  PlayerSetPunishmentPoints(0)
end
 
F_MissedClass = function()
  if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
    return
  end
  SetSkippedClass(true)
  StatAddToInt(166)
end
 
F_AttendedCurfew = function()
  if not PedInConversation(gPlayer) and not MissionActive() then
    TextPrintString("You got home in time for curfew", 4)
  end
end
 
F_MissedCurfew = function()
  if not PedInConversation(gPlayer) and not MissionActive() then
    TextPrint("TM_TIRED5", 4, 2)
  end
end
 
F_StartClass = function()
  if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
    return
  end
  F_RingSchoolBell()
  local l_6_0 = PlayerGetPunishmentPoints() + GetSkippingPunishment()
end
 
F_EndClass = function()
  if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
    return
  end
  F_RingSchoolBell()
end
 
F_StartMorning = function()
  F_UpdateTimeCycle()
end
 
F_EndMorning = function()
  F_UpdateTimeCycle()
end
 
F_StartLunch = function()
  if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
    F_UpdateTimeCycle()
    return
  end
  F_UpdateTimeCycle()
end
 
F_EndLunch = function()
  F_UpdateTimeCycle()
end
 
F_StartAfternoon = function()
  F_UpdateTimeCycle()
end
 
F_EndAfternoon = function()
  F_UpdateTimeCycle()
end
 
F_StartEvening = function()
  F_UpdateTimeCycle()
end
 
F_EndEvening = function()
  F_UpdateTimeCycle()
end
 
F_StartCurfew_SlightlyTired = function()
  F_UpdateTimeCycle()
end
 
F_StartCurfew_Tired = function()
  F_UpdateTimeCycle()
end
 
F_StartCurfew_MoreTired = function()
  F_UpdateTimeCycle()
end
 
F_StartCurfew_TooTired = function()
  F_UpdateTimeCycle()
end
 
F_EndCurfew_TooTired = function()
  F_UpdateTimeCycle()
end
 
F_EndTired = function()
  F_UpdateTimeCycle()
end
 
F_Nothing = function()
end
 
F_ClassWarning = function()
  if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
    return
  end
  local l_23_0 = math.random(1, 2)
end
 
F_UpdateTimeCycle = function()
  if not IsMissionCompleated("1_B") then
    local l_24_0 = GetCurrentDay(false)
    if l_24_0 < 0 or l_24_0 > 2 then
      SetCurrentDay(0)
    end
  end
  F_UpdateCurfew()
end
 
F_UpdateCurfew = function()
  local l_25_0 = shared.gCurfewRules
  if not l_25_0 then
    l_25_0 = F_CurfewDefaultRules
  end
  l_25_0()
end
 
F_CurfewDefaultRules = function()
  local l_26_0 = ClockGet()
  if l_26_0 >= 23 or l_26_0 < 7 then
    shared.gCurfew = true
  else
    shared.gCurfew = false
  end
end

that's all i have made but it doesn't work.
Can you see where it went wrong?
« Last Edit: October 13, 2022, 05:50:00 PM by Ordinarypeople »

Offline Altamurenza

  • Full Member
  • ***
  • Posts: 118
  • Gender: Male
  • I love cheat, unique, realistic, & expansion mod.
    • View Profile
Re: Question / how to add npc fighting style
« Reply #5 on: October 14, 2022, 03:19:36 AM »
First of all, I'm sorry, but your question was quite ambiguous to me.
There are three things came on top of my mind when I first saw your question:
1. You want to add another NPC's fighting style for NPC.
2. You want to add NPC's fighting style for Player.
3. You want to change Player and NPCs fighting style.

I looked at your latest reply and felt like none of them are seem to match your purpose here :hmm:.
From what I see, you're looking to add specific fighting animations to certain NPCs.

Anyway, I will not look over the mistakes of your script that you're just took it from Reath, because it takes time more for me to explain snowballing method than to answer your question. Besides, what I want to explain on this reply will have a strong correlation to my previous reply about PedGetTargetPed and PedFindInAreaXYZ.

To be simple, if you add these following lines to my previous example script (under "-- (4) main loop, ..."), it will do the same results as Reath's script.
Code: [Select]
-- get player coordinates.
local X, Y, Z = PlayerGetPosXYZ()

-- for loop and PedFindInAreaXYZ in a table.
for INDEX, PED in ({PedFindInAreaXYZ(X, Y, Z, 999999)}) do
    -- check the existence of pedestrian and exclude player from the list.
    if PedIsValid(PED) and PED ~= gPlayer then
       
        -- check if pedestrian is in combat and stands still.
        if PedIsInCombat(PED) and PedMePlaying(PED, 'DEFAULT_KEY') then
           
            -- check if pedestrian is Peanut and his target is pretty close to him.
            if PedGetName(PED) == 'N_Peanut' and DistanceBetweenPeds2D(PED, PedGetTargetPed(PED)) <= 1.5 then
                -- add Throat Grab for Peanut with 5% chance.
                if math.random(1, 100) <= 5 then
                    PedSetActionNode(PED, '/Global/G_Johnny/Offense/Special/SpecialActions/Grapples/Dash', 'Act/Anim/G_Johnny.act')
                end
                -- add Jackie Kick for Peanut with 10% chance.
                if math.random(1, 100) <= 10 then
                    PedSetActionNode(PED, '/Global/Nemesis/Offense/Medium/Strikes/HeavyAttacks/JackieKick', 'Act/Anim/Nemesis.act')
                end
                -- add Super Uppercut for Peanut with 3% chance.
                if math.random(1, 100) <= 3 then
                    PedSetActionNode(PED, '/Global/Nemesis/Offense/Short/Strikes/LightAttacks/JAB/HeavyAttacks/SuperUppercut', 'Act/Anim/Nemesis.act')
                end
            end
           
            -- if you want to add some more NPCs other than Peanut, it depends on your will to learn
            -- otherwise, it won't help :(
        end
    end
end

I tested the script myself and it worked. If it did not work for you, you probably made a mistake in compiling the script or the placement (remember to paste those lines under "-- (4) main loop, ..."). I only added some specific fighting animations to Peanut, but you can try to add another fighting animations to another NPCs.

Also, I'm sorry for making you put some efforts to do this. I don't believe in instant way, it won't last, the process will shape you out.

Stay curious, keep trying, and good luck.

Offline Ordinarypeople

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Question / how to add npc fighting style
« Reply #6 on: October 14, 2022, 04:28:40 AM »

apakah akan berhasil seperti ini?



utama = fungsi()
    - tunggu pemuatan game.
    sementara tidak SystemIsReady() atau AreaIsLoading() lakukan
        Tunggu(0)
    akhir
    MuatAnim()
    sementara lakukan
        Tunggu(0)
    akhir
akhir
GRUP lokal = {
    'Otoritas','Tinju','Russell','Nemesis','B_Striker' ,'CV_Female','CV_Male','DO_Edgar','DO_Grap','DO_StrikeCombo',
    'DO_Striker','F_Adult','F_BULLY','F_Douts','F_Girls','F_Greas','F_Jocks',' F_Nerds','F_OldPeds','F_Pref','F_Preps',
    'G_Grappler','
    'N_Striker','N_Striker_A','N_Striker_B','P_Grappler','P_Striker','PunchBag','Qped','Rat_Ped','Russell_Pbomb','Straf_Dout',
    'Straf_Fat','Straf_Female' ','Straf_Nerd','Straf_Prep','Straf_Savage','Straf_Wrest','TE_Female','MINI_React',
    }
    untuk _, ANIM di ipairs(GROUP)
        jika tidak HasAnimGroupLoaded (ANIM) maka
            LoadAnimationGroup
        akhir (
    ANIM )
    -- lingkaran.
    sementara benar lakukan
        Tunggu(0)
    akhir
   
lokal X, Y, Z = PlayerGetPosXYZ()
untuk INDEX, PED di ({PedFindInAreaXYZ(X, Y,

        jika PedIsInCombat(PED) dan PedMePlaying(PED, 'DEFAULT_KEY') maka
            jika PedGetName(PED) == 'N_Peanut' dan DistanceBetweenPeds2D(PED, PedGetTargetPed(PED)) <= 1,5 maka
                jika math.random(1, 100) <= 5 maka
                    PedSetActionNode(PED, '/Global/G_Johnny/Offense/Special/SpecialActions/Grapples/Dash', 'Act/Anim/G_Johnny.act')
                akhir
                jika math.random(1, 100) <= 10 maka
                    PedSetActionNode (PED, '/Global/Nemesis/Offense/Medium/Strikes/HeavyAttacks/JackieKick', 'Act/Anim/Nemesis.act')
                akhir
                jika math.random(1, 100) <= 3 maka
                    PedSetActionNode(PED, '/Global/Nemesis/Offense/Short/Strikes/LightAttacks/JAB/HeavyAttacks/SuperUppercut', 'Act/Anim/Nemesis.act')
                akhir
            akhir
          TextPrintString('Berhasil!', 1, 1)
           
        akhir
    akhir
 akhir

Offline Altamurenza

  • Full Member
  • ***
  • Posts: 118
  • Gender: Male
  • I love cheat, unique, realistic, & expansion mod.
    • View Profile
Re: Question / how to add npc fighting style
« Reply #7 on: October 14, 2022, 06:56:41 AM »
You cannot just translate them and put them on your script, that is not how it works. It will be BEST if you make a simple mod to begin with because I can clearly see that you just tried it blindly. I think, this topic is over, the answer is in front of your face and the rest is up to you. I hope you read some Lua documentations and manage to solve it.