Banner
Crosshairs Pack 1 (Advanced Crosshairs)
Thumbnail
Downloads12,314
Views45,016
Publish Date4 years ago
Last Updated2 years ago by
Version2
Avatar

Hi. Good day to you. This is an amazing mod you did here. I really enjoyed using your CrossHEV. The dynamic of the mod really helps me with my DS journey. Thank you so much for existing.

I'm also aware that you don't wanna make a single crosshair with a lot of variants but I'm thinking of making or tweaking the CrossHEV to have the double bar for the left side, particularly reflecting armor and health dynamics. That's why I'm thinking maybe I can do it myself but really need to hear from you.

I do not have a coding knowledge but I used to tweak HUD for l4d2 to make the total ammo for my gun appear towards the centre of the screen near the crosshair. How do I start to make the crosshair as intended? I hope to hear from you soon. Wishing you a nice day ahead.

Edit: Oh yeah. I don't intend to exploit your work. I really respect your decision on not making other variants for the crosshair. This is my little effort and initiative to make this happen. Consider this as someone who wants and they seek. I believe seeking from you would be the right thing. Anyways, have a nice day.

Avatar

Hi, I'm really glad you're enjoying the mods.
Here's a guide on addons- unfortunately, it's incomplete, but it may still help some: https://github.com/offyerrocker/PD2-AdvancedCrosshairs/wiki/Creating-Advanced-Addons

I'm glad you have some experience and initiative with modding. I hope you like a challenge, because this will be a bit more difficult than editing Source HUD layout files.
Fortunately, you don't need to really write new code, just copy+paste some existing code and change it a little. (And make sure it's written correctly for Lua syntax.)

As for how to make your changes, here is what you have to do:

  1. Add more parts for the double-bar that reflects your armor. The code that defines their initial placement is in the parts table in the addon.lua file. There, you will find each of the existing parts, so find the ones you want to copy (the empty bar and the filled bar are two separate images, so you will probably need to copy two parts- the empty and the fill.) and paste those new entries to the parts list, at the end so that you don't mess up the order of the existing ones.
  2. Adjust the distance value for your new entries only, because otherwise they'll overlap with the health bar part. Tweak the value until it's to your liking, but I'm guessing you will probably want it to be somewhere around 80.
  3. Add the code that makes it reflect the armor value. You'll see some code that says if index == 1 then, with numbers going up to elseif index == 4 then. This code controls scaling or movement for each part, and index tells the code which part that code is changing. Since you added new parts to the end of the list, they should be 5 and 6. Copy the code for the left outline and left fill, and change which number it's checking the index for. Then, you need to change it to reflect the armor instead of the health. I made a "shortcut" to the health ratio as health_ratio, which you can find around line 33. Copy that line and replace health_ratio with armor_ratio on that line, as that is what the function is called. Replace health_ratio with armor_ratio in your part code as well.

Getting the Lua syntax will be a challenge for a novice, so I recommend looking at some beginner's guides to Lua, or asking someone for help in the likely event that you don't get it perfectly right the first time, but I think you can do it.

Avatar

Hi @offyerrocker .

Good day to you. Firstly, I want to thank you for being willing to share with me on how to do the crosshair as intended. I managed to do the crosshair. Yayy. I really enjoy watching the dynamic of the bar. The crosshair is perfect. I love it. And what's even great is that I get to write the code hands-on and get to see the result. Really enjoyed the experience.

I really thank you so much for this opportunity. This may not be a great deal for others but I really see this as an achievement for myself. Wishing you a good life and have a nice day ahead.

Edit: Oh yeah. Is it okay if I ask you again in the future if anything inquired or happened? At the moment, the 2nd bar appears to have a different colour but looks perfect in my eyes. But yeah. Let's leave it for another day. As always, have a nice day.

Avatar

@MetsuFesto96
I'm really glad you enjoyed making it!
Sure, feel free to ask. I'm pretty busy lately so I can't always make mods on request anymore, but I'll try to at least answer questions if I have time. You can find me on the modworkshop discord, or here.

50 960