DayZ 1.24
Loading...
Searching...
No Matches
Raycaster.c
Go to the documentation of this file.
1// Item for raycast debugging. It's also fun to play around with at night.
2
3class Raycaster extends ItemBase
4{
5 protected ref Timer m_Timer;
6
7 override void OnWorkStart()
8 {
9 if (!GetGame().IsServer() || !GetGame().IsMultiplayer()) // Client side
10 StartPeriodicMeasurement();
11 }
12
14 {
15 if (!m_Timer)
16 m_Timer = new Timer;
17
18 m_Timer.Run(0.01, this, "PrepareMeasurement", null, true);
19 }
20
22 {
23 DoMeasurement();
24 DoMeasurement();
25 }
26
28 {
29 float dispersion = 80;
30
31 vector from = GetPosition() + (GetMemoryPointPos("beamStart") + ((GetOrientation() + Vector(90, 0, 0)).AnglesToVector() * 0.3));
33 vector to = from + (ori.AnglesToVector()) * 30;
37
38 bool is_collision = DayZPhysics.RaycastRV(from, to, contact_pos, contact_dir, contactComponent, NULL, NULL, GetHierarchyRootPlayer(), false, false, ObjIntersectIFire);
39
40 if (is_collision)
41 {
42 vector hit_normal = contact_dir.VectorToAngles();
43 hit_normal[1] = hit_normal[1] + 90;
44
45 // Generate result
46 Particle p = ParticleManager.GetInstance().PlayInWorld(ParticleList.DEBUG_DOT, contact_pos);
47 p.SetOrientation(hit_normal);
48 }
49 }
50
52 {
53 if (m_Timer)
54 m_Timer.Stop();
55 }
56
57 override void OnWorkStop()
58 {
59 if (!GetGame().IsServer() || !GetGame().IsMultiplayer()) // Client side
60 StopPeriodicMeasurement();
61 }
62
63 override void SetActions()
64 {
65 super.SetActions();
66
69 }
70}
void AddAction(typename actionName)
vector GetOrientation()
ref Timer m_Timer
Definition DayZGame.c:675
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
class JsonUndergroundAreaTriggerData GetPosition
static proto bool RaycastRV(vector begPos, vector endPos, out vector contactPos, out vector contactDir, out int contactComponent, set< Object > results=NULL, Object with=NULL, Object ignore=NULL, bool sorted=false, bool ground_only=false, int iType=ObjIntersectView, float radius=0.0, CollisionFlags flags=CollisionFlags.NEARESTCONTACT)
Raycasts world by given parameters.
override void OnWorkStart()
Definition Raycaster.c:7
void StartPeriodicMeasurement()
Definition Raycaster.c:13
override void SetActions()
Definition Raycaster.c:63
void PrepareMeasurement()
Definition Raycaster.c:21
void StopPeriodicMeasurement()
Definition Raycaster.c:51
override void OnWorkStop()
Definition Raycaster.c:57
void DoMeasurement()
Definition Raycaster.c:27
ref Timer m_Timer
Definition Raycaster.c:5
Definition EnMath.c:7
Legacy way of using particles in the game.
Definition Particle.c:7
static const int DEBUG_DOT
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].