Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
missionserver.c
Go to the documentation of this file.
1
2//: string uid of the player
4
5class MissionServer extends MissionBase
6{
7 ref array<Man> m_Players;
8 ref array<ref CorpseData> m_DeadPlayersArray;
9 ref map<PlayerBase, ref LogoutInfo> m_LogoutPlayers;
10 ref map<PlayerBase, ref LogoutInfo> m_NewLogoutPlayers;
11 ref RainProcurementHandler m_RainProcHandler;
12 const int SCHEDULER_PLAYERS_PER_TICK = 5;
13 int m_currentPlayer;
14 int m_RespawnMode;
15
16 // -----------------------
17 // ARTILLERY SOUNDS SETUP
18 // -----------------------
19 private float m_ArtyBarrageTimer = 0; // This is not to be edited in Init.c this is just to increment time
20
21 // Variables to be modified in Init.c
22 protected bool m_PlayArty = false; // Toggle if Off map artillery sounds are played
23 protected float m_ArtyDelay = 0; // Set how much time there is between two barrages (in seconds)
24 protected int m_MinSimultaneousStrikes = 0; // The MIN of simultaneous shots on the map (Will be clamped between 1 and max shots)
25 protected int m_MaxSimultaneousStrikes = 0; // The MAX of simultaneous shots on the map (Will be clamped between 1 and max amount of coords)
26 protected ref array<vector> m_FiringPos; // Where we should fire from. On Init set the relevant data
27
28 //All Chernarus firing coordinates
29 protected const ref array<vector> CHERNARUS_STRIKE_POS =
30 {
31 "-500.00 165.00 5231.69",
32 "-500.00 300.00 9934.41",
33 "10406.86 192.00 15860.00",
34 "4811.75 370.00 15860.00",
35 "-500.00 453.00 15860.00"
36 };
37
38 //All livonia firing coordinates
39 protected const ref array<vector> LIVONIA_STRIKE_POS =
40 {
41 "7440.00 417.00 -500.00",
42 "-500.00 276.00 5473.00",
43 "-500.00 265.00 9852.00",
44 "4953.00 240.00 13300.00",
45 "9620.00 188.00 13300.00",
46 "13300.00 204.00 10322.00",
47 "13300.00 288.00 6204.00",
48 "13300.00 296.00 -500.00"
49 };
50 // -----------------------
51 // END OF ARTILLERY SETUP
52 // -----------------------
53
56
57#ifndef NO_GUI
58 protected int m_ControlDisabledMode;
59 protected ref array<string> m_ActiveInputExcludeGroups; //exclude groups defined in 'specific.xml' file
60 protected ref array<int> m_ActiveInputRestrictions; //additional scripted restrictions
61 protected bool m_ProcessInputExcludes;
62#endif
63
65 {
66 g_Game.GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(this.UpdatePlayersStats, 30000, true);
67
68 m_DeadPlayersArray = new array<ref CorpseData>;
70 m_Players = new array<Man>;
71
72 m_LogoutPlayers = new map<PlayerBase, ref LogoutInfo>;
73 m_NewLogoutPlayers = new map<PlayerBase, ref LogoutInfo>;
74 m_RainProcHandler = new RainProcurementHandler(this);
75 m_ActiveRefresherLocations = new array<vector>();
76 }
77
79 {
80 g_Game.GetCallQueue(CALL_CATEGORY_GAMEPLAY).Remove(this.UpdatePlayersStats);
81 }
82
83 override void OnInit()
84 {
85 super.OnInit();
86 CfgGameplayHandler.LoadData();
87 PlayerSpawnHandler.LoadData();
89 UndergroundAreaLoader.SpawnAllTriggerCarriers();
90 //Either pass consts in Init.c or insert all desired coords (or do both ;))
92 }
93
94 override void OnMissionStart()
95 {
96 super.OnMissionStart();
97
98 // We will load the Effect areas on Default mission start
99 EffectAreaLoader.CreateZones();
100 }
101
102 override void OnUpdate(float timeslice)
103 {
104#ifndef NO_GUI
105#ifdef FEATURE_CURSOR
106 if (GetTimeStamp() == 0)
107 {
109 g_Game.GetUIManager().ShowUICursor(false);
110 }
111#endif
112#endif
113
114 UpdateDummyScheduler();
115 TickScheduler(timeslice);
117 m_WorldData.UpdateBaseEnvTemperature(timeslice); // re-calculate base enviro temperature
118 m_RainProcHandler.Update(timeslice);
119
120 RandomArtillery(timeslice);
121
122 super.OnUpdate(timeslice);
123
124#ifndef NO_GUI
125 UIManager uiManager = g_Game.GetUIManager();
126 UIScriptedMenu menu = uiManager.GetMenu();
127 Input input = g_Game.GetInput();
128
129 if (menu && !menu.UseKeyboard() && menu.UseMouse())
130 {
131 int i;
132 for (i = 0; i < 5; i++)
133 {
134 input.DisableKey(i | INPUT_DEVICE_MOUSE);
135 input.DisableKey(i | INPUT_ACTION_TYPE_DOWN_EVENT | INPUT_DEVICE_MOUSE);
136 input.DisableKey(i | INPUT_ACTION_TYPE_DOUBLETAP | INPUT_DEVICE_MOUSE);
137 }
138
139 for (i = 0; i < 6; i++)
140 {
141 input.DisableKey(i | INPUT_DEVICE_MOUSE_AXIS);
142 }
143 }
144
146 {
149 }
150#endif
151
152 }
153
155 {
156 m_RespawnMode = CfgGameplayHandler.GetDisableRespawnDialog();
157 g_Game.SetDebugMonitorEnabled(g_Game.ServerConfigGetInt("enableDebugMonitor"));
158
159 InitialiseWorldData();
160 }
161
162
163 void RandomArtillery(float deltaTime)
164 {
165 // ARTY barrage
166 if (m_PlayArty)
167 {
168 // We only perform timer checks and increments if we enabled the artillery barrage
169 if (m_ArtyBarrageTimer > m_ArtyDelay)
170 {
171 //We clamp to guarantee 1 and never have multiple shots on same pos, even in case of entry error
174
175 // Variables to be used in this scope
176 int randPos; // Select random position
177 Param1<vector> pos; // The value to be sent through RPC
178 array<ref Param> params; // The RPC params
179
181 {
182 // We only have one set of coordinates to send
183 randPos = Math.RandomIntInclusive(0, m_FiringPos.Count() - 1);
184 pos = new Param1<vector>(m_FiringPos[randPos]);
185 params = new array<ref Param>;
186 params.Insert(pos);
187 g_Game.RPC(null, ERPCs.RPC_SOUND_ARTILLERY, params, true);
188 }
189 else
190 {
191 //We will do some extra steps to
192 /*
193 1. Send multiple coords (Send one RPC per coord set)
194 2. Ensure we don't have duplicates
195 */
196 array<int> usedIndices = new array<int>; // Will store all previusly fired upon indices
197
198 // We determine how many positions fire between MIN and MAX
199 int randFireNb = Math.RandomIntInclusive(m_MinSimultaneousStrikes, m_MaxSimultaneousStrikes);
200 for (int i = 0; i < randFireNb; i++)
201 {
202 randPos = Math.RandomIntInclusive(0, m_FiringPos.Count() - 1);
203
204 if (usedIndices.Count() <= 0 || usedIndices.Find(randPos) < 0) //We do not find the index or array is empty
205 {
206 // We prepare to send the message
207 pos = new Param1<vector>(m_FiringPos[randPos]);
208 params = new array<ref Param>;
209
210 // We send the message with this set of coords
211 params.Insert(pos);
212 g_Game.RPC(null, ERPCs.RPC_SOUND_ARTILLERY, params, true);
213
214 // We store the last used value
215 usedIndices.Insert(randPos);
216 }
217 }
218 }
219
220 // Reset timer for new loop
221 m_ArtyBarrageTimer = 0.0;
222 }
223
224 m_ArtyBarrageTimer += deltaTime;
225 }
226 }
227
228 override bool IsServer()
229 {
230 return true;
231 }
232
233 override bool IsPlayerDisconnecting(Man player)
234 {
235 return (m_LogoutPlayers && m_LogoutPlayers.Contains(PlayerBase.Cast(player))) || (m_NewLogoutPlayers && m_NewLogoutPlayers.Contains(PlayerBase.Cast(player)));
236 }
237
239 {
240 PluginLifespan moduleLifespan;
241 Class.CastTo(moduleLifespan, GetPlugin(PluginLifespan));
242 array<Man> players = new array<Man>();
243 g_Game.GetPlayers(players);
244
245 foreach (Man man : players)
246 {
247 PlayerBase player;
248 if (Class.CastTo(player, man))
249 {
250 player.StatUpdateByTime(AnalyticsManagerServer.STAT_PLAYTIME);
251 player.StatUpdateByPosition(AnalyticsManagerServer.STAT_DISTANCE);
252
253 moduleLifespan.UpdateLifespan(player);
254 }
255 }
256
258 }
259
260 protected void AddNewPlayerLogout(PlayerBase player, notnull LogoutInfo info)
261 {
262 m_LogoutPlayers.Insert(player, info);
263 m_NewLogoutPlayers.Remove(player);
264 }
265
266 // check if logout finished for some players
268 {
269 for (int i = 0; i < m_LogoutPlayers.Count();)
270 {
271 LogoutInfo info = m_LogoutPlayers.GetElement(i);
272
273 if (g_Game.GetTime() >= info.param1)
274 {
275 PlayerIdentity identity;
276 PlayerBase player = m_LogoutPlayers.GetKey(i);
277 if (player)
278 {
279 identity = player.GetIdentity();
280 m_LogoutPlayers.Remove(player);
281 }
282 else
283 {
284 m_LogoutPlayers.RemoveElement(i);
285 }
286
287 // disable reconnecting to old char
288 // g_Game.RemoveFromReconnectCache(info.param2);
289
290 PlayerDisconnected(player, identity, info.param2);
291 }
292 else
293 {
294 ++i;
295 }
296 }
297 }
298
299 override void OnEvent(EventType eventTypeId, Param params)
300 {
301 PlayerIdentity identity;
302 PlayerBase player;
303 int counter = 0;
304
305 switch (eventTypeId)
306 {
308 ClientPrepareEventParams clientPrepareParams;
309 Class.CastTo(clientPrepareParams, params);
310 CfgGameplayHandler.SyncDataSendEx(clientPrepareParams.param1);
311 UndergroundAreaLoader.SyncDataSend(clientPrepareParams.param1);
312 CfgPlayerRestrictedAreaHandler.SyncDataSend(clientPrepareParams.param1);
313 OnClientPrepareEvent(clientPrepareParams.param1, clientPrepareParams.param2, clientPrepareParams.param3, clientPrepareParams.param4, clientPrepareParams.param5);
314 break;
315
317 ClientNewEventParams newParams;
318 Class.CastTo(newParams, params);
319 player = OnClientNewEvent(newParams.param1, newParams.param2, newParams.param3);
320 if (!player)
321 {
322 Debug.Log("ClientNewEvent: Player is empty");
323 return;
324 }
325 identity = newParams.param1;
326 InvokeOnConnect(player,identity);
327 SyncEvents.SendPlayerList();
328
329 ControlPersonalLight(player);
330 SyncGlobalLighting(player);
331
332 break;
333
335 ClientReadyEventParams readyParams;
336 Class.CastTo(readyParams, params);
337 identity = readyParams.param1;
338 Class.CastTo(player, readyParams.param2);
339 if (!player)
340 {
341 Debug.Log("ClientReadyEvent: Player is empty");
342 return;
343 }
344
345 OnClientReadyEvent(identity, player);
346 InvokeOnConnect(player, identity);
347 // Send list of players at all clients
348 SyncEvents.SendPlayerList();
349 ControlPersonalLight(player);
350 SyncGlobalLighting(player);
351 break;
352
354 ClientRespawnEventParams respawnParams;
355 Class.CastTo(respawnParams, params);
356 identity = respawnParams.param1;
357 Class.CastTo(player, respawnParams.param2);
358 if (!player)
359 {
360 Debug.Log("ClientRespawnEvent: Player is empty");
361 return;
362 }
363
364 OnClientRespawnEvent(identity, player);
365 break;
366
368 ClientReconnectEventParams reconnectParams;
369 Class.CastTo(reconnectParams, params);
370
371 identity = reconnectParams.param1;
372 Class.CastTo(player, reconnectParams.param2);
373 if (!player)
374 {
375 Debug.Log("ClientReconnectEvent: Player is empty");
376 return;
377 }
378
379 OnClientReconnectEvent(identity, player);
380 break;
381
384 Class.CastTo(discoParams, params);
385
386 identity = discoParams.param1;
387 Class.CastTo(player, discoParams.param2);
388 int logoutTime = discoParams.param3;
389 bool authFailed = discoParams.param4;
390
391 if (!player)
392 {
393 Debug.Log("ClientDisconnectenEvent: Player is empty");
394 return;
395 }
396
397 OnClientDisconnectedEvent(identity, player, logoutTime, authFailed);
398 break;
399
401 LogoutCancelEventParams logoutCancelParams;
402
403 Class.CastTo(logoutCancelParams, params);
404 Class.CastTo(player, logoutCancelParams.param1);
405 identity = player.GetIdentity();
406 if (identity)
407 {
408 // disable reconnecting to old char
409 // g_Game.RemoveFromReconnectCache(identity.GetId());
410 Print("[Logout]: Player " + identity.GetId() + " cancelled");
411 }
412 else
413 {
414 Print("[Logout]: Player cancelled");
415 }
416 m_LogoutPlayers.Remove(player);
417 m_NewLogoutPlayers.Remove(player);
418 break;
419 }
420 }
421
423 {
424 Debug.Log("InvokeOnConnect:"+this.ToString(),"Connect");
425 if (player)
426 player.OnConnect();
427 }
428
430 {
431 Debug.Log("InvokeOnDisconnect:"+this.ToString(),"Connect");
432 if (player)
433 player.OnDisconnect();
434 }
435
436 void OnClientPrepareEvent(PlayerIdentity identity, out bool useDB, out vector pos, out float yaw, out int preloadTimeout)
437 {
438 if (GetHive())
439 {
440 // use character from database
441 useDB = true;
442 }
443 else
444 {
445 // use following data without database
446 useDB = false;
447 pos = "1189.3 0.0 5392.48";
448 yaw = 0;
449 }
450 }
451
452 // Enables/Disables personal light on the given player.
454 {
455 if (player)
456 {
457 bool is_personal_light = ! g_Game.ServerConfigGetInt("disablePersonalLight");
458 Param1<bool> personal_light_toggle = new Param1<bool>(is_personal_light);
459 g_Game.RPCSingleParam(player, ERPCs.RPC_TOGGLE_PERSONAL_LIGHT, personal_light_toggle, true, player.GetIdentity());
460 }
461 else
462 {
463 Error("Error! Player was not initialized at the right time. Thus cannot send RPC command to enable or disable personal light!");
464 }
465 }
466
467 // syncs global lighting setup from the server (lightingConfig server config parameter)
469 {
470 if (player)
471 {
472 int lightingID = g_Game.ServerConfigGetInt("lightingConfig");
473 Param1<int> lightID = new Param1<int>(lightingID);
474 g_Game.RPCSingleParam(player, ERPCs.RPC_SEND_LIGHTING_SETUP, lightID, true, player.GetIdentity());
475 }
476 }
477
480 {
481 //creates temporary server-side structure for handling default character spawn
482 return g_Game.GetMenuDefaultCharacterData(false).DeserializeCharacterData(ctx);
483 }
484
485 //
486 PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
487 {
488 Entity playerEnt;
489 playerEnt = g_Game.CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
490 Class.CastTo(m_player, playerEnt);
491
492 g_Game.SelectPlayer(identity, m_player);
493
494 return m_player;
495 }
496
499 {
500 int slot_ID;
501 string attachment_type;
502 for (int i = 0; i < DefaultCharacterCreationMethods.GetAttachmentSlotsArray().Count(); i++)
503 {
504 slot_ID = DefaultCharacterCreationMethods.GetAttachmentSlotsArray().Get(i);
505 attachment_type = "";
506 if (m_RespawnMode != GameConstants.RESPAWN_MODE_CUSTOM || !char_data.GetAttachmentMap().Find(slot_ID,attachment_type) || !VerifyAttachmentType(slot_ID,attachment_type)) //todo insert verification fn here
507 {
508 //randomize
509 if (DefaultCharacterCreationMethods.GetConfigArrayCountFromSlotID(slot_ID) > 0)
510 {
511 attachment_type = DefaultCharacterCreationMethods.GetConfigAttachmentTypes(slot_ID).GetRandomElement();
512 }
513 else //undefined, moving on
514 continue;
515 }
516
517 if (attachment_type != "")
518 {
519 m_player.GetInventory().CreateAttachmentEx(attachment_type,slot_ID);
520 }
521 }
522
524 }
525
527 void StartingEquipSetup(PlayerBase player, bool clothesChosen)
528 {
529 }
530
531 bool VerifyAttachmentType(int slot_ID, string attachment_type)
532 {
533 return DefaultCharacterCreationMethods.GetConfigAttachmentTypes(slot_ID).Find(attachment_type) > -1;
534 }
535
537 {
538 string characterType = g_Game.CreateRandomPlayer();
539 bool generateRandomEquip = false;
540
541 // get login data for new character
542 if (ProcessLoginData(ctx) && (m_RespawnMode == GameConstants.RESPAWN_MODE_CUSTOM) && !g_Game.GetMenuDefaultCharacterData(false).IsRandomCharacterForced())
543 {
544 if (g_Game.ListAvailableCharacters().Find(g_Game.GetMenuDefaultCharacterData().GetCharacterType()) > -1)
545 characterType = g_Game.GetMenuDefaultCharacterData().GetCharacterType();
546 }
547 else
548 {
549 generateRandomEquip = true;
550 }
551
552 if (PlayerSpawnHandler.IsInitialized())
553 {
554 PlayerSpawnPreset presetData = PlayerSpawnHandler.GetRandomCharacterPreset();
555 if (presetData && presetData.IsValid())
556 {
557 string presetCharType = presetData.GetRandomCharacterType();
558 if (presetCharType == string.Empty)
559 presetCharType = characterType;
560 if (CreateCharacter(identity, pos, ctx, presetCharType) != null)
561 {
562 PlayerSpawnHandler.ProcessEquipmentData(m_player,presetData);
563 return m_player;
564 }
565 else
566 {
567 ErrorEx("Failed to create character from type: " + presetCharType + ", using default spawning method");
568 }
569 }
570 else
571 {
572 ErrorEx("Failed to load PlayerSpawnPreset data properly, using default spawning method");
573 }
574 }
575
576 if (CreateCharacter(identity, pos, ctx, characterType))
577 {
578 if (generateRandomEquip)
579 g_Game.GetMenuDefaultCharacterData().GenerateRandomEquip();
580 EquipCharacter(g_Game.GetMenuDefaultCharacterData());
581 }
582
583 return m_player;
584 }
585
587 {
588 g_Game.SelectPlayer(identity, player);
589
590 #ifdef DIAG_DEVELOPER
591 if (FeatureTimeAccel.m_CurrentTimeAccel)
592 {
593 g_Game.RPCSingleParam(player, ERPCs.DIAG_TIMEACCEL_CLIENT_SYNC, FeatureTimeAccel.m_CurrentTimeAccel, true, identity);
594 }
595 #endif
596 }
597
599 {
600 if (player)
601 {
602 if (player.IsUnconscious() || player.IsRestrained())
603 {
604 PluginAdminLog adm = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
605 adm.PlayerKilledByRespawn(player);
606
607 // kill character
608 player.SetHealth("", "", 0.0);
609 }
610 }
611
612 #ifdef DIAG_DEVELOPER
613 if (FeatureTimeAccel.m_CurrentTimeAccel)
614 {
615 g_Game.RPCSingleParam(player, ERPCs.DIAG_TIMEACCEL_CLIENT_SYNC, FeatureTimeAccel.m_CurrentTimeAccel, true, identity);
616 }
617 #endif
618 }
619
621 {
622 if (player)
623 {
624 player.OnReconnect();
625 }
626 }
627
628 void OnClientDisconnectedEvent(PlayerIdentity identity, PlayerBase player, int logoutTime, bool authFailed)
629 {
630 bool disconnectNow = true;
631
632 // TODO: get out of vehicle
633 // using database and no saving if authorization failed
634 if (GetHive() && !authFailed)
635 {
636 if (player.IsAlive())
637 {
638 if (!m_LogoutPlayers.Contains(player) && !m_NewLogoutPlayers.Contains(player))
639 {
640 Print("[Logout]: New player " + identity.GetId() + " with logout time " + logoutTime.ToString());
641
642 // send statistics to client
643 player.StatSyncToClient();
644
645 // inform client about logout time
646 g_Game.SendLogoutTime(player, logoutTime);
647
648 // wait for some time before logout and save
649 LogoutInfo params = new LogoutInfo(g_Game.GetTime() + logoutTime * 1000, identity.GetId());
650
651 m_NewLogoutPlayers.Insert(player, params);
652 g_Game.GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(AddNewPlayerLogout, 0, false, player, params);
653
654 // allow reconnecting to old char only if not in cars, od ladders etc. as they cannot be properly synchronized for reconnect
655 //if (!player.GetCommand_Vehicle() && !player.GetCommand_Ladder())
656 //{
657 // g_Game.AddToReconnectCache(identity);
658 //}
659 // wait until logout timer runs out
660 disconnectNow = false;
661 }
662 return;
663 }
664 }
665
666 if (disconnectNow)
667 {
668 Print("[Logout]: New player " + identity.GetId() + " with instant logout");
669
670 // inform client about instant logout
671 g_Game.SendLogoutTime(player, 0);
672
673 PlayerDisconnected(player, identity, identity.GetId());
674 }
675 }
676
677 void PlayerDisconnected(PlayerBase player, PlayerIdentity identity, string uid)
678 {
679 // Note: At this point, identity can be already deleted
680 if (!player)
681 {
682 Print("[Logout]: Skipping player " + uid + ", already removed");
683 return;
684 }
685
686 // disable reconnecting to old char
687 //g_Game.RemoveFromReconnectCache(uid);
688
689 // now player can't cancel logout anymore, so call everything needed upon disconnect
690 InvokeOnDisconnect(player);
691
692 Print("[Logout]: Player " + uid + " finished");
693
694 if (GetHive())
695 {
696 // save player
697 player.Save();
698
699 // unlock player in DB
700 GetHive().CharacterExit(player);
701 }
702
703 // handle player's existing char in the world
704 player.ReleaseNetworkControls();
705 HandleBody(player);
706
707 // remove player from server
708 g_Game.DisconnectPlayer(identity, uid);
709 // Send list of players at all clients
710 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(SyncEvents.SendPlayerList, 1000);
711 }
712
714 {
715 if (player.IsUnconscious() || player.IsRestrained())
716 {
717 switch (player.GetKickOffReason())
718 {
719 case EClientKicked.SERVER_EXIT:
720 return false;
721 case EClientKicked.KICK_ALL_ADMIN:
722 return false;
723 case EClientKicked.KICK_ALL_SERVER:
724 return false;
725 case EClientKicked.SERVER_SHUTDOWN:
726 return false;
727 default:
728 return true;
729 }
730 }
731
732 return false;
733 }
734
736 {
737 if (player.IsAlive())
738 {
739 if (ShouldPlayerBeKilled(player))
740 {
741 PluginAdminLog adm = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
742 adm.PlayerKilledByDisconnect(player);
743
744 player.SetHealth("", "", 0.0);//kill
745 }
746 else
747 {
748 player.Delete();// remove the body
749 }
750 }
751 }
752
753 void TickScheduler(float timeslice)
754 {
755 g_Game.GetWorld().GetPlayerList(m_Players);
756 int players_count = m_Players.Count();
757 int tick_count_max = Math.Min(players_count, SCHEDULER_PLAYERS_PER_TICK);
758
759 for (int i = 0; i < tick_count_max; ++i)
760 {
761 if (m_currentPlayer >= players_count)
762 {
763 m_currentPlayer = 0;
764 }
765
766 PlayerBase currentPlayer = PlayerBase.Cast(m_Players.Get(m_currentPlayer));
767 if (currentPlayer)
768 currentPlayer.OnTick();
769 ++m_currentPlayer;
770 }
771 }
772
773 //--------------------------------------------------
774 override bool InsertCorpse(Man player)
775 {
776 CorpseData corpse_data = new CorpseData(PlayerBase.Cast(player),g_Game.GetTime());
777 return m_DeadPlayersArray.Insert(corpse_data) >= 0;
778 }
779
781 {
782 int nDeadPlayers = m_DeadPlayersArray.Count();
783 if (nDeadPlayers == 0)//nothing to process, abort
784 return;
785 int current_time = g_Game.GetTime();
786 array<int> invalid_corpses = new array<int>;
787 CorpseData corpse_data;
788
789 for (int i = 0; i < nDeadPlayers; ++i)
790 {
791 corpse_data = m_DeadPlayersArray.Get(i);
792 if (!corpse_data || (corpse_data && (!corpse_data.m_Player || !corpse_data.m_bUpdate)))
793 {
794 invalid_corpses.Insert(i);
795 }
796 else if (corpse_data.m_bUpdate && current_time - corpse_data.m_iLastUpdateTime >= 30000)
797 {
798 corpse_data.UpdateCorpseState();
799 corpse_data.m_iLastUpdateTime = current_time;
800 }
801 }
802
803 //cleanup
804 int nInvalidCorpses = invalid_corpses.Count();
805 if (nInvalidCorpses > 0)
806 {
807 for (i = nInvalidCorpses - 1; i >= 0; --i)
808 {
809 m_DeadPlayersArray.Remove(invalid_corpses.Get(i));
810 }
811 }
812 }
813 //--------------------------------------------------
814
815 override void SyncRespawnModeInfo(PlayerIdentity identity)
816 {
817 ScriptRPC rpc = new ScriptRPC();
818 rpc.Write(m_RespawnMode);
819 rpc.Send(null, ERPCs.RPC_SERVER_RESPAWN_MODE, true, identity);
820 }
821
823 {
824 return m_RainProcHandler;
825 }
826
828 {
829 return m_ActiveRefresherLocations;
830 }
831
832#ifndef NO_GUI
834 override void RemoveActiveInputExcludes(array<string> excludes, bool bForceSupress = false)
835 {
836 super.RemoveActiveInputExcludes(excludes,bForceSupress);
837
838 if (excludes.Count() != 0)
839 {
840 bool changed = false;
841
843 {
844 foreach (string excl : excludes)
845 {
846 if (m_ActiveInputExcludeGroups.Find(excl) != -1)
847 {
848 m_ActiveInputExcludeGroups.RemoveItem(excl);
849 changed = true;
850 }
851 }
852
853 if (changed)
854 {
856 }
857 }
858
859 // supress control for next frame
860 GetUApi().SupressNextFrame(bForceSupress);
861 }
862 }
863
865 override void RemoveActiveInputRestriction(int restrictor)
866 {
867 //unique behaviour outside regular excludes
868 if (restrictor > -1)
869 {
870 switch (restrictor)
871 {
872 case EInputRestrictors.INVENTORY:
873 {
874 GetUApi().GetInputByID(UAWalkRunForced).ForceEnable(false); // force walk off!
875 break;
876 }
877 case EInputRestrictors.MAP:
878 {
879 GetUApi().GetInputByID(UAWalkRunForced).ForceEnable(false); // force walk off!
880 break;
881 }
882 }
883
884 if (m_ActiveInputRestrictions && m_ActiveInputRestrictions.Find(restrictor) != -1)
885 {
886 m_ActiveInputRestrictions.RemoveItem(restrictor);
887 }
888 }
889 }
890
892 override void AddActiveInputExcludes(array<string> excludes)
893 {
894 super.AddActiveInputExcludes(excludes);
895
896 if (excludes.Count() != 0)
897 {
898 bool changed = false;
900 {
902 }
903
904 foreach (string excl : excludes)
905 {
906 if (m_ActiveInputExcludeGroups.Find(excl) == -1)
907 {
908 m_ActiveInputExcludeGroups.Insert(excl);
909 changed = true;
910 }
911 }
912
913 if (changed)
914 {
916 #ifdef BULDOZER
917 GetUApi().SupressNextFrame(true);
918 #endif
919 }
920 }
921 }
922
924 override void AddActiveInputRestriction(int restrictor)
925 {
926 //unique behaviour outside regular excludes
927 if (restrictor > -1)
928 {
929 switch (restrictor)
930 {
931 case EInputRestrictors.INVENTORY:
932 {
933 GetUApi().GetInputByID(UAWalkRunForced).ForceEnable(true); // force walk on!
934 PlayerBase player = PlayerBase.Cast( g_Game.GetPlayer() );
935 if ( player )
936 {
937 ItemBase item = player.GetItemInHands();
938 if (item && item.IsWeapon())
939 player.RequestResetADSSync();
940 }
941 break;
942 }
943 case EInputRestrictors.MAP:
944 {
945 GetUApi().GetInputByID(UAWalkRunForced).ForceEnable(true); // force walk on!
946 break;
947 }
948 }
949
951 {
953 }
954 if (m_ActiveInputRestrictions.Find(restrictor) == -1)
955 {
956 m_ActiveInputRestrictions.Insert(restrictor);
957 }
958 }
959 }
960
962 override void RefreshExcludes()
963 {
965 }
966
968 protected void PerformRefreshExcludes()
969 {
971 {
972 foreach (string excl : m_ActiveInputExcludeGroups)
973 {
974 GetUApi().ActivateExclude(excl);
975 }
976 }
977
978 GetUApi().UpdateControls();
979 }
980
982 override void EnableAllInputs(bool bForceSupress = false)
983 {
985
987 {
988 int count = m_ActiveInputRestrictions.Count();
989 for (int i = 0; i < count; i++)
990 {
991 RemoveActiveInputRestriction(m_ActiveInputRestrictions[0]);
992 }
993 m_ActiveInputRestrictions.Clear(); //redundant?
994 }
996 {
998 }
999
1000 GetUApi().UpdateControls(); //it is meant to happen instantly, does not wait for update to process
1001 GetUApi().SupressNextFrame(bForceSupress); // supress control for next frame
1002 }
1003
1005 override bool IsControlDisabled()
1006 {
1007 bool active = false;
1009 {
1010 active |= m_ActiveInputExcludeGroups.Count() > 0;
1011 }
1013 {
1014 active |= m_ActiveInputRestrictions.Count() > 0;
1015 }
1016 active |= m_ControlDisabledMode >= INPUT_EXCLUDE_ALL; //legacy stuff, Justin case
1017 return active;
1018 }
1019
1021 override bool IsInputExcludeActive(string exclude)
1022 {
1023 return m_ActiveInputExcludeGroups && m_ActiveInputExcludeGroups.Find(exclude) != -1;
1024 }
1025
1027 override bool IsInputRestrictionActive(int restriction)
1028 {
1029 return m_ActiveInputRestrictions && m_ActiveInputRestrictions.Find(restriction) != -1;
1030 }
1031#endif
1032
1034 PluginAdditionalInfo m_moduleDefaultCharacter;
1035}
1036
Super root of all classes in Enforce script.
Definition enscript.c:11
Definition debug.c:2
Definition camera.c:2
Definition input.c:11
Definition enmath.c:7
override void EnableAllInputs(bool bForceSupress=false)
Removes all active input excludes and restrictions.
void RandomArtillery(float deltaTime)
void ~MissionServer()
ref array< vector > m_FiringPos
void EquipCharacter(MenuDefaultCharacterData char_data)
Spawns character equip from received data. Checks validity against config, randomizes if invalid valu...
override void AddActiveInputExcludes(array< string > excludes)
Adds one or more exclude groups to disable and refreshes excludes.
int m_ControlDisabledMode
override void OnUpdate(float timeslice)
override void OnInit()
override void RemoveActiveInputExcludes(array< string > excludes, bool bForceSupress=false)
Removes one or more exclude groups and refreshes excludes.
int m_MaxSimultaneousStrikes
PluginAdditionalInfo m_moduleDefaultCharacter
DEPRECATED.
void AddNewPlayerLogout(PlayerBase player, notnull LogoutInfo info)
void SyncGlobalLighting(PlayerBase player)
override bool IsInputExcludeActive(string exclude)
Returns true if the particular input exclude group had been activated via script and is active.
ref array< string > m_ActiveInputExcludeGroups
override bool InsertCorpse(Man player)
override bool IsControlDisabled()
returns if ANY exclude groups, restriction (or deprecated disable, if applicable) is active
void UpdateCorpseStatesServer()
override RainProcurementHandler GetRainProcurementHandler()
override void OnGameplayDataHandlerLoad()
void HandleBody(PlayerBase player)
void MissionServer()
override bool IsServer()
void TickScheduler(float timeslice)
const ref array< vector > CHERNARUS_STRIKE_POS
override bool IsInputRestrictionActive(int restriction)
Returns true if the particular 'restriction' (those govern special behaviour outside regular input ex...
override void OnEvent(EventType eventTypeId, Param params)
MissionBase m_mission
ref array< int > m_ActiveInputRestrictions
void UpdatePlayersStats()
bool ProcessLoginData(ParamsReadContext ctx)
returns whether received data is valid, ctx can be filled on client in StoreLoginData()
void InvokeOnConnect(PlayerBase player, PlayerIdentity identity)
override void RefreshExcludes()
queues refresh of input excludes
PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
void PlayerDisconnected(PlayerBase player, PlayerIdentity identity, string uid)
bool ShouldPlayerBeKilled(PlayerBase player)
float m_ArtyDelay
void InvokeOnDisconnect(PlayerBase player)
void ControlPersonalLight(PlayerBase player)
bool VerifyAttachmentType(int slot_ID, string attachment_type)
override void AddActiveInputRestriction(int restrictor)
Adds one input restriction (specific behaviour oudside regular excludes, defined below).
const ref array< vector > LIVONIA_STRIKE_POS
void StartingEquipSetup(PlayerBase player, bool clothesChosen)
can be overriden to manually set up starting equip. 'clothesChosen' is legacy parameter,...
PlayerBase m_player
void OnClientReadyEvent(PlayerIdentity identity, PlayerBase player)
void OnClientPrepareEvent(PlayerIdentity identity, out bool useDB, out vector pos, out float yaw, out int preloadTimeout)
override void SyncRespawnModeInfo(PlayerIdentity identity)
void OnClientDisconnectedEvent(PlayerIdentity identity, PlayerBase player, int logoutTime, bool authFailed)
void UpdateLogoutPlayers()
bool m_ProcessInputExcludes
void PerformRefreshExcludes()
applies queued excludes (0 == clear excludes)
override void RemoveActiveInputRestriction(int restrictor)
Removes one restriction (specific behaviour oudside regular excludes, defined below).
override void OnMissionStart()
void OnClientReconnectEvent(PlayerIdentity identity, PlayerBase player)
PlayerBase OnClientNewEvent(PlayerIdentity identity, vector pos, ParamsReadContext ctx)
override array< vector > GetActiveRefresherLocations()
void OnClientRespawnEvent(PlayerIdentity identity, PlayerBase player)
int m_MinSimultaneousStrikes
override bool IsPlayerDisconnecting(Man player)
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
The class that will be instanced (moddable).
Definition gameplay.c:389
override bool UseMouse()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
EClientKicked
DayZGame g_Game
Definition dayzgame.c:3942
proto string ToString()
WorldData m_WorldData
Definition environment.c:85
ERPCs
Definition erpcs.c:2
const EventType LogoutCancelEventTypeID
params: LogoutCancelEventParams
Definition gameplay.c:529
Param1< Man > LogoutCancelEventParams
Player.
Definition gameplay.c:435
const EventType ClientNewEventTypeID
params: ClientNewEventParams
Definition gameplay.c:509
Param5< PlayerIdentity, bool, vector, float, int > ClientPrepareEventParams
PlayerIdentity, useDB, pos, yaw, preloadTimeout (= additional time in seconds to how long server wait...
Definition gameplay.c:414
Serializer ParamsReadContext
Definition gameplay.c:15
Param2< PlayerIdentity, Man > ClientRespawnEventParams
PlayerIdentity, Man.
Definition gameplay.c:420
const EventType ClientReconnectEventTypeID
params: ClientReconnectEventParams
Definition gameplay.c:515
Param4< PlayerIdentity, Man, int, bool > ClientDisconnectedEventParams
PlayerIdentity, Man, LogoutTime, AuthFailed.
Definition gameplay.c:426
const EventType ClientRespawnEventTypeID
params: ClientRespawnEventParams
Definition gameplay.c:513
Param2< PlayerIdentity, Man > ClientReconnectEventParams
PlayerIdentity, Man.
Definition gameplay.c:424
Param2< PlayerIdentity, Man > ClientReadyEventParams
PlayerIdentity, Man.
Definition gameplay.c:422
Param3< PlayerIdentity, vector, Serializer > ClientNewEventParams
PlayerIdentity, PlayerPos, Top, Bottom, Shoe, Skin.
Definition gameplay.c:416
const EventType ClientDisconnectedEventTypeID
params: ClientDisconnectedEventParams
Definition gameplay.c:519
const EventType ClientReadyEventTypeID
params: ClientReadyEventParams
Definition gameplay.c:517
const EventType ClientPrepareEventTypeID
params: ClientPrepareEventParams
Definition gameplay.c:507
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
proto void Print(void var)
Prints content of variable to console/log.
enum ShapeType ErrorEx
const int INPUT_EXCLUDE_ALL
Definition constants.c:657
const int INPUT_DEVICE_MOUSE
Definition constants.c:24
const int INPUT_ACTION_TYPE_DOUBLETAP
Definition constants.c:40
const int INPUT_DEVICE_MOUSE_AXIS
Definition constants.c:42
const int INPUT_ACTION_TYPE_DOWN_EVENT
Definition constants.c:33
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
TypeID EventType
Definition enwidgets.c:55
Empty
Definition hand_states.c:14
proto native Hive GetHive()
Param2< int, string > LogoutInfo
int time of the logout end
void PluginLifespan()
PluginBase GetPlugin(typename plugin_type)
proto native UAInputAPI GetUApi()