DayZ 1.24
Loading...
Searching...
No Matches
TrapSpawnBase Class Reference

Private Member Functions

void Trap_FishNet ()
 
override void OnVariablesSynchronized ()
 
override void SpawnCatch ()
 
override bool IsPlaceableAtPosition (vector position)
 
override bool CanReceiveAttachment (EntityAI attachment, int slotId)
 
override void OnPlacementComplete (Man player, vector position="0 0 0", vector orientation="0 0 0")
 
override bool IsDeployable ()
 
override string GetDeploySoundset ()
 
override string GetLoopDeploySoundset ()
 
void Trap_RabbitSnare ()
 
override bool CanBePlaced (Man player, vector position)
 
override void OnVariablesSynchronized ()
 
override void SetupTrap ()
 
override void SpawnCatch ()
 
override void OnPlacementComplete (Man player, vector position="0 0 0", vector orientation="0 0 0")
 
override bool IsDeployable ()
 
override string GetDeploySoundset ()
 
override string GetLoopDeploySoundset ()
 
override void SetActions ()
 
override void AlignCatch (ItemBase obj, string catch_name)
 
void Trap_SmallFish ()
 
override void OnVariablesSynchronized ()
 
override void SpawnCatch ()
 
override bool IsPlaceableAtPosition (vector position)
 
override bool CanReceiveAttachment (EntityAI attachment, int slotId)
 

Detailed Description

Definition at line 1 of file Trap_FishNet.c.

Member Function Documentation

◆ AlignCatch()

override void TrapSpawnBase::AlignCatch ( ItemBase obj,
string catch_name )
inlineprivate

Definition at line 187 of file Trap_RabbitSnare.c.

188 {
189 if (catch_name == "Animal_LepusEuropaeus")
190 {
191 obj.SetOrientation(GetOrientation());
192
193 vector forward_vec = GetDirection();
194 vector side_vec = forward_vec.Perpend() * -0.22;
195 forward_vec = forward_vec * -0.3;
196
197 vector chatch_pos = obj.GetPosition() + forward_vec + side_vec;
198 obj.SetPosition(chatch_pos);
199 }
200 }
vector GetOrientation()

References GetOrientation().

◆ CanBePlaced()

override bool TrapSpawnBase::CanBePlaced ( Man player,
vector position )
inlineprivate

Definition at line 31 of file Trap_RabbitSnare.c.

32 {
34 return true;
35
36 int liquidType;
37 string surfaceType;
38 g_Game.SurfaceUnderObject(PlayerBase.Cast(player).GetHologramLocal().GetProjectionEntity(), surfaceType, liquidType);
39
40 return g_Game.IsSurfaceDigable(surfaceType);
41 }
DayZGame g_Game
Definition DayZGame.c:3528
bool m_IsBeingPlaced
Definition ItemBase.c:4731

References g_Game, and m_IsBeingPlaced.

◆ CanReceiveAttachment() [1/2]

override bool TrapSpawnBase::CanReceiveAttachment ( EntityAI attachment,
int slotId )
inlineprivate

Definition at line 94 of file Trap_FishNet.c.

95 {
96 if (!attachment.IsInherited(Worm))
97 return false;
98
99 return super.CanReceiveAttachment(attachment, slotId);
100 }

◆ CanReceiveAttachment() [2/2]

override bool TrapSpawnBase::CanReceiveAttachment ( EntityAI attachment,
int slotId )
inlineprivate

Definition at line 90 of file Trap_SmallFish.c.

91 {
92 if (!attachment.IsInherited(Worm))
93 return false;
94
95 return super.CanReceiveAttachment(attachment, slotId);
96 }

◆ GetDeploySoundset() [1/2]

override string TrapSpawnBase::GetDeploySoundset ( )
inlineprivate

Definition at line 168 of file Trap_FishNet.c.

169 {
170 return "placeFishNetTrap_SoundSet";
171 }

◆ GetDeploySoundset() [2/2]

override string TrapSpawnBase::GetDeploySoundset ( )
inlineprivate

Definition at line 162 of file Trap_RabbitSnare.c.

163 {
164 return "placeRabbitSnareTrap_SoundSet";
165 }

◆ GetLoopDeploySoundset() [1/2]

override string TrapSpawnBase::GetLoopDeploySoundset ( )
inlineprivate

Definition at line 173 of file Trap_FishNet.c.

174 {
175 return "fishnet_deploy_SoundSet";
176 }

Referenced by ItemBase::PlayDeployLoopSound().

◆ GetLoopDeploySoundset() [2/2]

override string TrapSpawnBase::GetLoopDeploySoundset ( )
inlineprivate

Definition at line 167 of file Trap_RabbitSnare.c.

168 {
169 return "rabbitsnare_deploy_SoundSet";
170 }

