Bully-Board
Bully Modding Section => Modding Questions/Help => Topic started by: Micha on April 13, 2021, 04:35:03 PM
-
So I've been trying to dip my toes into script modding but have been failing miserably. Basically what I've been trying to do is create a script through STimeCycle.lua file to create damage multipliers for certain characters and especially bosses, but once I compile the file and add it to scripts.img nothing happens once I load the game. I wanted to try this out after going through the script of one of Daboss' modds and she was even nice enough to give some tips but I still haven't been able to figure this out yet because honestly in some ways I feel like I don't have a clue about what I'm doing. If someone could help me out it would be really appreciated, I'll add the script of what I was trying to do, just don't judge me too hard please ;)
-
Well... beginning to script modding is not very easy at first. But once you get the hang of it, things will come.
I am no expert and I have no idea how to do that via scripting... sorry
However, there is another way to do that: pedstats.dat
It's much easier to edit this file on excel and I strongly advise it. Column AG has the description of "Damage_Scale"
-
Nothing happens because the script isn't running in the first place.
All of those functions need to be called.
They are new so the game doesn't use them.
By default, STimeCycle isn't even a script that works on its own.
It's just a collection of functions to be used by the game by other scripts.
A script of its own works by having a Main function where you can start doing stuff.
(There's also MissionSetup. It'll be the first-ever function to be read if present, otherwise the game skips to Main)
Unlike editing .dat files, you can't really trial and error in Lua, you have to know what you're doing.
So learn some basic Lua (https://www.youtube.com/playlist?list=PLyQg3m0a5UitP1lHptwWc_4N2ZkRQBfrZ), first, then you can check Derpy's old tutorials (https://www.youtube.com/playlist?list=PLJIBGPRKpwTtwKG0a-vG2Yuq1aPA-jCjN), too.
From what I can tell, the script doesn't really do much to begin with.
It gets the name of some peds and then gives a random number for each, but never actually multiplies their damage.
-
Yeah, makes sense. I already had the gut feeling that I needed to start from scratch when I noticed that it wasn't having any effect and in reality, I really had no idea about what I was trying to do. Thanks for the advice, I'll make sure to take some more time to try and get it done the right way. What is the best command for damage multiplication btw? is it PedSetDamageGivenMultiplier or is there a better way?
-
Well... beginning to script modding is not very easy at first. But once you get the hang of it, things will come.
I am no expert and I have no idea how to do that via scripting... sorry
However, there is another way to do that: pedstats.dat
It's much easier to edit this file on excel and I strongly advise it. Column AG has the description of "Damage_Scale"
Yeah, when you try to do it it's even harder than it seems. I've also been there and tried the "Damage_Scale" column but it only seems to work with weapon damage, so you can make Boss Norton for example nuke you with his sledgehammer, but normal attack damage seems to be unaffected.
-
What is the best command for damage multiplication btw? is it PedSetDamageGivenMultiplier or is there a better way?
Yeah, PedSetDamageGivenMultiplier(ped, damagetype, multiplier) does the job.
IIRC I helped someone else with this, check my post history.
-
Hi Simon, I've been looking at tutorials that focus on the STimeCycle and they help a lot and I can see now that I need to apply a proper main function for it to work. I'm just not completely sure about the right structure, could you maybe point me in the right direction. I'll include a file with how I've been trying to approach this differently. There are a lot of good lua tutorials but I have not found as many that focus on the STimeCycle file,
-
I've actually watched Derpy's second tutorial again and it cleared a lot of things up with the functions, I'm just trying to ensure that I can structure the creation of a new function for the multiplier within the main thread properly for the STimeCycle file.
-
What is wrong with the first main:
- Not sure why you wait 1 second after you've already waited for the game to be ready.
- LoadAnims() is a function that doesn't exist. The game will get stuck there and the script won't continue.
- CreateThread() is used in the wrong way:
CreateThread("ThreadName") --Correct
CreateThread(ThreadName) --Incorrect
- You have a continuous loop that always waits 1 second and does absolutely nothing, other than getting the game stuck.
What is wrong with the second main:
- LoadAnim() is a function that doesn't exist.
- DamageMultiplier would be better outside of that loop and as a thread of its own, to avoid getting the game stuck.
What is wrong with DamageMultiplier:
- PedFoundInAreaXYZ() is a function that doesn't exist.
- "-=" gives issues with the compiler because it's not a thing. You might be confusing it with "~=" which is "equals not"
- PedisModel should be PedIsModel. Code is case-sensitive.
- I think you meant math.random(1, 25), not math.random(1.25)
- Some issues with PedSetActionTree():
- You have a typo. "/Global/" not ",Global/".
- "Act/Anim/" is redundant, you can remove that, and just leave the name.
- The name of the action tree must always end with ".act"
-
Thank you for your advice, it's very helpful. What if I then structure the script like this?
Never mind, still didn't work. I'll try again
-
I've made it again, the main thing I'm not certain about is how the main function should be structured in STimeCycle compared to if it's made for a mission. I'm also not a hundred percent sure if I'm structuring the damage multiplier function correctly.
-
You still kept the 1-second constant loop at the end of Main.
As I said, you're getting the script stuck (for when you script something below it), as it will just keep waiting forever.
Other than that, structure-wise the script is fine, though scripting-wise DamageMultiplication is broken, and nothing will happen.
Here's a quick script I'd do for what you're trying to do:
(Keep in mind I'm not good with this kind of loop. An issue here is that, for example, whatever you script, like the damage multiplier, will CONSTANTLY be applied. In this case it's harmless, but if you do something else, like say, spawning something, well... it's going to keep spawning forever until the game crashes)
while true do --Anything inside here gets looped forever
FindX, FindY, FindZ = PlayerGetPosXYZ() --Constantly gets Jimmy's coordinates, and gives each coordinate a name, to use as you please.
TextPrintString("Finding peds matching specified conditions...", 1, 1) --Constantly prints this when not printing anything below, aka before it finds a ped. Printing text is the easiest way to see your script working in real time.
for i, Ped in ({PedFindInAreaXYZ(FindX, FindY, FindZ, 80)}) do --Starts a loop of constantly finding peds in a specific range (80) and stores them in a table.
if i ~= gPlayer and not PedIsDead(Ped) then --Some conditions
if PedGetFaction(Ped) == 5 then --Preppies faction condition
TextPrintString("Found a prep!", 1, 1)
--Script something here idk
elseif PedGetFaction(Ped) == 1 then --Nerds faction condition
TextPrintString("Found a Nerd!", 1, 1)
--Script something here idk
end
end
end
Wait(0)
end
-
Okay, thanks, I'll keep messing around with it and see if I can make stuff work. At the very least I've become more mindful of the mistakes I make. I will probably need to keep trying this out a lot more though to get the hang of it. This has been very helpful though so thank you Simon.
-
I tried your method but the game crashed once I pressed start on the game menu, at least I know that the script is being read this way because previously nothing happened. But I must have messed something up.
My apologies btw if I keep posting stuff, I just wanted to see if I could figure this out. But maybe I also need to try to understand it a bit better before I do so.
-
So I added wait(1000) after "While true do" and it ended up working. Though the only obvious change at first was that the text "Finding peds matching specified conditions..." and "Found a prep!" showed up after being near a prep. But it only worked for preps, while I also added the command for jocks and greasers. I wasn't able to determine whether the multiplier worked.
But I'm so happy that you could visually see that something worked and was affected by the script.
Thank you so much Simon, you've helped me a whole lot.
-
It crashed before you added the "Wait(1000)" because you accidentally swapped the position of the "wait(0)" with "end".
The structure of a while true do is:
While true do
--Your code here
Wait(0)
end
Not:
While true do
end
Wait(0)
Fix this and you can get rid of that "Wait(1000)".
I've noticed you forgot to change the faction ID for the Jocks and Greasers and left 1, which is for nerds.
This means the game will never be able to find Damon and Norton because they're not part of the Nerd clique.
Derpy's Lua Reference site (https://derpy54320.github.io/Bully-LUA-Reference/index.html) has lists of all kinds of stuff you might need.
Also, again, remember that (most) code is case-sensitive.
You typed "ped" in PedGetName(), when I programmed the for loop to work with "Ped".
-
You were a hundred percent right, it works this way. The only thing I'm not sure about is the actual damage multiplier as I did not notice any significant difference in the damage Jimmy took and I can't see how much damage is being done exactly.
-
It doesn't work because:
- You changed PedSetDamageGivenMultiplier() to PedGetDamageGivenMultiplier().
PedGetDamageGivenMultiplier() returns the value of the ped's current damage multiplier value. Don't think you need that. - The game is trying to find "ped" and not "Ped". Code is case-sensitive.
-
I tried this with two different methods but the multiplier didn't seem to have an effect on either of them.
-
Because in both files you still have both "ped" and "Ped" in different places.
Looks like you hate that P, huh? lol
It's either "Ped" or "ped". You can't mix them.
Paste this commented line on top of your scripts so you don't forget:
--"Dear me: Remember code is case-sensitive."
(Commented lines are ignored by the compiler, so you can have notes in your scripts and stuff)
-
Yeah, I'm aware. I have ADHD so my attention span is not exactly good, I easily overlook this stuff if I don't specifically pay attention to it because else I assume I wrote it differently. It's an absolute pain in the arse :blank: .
Anyways, I was also able to make the multiplier work for individual characters using Derpy's difficulty mod to apply this stuff. Unlike at the beginning, where I had no idea about what I was doing, this time I was able to identify which functions and parts of the main function were important to make the multiplier work because of what you already have shown to me.
I'll try to use your method again while paying more specific attention to case sensitivity. I know I can be difficult to deal with, but still thanks for showing me all this stuff.
-
Would this be the right approach to how you introduced the script or am I still getting it wrong?
-
PedIsDead() checks for Ped instead of ped, so the script will get stuck there.
-
Now it finally worked, thank you for everything. You've helped a ton.