Raised This Month: $12 Target: $400
 3% 

Solved Attack in straight line with traceline


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 06-03-2021 , 03:30   Attack in straight line with traceline
Reply With Quote #1

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.



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)

__________________
My plugin:

Last edited by Celena Luna; 06-06-2021 at 06:50. Reason: it doesn't work
Celena Luna is offline
DeMNiX
Veteran Member
Join Date: Nov 2011
Location: Russia
Old 06-04-2021 , 00:00   Re: Attack in straight line with traceline
Reply With Quote #2

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]
__________________
My channel with test codes
https://www.youtube.com/user/demnix03

Zombie Riot [Scenario & bots-zombie 11.11.2023]
https://youtu.be/8ZZan-aq2sc
DeMNiX is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 06-06-2021 , 06:49   Re: Attack in straight line with traceline
Reply With Quote #3

oh, thank you
it works
__________________
My plugin:

Last edited by Celena Luna; 06-06-2021 at 06:49.
Celena Luna is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:01.


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