◆ IsDeployable() [1/2]

override bool TrapSpawnBase::IsDeployable ( )
inlineprivate

Definition at line 163 of file Trap_FishNet.c.

164 {
165 return true;
166 }

◆ IsDeployable() [2/2]

override bool TrapSpawnBase::IsDeployable ( )
inlineprivate

Definition at line 157 of file Trap_RabbitSnare.c.

158 {
159 return true;
160 }

◆ IsPlaceableAtPosition() [1/2]

override bool TrapSpawnBase::IsPlaceableAtPosition ( vector position)
inlineprivate

Definition at line 89 of file Trap_FishNet.c.

90 {
91 return IsSurfaceWater(position);
92 }

Referenced by ItemBase::CanBePlaced(), and ItemBase::IsPlaceable().

◆ IsPlaceableAtPosition() [2/2]

override bool TrapSpawnBase::IsPlaceableAtPosition ( vector position)
inlineprivate

Definition at line 85 of file Trap_SmallFish.c.

86 {
87 return IsSurfaceWater(position);
88 }

◆ OnPlacementComplete() [1/2]

override void TrapSpawnBase::OnPlacementComplete ( Man player,
vector position = "0 0 0",
vector orientation = "0 0 0" )
inlineprivate

Definition at line 156 of file Trap_FishNet.c.

157 {
158 super.OnPlacementComplete(player, position, orientation);
159
160 SetIsPlaceSound(true);
161 }
void SetIsPlaceSound(bool is_place_sound)
Definition ItemBase.c:8962

References SetIsPlaceSound().

◆ OnPlacementComplete() [2/2]

override void TrapSpawnBase::OnPlacementComplete ( Man player,
vector position = "0 0 0",
vector orientation = "0 0 0" )
inlineprivate

Definition at line 150 of file Trap_RabbitSnare.c.

151 {
152 super.OnPlacementComplete(player, position, orientation);
153 SetOrientation(orientation);
154 SetIsPlaceSound(true);
155 }

References SetIsPlaceSound().

◆ OnVariablesSynchronized() [1/3]

override void TrapSpawnBase::OnVariablesSynchronized ( )
inlineprivate

Definition at line 29 of file Trap_FishNet.c.

30 {
31 super.OnVariablesSynchronized();
32
33 if (IsPlaceSound())
35 }
void PlayPlaceSound()
Definition ItemBase.c:9027
bool IsPlaceSound()
Definition ItemBase.c:8967

References IsPlaceSound(), and PlayPlaceSound().

◆ OnVariablesSynchronized() [2/3]

override void TrapSpawnBase::OnVariablesSynchronized ( )
inlineprivate

Definition at line 43 of file Trap_RabbitSnare.c.

44 {
45 super.OnVariablesSynchronized();
46
47 if (IsPlaceSound())
49 }

References IsPlaceSound(), and PlayPlaceSound().

◆ OnVariablesSynchronized() [3/3]

override void TrapSpawnBase::OnVariablesSynchronized ( )
inlineprivate

Definition at line 28 of file Trap_SmallFish.c.

29 {
30 super.OnVariablesSynchronized();
31
32 if (IsPlaceSound())
34 }

References IsPlaceSound(), and PlayPlaceSound().

◆ SetActions()

override void TrapSpawnBase::SetActions ( )
inlineprivate

Definition at line 172 of file Trap_RabbitSnare.c.

173 {
174 super.SetActions();
175
176 // We remove the hunting trap deploy action in order to all advanced placement
178
180 AddAction(ActionDeployObject);
181 }
void AddAction(typename actionName)
void RemoveAction(typename actionName)

References AddAction(), and RemoveAction().

◆ SetupTrap()

override void TrapSpawnBase::SetupTrap ( )
inlineprivate

Definition at line 51 of file Trap_RabbitSnare.c.

52 {
53 if (GetGame().IsServer())
54 {
55 if (GetHierarchyRootPlayer().CanDropEntity(this))
56 {
57 if (IsRuined())
58 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
59 else
60 {
61 PlayerBase owner_player = PlayerBase.Cast(GetHierarchyRootPlayer());
62
63 //GetDirection
64 vector trapPos = owner_player.GetDirection();
65 trapPos[1] = 0;
66 SetPosition(owner_player.GetPosition() + trapPos);
67
68 SetActive();
69
70 SetOrientation(owner_player.GetOrientation());
71 }
72 }
73 }
74 }
void SetActive()
Definition TrapBase.c:409
proto native CGame GetGame()
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition Effect.c:420

References GetGame(), SetActive(), and SetPosition().

◆ SpawnCatch() [1/3]

override void TrapSpawnBase::SpawnCatch ( )
inlineprivate

Definition at line 41 of file Trap_FishNet.c.

