Jump to content

Search the Community

Showing results for tags 'code'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • News & Announcements
    • News
  • Project Zomboid
    • PZ Updates
    • General Discussions
    • Bug Reports
    • PZ Support
    • PZ Multiplayer
    • PZ Community & Creativity
    • PZ Suggestions
  • PZ Modding
    • Tutorials & Resources
    • Mods
    • Items
    • Mapping
    • Mod Ideas and Requests
  • General Games Development
    • Indie Scene
  • Other Discussions
    • General Discussion
    • Forum Games & Activities

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Found 6 results

  1. So I ve been trying to find definitive answers to a few infection questions, but I only found quotes and sayings with no 100% certainty, so I started digging through the Project Zomboid code and here are my findings. All of the game mechanics in this thread are true as of version 39.67.5 (No changes from 38.30) Spoilers here to avoid huge wall of text. Read the TL;DR if you dont care about details: TL;DR By default: Bites are 100% deadly. Scratches are 25% deadly. Both Thick skin and Blunt Guard skills (Blade Guard if wielding a blade weapon) adds in avoiding bites and scratches, and Thick skin further reduces the probability of a deadly scratch. Thin skin worsens everything. More game mechanics: Traits Lucky/Unlucky Prone to Illness/Resilient General Panic Sleep and related effects Melee damage mechanics If someone has suggestions, questions about parts of code and such, or found any errors/things I might have overlooked, feel free to post or msg me about it and I ll do my best to check.
  2. Would it be possible to code in a new button config that provides for a "drop all bags" button? After an unfortunate death last night of a good character, I got caught kinda off guard by a couple zeds, which quickly turned into 4 or 5. I had intended to quickly open inventory to drop my overweight dumbness, but that GUI is just too cumbersome to pull that off in the middle of a shove-swing-stomp fiasco. I could have made it out had there been a key that allows you to drop any equipped bags (hence, overloading weight). Granted that any overloading weight on your immediate self would be tantamount to suicide anyway, but being able to drop bags by keystroke (say, ~ or Backspace) could mean the difference between life and zombification.
  3. I have started modding PZ and I was experimenting with key registry trying to figure out which keys are what by printing them in the console. This failed to print keys to console so I tried spawning something to the players inventory (something I've done before) I have searched and found no info on left click behaviour or detecting it. But this piece of code just doesn't work and through testing Print(); doesn't work in code that does work. The sub directory for this file is media\lua I have also tried media\lua\server and media\lua\client. TTG_Click = {};TTG_Click.characterInfo = nil;TTG_Click.click = function(_keyPressed) local player = getSpecificPlayer(0); local key = _keyPressed; player:getInventory():AddItem("Base.Pistol"); print(key);endEvents.OnKeyPressed.Add(TTG_Click.click);Any Ideas on what's gone wrong? The file is called TTG_Click.lua Edit: Thank you for moving me I was on the help sub forum for mods when I clicked start new topic don't know how it ended up there. Requesting a mod remove this thread. I never found out what the issue was but I was directed to a completely different solution and implementation.
  4. Hi, I am very noob with all this coding thing and Lua files. I tried to do some things for adding to the game, some of them asked before in Suggestion forum. The thing is I managed to do some of them, but find a BIG BUG when I made a Ranged Weapon. At first couldnt shoot with it. Then I thought I fixed some things but instead the weapon became endless ammo. It shoots, it does what was supossed to do in the rest of things, but the ammo don't decrease. Then I messed all up in the ReloadUtil file and ... well, I am a bit lost. At first I tried to make the weapon use the same pistol clip as the default gun, but couldnt do it to reload, so I made a new item, SBerettaclip (it is almost the same as default but with a change in name and I get it from Necroforge spawning by this moment). Here are the Items as part of WeaponsGuns txt file in the folder scripts: And here is the CompilationReloadUtil lua file put in the folder lua/shared/Reloading: Can somebody pleazeeeeed help me with this mess?
  5. First, this all comes from NCrawler, who seems to have left the community 6 months back. It's from a beta of his YAWM that never was released. I have it since I was a beta tester for him at the time he left. The purpose of this is to allow the modder far more flexibility in how his items are spawned, when, and with what. It also allows a modder to set values lower than 0.01 for probability, in fact as low as desired (1 in 10,000, okay!). Some of this has been heavily altered by me for personal use with the KY firearms mod that's currently out in this forum, but it can work with any items mod you like. This works through the media\lua\server\Items subfolder. Add this to the bottom to start. The random value generator is used an awful lot, and the Events line is what calls the script to run each time a container is "filled" by the game engine. Without that, nothing will happen. --From RoboMat's RMUtility Modfunction rnd(_value) return ZombRand(_value) + 1;endEvents.OnFillContainer.Add(spawnNCStuff);Next is the main function. Note that "OnFillContainer" will pass 3 values to this, the room name (the first value we see in SuburbsDistribution tables, like "kitchen"), the type of container (the second value, "all" or "metal_shelves"), and the specific container being filled: function spawnNCStuff(_roomName, _containerType, _containerFilled)-- ALL THE IF AND WHILE LOOPS DISCUSSED BELOW GO IN HEREendNow we can use these in IF statements to specify when to spawn things depending on room type or container type: if _containerType == "wardrobe" then-- STUFFend if _roomName ~= "kitchen" then if _containerType == "counter" or _containerType == "locker" or _containerType == "metal_shelves" then-- STUFFendendWithin these, we can set how rare the spawn is thusly: --Roll for firearm (0.2% chance) if rnd(1000) >= 999 then-- STUFFendThe next part is a bit trickier. It requires two things. First, the code within the above IF statements. Second, a separate array outside of this entire function. Let's start with the array. Here's an example for guns and their respective ammo: gun_array = { "RKFmod.ColtPython", "RKFmod.TaurusModel444RagingBull", "RKFmod.Kimber1911", "RKFmod.Ruger1022ArchangelNomad", "RKFmod.Ruger1022", "RKFmod.MarlinModel795", "RKFmod.MarlinModel795", "RKFmod.MarlinModel795", "RKFmod.MarlinModel795",};ammo_array = { "RKFmod.357Mrounds", "RKFmod.44rounds", "RKFmod.45rounds", "RKFmod.Ruger1022ArchangelNomadMag", "RKFmod.Ruger1022Mag", "RKFmod.MarlinModel795Mag", "RKFmod.MarlinModel795Mag", "RKFmod.MarlinModel795Mag", "RKFmod.MarlinModel795Mag",};Notice how the first member of the array in gun_array matches the first member of ammo_array, and so on to the end? This is important if you want to spawn matching items together. Also notice how we've had the Marlin 795 repeated 3 times, so it takes up 4 of the 8 choices? That means it has a 50% chance of spawning IF any gun is spawned from its array. This is how to make specific entries more or less likely within the array. Now, let's assume we have several such paired arrays, one for long rifles, one for pistols, one for AR-15s, etc. We want to choose randomly which to pick from when spawning. Next the code for the main function: weaponType = rnd(100); if weaponType <= 50 then --pistols-- STUFF elseif weaponType > 50 and weaponType <= 90 then --rifles-- STUFF elseif weaponType > 90 then --AR-15s-- STUFF endSo here you can see we are choosing between which set of arrays to spawn from. Next, to pick a member of the array to spawn: gun_Index = rnd(#gun_array); _containerFilled:AddItem(gun_array[gun_index]);#gun_array means that it counts the number of entires in our gun_array. The rnd function picks a random number within that range. Then we have the main "doer" of this whole thing, the AddItem() command. This adds in the selected item to the specific container. You could just replace (gun_array[gun_index]) with ("mymod.my_gun") and it'd work just as well. Now here's a fun twist. You can add specific ammo/magazines/etc to the spawn as well: NCY_ammovar = rnd(100); if NCY_ammovar >= 40 then --Add 1 magazine for that weapon(60% chance) _containerFilled:AddItem(ammo_array[gun_index]); if NCY_ammovar >= 75 then --Another mag (25% chance) _containerFilled:AddItem(ammo_array[gun_index]); if NCY_ammovar >= 92 then --2 more mags (8% chance) _containerFilled:AddItem(ammo_array[gun_index]); _containerFilled:AddItem(ammo_array[gun_index]); end end endLet's walk through that a bit slowly. First, we have a new random value, this is just used to see if we want to spawn something or not. You could just make this 100, so something always spawns (or nix the IF statements and just follow with an AddItem() command). But here it's random, and the first checks to see if it's >= 40, which means 60% of the time we'll get ammo spawned with the gun. Notice that we're using the SAME gun_index value as before, we haven't rerandomized it, but now with the ammo array? Yes, this is how we get a matching gun/magazine/ammo spawn. Then you can see that there are two additional IF checks, for rarer likelihood of further spare ammo. This can be tailored however you like, once you understand the basic syntax of what's going on here. There's a lot more you can do with this stuff, like spawning a melee if a gun doesn't spawn, using an ELSE statement that follows the original IF statement way above. Sky's the limit. I'm not going to say this is the most streamlined code imaginable, but it works and it's pretty easy to edit on the fly and adjust to how you like it. Anyway, let's look at a finished version of what we just did (different names for some things, but exact same structure/commands): This was altered by me to work with the KY firearms mod, for personal use. I guess now it's open to all. I will also post the original YAWmod lua if anyone wants to experiment with thatj. NOTE: You will want to get rid of all the... table.insert(SuburbsDistributions["garagestorage"]["all"].items, "RKFmod.BoxOf22");...type code if you want to do this, or at least that which is relevant to what you're trying to achieve with these functions. Anyway, thanks should go to NCrawler, wherever he is, as far as I know he was the one to come up with this approach and code for this game.
  6. Hi guys I only just now found out zoom is back in the game (IKR only just 5 minutes ago...) Would it be possible to make a script to auto zoom in the camera all the way as i enter a building(such as every thing you can walk into from the outdoors).Then zoom out to its default zoom as i exit the buildings. How hard would it exactly be? I would think of this being useful maybe not only to me but others aswell.As the thought of this idea popped into my head i was overwhelmed with excitement
  • Create New...