Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
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
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
23
25 {
27 }
28
33
38 //==============================================
39 // SetcharacterID
40 //==============================================
41 void SetCharacterID(int char_id)
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 {
143 return -1;
144 }
145
146 if ( m_CharacterId + 1 < count )
147 {
148 return m_CharacterId + 1;
149 }
150 else
151 {
152 return -1;
153 }
154 }
155
156 //==============================================
157 // GetPrevCharacterID
158 //==============================================
160 {
161 int count = m_CharacterDta.GetCharactersCount();
162
163 if ( count == 0 )
164 {
165 return -1;
166 }
167
168 if ( m_CharacterId > -1 )
169 {
170 return m_CharacterId - 1;
171 }
172
173 return count - 1;
174 }
175
176 //==============================================
177 // CreateNewCharacterRandom
178 //==============================================
180 {
181 // Select random gender
183
184 // Select random character skin (class name)
185 string char_name_random = m_Characters[GetCharacterGender()].GetRandomElement();
186
187 // Create new character
188 CreateNewCharacterByName( char_name_random );
189 }
190
191 //==============================================
192 // CreateNewCharacterById
193 //==============================================
194 void CreateNewCharacterById( int character_id )
195 {
196 if ( character_id == GameConstants.DEFAULT_CHARACTER_MENU_ID )
197 {
199 }
200 else
201 {
203 }
204 }
205
206 //==============================================
207 // CreateNewCharacterByName
208 //==============================================
209 void CreateNewCharacterByName( string character_name, bool randomize_equip = true )
210 {
211 m_CharacterType = character_name;
212 g_Game.GetMenuDefaultCharacterData().SetCharacterType(m_CharacterType);
213 if (randomize_equip)
214 g_Game.GetMenuDefaultCharacterData().GenerateRandomEquip();
215
217 }
218
220 {
222 //m_CharacterDta.RequestGetDefaultCharacterData();
223 m_CharacterType = g_Game.GetMenuDefaultCharacterData().GetCharacterType();
224 if (m_CharacterType != "")
225 {
227 }
228
230 {
231 m_CharacterObj.PlaceOnSurface();
232 m_CharacterObj.SetPosition(m_CharacterPos);
233 m_CharacterObj.SetOrientation(m_CharacterRot);
234 }
235 else
236 {
237 string default_name = Widget.TranslateString( GameConstants.DEFAULT_CHARACTER_NAME );
239 //m_CharacterDta.SetCharacterName(GameConstants.DEFAULT_CHARACTER_MENU_ID, default_name);
240 g_Game.GetMenuDefaultCharacterData().SetCharacterName(GameConstants.DEFAULT_CHARACTER_NAME);
241 }
242 }
243
244 void GetLastPlayedServer(int characterID, out string address, out string name, out int port)
245 {
246 m_CharacterDta.GetLastServerAddress(characterID,address);
247 port = m_CharacterDta.GetLastServerPort(characterID);
248 m_CharacterDta.GetLastServerName(characterID,name);
249 }
250
251 void GetLastPlayedServerEx(int characterID, out string address, out string name, out int port, out int steamQueryPort)
252 {
253 steamQueryPort = m_CharacterDta.GetLastSteamQueryPort(characterID);
254 GetLastPlayedServer(characterID, address, name, port);
255 }
256
257 //==============================================
258 // CreateNewCharacter
259 //==============================================
261 {
262 // Unload old character (if exist)
264
265 // Create Character
267
268 if (m_CharacterObj)
269 {
270 m_CharacterObj.PlaceOnSurface();
271 m_CharacterObj.SetOrientation(m_CharacterRot);
272 g_Game.GetMenuDefaultCharacterData().EquipDefaultCharacter(m_CharacterObj);
273 }
274
275 //Create New Random Character
276 SetupPlayerName( true );
277 }
278
280 /*void EquipNewCharacter()
281 {
282 int slot_ID;
283 string attachment_type;
284 for (int i = 0; i < DefaultCharacterCreationMethods.GetAttachmentSlotsArray().Count(); i++)
285 {
286 slot_ID = DefaultCharacterCreationMethods.GetAttachmentSlotsArray().Get(i);
287 if (DefaultCharacterCreationMethods.GetConfigArrayCountFromSlotID(slot_ID) > 0)
288 {
289 attachment_type = DefaultCharacterCreationMethods.GetConfigAttachmentTypes(slot_ID).GetRandomElement();
290 if (attachment_type != "")
291 SetAttachment(attachment_type,slot_ID);
292 }
293 }
294 }*/
295
296 //==============================================
297 // LoadCharacterData
298 //==============================================
299 void LoadCharacterData(vector char_pos, vector char_rot, bool default_char = false)
300 {
301 m_CharacterDta = g_Game.GetMenuData();
302 m_CharacterPos = char_pos;
303 m_CharacterRot = char_rot;
304
305 if (!default_char && m_CharacterDta.GetLastPlayedCharacter() > -1 )
306 {
307 m_CharacterId = m_CharacterDta.GetLastPlayedCharacter();
308 string characterName = g_Game.GetPlayerGameName();
309 m_CharacterDta.GetCharacterName(m_CharacterId, characterName);
310 g_Game.SetPlayerGameName(characterName);
311 }
312
313 // Load all avalible options for character creation; mostly legacy stuff
314 g_Game.ConfigGetTextArray("cfgCharacterCreation" + " gender", m_CharGenderList);
315 g_Game.ConfigGetTextArray("cfgCharacterCreation" + " top", m_CharShirtList);
316 g_Game.ConfigGetTextArray("cfgCharacterCreation" + " bottom", m_CharPantsList);
317 g_Game.ConfigGetTextArray("cfgCharacterCreation" + " shoe", m_CharShoesList);
318
319 // Init character table
320 m_Characters.Clear();
321 m_Characters.Insert( ECharGender.Male, new array<string> );
322 m_Characters.Insert( ECharGender.Female, new array<string> );
323
324 // Sort character by Gender
325 TStringArray characters = g_Game.ListAvailableCharacters();
326 for (int i = 0; i < characters.Count(); i++)
327 {
328 string char_cfg_name = characters.Get(i);
329 if ( g_Game.IsKindOf(char_cfg_name, "SurvivorMale_Base") )
330 {
331 m_Characters[ECharGender.Male].Insert( char_cfg_name );
332 }
333 else
334 {
335 m_Characters[ECharGender.Female].Insert( char_cfg_name );
336 }
337 }
338
339 CreateNewCharacterById(m_CharacterId/*, m_CharacterPos, m_CharacterRot*/);
340
341 if (GetCharacterObj() )
342 {
343 if ( GetCharacterObj().IsMale() )
345 else
347 }
348 }
349
350 //-------------------------
351 // CharacterUnload
352 //-------------------------
353 protected void CharacterUnload()
354 {
355 if ( m_CharacterObj )
356 {
357 g_Game.ObjectDelete(m_CharacterObj);
358 m_CharacterObj = NULL;
359 }
360 }
361
362 //-------------------------
363 // CharacterLoad
364 //-------------------------
365 protected void CharacterLoad( int character_id, vector char_pos, vector char_rot )
366 {
367 if ( character_id == -1 )
368 {
369 Error("IntroSceneCharacter->CharacterLoad: character_id = "+ character_id +" Cant Load Character!!!");
370 return;
371 }
372
374
375 SetCharacterID( character_id );
376
377 m_CharacterObj = PlayerBase.Cast( m_CharacterDta.CreateCharacterPerson( character_id ) );
378
379 if ( m_CharacterObj )
380 {
381
382 m_CharacterObj.PlaceOnSurface();
383 m_CharacterObj.SetPosition(char_pos);
384 m_CharacterObj.SetOrientation(char_rot);
385 }
386 }
387
388 //-------------------------
389 // SetupPlayerName
390 //-------------------------
391 protected void SetupPlayerName( bool new_name )
392 {
394
395#ifdef PLATFORM_CONSOLE
396 BiosUserManager user_manager = g_Game.GetUserManager();
397 if( user_manager )
398 {
399 BiosUser user = user_manager.GetSelectedUser();
400 if( user )
401 {
402 name = user.GetName();
403 }
404 }
405#else
406 if ( !new_name )
407 {
408 m_CharacterDta.GetCharacterName(m_CharacterId, name);
409 }
410#endif
411
412 g_Game.SetPlayerGameName(name);
413 }
414
415 //==============================================
416 // SetAttachment
417 //==============================================
418 void SetAttachment(string type, int slot)
419 {
420 if ( !m_CharacterObj )
421 {
422 return;
423 }
424
425 g_Game.ObjectDelete(m_CharacterObj.GetInventory().FindAttachment(slot));
426
427 EntityAI entity = EntityAI.Cast( g_Game.CreateObjectEx(type, m_CharacterObj.GetPosition(), ECE_PLACE_ON_SURFACE) );
428
429 if (entity)
430 {
431 m_CharacterObj.LocalTakeEntityAsAttachmentEx(entity, slot);
432 }
433 }
434
435 string GetCharacterNameById(int char_id )
436 {
437 string character_name;
439 {
440 character_name = g_Game.GetMenuDefaultCharacterData().GetCharacterName();
441 }
442 else
443 {
444 m_CharacterDta.GetCharacterName(char_id, character_name);
445 }
446 return character_name;
447 }
448
450 {
451 string character_name;
452 if (IsDefaultCharacter())
453 {
454 character_name = g_Game.GetMenuDefaultCharacterData().GetCharacterName();
455 }
456 else
457 {
458 m_CharacterDta.GetCharacterName(m_CharacterId, character_name);
459 }
460 return character_name;
461 }
462
463 //==============================================
464 // SaveCharName
465 //==============================================
466 void SaveCharName( string name )
467 {
468 if (IsDefaultCharacter())
469 {
470 g_Game.GetMenuDefaultCharacterData().SetCharacterName(name);
471 }
472 else
473 {
474 m_CharacterDta.SetCharacterName(m_CharacterId, name);
475 }
476 m_CharacterDta.SaveCharactersLocal();
477 }
478
479 //==============================================
480 // SaveDefaultCharacter
481 //==============================================
483 {
484 //if (m_CharacterObj)
485 {
486 m_CharacterDta.RequestSetDefaultCharacterData();
487 }
488 }
489}
const int ECE_PLACE_ON_SURFACE
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
proto native owned string GetName()
proto native BiosUser GetSelectedUser()
Returns the currently selected user.
TODO doc.
Definition enscript.c:118
ref TStringArray m_CharShoesList
MenuData m_CharacterDta
void CreateDefaultCharacter()
void SetAttachment(string type, int slot)
bool IsCharacterFemale()
void SetupPlayerName(bool new_name)
int GetPrevCharacterID()
bool IsDefaultCharacter()
vector m_CharacterPos
TStringArray GetCharGenderList()
void CreateNewCharacter()
void SetToDefaultCharacter()
int GetNextCharacterID()
vector GetPosition()
ref TStringArray m_CharShirtList
TStringArray GetCharList(ECharGender gender)
ref TStringArray m_CharPantsList
void SaveCharName(string name)
void LoadCharacterData(vector char_pos, vector char_rot, bool default_char=false)
Generates random equip for the new IntroSceneCharacter, whatever is defined in 'cfgCharacterCreation'...
void CreateNewCharacterByName(string character_name, bool randomize_equip=true)
TStringArray GetCharShirtsList()
string GetCharacterName()
ECharGender m_CharGender
TStringArray GetCharPantsList()
ref TStringArray m_CharGenderList
ref map< ECharGender, ref array< string > > m_Characters
void SaveDefaultCharacter()
PlayerBase m_CharacterObj
void SetCharacterID(int char_id)
TStringArray GetCharShoesList()
vector m_CharacterRot
ECharGender GetCharacterGender()
string GetCharacterNameById(int char_id)
string m_CharacterType
void CharacterUnload()
void CreateNewCharacterRandom()
void GetLastPlayedServer(int characterID, out string address, out string name, out int port)
void GetLastPlayedServerEx(int characterID, out string address, out string name, out int port, out int steamQueryPort)
void SetCharacterGender(ECharGender gender)
void ~IntroSceneCharacter()
void CharacterLoad(int character_id, vector char_pos, vector char_rot)
PlayerBase GetCharacterObj()
void CreateNewCharacterById(int character_id)
void IntroSceneCharacter()
Definition enmath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame g_Game
Definition dayzgame.c:3942
ECharGender
Definition echargender.c:2
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
const string DEFAULT_CHARACTER_NAME
Definition constants.c:985
const int DEFAULT_CHARACTER_MENU_ID
Definition constants.c:987
array< string > TStringArray
Definition enscript.c:712
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].