42 {
43 super.SpawnCatch();
44
45 if (m_CanCatch)
46 {
48 vector pos = GetPosition();
49
50 ItemBase catch;
51 // Select catch type depending on water type ( FRESH VS SALT )
52 if (GetGame().SurfaceIsSea(pos[0], pos[2]))
53 catches = m_CatchesSea;
54 else if (GetGame().SurfaceIsPond(pos[0], pos[2]))
55 catches = m_CatchesPond;
56
57 if (catches && catches.Count() > 0)
58 {
59 // select random object from catches
60 int count = catches.Count() - 1;
62
63 if (Math.RandomFloat(0, 100) < m_FinalCatchProb)
64 {
65 catch = ItemBase.Cast(GetGame().CreateObjectEx(catches.GetKeyByIndex(randomCatchIndex), m_PreyPos, ECE_NONE));
66
67 // Set the quantity of caught prey
68 if (catch)
69 CatchSetQuant(catch);
70 }
71
72 // We change the trap state and visuals
73 SetUsed();
74
75 // We remove the bait from this trap
76 if (m_Bait)
77 m_Bait.Delete();
78 }
79
80 // Deal damage to trap
81 AddDefect();
82 }
83 }
const int ECE_NONE
void AddDefect()
Definition TrapBase.c:403
class JsonUndergroundAreaTriggerData GetPosition
Definition EnMath.c:7
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].

References AddDefect(), ECE_NONE, GetGame(), GetPosition, Math::RandomFloat(), and Math::RandomInt().

◆ SpawnCatch() [2/3]

override void TrapSpawnBase::SpawnCatch ( )
inlineprivate

Definition at line 76 of file Trap_RabbitSnare.c.

77 {
78 super.SpawnCatch();
79
80 if (m_CanCatch)
81 {
83
84 // We read the relevant catch map
85 ItemBase catch;
86 catches = m_CatchesGroundAnimal;
87
88 // The catch map contains data
89 if (catches && catches.Count() > 0)
90 {
91 // select random object from catches
92 int count = catches.Count() - 1;
94
95 if (Math.RandomFloat(0, 100) < m_FinalCatchProb)
96 {
97 if (m_Bait)
98 {
99 if (m_Bait.IsInherited(Worm))
100 {
101 // We can only catch chicken, so exclude the rabbit
103 catch = ItemBase.Cast(GetGame().CreateObjectEx(catches.GetKeyByIndex(randomCatchIndex), m_PreyPos, ECE_PLACE_ON_SURFACE));
104 }
105 else
106 {
107 // Get the last index, which is the rabbit
109 catch = ItemBase.Cast(GetGame().CreateObjectEx(catches.GetKeyByIndex(randomCatchIndex), m_PreyPos, ECE_PLACE_ON_SURFACE));
110 }
111 }
112 else
113 {
114 // No bait, 50 / 50 rabbit
116 if (randomCatchIndex == 0)
117 {
119 catch = ItemBase.Cast(GetGame().CreateObjectEx(catches.GetKeyByIndex(randomCatchIndex), m_PreyPos, ECE_PLACE_ON_SURFACE));
120 }
121 else
122 {
124 catch = ItemBase.Cast(GetGame().CreateObjectEx(catches.GetKeyByIndex(randomCatchIndex), m_PreyPos, ECE_PLACE_ON_SURFACE));
125 }
126 }
127
128 // We set quantity of prey
129 if (catch)
130 CatchSetQuant(catch);
131 }
132
133 // We update the state
134 SetUsed();
135
136 // We remove the bait from this trap
137 if (m_Bait)
138 m_Bait.Delete();
139 }
140
141 // We damage the trap
142 AddDefect();
143 }
144 }
const int ECE_PLACE_ON_SURFACE
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Definition EnMath.c:54

References AddDefect(), ECE_PLACE_ON_SURFACE, GetGame(), Math::RandomFloat(), Math::RandomInt(), and Math::RandomIntInclusive().

◆ SpawnCatch() [3/3]

override void TrapSpawnBase::SpawnCatch ( )
inlineprivate

Definition at line 36 of file Trap_SmallFish.c.

37 {
38 super.SpawnCatch();
39
40 if (m_CanCatch)
41 {
42 // We get the prey position for spawning
44 vector pos = GetPosition();
45
46 ItemBase catch;
47 // Select catch type depending on water type ( FRESH VS SALT )
48 if (GetGame().SurfaceIsSea(pos[0], pos[2]))
49 catches = m_CatchesSea;
50 else if (GetGame().SurfaceIsPond(pos[0], pos[2]))
51 catches = m_CatchesPond;
52
53 if (catches && catches.Count() > 0)
54 {
55 // select random object from catches
56 int count = catches.Count() - 1;
58
59 if (Math.RandomFloat(0, 100) < m_FinalCatchProb)
60 {
61 catch = ItemBase.Cast(GetGame().CreateObjectEx(catches.GetKeyByIndex(randomCatchIndex), m_PreyPos, ECE_NONE));
62
63 // Set the quantity of caught prey
64 if (catch)
65 CatchSetQuant(catch);
66 }
67
68 // We change the trap state and visuals
69 SetUsed();
70
71 // We remove the bait from this trap
72 if (m_Bait)
73 m_Bait.Delete();
74 }
75
76 // Deal damage to trap
77 AddDefect();
78 }
79 }

