Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
Cool cool, Knockout should be very simple for compatibility; all that really needs to be done on my end is to add some logic when handling injuries to determine if the player should be knocked out.
I also intend to add flat damage that is currently missing from PVI, along with airbag support.
I haven't looked at airbags yet since they we're released after the Working Seatbelt patch, but I imagine you have them setup fairly similarly. Are airbags handled in the same sense where the status & condition of the airbag is stored in mod data like seatbelt status
(seatbeltIsBuckled = p:getModData().Seatbelt_sbStatus)
Or are the airbags physical car parts that I'd have to check for whatever car the player is driving?
Generally speaking, what you want to do is
1- if vars.airbagModule
2- Get character seat and check if its 0 or 1 (since airbags are only in driver or passenger seats)
3- local airbagPart = WorkingSeatbelt.getAirbagPart(seat, vehicle)
4- if airbagPart and not airbagPart:isInventoryItemUninstalled() then
5- if crash damage >= vars.airbagMinimumCrashStrength then
6- reductionType = "airbag" (Maybe? I have no idea how you handle that in your code, but like I said, this is passed later in my code to the ontick functions to handle damage reduction)
7- deployAirbag(character, charVehicleId, charSeat) (This doesn't apply actual damage reduction. Just does stuff like playing the sound, removing the airbag, etc)
Example:
As a side note, I released an update yesterday for ejecting players out of the car and throwing them out of the windshield if seatbelt isn't buckled and windshield is smashed. It "probably" may need a compatibility patch as well!
I'm assuming 'vars.airbagModule' in your step 1 is just checking sandbox vars if airbags are enabled?
reductionType will be very simple, I already have code for determining what type of helmet a player wears in the event of a crash ("None", "Half" , "Full").
I'll have to dive into the javadoc and see if there's a method that returns the seat number (I imagine there is, I've just not looked very far into the Vehicle class).
PVI also has the luxury of not needing to add & remove the onTick functions because it has full control of the damage numbers it's dealing, as opposed to needing to detect damage, hook into it, then apply damage reductions, so the 'if reductionType then' check will be very simple for PVI.
Is there a chance I could get you to define 'deployAirbag' in the Working Seatbelt table so there doesn't have to be a bunch of redundant code in PVI?
I'll also have a look into your player ejection addon; is the function for handling it declared in the Working Seatbelt table like Knockout is, or is it a bit more hands on like airbags?
I use onTick (surprise surprise) as well for ejecting player, but since you don't need it, you can directly call WorkingSeatbelt.ejectPlayer(), and the mod takes care of the rest. Before you do, you need to check if the player should be ejected in first place using your own conditions + the shouldBeEjected function (which is also not defined in the table). A little side note, the distance at which player gets thrown from the car and the damage dealt are currently hard coded in the ejectPlayer function. I'll try to release an update tonight that:
Adds shouldBeEjected and deployAirbag to the table
Makes the damage and distance more dynamic/not hardcoded
You could use vehicle:getSeat(character) to get the seat number.
By the way, great job with PVI! :)
I appreciate all the help and insight you've given me, and don't feel rushed at all to get a patch out if you feel that way from me pestering you lol. I've got university classes, of which a bunch have labs attached to them so I likely won't get an update out for a few months or over some weekends/weekdays where I'm more free.
One last thing, I've thought about making a library of some basic helper functions to use for future mods and haven't used Lua outside of PZ. Do I have to add functions to the table to be able to call them, or does simply not declaring the function as local and then having the 'PVI = PVI or {}' allow me to access functions & variables inside that file?
Thanks again for all your help!
I actually just released a hotfix for the mod, since I made a blunder in the code that had a little annoying damage indicator appearing above players when they crashed. Anyways, the update also includes moving previously mentioned functions to the tables.
You have to assign functions and variables to the table to be able to call them from other locations to the best of my knowledge. I too used Lua for the first time in PZ modding so I am not the most knowledgeable person about it haha
A better practice than both of these two is to use modules, which should be more efficient. However, I am guilty of always forgetting to use this. At one point in the future I want to update all of my mods to this
So I've got the following working--as far as I can tell--correctly:
- Knockout on collision, knockout chance can be specified for low/med/high/fatal severity crashes individually in PVI's sandbox options.
- Airbags deploy and the damage reduction is stacked with seatbelts up to a cap that is specified in sandbox options
- Ejection from the vehicle.
Currently, I'm not checking for any conditions to eject the player and I'm just ejecting them whenever a collision happens (for testing). The only thing I'm noticing and can see from 'WorkingSeatbelt.ejectPlayer' is lines 118 - 127; the flat damage caused from the ejection you add to each body part stacks on top of what PVI will deal with this next update.
Do you think you could add a check to see if PVI is installed just before you modify the body part health to alleviate this issue?
You could use this from PVI to check if you'd like:
Where the 'modID' parameter is just the Mod ID on the workshop page of that mod (for PVI this is: ProperVehicleInjuriesMP)
You can also modify the players general health without iterating through each body part which gives a much easier to understand idea for how much damage you're dealing with:
Other than that, pretty much all of the next update is done, and hopefully functional! I'm doing some testing now to make sure the update behaves properly, but all is good for now.
I've attached screenshots below, but it seems that vehicles do not update vehicle:getDir() like the player does, causing this condition to almost always return false.
When driving a test car I spawned in, driving southbound the Muldraugh highway will fail to cause an ejection, even when all other conditions are true.
The debug message on screen is the difference in speed pre/post collision, basically how severe it was, and the left is tostring(p:getDir() == p:getVehicle():getDir())
Southbound collision[gyazo.com]
Here's the same scenario, but this time going Northbound:
Northbound collision[gyazo.com]
I've checked all the other conditions in 'WorkingSeatbelt.shouldBeEjected()' and all are as expected, but the vehicle objects direction doesn't appear to be updating.
I've tried other vehicles, but their direction seems to be stuck at whatever direction they were facing when they spawned. Heres the same test but with a red van I found naturally spawned in Muldraugh:
This is when colliding in the direction the vehicle spawned facing
Collision while going southbound[gyazo.com]
This is going the direction opposite of the vehicle spawning
Collision while going northbound[gyazo.com]
I even tried checking the direction after colliding, but the vehicles direction is still stuck as south or 'S' despite very clearly facing north:
Sanity check in Lua console in-game[gyazo.com]
Any thoughts? Going to try looking into if theres another function that may be more reliable, or try ask for help as to why getDir() isn't updating for vehicles but does for the player.
I've modified the eject player code to apply player damage only if PVI mod is not enabled. Additionally, ReduceGeneralHealth is definitely a better and more straightforward way. I didn't know that function existed, but thanks! I'm using it now.
That's interesting then, I'll have to take another look at it tomorrow, and thanks for that update!
From the tests I'd been doing (just in the lua console in game to save time) the vehicles getDir() stayed static, even though the driver/player had very much changed directions :/
I'll try running some debug lines and see if I can see the direction of the vehicle changing, if not I'll see if anyone in the mod-development channel on the PZ discord has any ideas.
Thanks as always, I'll send an update either tomorrow or whenever I work on the mod again!
Turns out it's pretty simple, I've attached a link to a gif showing this, but turns out BaseVehicle has a method 'getTransmissionNumberLetter()' that returns a string representing the gear the vehicles transmission is in ("R" for reverse, "N" for neutral, "1" for first gear, etc).
So with this transmission letter, I can check if it's anything but "R" and then set the vehicles direction to the players direction. Otherwise, we use the function 'reverse(IsoDirections directionToReverse)' in the 'IsoDirections' class and pass the player's getDir() as it's parameter, and set the vehicles direction to that.
The showcase gif[gyazo.com]
The code I'm talking about above:
I think I'm going to head forward with this implementation to fix the issue I mentioned yesterday, will also add an option in PVI's sandbox options to enable or disable this if is seems to cause issues in the future.
Thanks again for all your help!
If there's any other mods/updates you publish, don't hesitate to post a discussion on PVI's workshop page to let me know :)
Thanks again for all your help!
By the way, being in contact over discord might be easier for the future. You can message me at @arendameth