Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_VehicleSpawner.c
Go to the documentation of this file.
1
[
EntityEditorProps
(
category
:
"GameScripted/ScriptWizard"
, description:
"THIS IS THE SCRIPT DESCRIPTION."
, color:
"0 0 255 255"
)]
2
class
SCR_VehicleSpawnerClass
:
ScriptComponentClass
3
{
4
}
5
6
class
SCR_VehicleSpawner :
ScriptComponent
7
{
8
static
const
float
MIN_DISTANCE
= 10;
9
10
[
Attribute
(
""
,
UIWidgets
.ResourceNamePicker,
""
,
""
)]
11
private
ref array<ResourceName> m_aPrefabs;
12
13
private
IEntity
m_pSpawnedEntity;
14
private
IEntity
m_owner
;
15
16
private
bool
m_bSpawned
=
false
;
17
18
//------------------------------------------------------------------------------------------------
19
override
void
OnPostInit
(
IEntity
owner)
20
{
21
m_owner
= owner;
22
}
23
24
//------------------------------------------------------------------------------------------------
28
ResourceName PickRandomResource(array<ResourceName> resources)
29
{
30
if
(!resources)
31
return
string
.Empty;
32
33
int
count = resources.Count();
34
if
(count < 1)
35
return
string
.Empty;
36
37
int
randomIndex = Math.RandomInt(0, count);
38
return
resources[randomIndex];
39
}
40
41
//------------------------------------------------------------------------------------------------
43
void
PerformSpawn()
44
{
45
if
(!
m_owner
)
46
return
;
47
48
if
(m_pSpawnedEntity && vector.Distance(m_pSpawnedEntity.
GetOrigin
(),
m_owner
.
GetOrigin
()) <
MIN_DISTANCE
)
49
return
;
50
51
ArmaReforgerScripted
game
=
GetGame
();
52
if
(!
game
)
53
return
;
54
55
if
(!
game
.InPlayMode())
56
return
;
57
58
59
// server only
60
if
(RplSession.Mode() ==
RplMode
.Client)
61
return
;
62
63
ResourceName randomResource = PickRandomResource(m_aPrefabs);
64
if
(randomResource ==
string
.Empty)
65
{
66
Print
(
"Resource is null or empty! Cannot spawn!"
,
LogLevel
.ERROR);
67
return
;
68
}
69
70
Resource resource = Resource.Load(randomResource);
71
if
(!resource)
72
return
;
73
74
ref
EntitySpawnParams
params
=
new
EntitySpawnParams
();
75
params
.TransformMode = ETransformMode.WORLD;
76
m_owner
.
GetTransform
(
params
.Transform);
77
78
m_pSpawnedEntity =
game
.SpawnEntityPrefab(resource,
m_owner
.
GetWorld
(),
params
);
79
}
80
81
//------------------------------------------------------------------------------------------------
82
// constructor
86
void
SCR_VehicleSpawner(IEntityComponentSource src,
IEntity
ent,
IEntity
parent)
87
{
88
}
89
90
//------------------------------------------------------------------------------------------------
91
// destructor
92
void
~SCR_VehicleSpawner()
93
{
94
// server only
95
if
(RplSession.Mode() ==
RplMode
.Client)
96
return
;
97
98
if
(m_pSpawnedEntity)
99
delete
m_pSpawnedEntity;
100
101
m_pSpawnedEntity = null;
102
}
103
}
game
ref DSGameConfig game
Definition
DSConfig.c:81
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
RplMode
RplMode
Mode of replication.
Definition
RplMode.c:9
m_bSpawned
bool m_bSpawned
Definition
SCR_AmbientPatrolSpawnPointComponent.c:44
m_owner
IEntity m_owner
Definition
SCR_CharacterRegistrationComponent.c:10
EntityEditorProps
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
Definition
SCR_CompassComponent.c:10
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
MIN_DISTANCE
SCR_VehicleSpawnerClass MIN_DISTANCE
IEntity
enum EVehicleType IEntity
IEntity
Definition
IEntity.c:13
IEntity::GetOrigin
proto external vector GetOrigin()
IEntity::GetWorld
proto external BaseWorld GetWorld()
IEntity::GetTransform
proto external void GetTransform(out vector mat[])
SCR_VehicleSpawnerClass
Definition
SCR_VehicleSpawner.c:3
ScriptComponentClass
Definition
ScriptComponentClass.c:8
ScriptComponent
Definition
ScriptComponent.c:24
UIWidgets
Definition
attributes.c:40
EntitySpawnParams
void EntitySpawnParams()
Definition
gameLib.c:130
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
OnPostInit
@ OnPostInit
Definition
SndComponentCallbacks.c:15
scripts
Game
Components
SCR_VehicleSpawner.c
Generated by
1.17.0