References AddDefect(), ECE_NONE, GetGame(), GetPosition, Math::RandomFloat(), and Math::RandomInt().

◆ Trap_FishNet()

void TrapSpawnBase::Trap_FishNet ( )
inlineprivate

Definition at line 3 of file Trap_FishNet.c.

4 {
5 m_DefectRate = 15; //Added damage after trap activation
6
8 m_UpdateWaitTime = 30;
9 m_IsFoldable = true;
10
11 m_MinimalDistanceFromPlayersToCatch = 15;
12
13 m_BaitCatchProb = 85;
14 m_NoBaitCatchProb = 15;
15
16 m_AnimationPhaseSet = "inventory";
17 m_AnimationPhaseTriggered = "placing";
18 m_AnimationPhaseUsed = "triggered";
19
20 m_WaterSurfaceForSetup = true;
21
22 m_CatchesPond = new multiMap<string, float>;
23 m_CatchesPond.Insert("Carp", 1);
24
25 m_CatchesSea = new multiMap<string, float>;
26 m_CatchesSea.Insert("Mackerel", 1);
27 }
string m_AnimationPhaseTriggered
Definition TrapBase.c:34
float m_DefectRate
Definition TrapBase.c:19
string m_AnimationPhaseSet
Definition TrapBase.c:33
float m_InitWaitTime
Definition TrapBase.c:17

References m_AnimationPhaseSet, m_AnimationPhaseTriggered, m_DefectRate, m_InitWaitTime, and Math::RandomFloat().

◆ Trap_RabbitSnare()

void TrapSpawnBase::Trap_RabbitSnare ( )
inlineprivate

Definition at line 3 of file Trap_RabbitSnare.c.

4 {
5 m_DefectRate = 15; //Added damage after trap activation
6
8 m_UpdateWaitTime = 30;
9 m_IsFoldable = true;
10 m_IsUsable = true;
11 m_MinimalDistanceFromPlayersToCatch = 10;
12
13 m_BaitCatchProb = 85;
14 m_NoBaitCatchProb = 15;
15
16 m_AnimationPhaseSet = "inventory";
17 m_AnimationPhaseTriggered = "placing";
18 m_AnimationPhaseUsed = "triggered";
19
20 m_WaterSurfaceForSetup = false;
21
22 m_CatchesGroundAnimal = new multiMap<string, float>;
23 m_CatchesGroundAnimal.Insert("DeadRooster", 1);
24 m_CatchesGroundAnimal.Insert("DeadChicken_White", 1);
25 m_CatchesGroundAnimal.Insert("DeadChicken_Spotted", 1);
26 m_CatchesGroundAnimal.Insert("DeadChicken_Brown", 1);
27 // ALWAYS keep rabbit last as that is how it gets the rabbit in case of rabbit specific bait
28 m_CatchesGroundAnimal.Insert("DeadRabbit", 1);
29 }

References m_AnimationPhaseSet, m_AnimationPhaseTriggered, m_DefectRate, m_InitWaitTime, and Math::RandomInt().

◆ Trap_SmallFish()

void TrapSpawnBase::Trap_SmallFish ( )
inlineprivate

Definition at line 3 of file Trap_SmallFish.c.

4 {
5 m_DefectRate = 15; //Added damage after trap activation
6
8 m_UpdateWaitTime = 30;
9
10 m_AnimationPhaseSet = "inventory";
11 m_AnimationPhaseTriggered = "placing";
12 m_AnimationPhaseUsed = "triggered";
13
14 m_MinimalDistanceFromPlayersToCatch = 15;
15
16 m_BaitCatchProb = 85;
17 m_NoBaitCatchProb = 15;
18
19 m_WaterSurfaceForSetup = true;
20
21 m_CatchesPond = new multiMap<string, float>;
22 m_CatchesPond.Insert("Bitterlings", 1);
23
24 m_CatchesSea = new multiMap<string, float>;
25 m_CatchesSea.Insert("Sardines", 1);
26 }

References m_AnimationPhaseSet, m_AnimationPhaseTriggered, m_DefectRate, m_InitWaitTime, and Math::RandomFloat().


The documentation for this class was generated from the following files: