Syran0 Posted August 3, 2009 Posted August 3, 2009 if(GetLifeState(bEnt) && bEnt != Base.m_pMyPlayer->BaseEnt() && Base.m_pEngine->GetPlayerInfo(i,&pInfo)) { Draw3DBox(bEnt->GetAbsOrigin(),Vector(20,20,70),Vector(-20,-20,-10),bEnt->GetAbsAngles(),0,255,128); int delay = 55; if(Base.m_pEngine->GetNetChannelInfo()->GetAvgData( FLOW_OUTGOING ) <= 125) delay = 111; if(Base.m_pEngine->GetNetChannelInfo()->GetAvgData( FLOW_OUTGOING ) <= 67) delay = 222; if(Base.m_pEngine->GetNetChannelInfo()->GetAvgData( FLOW_OUTGOING ) <= 34) delay = 333; if(PredPlayer[i].dwLast + 500 < GetTickCount()) { PredPlayer[i].vecOldPosition = bEnt->GetAbsOrigin(); PredPlayer[i].dwLast = GetTickCount(); } //Wohoo we can learn :o //if(last_safe + 5000 < GetTickCount() && count_pos <= 200) // safe pos every 5000 ticks //{ // last_safe = GetTickCount(); // pos[count_pos].pos = bEnt->EyePosition(); // count_pos += 1; //} Vector delta; delta.x = (bEnt->GetAbsOrigin()[0]-PredPlayer[i].vecOldPosition[0]); delta.y = (bEnt->GetAbsOrigin()[1]-PredPlayer[i].vecOldPosition[1]); delta.z = (bEnt->GetAbsOrigin()[2]-PredPlayer[i].vecOldPosition[2]); vPredict = bEnt->GetAbsOrigin(); vPredict += Vector(delta); Draw3DBox(vPredict,Vector(20,20,70),Vector(-20,-20,-10),bEnt->GetAbsAngles(),255,0,0); float last_distance = 9999999999; //We dont want it flicker to much if(last_update + 500 < GetTickCount()) { for(int c = 0; c <= count_pos; c++) { if(v_distance(vPredict,pos[c].pos) < last_distance && v_distance(vPredict,pos[c].pos) < pos[c].last_distance) { final = pos[c].pos; last_distance = v_distance(vPredict,pos[c].pos); } pos[c].last_distance = v_distance(vPredict,pos[c].pos); } last_update = GetTickCount(); } Draw3DBox(final,Vector(20,20,70),Vector(-20,-20,-10),bEnt->GetAbsAngles(),255,255,255); Vector sc1,sc2,sc3,sc4,sc5; Base.m_pNeeded->WorldToScreen(bEnt->GetAbsOrigin(),sc1); Base.m_pNeeded->WorldToScreen(vPredict,sc2); Base.m_pNeeded->WorldToScreen(vPredict+Vector(delta),sc3); Base.m_pNeeded->WorldToScreen(vPredict+Vector(delta)+Vector(delta),sc4); Base.m_pNeeded->WorldToScreen(final,sc5); Base.m_pMatSurface->DrawSetColor(RGBA(COLORCODE(0,255,0,188))); Base.m_pMatSurface->DrawLine(sc1.x,sc1.y,sc2.x,sc2.y); //Base.m_pMatSurface->DrawLine(sc2.x,sc2.y,sc3.x,sc3.y); //Base.m_pMatSurface->DrawLine(sc1.x,sc1.y,sc5.x,sc5.y); //Base.m_pMatSurface->DrawLine(sc3.x,sc3.y,sc4.x,sc4.y); //} } Dust2 Sample: pos[0].pos = Vector(-1676.854736, 832.136658, 96.031250); pos[1].pos = Vector(-763.226501, 1426.699341, -47.968750); pos[2].pos = Vector(-1540,2648,45); pos[3].pos = Vector(1135,2455,140); pos[4].pos = Vector(448.000000, 2464.000000, -49.000000); pos[5].pos = Vector(1007.968750, 2383.991943, 92.156372); pos[6].pos = Vector(1714.089233, 1808.004517, 110.096924); pos[7].pos = Vector(1040.003906, 3055.968750, 208.033218); pos[8].pos = Vector(571.968750, 2783.989746, 160.031250); pos[9].pos = Vector(478.466980, 2052.467041, 160.031250); pos[10].pos = Vector(147.024597, 1472.468140, 64.031250); pos[11].pos = Vector(-193.497742, 1028.399048, 64.031250); pos[12].pos = Vector(-69.305428, 387.033905, 66.333832); pos[13].pos = Vector(369.842957, 64.893188, 70.658691); pos[14].pos = Vector(611.681824, 495.457245, 66.468399); pos[15].pos = Vector(-405.135773, -567.175903, 84.560310); pos[16].pos = Vector(-685.809143, -808.182251, 198.972778); pos[17].pos = Vector(-1480.645508, -277.218750, 193.653259); pos[18].pos = Vector(-1892.091309, 641.516541, 96.031250); pos[19].pos = Vector(-1974.386475, 1433.407471, 96.031250); pos[20].pos = Vector(-2095.760254, 2541.095459, 96.031250); pos[21].pos = Vector(-2031.968750, 3119.968750, 83.968750); pos[22].pos = Vector(-1616.013794, 1632.031250, 79.986862); pos[23].pos = Vector(-1033.080078, 2096.180420, 18.727989); pos[24].pos = Vector(-408.170013, 1618.152832, -61.855171); Structures: struct positions { Vector pos; float last_distance; }; positions pos[512]; struct PredPlayer { DWORD dwLast; Vector vecOldPosition; }; PredPlayer PredPlayer[64]; 3D Box: void Draw3DBox(Vector or, Vector min, Vector max, QAngle ang,int r, int g, int b) { Base.m_pMatSurface->DrawSetColor(RGBA(COLORCODE(r,g,b,255))); Vector p1,p2,p3,p4,p5,p6,p7,p8; Vector s1,s2,s3,s4,s5,s6,s7,s8; p1 = or + min; p2 = or + Vector(max.x,min.y,min.z); p3 = or + Vector(min.x,max.y,min.z); p4 = or + Vector(max.x,max.y,min.z); p5 = or + max; p6 = or + Vector(min.x,max.y,max.z); p7 = or + Vector(min.x,min.y,max.z); p8 = or + Vector(max.x,min.y,max.z); Base.m_pNeeded->WorldToScreen(p1,s1); Base.m_pNeeded->WorldToScreen(p2,s2); Base.m_pNeeded->WorldToScreen(p3,s3); Base.m_pNeeded->WorldToScreen(p4,s4); Base.m_pNeeded->WorldToScreen(p5,s5); Base.m_pNeeded->WorldToScreen(p6,s6); Base.m_pNeeded->WorldToScreen(p7,s7); Base.m_pNeeded->WorldToScreen(p8,s8); Base.m_pMatSurface->DrawLine(s1.x,s1.y,s2.x,s2.y); Base.m_pMatSurface->DrawLine(s1.x,s1.y,s3.x,s3.y); Base.m_pMatSurface->DrawLine(s1.x,s1.y,s7.x,s7.y); Base.m_pMatSurface->DrawLine(s2.x,s2.y,s8.x,s8.y); Base.m_pMatSurface->DrawLine(s2.x,s2.y,s4.x,s4.y); Base.m_pMatSurface->DrawLine(s3.x,s3.y,s4.x,s4.y); Base.m_pMatSurface->DrawLine(s3.x,s3.y,s6.x,s6.y); Base.m_pMatSurface->DrawLine(s4.x,s4.y,s5.x,s5.y); Base.m_pMatSurface->DrawLine(s5.x,s5.y,s6.x,s6.y); Base.m_pMatSurface->DrawLine(s5.x,s5.y,s8.x,s8.y); Base.m_pMatSurface->DrawLine(s6.x,s6.y,s7.x,s7.y); Base.m_pMatSurface->DrawLine(s7.x,s7.y,s8.x,s8.y); } Distance: float v_distance( Vector from,Vector to ) { Vector angle; angle.x = to.x - from.x; angle.y = to.y - from.y; angle.z = to.z - from.z; return sqrt(angle.x*angle.x + angle.y*angle.y + angle.z*angle.z); } floxy ; venoma Quote
Syran0 Posted August 13, 2009 Author Posted August 13, 2009 If you can't code, you'll never understand ;) Quote
Morian Posted August 13, 2009 Posted August 13, 2009 Topic moved to right section. By the way, w8 for my feedback, tommor i will test all. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.