[Tutorial] FIX ATTACHEMENTS LOGIC

Joined
Nov 28, 2014
Messages
480
Reaction score
286
I was here testing some things and playing around with the code a bit, my character had no skills at all, I thought I'd put an ATTM to improve the weapon's recoil and kill zombies, I ended up discovering that this **** was useless... then I thought let's make sense of what the original developers didn't care about.

Laser Logic: for when you are not pressing the mouse aim button
Forward Grip Logic: for when pressing the mouse aim button and for when it is disabled as well


All these settings can be customized by you, I just left here a simple basis of how to do it.

sorry my **** english!

View attachment 268060

open WarZ.sln
search for
Code:
if (wpn->getCategory()==storecat_SHTG) spread *= 1.2f;

add abellow
Code:
    //DouglasPro:: recoil forward grip and others
    if(wpn->m_Attachments[WPN_ATTM_BOTTOM_RAIL] && (wpn->m_Attachments[WPN_ATTM_BOTTOM_RAIL]->m_itemID == 400000 || wpn->m_Attachments[WPN_ATTM_BOTTOM_RAIL]->m_itemID == 400009
        || wpn->m_Attachments[WPN_ATTM_BOTTOM_RAIL]->m_itemID == 400088))
    {
        spread *= 0.5f;
        recoil *= 0.5f;
    }
    if(wpn->m_Attachments[WPN_ATTM_LEFT_RAIL] && (wpn->m_Attachments[WPN_ATTM_LEFT_RAIL]->m_itemID == 400004) && (!m_isAiming)){ //DouglasPro:: logic for laser rifle
        spread *= 0.2f;
        recoil *= 0.2f;
    }
 
I don't understand why this hard code is needed if you can configure it through attachments in itemDB to reduce recoil and weapon spread.

also if you want to increase accuracy in aiming mode you don't need to do so much useless code. If you already have the AttachmentArmory setting why are you adding it inside the shot logic?

C++:
// new recoil logic
if (wpn)
{
    if (m_isAiming) {
        RecoilViewModTarget.y += recoil * u_GetRandom(-wpn->m_pConfig->m_recoil_down, wpn->m_pConfig->m_recoil_up / 1.1f);
        RecoilViewModTarget.x += recoil * u_GetRandom(-wpn->m_pConfig->m_recoil_left / 1.3f, wpn->m_pConfig->m_recoil_right / 1.3f);
    }
    else {
        RecoilViewModTarget.y += recoil * u_GetRandom(-wpn->m_pConfig->m_recoil_down, wpn->m_pConfig->m_recoil_up);
        RecoilViewModTarget.x += recoil * u_GetRandom(-wpn->m_pConfig->m_recoil_left, wpn->m_pConfig->m_recoil_right);
    }
     
}
Congratulations, you have read the manual.
 
Last edited:
Back