DayZ 1.24
Loading...
Searching...
No Matches
IntroSceneCharacter.c
Go to the documentation of this file.
1class IntroSceneCharacter extends Managed
2{
3 protected int m_CharacterId;
4 protected string m_CharacterType;
9
10 protected ref TStringArray m_CharGenderList = new TStringArray;
11 protected ref TStringArray m_CharShirtList = new TStringArray; //legacy
12 protected ref TStringArray m_CharPantsList = new TStringArray; //legacy
13 protected ref TStringArray m_CharShoesList = new TStringArray; //legacy
14
16
18
20 {
22 }
23
25 {
27 }
28
30 {
31 return m_CharacterId == GameConstants.DEFAULT_CHARACTER_MENU_ID;
32 }
33
38 //==============================================
39 // SetcharacterID
40 //==============================================
42 {
43 m_CharacterId = char_id;
44 }
45
46 //==============================================
47 // GetCharacterID
48 //==============================================
50 {
51 return m_CharacterId;
52 }
53
54 //==============================================
55 // GetCharacterObj
56 //==============================================
61
62 //==============================================
63 // GetCharGenderList
64 //==============================================
69
70 //==============================================
71 // GetCharGenderList
72 //==============================================
74 {
75 return m_Characters[gender];
76 }
77
78 //==============================================
79 // GetCharShirtsList
80 //==============================================
85
86 //==============================================
87 // GetCharPantsList
88 //==============================================
93
94 //==============================================
95 // GetCharShoesList
96 //==============================================
101
102 //==============================================
103 // SetCharacterGender
104 //==============================================
106 {
107 m_CharGender = gender;
108 }
109
110 //==============================================
111 // IsCharacterFemale
112 //==============================================
114 {
115 return (m_CharGender == ECharGender.Female);
116 }
117
118 //==============================================
119 // SetCharacterGender
120 //==============================================
122 {
123 return m_CharGender;
124 }
125
126 //==============================================
127 // GetPosition
128 //==============================================
130 {
131 return m_CharacterObj.GetPosition();
132 }
133
134 //==============================================
135 // GetNextCharacterID
136 //==============================================
138 {
139 int count = m_CharacterDta.GetCharactersCount();
140
141 if (count == 0)
142 return -1;
143
144 if (m_CharacterId + 1 < count)
145 return m_CharacterId + 1;
146 else
147 return -1;
148 }
149
150 //==============================================
151 // GetPrevCharacterID
152 //==============================================
154 {
155 int count = m_CharacterDta.GetCharactersCount();
156
157 if (count == 0)
158 return -1;
159
160 if (m_CharacterId > -1)
161 return m_CharacterId - 1;
162
163 return count - 1;
164 }
165
166 //==============================================
167 // CreateNewCharacterRandom
168 //==============================================
170 {
171 // Select random gender
173
174 // Select random character skin (class name)
175 string char_name_random = m_Characters[GetCharacterGender()].GetRandomElement();
176
177 // Create new character
179 }
180
181 //==============================================
182 // CreateNewCharacterById
183 //==============================================
185 {
188 else
189 CharacterLoad(character_id, m_CharacterPos, m_CharacterRot);
190 }
191
192 //==============================================
193 // CreateNewCharacterByName
194 //==============================================
196 {
197 m_CharacterType = character_name;
198 GetGame().GetMenuDefaultCharacterData().SetCharacterType(m_CharacterType);
199 if (randomize_equip)
200 GetGame().GetMenuDefaultCharacterData().GenerateRandomEquip();
201
203 }
204
206 {
208 //m_CharacterDta.RequestGetDefaultCharacterData();
209 m_CharacterType = GetGame().GetMenuDefaultCharacterData().GetCharacterType();
210 if (m_CharacterType != "")
212
213 if (m_CharacterObj)
214 {
215 m_CharacterObj.PlaceOnSurface();
216 m_CharacterObj.SetPosition(m_CharacterPos);
217 m_CharacterObj.SetOrientation(m_CharacterRot);
218 }
219 else
220 {
223 //m_CharacterDta.SetCharacterName(GameConstants.DEFAULT_CHARACTER_MENU_ID, default_name);
224 GetGame().GetMenuDefaultCharacterData().SetCharacterName(GameConstants.DEFAULT_CHARACTER_NAME);
225 }
226 }
227
228 void GetLastPlayedServer(int characterID, out string address, out string name, out int port)
229 {
231 port = m_CharacterDta.GetLastServerPort(characterID);
232 m_CharacterDta.GetLastServerName(characterID, name);
233 }
234 //==============================================
235 // CreateNewCharacter
236 //==============================================
238 {
239 // Unload old character (if exist)
241
242 // Create Character
243 m_CharacterObj = PlayerBase.Cast(g_Game.CreateObjectEx(m_CharacterType, m_CharacterPos, ECE_PLACE_ON_SURFACE));
244
245 if (m_CharacterObj)
246 {
247 m_CharacterObj.PlaceOnSurface();
248 m_CharacterObj.SetOrientation(m_CharacterRot);
249 GetGame().GetMenuDefaultCharacterData().EquipDefaultCharacter(m_CharacterObj);
250 }
251
252 //Create New Random Character
253 SetupPlayerName(true);
254 }
255
257 /*void EquipNewCharacter()
258 {
259 int slot_ID;
260 string attachment_type;
261 for (int i = 0; i < DefaultCharacterCreationMethods.GetAttachmentSlotsArray().Count(); i++)
262 {
263 slot_ID = DefaultCharacterCreationMethods.GetAttachmentSlotsArray().Get(i);
264 if (DefaultCharacterCreationMethods.GetConfigArrayCountFromSlotID(slot_ID) > 0)
265 {
266 attachment_type = DefaultCharacterCreationMethods.GetConfigAttachmentTypes(slot_ID).GetRandomElement();
267 if (attachment_type != "")
268 SetAttachment(attachment_type,slot_ID);
269 }
270 }
271 }*/
272
273 //==============================================
274 // LoadCharacterData
275 //==============================================
277 {
278 m_CharacterDta = g_Game.GetMenuData();
279 m_CharacterPos = char_pos;
280 m_CharacterRot = char_rot;
281
282 if (!default_char && m_CharacterDta.GetLastPlayedCharacter() > -1)
283 {
284 m_CharacterId = m_CharacterDta.GetLastPlayedCharacter();
285 m_CharacterDta.GetCharacterName(m_CharacterId, g_Game.GetPlayerGameName());
286 }
287
288 // Load all avalible options for character creation; mostly legacy stuff
289 g_Game.ConfigGetTextArray("cfgCharacterCreation" + " gender", m_CharGenderList);
290 g_Game.ConfigGetTextArray("cfgCharacterCreation" + " top", m_CharShirtList);
291 g_Game.ConfigGetTextArray("cfgCharacterCreation" + " bottom", m_CharPantsList);
292 g_Game.ConfigGetTextArray("cfgCharacterCreation" + " shoe", m_CharShoesList);
293
294 // Init character table
295 m_Characters.Clear();
296 m_Characters.Insert(ECharGender.Male, new array<string>);
297 m_Characters.Insert(ECharGender.Female, new array<string>);
298
299 // Sort character by Gender
300 TStringArray characters = GetGame().ListAvailableCharacters();
301 for (int i = 0; i < characters.Count(); i++)
302 {
303 string char_cfg_name = characters.Get(i);
304 if (GetGame().IsKindOf(char_cfg_name, "SurvivorMale_Base"))
305 m_Characters[ECharGender.Male].Insert(char_cfg_name);
306 else
307 m_Characters[ECharGender.Female].Insert(char_cfg_name);
308 }
309
310 CreateNewCharacterById(m_CharacterId/*, m_CharacterPos, m_CharacterRot*/);
311
312 if (GetCharacterObj())
313 {
314 if (GetCharacterObj().IsMale())
316 else
318 }
319 }
320
321 //-------------------------
322 // CharacterUnload
323 //-------------------------
324 protected void CharacterUnload()
325 {
326 if (m_CharacterObj)
327 {
328 g_Game.ObjectDelete(m_CharacterObj);
329 m_CharacterObj = NULL;
330 }
331 }
332
333 //-------------------------
334 // CharacterLoad
335 //-------------------------
337 {
338 if (character_id == -1)
339 {
340 Error("IntroSceneCharacter->CharacterLoad: character_id = " + character_id + " Cant Load Character!!!");
341 return;
342 }
343
345
347
348 m_CharacterObj = PlayerBase.Cast(m_CharacterDta.CreateCharacterPerson(character_id));
349
350 if (m_CharacterObj)
351 {
352
353 m_CharacterObj.PlaceOnSurface();
354 m_CharacterObj.SetPosition(char_pos);
355 m_CharacterObj.SetOrientation(char_rot);
356 }
357 }
358
359 //-------------------------
360 // SetupPlayerName
361 //-------------------------
362 protected void SetupPlayerName(bool new_name)
363 {
365
366#ifdef PLATFORM_CONSOLE
367 BiosUserManager user_manager = GetGame().GetUserManager();
368 if (user_manager)
369 {
370 BiosUser user = user_manager.GetSelectedUser();
371 if (user)
372 name = user.GetName();
373 }
374#else
375 if (!new_name)
376 m_CharacterDta.GetCharacterName(m_CharacterId, name);
377#endif
378
379 g_Game.SetPlayerGameName(name);
380 }
381
382 //==============================================
383 // SetAttachment
384 //==============================================
385 void SetAttachment(string type, int slot)
386 {
387 if (!m_CharacterObj)
388 return;
389
390 g_Game.ObjectDelete(m_CharacterObj.GetInventory().FindAttachment(slot));
391
392 EntityAI entity = EntityAI.Cast(g_Game.CreateObjectEx(type, m_CharacterObj.GetPosition(), ECE_PLACE_ON_SURFACE));
393
394 if (entity)
395 m_CharacterObj.LocalTakeEntityAsAttachmentEx(entity, slot);
396 }
397
399 {
400 string character_name;
402 character_name = GetGame().GetMenuDefaultCharacterData().GetCharacterName();
403 else
404 m_CharacterDta.GetCharacterName(char_id, character_name);
405 return character_name;
406 }
407
409 {
410 string character_name;
411 if (IsDefaultCharacter())
412 character_name = GetGame().GetMenuDefaultCharacterData().GetCharacterName();
413 else
414 m_CharacterDta.GetCharacterName(m_CharacterId, character_name);
415 return character_name;
416 }
417
418 //==============================================
419 // SaveCharName
420 //==============================================
421 void SaveCharName(string name)
422 {
423 if (IsDefaultCharacter())
424 GetGame().GetMenuDefaultCharacterData().SetCharacterName(name);
425 else
426 m_CharacterDta.SetCharacterName(m_CharacterId, name);
427 m_CharacterDta.SaveCharactersLocal();
428 }
429
430 //==============================================
431 // SaveDefaultCharacter
432 //==============================================
434 {
435 //if (m_CharacterObj)
436 {
437 m_CharacterDta.RequestSetDefaultCharacterData();
438 }
439 }
440}
const int ECE_PLACE_ON_SURFACE
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Definition DayZGame.c:3528
ECharGender
Definition ECharGender.c:2
TODO doc.
Definition EnScript.c:118
PlayerBase GetCharacterObj()
ref TStringArray m_CharGenderList
void SetAttachment(string type, int slot)
string m_CharacterType
string GetCharacterName()
void CreateDefaultCharacter()
TStringArray GetCharShoesList()
vector GetPosition()
void CreateNewCharacter()
void SetCharacterGender(ECharGender gender)
void SetCharacterID(int char_id)
void CharacterUnload()
int GetPrevCharacterID()
void CreateNewCharacterById(int character_id)
int GetNextCharacterID()
void CharacterLoad(int character_id, vector char_pos, vector char_rot)
void GetLastPlayedServer(int characterID, out string address, out string name, out int port)
TStringArray GetCharShirtsList()
void CreateNewCharacterRandom()
void SaveCharName(string name)
void SetToDefaultCharacter()
ref TStringArray m_CharShirtList
bool IsDefaultCharacter()
void SetupPlayerName(bool new_name)
ref TStringArray m_CharPantsList
vector m_CharacterPos
PlayerBase m_CharacterObj
MenuData m_CharacterDta
void SaveDefaultCharacter()
void CreateNewCharacterByName(string character_name, bool randomize_equip=true)
TStringArray GetCharGenderList()
TStringArray GetCharPantsList()
TStringArray GetCharList(ECharGender gender)
void IntroSceneCharacter()
vector m_CharacterRot
ref TStringArray m_CharShoesList
string GetCharacterNameById(int char_id)
void LoadCharacterData(vector char_pos, vector char_rot, bool default_char=false)
Generates random equip for the new IntroSceneCharacter, whatever is defined in 'cfgCharacterCreation'...
bool IsCharacterFemale()
ECharGender GetCharacterGender()
ECharGender m_CharGender
void ~IntroSceneCharacter()
Definition EnMath.c:7
proto native int GetLastPlayedCharacter()
proto void GetCharacterName(int index, out string name)
proto native int GetLastServerPort(int index)
proto void GetLastServerAddress(int index, out string address)
proto native int GetCharactersCount()
proto void RequestSetDefaultCharacterData()
proto void GetLastServerName(int index, out string address)
proto native Man CreateCharacterPerson(int index)
Return Character person or null if character initialization failed (inventory load,...
proto native void SaveCharactersLocal()
Saves characters menu data to file.
proto native void SetCharacterName(int index, string newName)
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
const int DEFAULT_CHARACTER_MENU_ID
Definition constants.c:840
const string DEFAULT_CHARACTER_NAME
Definition constants.c:838
array< string > TStringArray
Definition EnScript.c:666
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].