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!

Tut: copy pasta fixed weapon backright without game crash - 3rd attm

Experienced Elementalist
Joined
May 28, 2017
Messages
225
Reaction score
127
Hey guys Im IKaruzI and the coder of zmmo,

Now the time came that I have to do some easy tutorials, because iss is 100% dead from now!

copy pasta should work, this will display the gun as first person model on your back, without game crash.

Code:
void CUberEquip::Draw(const r3dSkeleton* skel, const D3DXMATRIX& CharMat, bool draw_weapon, DrawType dt, bool first_person)
{
    //todo: call extern void r3dMeshSetWorldMatrix(const D3DXMATRIX& world)
    // instead of mesh->SetWorldMatrix

    // in first person mode we need to render player and gun into different Z range
    if(dt == DT_AURA)
    {
        float expandConst[ 4 ] = { r_aura_extrude->GetFloat(), 0.f, 0.f, 0.f } ;
        D3D_V(r3dRenderer->pd3ddev->SetVertexShaderConstantF(23, expandConst, 1)) ;
    }

    skel->SetShaderConstants();

    for(int i=0; i<=SLOT_Backpack; i++) //Disable BackPack, This logic will cause the player who uses the backpack ID 999333 to become invisible
    {
         if((d_disable_backpacks_draw->GetBool() /*g_RenderBackpack->GetInt() == 1*/ || player->CurLoadout.BackpackID >= 20260 && player->CurLoadout.BackpackID <= 20264) && i == SLOT_Backpack)
             continue;

        DrawSlot((ESlot)i, CharMat, dt, true, first_person, NULL);
    }


    if(dt != DT_AURA)
    {
        D3DXMATRIX world = getWeaponBone(skel, CharMat);
        if(!first_person)
        {
            if(slots_[SLOT_WeaponBackRight].wpn) // tobi 1
            {
                world = getWeaponBone(skel, CharMat);
                bool skinned = false;
                r3dSkeleton* wpnSkel = game_new r3dSkeleton(); // so traurig fixt waffe aufm rücken und crasht nichtmal....
                Weapon* wpn = slots_[SLOT_WeaponBackRight].wpn;

                wpn->checkForSkeleton(); // so traurig fixt waffe aufm rücken und crasht nichtmal.... und dann nocheinmal checken lassen und gut ist.
                //game_new r3dAnimation();

                //wpn->m_pConfig->m_AnimPool_FPS = game_new r3dAnimPool();
                //wpn->m_WeaponAnim_FPS = game_new r3dAnimation();

                //if(wpn->getAnimation()->bInited == 0)
                //    wpn->getAnimation()->bInited = 1;

                if(wpn)
                {
                    r3dMesh* msh = wpn->getModel(true, first_person);
                    if(msh->IsSkeletal() && wpn->getConfig()->getSkeleton())
                    {
                        wpn->getAnimation()->Recalc();
                        wpn->getAnimation()->pSkeleton->SetShaderConstants();
                        wpnSkel = wpn->getAnimation()->pSkeleton;
                        skinned = true;
                    }
                    //skel->GetBoneWorldTM("Weapon_BackRight", &world, CharMat);
                    //DrawSlot(SLOT_WeaponBackRight, world, dt, skinned, first_person, wpnSkel);
                }
                
                //slots_[SLOT_WeaponBackRight].wpn->isWeaponBack(true);
                skel->GetBoneWorldTM("Weapon_BackRight", &world, CharMat);
                DrawSlot(SLOT_WeaponBackRight, world, dt, skinned, first_person, wpnSkel);

                //game_new r3dAnimation();
                //DrawSlot(SLOT_WeaponBackRight, world, dt, false, first_person, NULL);
            }
            //else {
            //    slots_[SLOT_WeaponBackRight].wpn->isWeaponBack(false);
            //}
            if(slots_[SLOT_WeaponSide].wpn)
            {
                if(slots_[SLOT_WeaponSide].wpn->getCategory() == storecat_MELEE) {
                    skel->GetBoneWorldTM("Weapon_Side", &world, CharMat);

                    D3DXMATRIX mr1;
                    D3DXMatrixRotationYawPitchRoll(&mr1, 0, R3D_PI/2 + 40, 30);
                    skel->GetBoneWorldTM("Weapon_Side", &world, CharMat);
                    world = mr1 * world;

                    DrawSlot(SLOT_WeaponSide, world, dt, false, first_person, NULL);
                }
                else {
                    world = getWeaponBone(skel, CharMat);
                    bool skinned = false;
                    r3dSkeleton* wpnSkel = game_new r3dSkeleton();
                    Weapon* wpn = slots_[SLOT_WeaponSide].wpn;

                    wpn->checkForSkeleton();

                    if(wpn)
                    {
                        r3dMesh* msh = wpn->getModel(true, first_person);
                        if(msh->IsSkeletal() && wpn->getConfig()->getSkeleton())
                        {
                            wpn->getAnimation()->Recalc();
                            wpn->getAnimation()->pSkeleton->SetShaderConstants();
                            wpnSkel = wpn->getAnimation()->pSkeleton;
                            skinned = true;
                        }

                        //skel->GetBoneWorldTM("Weapon_Side", &world, CharMat);
                        //DrawSlot(SLOT_WeaponSide, world, dt, skinned, first_person, wpnSkel);
                    }
                //    slots_[SLOT_WeaponSide].wpn->isWeaponSide(true);
                    skel->GetBoneWorldTM("Weapon_Side", &world, CharMat);
                    DrawSlot(SLOT_WeaponSide, world, dt, skinned, first_person, wpnSkel);
                //    DrawSlot(SLOT_WeaponSide, world, dt, false, first_person, NULL);
                }
            }
            //else {
            //    slots_[SLOT_WeaponSide].wpn->isWeaponSide(false);
        //    }
        }

        if(draw_weapon)
        {
            world = getWeaponBone(skel, CharMat);
            bool skinned = false;
            r3dSkeleton* wpnSkel = NULL;
            Weapon* wpn = slots_[SLOT_Weapon].wpn;
            if(wpn)
            {
                r3dMesh* msh = wpn->getModel(true, first_person);
                if(msh->IsSkeletal() && wpn->getConfig()->getSkeleton())
                {
                    wpn->getAnimation()->Recalc();
                    wpn->getAnimation()->pSkeleton->SetShaderConstants();
                    wpnSkel = wpn->getAnimation()->pSkeleton;
                    skinned = true;
                }
            }
            DrawSlot(SLOT_Weapon, world, dt, skinned, first_person, wpnSkel);
        }
    }
}
 
Back
Top