AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Attack in straight line with traceline (https://forums.alliedmods.net/showthread.php?t=332825)

Celena Luna 06-03-2021 03:30

Attack in straight line with traceline
 
Edit 2 : After fixing some silly mistake, it still didn't work

I was trying to make an attack that deal damage to all enemy in line with fixed ranged
I am not sure where I got it wrong.

https://i.imgur.com/VV8mNkRh.png

PHP Code:

public Check_Tentacle(id)
{
    new 
Float:vecStart[3], Float:vecViewOfs[3]
    new 
Float:vecEnd[3], Float:vAngle[3], Float:vecForward[3]
    new 
tr create_tr2()

    
//Start Pos
    
pev(idpev_originvecStart)
    
pev(idpev_view_ofsvecViewOfs)

    
xs_vec_add(vecStartvecViewOfsvecStart)

    
//End Pos
    
pev(idpev_v_anglevAngle)
    
angle_vector(vAngleANGLEVECTOR_FORWARDvecForward)

    
vecEnd[0] = vecEnd[0] + float(TENTACLE_DISTANCE) * vecForward[0]
    
vecEnd[1] = vecEnd[1] + float(TENTACLE_DISTANCE) * vecForward[1]
    
vecEnd[2] = vecEnd[2] + float(TENTACLE_DISTANCE) * vecForward[2]

    
/*static Float:flViewAngle[3], Float:flPunchAngle[3], Float:flVelocity[3]

    pev(id, pev_v_angle, flViewAngle)
    pev(id, pev_punchangle, flPunchAngle)

    xs_vec_add(flViewAngle, flPunchAngle, flVelocity)
    engfunc(EngFunc_MakeVectors, flVelocity)

    GetGunPosition(id, flSrc)
    global_get(glb_v_forward, flAiming)*/

    
new Float:newStart[3];
    
newStart vecStart;

    new 
entIgnore id
    
new bool:done false;

    while (!
done) {
        
//new hitEnt = trace_line(id, vecStart, vecEnd, vStart)
        
engfunc(EngFunc_TraceLinevecStartvecEndDONT_IGNORE_MONSTERSentIgnoretr)
        
get_tr2(trTR_vecEndPosvecStart);
        new 
hitEnt get_tr2(trTR_pHit)

        if (
hitEnt <= 0) {
            
done true;
        } else {
            
entIgnore hitEnt
            
if(!is_user_alive(hitEnt)) 
                if(!
zp_get_user_zombie(hitEnt)) 
                {
                    
rg_multidmg_clear()
                    
ExecuteHamB(Ham_TraceAttackhitEntid100.0vecStarttrDMG_BULLET//Infect
                    
rg_multidmg_apply(idid)
                    
//ExecuteHamB(Ham_TakeDamage, hitEnt, 0, id, 100.0, DMG_BULLET) //Infect    
                
}
        }
    }

    
//Fix VecStart
    
pev(idpev_originvecStart)

    
xs_vec_add(vecStartvecViewOfsvecStart)

    
//Draw Laser
    
message_begin(MSG_ONE,SVC_TEMPENTITY,{0,0,0},id)
    
write_byteTE_BEAMPOINTS )        
    
engfunc(EngFunc_WriteCoordvecStart[0])
    
engfunc(EngFunc_WriteCoordvecStart[1])
    
engfunc(EngFunc_WriteCoordvecStart[2])
    
engfunc(EngFunc_WriteCoordvecEnd[0])
    
engfunc(EngFunc_WriteCoordvecEnd[1])
    
engfunc(EngFunc_WriteCoordvecEnd[2])
    
write_shortg_Beam //index
    
write_byte//frame
    
write_byte//frame rate
    
write_byte50 //life
    
write_byte40 //wide    
    
write_byte)   //noise
    
write_byte255 )
    
write_byte255 )
    
write_byte255 )
    
write_byte200 )    
    
write_byte
    
message_end()

    
    
free_tr2(tr)



DeMNiX 06-04-2021 00:00

Re: Attack in straight line with traceline
 
Code:

    // now its just a vector
    vecEnd[0] = vecEnd[0] + float(TENTACLE_DISTANCE) * vecForward[0]
    vecEnd[1] = vecEnd[1] + float(TENTACLE_DISTANCE) * vecForward[1]
    vecEnd[2] = vecEnd[2] + float(TENTACLE_DISTANCE) * vecForward[2]

=>
Code:

 
    // now its the end position
    vecEnd[0] = vecStart[0] + float(TENTACLE_DISTANCE) * vecForward[0]
    vecEnd[1] = vecStart[1] + float(TENTACLE_DISTANCE) * vecForward[1]
    vecEnd[2] = vecStart[2] + float(TENTACLE_DISTANCE) * vecForward[2]


Celena Luna 06-06-2021 06:49

Re: Attack in straight line with traceline
 
oh, thank you
it works :3


All times are GMT -4. The time now is 18:50.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.