Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
dayzspectator.c
Go to the documentation of this file.
1
class
DayZSpectator
:
Camera
2
{
3
private
float
m_SpeedMultiplier
= 1.0;
4
5
private
float
m_SendUpdateAcc
= 0.0;
6
7
void
DayZSpectator
()
8
{
9
SetEventMask(
EntityEvent
.FRAME);
10
}
11
12
override
void
EOnFrame
(
IEntity
other,
float
timeSlice)
13
{
14
if
(
GetUApi
().GetInputByID(UACarShiftGearUp).LocalPress())
15
m_SpeedMultiplier
=
m_SpeedMultiplier
+ 2;
16
if
(
GetUApi
().GetInputByID(UACarShiftGearDown).LocalPress())
17
m_SpeedMultiplier
=
m_SpeedMultiplier
- 2;
18
19
float
speed = 5.0 *
m_SpeedMultiplier
;
20
if
(
GetUApi
().GetInputByID(UATurbo).LocalValue())
21
speed *= 2;
22
23
float
forward =
GetUApi
().
GetInputByID
(UAMoveForward).
LocalValue
() -
GetUApi
().
GetInputByID
(UAMoveBack).
LocalValue
();
24
float
strafe =
GetUApi
().
GetInputByID
(UAMoveRight).
LocalValue
() -
GetUApi
().
GetInputByID
(UAMoveLeft).
LocalValue
();
25
26
vector
direction = GetDirection();
27
vector
directionAside =
vector
.
Up
* direction;
28
29
vector
oldPos =
GetPosition
();
30
vector
forwardChange = forward * timeSlice * direction * speed;
31
vector
strafeChange = strafe * timeSlice * directionAside * speed;
32
vector
newPos = oldPos + forwardChange + strafeChange;
33
float
yMin =
g_Game
.SurfaceRoadY(newPos[0], newPos[2]);
34
if
(newPos[1] < yMin)
35
newPos[1] = yMin;
36
37
SetPosition
(newPos);
38
39
float
yawDiff =
GetUApi
().
GetInputByID
(UAAimLeft).
LocalValue
() -
GetUApi
().
GetInputByID
(UAAimRight).
LocalValue
();
40
float
pitchDiff =
GetUApi
().
GetInputByID
(UAAimDown).
LocalValue
() -
GetUApi
().
GetInputByID
(UAAimUp).
LocalValue
();
41
vector
oldOrient =
GetOrientation
();
42
vector
newOrient = oldOrient;
43
newOrient[0] = newOrient[0] -
Math
.
RAD2DEG
* yawDiff * timeSlice;
44
newOrient[1] = newOrient[1] -
Math
.
RAD2DEG
* pitchDiff * timeSlice;
45
if
(newOrient[1] < -89)
46
newOrient[1] = -89;
47
if
(newOrient[1] > 89)
48
newOrient[1] = 89;
49
50
SetOrientation(newOrient);
51
52
if
(
m_SendUpdateAcc
> 0.5)
53
{
54
g_Game
.UpdateSpectatorPosition(newPos);
55
m_SendUpdateAcc
= 0;
56
}
57
58
m_SendUpdateAcc
=
m_SendUpdateAcc
+ timeSlice;
59
}
60
};
GetOrientation
vector GetOrientation()
Definition
areadamagemanager.c:306
Camera
Definition
camera.c:85
DayZSpectator::DayZSpectator
void DayZSpectator()
Definition
dayzspectator.c:7
DayZSpectator::m_SendUpdateAcc
float m_SendUpdateAcc
Definition
dayzspectator.c:5
DayZSpectator::EOnFrame
override void EOnFrame(IEntity other, float timeSlice)
Definition
dayzspectator.c:12
DayZSpectator::m_SpeedMultiplier
float m_SpeedMultiplier
Definition
dayzspectator.c:3
IEntity
Internal ancestor of all Entity implementations.
Definition
enentity.c:165
Math
Definition
enmath.c:7
UAInputAPI::GetInputByID
proto native UAInput GetInputByID(int iID)
returns list of all bindable (i.e. visible) inputs from the active group ('core' by default)
UAInput::LocalValue
proto native float LocalValue()
vector
Definition
enconvert.c:119
vector::Up
static const vector Up
Definition
enconvert.c:120
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
SetPosition
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition
effect.c:463
EntityEvent
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition
enentity.c:45
Math::RAD2DEG
static const float RAD2DEG
Definition
enmath.c:16
GetPosition
vector GetPosition()
Get the world position of the Effect.
Definition
effect.c:473
GetUApi
proto native UAInputAPI GetUApi()
Games
Dayz
scripts
4_world
entities
dayzspectator.c
Generated by
1.17.0