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.
-- 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 tutorialNow, 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:
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 PedGetTargetPedThis 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).
-- 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 PedFindInAreaXYZThis 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, ...".
-- 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.