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


Author Topic: Damage multiplier script  (Read 6684 times)

0 Members and 3 Guests are viewing this topic.

Offline Micha

  • Intelectual Wannabe
  • Jr. Member
  • **
  • Posts: 65
  • Gender: Male
    • View Profile
Damage multiplier script
« 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 ;)
« Last Edit: April 13, 2021, 04:56:36 PM by Micha »

Offline Razc01na

  • Lord Slayer
  • Full Member
  • ***
  • Posts: 156
  • Gender: Male
  • Doom is life
    • View Profile
Re: Damage multiplier script
« Reply #1 on: April 13, 2021, 06:44:02 PM »
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"

Offline SimonBestia

  • Full Member
  • ***
  • Posts: 294
  • Gender: Male
  • Bully-Board's Best Weeb
    • View Profile
    • Youtube Channel
Re: Damage multiplier script
« Reply #2 on: April 14, 2021, 02:57:10 AM »
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, first, then you can check Derpy's old tutorials, 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.

Offline Micha

  • Intelectual Wannabe
  • Jr. Member
  • **
  • Posts: 65
  • Gender: Male
    • View Profile
Re: Damage multiplier script
« Reply #3 on: April 14, 2021, 03:35:05 AM »
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?

Offline Micha

  • Intelectual Wannabe
  • Jr. Member
  • **
  • Posts: 65
  • Gender: Male
    • View Profile
Re: Damage multiplier script
« Reply #4 on: April 14, 2021, 03:40:29 AM »
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.

Offline SimonBestia

  • Full Member
  • ***
  • Posts: 294
  • Gender: Male
  • Bully-Board's Best Weeb
    • View Profile
    • Youtube Channel
Re: Damage multiplier script
« Reply #5 on: April 14, 2021, 03:55:02 AM »
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.

Offline Micha

  • Intelectual Wannabe
  • Jr. Member
  • **
  • Posts: 65
  • Gender: Male
    • View Profile
Re: Damage multiplier script
« Reply #6 on: April 14, 2021, 10:42:41 AM »
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,

Offline Micha

  • Intelectual Wannabe
  • Jr. Member
  • **
  • Posts: 65
  • Gender: Male
    • View Profile
Re: Damage multiplier script
« Reply #7 on: April 14, 2021, 12:17:09 PM »
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.

Offline SimonBestia

  • Full Member
  • ***
  • Posts: 294
  • Gender: Male
  • Bully-Board's Best Weeb
    • View Profile
    • Youtube Channel
Re: Damage multiplier script
« Reply #8 on: April 14, 2021, 12:19:06 PM »
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:
Code: [Select]
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"

Offline Micha

  • Intelectual Wannabe
  • Jr. Member
  • **
  • Posts: 65
  • Gender: Male
    • View Profile
Re: Damage multiplier script
« Reply #9 on: April 14, 2021, 12:44:33 PM »
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
« Last Edit: April 14, 2021, 01:05:14 PM by Micha »

Offline Micha

  • Intelectual Wannabe
  • Jr. Member
  • **
  • Posts: 65
  • Gender: Male
    • View Profile
Re: Damage multiplier script
« Reply #10 on: April 14, 2021, 01:18:51 PM »
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.

Offline SimonBestia

  • Full Member
  • ***
  • Posts: 294
  • Gender: Male
  • Bully-Board's Best Weeb
    • View Profile
    • Youtube Channel
Re: Damage multiplier script
« Reply #11 on: April 14, 2021, 01:26:20 PM »
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)
Code: [Select]
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
« Last Edit: April 14, 2021, 01:35:11 PM by SimonBestia »

Offline Micha

  • Intelectual Wannabe
  • Jr. Member
  • **
  • Posts: 65
  • Gender: Male
    • View Profile
Re: Damage multiplier script
« Reply #12 on: April 14, 2021, 01:44:36 PM »
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.

Offline Micha

  • Intelectual Wannabe
  • Jr. Member
  • **
  • Posts: 65
  • Gender: Male
    • View Profile
Re: Damage multiplier script
« Reply #13 on: April 14, 2021, 03:47:33 PM »
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.
« Last Edit: April 14, 2021, 04:07:47 PM by Micha »

Offline Micha

  • Intelectual Wannabe
  • Jr. Member
  • **
  • Posts: 65
  • Gender: Male
    • View Profile
Re: Damage multiplier script
« Reply #14 on: April 14, 2021, 04:43:04 PM »
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.