This repository was archived by the owner on Feb 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathPrediction.cpp
79 lines (58 loc) · 2.27 KB
/
Prediction.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "stdafx.h"
#include "Prediction.h"
Prediction::Prediction()
{
}
Prediction::~Prediction()
{
}
RVector3 LinePrediction::Calculate(Obj_AI_Base * target,float range,float missilespeed,float casttime)
{
float t = RVector3((target->GetPosition() - ObjectManager::GetPlayer()->GetPosition())).Length() /missilespeed;
t += casttime;
auto aim = *target->GetAIManager_Client();
auto comm = aim->GetActor();
auto veloc = *comm->GetVelocity();
veloc.y = 0;
RVector3 orientation = veloc.Normalize();//target->GetAllShield->vVelocity.Normalized();
//Normalize(orientation);
if (!target->IsValidTarget(range))
return RVector3(0, 0, 0);
if ( veloc.x == 0 && veloc.z ==0 )
{
//ENGINE_MSG("GetServerPosition %f %f %f\n", orientation.x, orientation.y, orientation.z);
//Beep(2000,200);
return target->GetServerPosition();
}
int pcolor = 0xFF0000;
lol::r3dDrawCircle.Call(&target->GetPosition(), 300, &pcolor, 0, 0, 0, 1);
RVector3 result = target->GetPosition() + *target->GetCharData()->GetMoveSpeed() * orientation * t;
D3DCOLOR predcolor = D3DCOLOR_ARGB(255, 0, 0, 255);
RVector3 predict2d, local2d;
render.r3dWorldToScreen(&result, &predict2d);
render.r3dWorldToScreen(&target->GetPosition(), &local2d);
render.DrawLine(local2d.x, local2d.y, predict2d.x, predict2d.y, 5, predcolor);
if (result.Distance(ObjectManager::GetPlayer()->GetPosition()) > range)
return RVector3(0, 0, 0);
//ENGINE_MSG("result %f %f %f : time : %f\n", orientation.x, orientation.y, orientation.z,t);
return result;
}
RVector3 CirclePrediction::Calculate(Obj_AI_Base * target, float range, float missilespeed,float radius, float casttime)
{
auto aim = *target->GetAIManager_Client();
auto comm = aim->GetActor();
auto veloc = *comm->GetVelocity();
veloc.y = 0;
RVector3 orientation = veloc.Normalize();//target->GetAllShield->vVelocity.Normalized();
//Normalize(orientation);
if (!target->IsValidTarget(range))
return RVector3(0, 0, 0);
if (veloc.x == 0 && veloc.z == 0)
{
return target->GetServerPosition();
}
RVector3 result = target->GetPosition() + *target->GetCharData()->GetMoveSpeed() * orientation * casttime;
int pcolor = 0x0000FF;
lol::r3dDrawCircle.Call(&result, radius, &pcolor, 0, 0, 0, 1);
return result;
}