Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Tutorial] BUG FIX MUZZLE BLOCK (inside of wall)

Junior Spellweaver
Joined
Jan 19, 2014
Messages
136
Reaction score
126
ATUALIZADO 06.10.2023

English


This is one of the worst things in warz, the player sticks to the wall and shoots without giving the player a chance to fight back for not having vision. In Brazil we call it "BUG DA MÃOZINHA".

PT-BR

Essa é uma das piores coisas do warz, o jogador colar na parede e atirar sem dar chance do jogador revidar por não ter visão. No Brasil chamamos de "BUG DA MÃOZINHA".


Credits, myself! If you made the solution on your own, congratulations, I bring this tutorial for those who still enjoy playing with WARZ.After days reading the codes I came to this tutorial and I thank RAGEZONE for everything we've shared so far, some boring and tiring like the AdminWarZ posts, but I'm still grateful.

Creditos, eu mesmo! Se você fez por conta própria a solução parabéns, eu trago este tutorial para aqueles que ainda curtem brincar um pouco com WARZ. Após dias lendo os códigos cheguei a este tutorial e agradeço a RAGEZONE por tudo que compartilhamos até hoje, alguns chatos e cansativos como os posts do AdminWarZ, mas ainda sim estou agradecido.


See in the screenshot that you need to get the whole body out to be able to shoot.

Veja na screenshot que precisa por todo corpo para fora, para poder atirar.


EaH4sx2 - [Tutorial] BUG FIX MUZZLE BLOCK (inside of wall) - RaGEZONE Forums





let's go to the tutorial

Vamos ao que interessa


In WarZ.sln
Search for:

Code:
// check muzzle block except when using scope

Find it!
Code:
if(!m_isInScope && wpn->getCategory()!=storecat_MELEE && isMuzzlerBlocked(this, GetMuzzlerPosition()))        m_isPressedFireTrigger = false;

And leave it at that!
Code:
if(!m_isInScope && wpn->getCategory()!=storecat_MELEE && isMuzzlerBlocked(this, GetHeadPosition(), GetMuzzlerPosition())) m_isPressedFireTrigger = false;

Now new search.Look for it here!
Code:
// check if muzzler is visible, and if not (inside of wall) then we do not shoot anything

CHANGE ALL CODE .
Code:
static bool isMuzzlerBlocked(obj_Player* pl, const r3dPoint3D& muzzlePos)

FOR...
Code:
static bool isMuzzlerBlocked(obj_Player* pl, const r3dPoint3D& HeadPos, const r3dPoint3D& muzzlePos)
{
    // check if muzzler is visible, and if not (inside of wall) then we do not shoot anything
    bool muzzlerBlocked = false;
    {
        r3dVector temp = muzzlePos-HeadPos;
        float len = temp.Length();
        temp.Normalize();
        if(len > 0)
        {
            PxRaycastHit hit;
            PxSceneQueryFilterData filter(PxFilterData(COLLIDABLE_STATIC_MASK,0,0,0), PxSceneQueryFilterFlags(PxSceneQueryFilterFlag::eDYNAMIC|PxSceneQueryFilterFlag::eSTATIC));
            muzzlerBlocked = g_pPhysicsWorld->raycastSingle( PxVec3(HeadPos.x,HeadPos.y,HeadPos.z), PxVec3(temp.x, temp.y, temp.z), len, PxSceneQueryFlags(PxSceneQueryFlag::eIMPACT), hit, filter);
        }
    }
    if(muzzlerBlocked)
        return true;

    const float MAX_CASTING_DISTANCE = 20000.f;
    r3dPoint3D dir;
    if(pl->m_isInScope || g_camera_mode->GetInt() != 1)
        r3dScreenTo3D(r3dRenderer->ScreenW2, r3dRenderer->ScreenH2, &dir);
    else
        r3dScreenTo3D(r3dRenderer->ScreenW2, r3dRenderer->ScreenH*0.32f, &dir);

    // check if camera->shoot_target position agains camera->muzzler (disable shooting when close to wall, but looking at step edge)
    float distToMuzzler = (HeadPos-muzzlePos).Length();
    {
        PxRaycastHit hit;
        PxSceneQueryFilterData filter(PxFilterData(COLLIDABLE_STATIC_MASK,0,0,0), PxSceneQueryFilterFlags(PxSceneQueryFilterFlag::eDYNAMIC|PxSceneQueryFilterFlag::eSTATIC));
        if(g_pPhysicsWorld->raycastSingle(PxVec3(HeadPos.x, HeadPos.y, HeadPos.z), PxVec3(dir.x, dir.y, dir.z), MAX_CASTING_DISTANCE, PxSceneQueryFlags(PxSceneQueryFlag::eDISTANCE), hit, filter))
        {
            if(hit.distance < distToMuzzler)
            {
                // shooting blocked before muzzler
                return true;
            }
        }
    }

    return false;
}

Build the client and be happy!
 

Attachments

You must be registered for see attachments list
Last edited:
Initiate Mage
Joined
Jul 24, 2021
Messages
2
Reaction score
0
Excellent I will report back and test.

I really like your HUD.
How did you do it?
 
Back
Top