12 const int SCHEDULER_PLAYERS_PER_TICK = 5;
19 private float m_ArtyBarrageTimer = 0;
22 protected bool m_PlayArty =
false;
23 protected float m_ArtyDelay = 0;
24 protected int m_MinSimultaneousStrikes = 0;
25 protected int m_MaxSimultaneousStrikes = 0;
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"
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"
89 super.OnMissionStart();
97 UpdateDummyScheduler();
101 m_RainProcHandler.Update(timeslice);
105 super.OnUpdate(timeslice);
113 InitialiseWorldData();
123 if (m_ArtyBarrageTimer > m_ArtyDelay)
126 m_MaxSimultaneousStrikes =
Math.Clamp(m_MaxSimultaneousStrikes, 1, m_FiringPos.Count());
127 m_MinSimultaneousStrikes =
Math.Clamp(m_MinSimultaneousStrikes, 1, m_MaxSimultaneousStrikes);
134 if (m_MaxSimultaneousStrikes == 1)
137 randPos =
Math.RandomIntInclusive(0, m_FiringPos.Count() - 1);
138 pos =
new Param1<vector>(m_FiringPos[randPos]);
141 GetGame().RPC(null,
ERPCs.RPC_SOUND_ARTILLERY, params,
true);
153 int randFireNb =
Math.RandomIntInclusive(m_MinSimultaneousStrikes, m_MaxSimultaneousStrikes);
154 for (
int i = 0; i < randFireNb; i++)
156 randPos =
Math.RandomIntInclusive(0, m_FiringPos.Count() - 1);
158 if (usedIndices.Count() <= 0 || usedIndices.Find(randPos) < 0)
161 pos =
new Param1<vector>(m_FiringPos[randPos]);
166 GetGame().RPC(null,
ERPCs.RPC_SOUND_ARTILLERY, params,
true);
169 usedIndices.Insert(randPos);
175 m_ArtyBarrageTimer = 0.0;
178 m_ArtyBarrageTimer += deltaTime;
189 return (m_LogoutPlayers && m_LogoutPlayers.Contains(
PlayerBase.Cast(player))) || (m_NewLogoutPlayers && m_NewLogoutPlayers.Contains(
PlayerBase.Cast(player)));
199 foreach (Man man : players)
202 if (
Class.CastTo(player, man))
207 moduleLifespan.UpdateLifespan(player);
216 m_LogoutPlayers.Insert(player, info);
217 m_NewLogoutPlayers.Remove(player);
223 for (
int i = 0; i < m_LogoutPlayers.Count();)
225 LogoutInfo info = m_LogoutPlayers.GetElement(i);
230 PlayerBase player = m_LogoutPlayers.GetKey(i);
233 identity = player.GetIdentity();
234 m_LogoutPlayers.Remove(player);
238 m_LogoutPlayers.RemoveElement(i);
263 Class.CastTo(clientPrepareParams, params);
267 OnClientPrepareEvent(clientPrepareParams.param1, clientPrepareParams.param2, clientPrepareParams.param3, clientPrepareParams.param4, clientPrepareParams.param5);
272 Class.CastTo(newParams, params);
273 player =
OnClientNewEvent(newParams.param1, newParams.param2, newParams.param3);
276 Debug.Log(
"ClientNewEvent: Player is empty");
279 identity = newParams.param1;
290 Class.CastTo(readyParams, params);
291 identity = readyParams.param1;
292 Class.CastTo(player, readyParams.param2);
295 Debug.Log(
"ClientReadyEvent: Player is empty");
309 Class.CastTo(respawnParams, params);
310 identity = respawnParams.param1;
311 Class.CastTo(player, respawnParams.param2);
314 Debug.Log(
"ClientRespawnEvent: Player is empty");
323 Class.CastTo(reconnectParams, params);
325 identity = reconnectParams.param1;
326 Class.CastTo(player, reconnectParams.param2);
329 Debug.Log(
"ClientReconnectEvent: Player is empty");
338 Class.CastTo(discoParams, params);
340 identity = discoParams.param1;
341 Class.CastTo(player, discoParams.param2);
342 int logoutTime = discoParams.param3;
343 bool authFailed = discoParams.param4;
347 Debug.Log(
"ClientDisconnectenEvent: Player is empty");
357 Class.CastTo(logoutCancelParams, params);
358 Class.CastTo(player, logoutCancelParams.param1);
359 identity = player.GetIdentity();
364 Print(
"[Logout]: Player " + identity.GetId() +
" cancelled");
368 Print(
"[Logout]: Player cancelled");
370 m_LogoutPlayers.Remove(player);
371 m_NewLogoutPlayers.Remove(player);
387 player.OnDisconnect();
401 pos =
"1189.3 0.0 5392.48";
412 Param1<bool> personal_light_toggle =
new Param1<bool>(is_personal_light);
413 GetGame().RPCSingleParam(player,
ERPCs.RPC_TOGGLE_PERSONAL_LIGHT, personal_light_toggle,
true, player.GetIdentity());
417 Error(
"Error! Player was not initialized at the right time. Thus cannot send RPC command to enable or disable personal light!");
427 Param1<int> lightID =
new Param1<int>(lightingID);
428 GetGame().RPCSingleParam(player,
ERPCs.RPC_SEND_LIGHTING_SETUP, lightID,
true, player.GetIdentity());
443 playerEnt =
GetGame().CreatePlayer(identity, characterName, pos, 0,
"NONE");
455 string attachment_type;
456 for (
int i = 0; i < DefaultCharacterCreationMethods.GetAttachmentSlotsArray().
Count(); i++)
458 slot_ID = DefaultCharacterCreationMethods.GetAttachmentSlotsArray().Get(i);
459 attachment_type =
"";
460 if (m_RespawnMode !=
GameConstants.RESPAWN_MODE_CUSTOM || !char_data.GetAttachmentMap().Find(slot_ID,attachment_type) || !VerifyAttachmentType(slot_ID,attachment_type))
463 if (DefaultCharacterCreationMethods.GetConfigArrayCountFromSlotID(slot_ID) > 0)
465 attachment_type = DefaultCharacterCreationMethods.GetConfigAttachmentTypes(slot_ID).GetRandomElement();
471 if (attachment_type !=
"")
473 m_player.GetInventory().CreateAttachmentEx(attachment_type,slot_ID);
487 return DefaultCharacterCreationMethods.GetConfigAttachmentTypes(slot_ID).Find(attachment_type) > -1;
493 bool generateRandomEquip =
false;
498 if (
GetGame().ListAvailableCharacters().Find(
GetGame().GetMenuDefaultCharacterData().GetCharacterType()) > -1)
503 generateRandomEquip =
true;
509 if (presetData && presetData.IsValid())
511 string presetCharType = presetData.GetRandomCharacterType();
512 if (presetCharType ==
string.
Empty)
513 presetCharType = characterType;
521 ErrorEx(
"Failed to create character from type: " + presetCharType +
", using default spawning method");
526 ErrorEx(
"Failed to load PlayerSpawnPreset data properly, using default spawning method");
532 if (generateRandomEquip)
542 GetGame().SelectPlayer(identity, player);
544 #ifdef DIAG_DEVELOPER
545 if (FeatureTimeAccel.m_CurrentTimeAccel)
547 GetGame().RPCSingleParam(player,
ERPCs.DIAG_TIMEACCEL_CLIENT_SYNC, FeatureTimeAccel.m_CurrentTimeAccel,
true, identity);
556 if (player.IsUnconscious() || player.IsRestrained())
558 PluginAdminLog adm = PluginAdminLog.Cast(
GetPlugin(PluginAdminLog));
559 adm.PlayerKilledByRespawn(player);
562 player.SetHealth(
"",
"", 0.0);
566 #ifdef DIAG_DEVELOPER
567 if (FeatureTimeAccel.m_CurrentTimeAccel)
569 GetGame().RPCSingleParam(player,
ERPCs.DIAG_TIMEACCEL_CLIENT_SYNC, FeatureTimeAccel.m_CurrentTimeAccel,
true, identity);
578 player.OnReconnect();
584 bool disconnectNow =
true;
590 if (player.IsAlive())
592 if (!m_LogoutPlayers.Contains(player) && !m_NewLogoutPlayers.Contains(player))
594 Print(
"[Logout]: New player " + identity.GetId() +
" with logout time " + logoutTime.ToString());
597 player.StatSyncToClient();
600 GetGame().SendLogoutTime(player, logoutTime);
605 m_NewLogoutPlayers.Insert(player, params);
614 disconnectNow =
false;
622 Print(
"[Logout]: New player " + identity.GetId() +
" with instant logout");
625 GetGame().SendLogoutTime(player, 0);
636 Print(
"[Logout]: Skipping player " + uid +
", already removed");
646 Print(
"[Logout]: Player " + uid +
" finished");
654 GetHive().CharacterExit(player);
658 player.ReleaseNetworkControls();
662 GetGame().DisconnectPlayer(identity, uid);
669 if (player.IsUnconscious() || player.IsRestrained())
671 switch (player.GetKickOffReason())
691 if (player.IsAlive())
695 PluginAdminLog adm = PluginAdminLog.Cast(
GetPlugin(PluginAdminLog));
696 adm.PlayerKilledByDisconnect(player);
698 player.SetHealth(
"",
"", 0.0);
709 GetGame().GetWorld().GetPlayerList(m_Players);
710 int players_count = m_Players.Count();
711 int tick_count_max =
Math.Min(players_count, SCHEDULER_PLAYERS_PER_TICK);
713 for (
int i = 0; i < tick_count_max; i++)
715 if (m_currentPlayer >= players_count)
723 currentPlayer.OnTick();
732 return m_DeadPlayersArray.Insert(corpse_data) >= 0;
737 if (m_DeadPlayersArray.Count() == 0)
743 for (
int i = 0; i < m_DeadPlayersArray.Count(); i++)
745 corpse_data = m_DeadPlayersArray.Get(i);
746 if (!corpse_data || (corpse_data && (!corpse_data.m_Player || !corpse_data.m_bUpdate)))
748 invalid_corpses.Insert(i);
750 else if (corpse_data.m_bUpdate && current_time - corpse_data.m_iLastUpdateTime >= 30000)
752 corpse_data.UpdateCorpseState();
753 corpse_data.m_iLastUpdateTime = current_time;
758 if (invalid_corpses.Count() > 0)
760 for (i = invalid_corpses.Count() - 1; i > -1; i--)
762 m_DeadPlayersArray.Remove(invalid_corpses.Get(i));
771 rpc.Write(m_RespawnMode);
772 rpc.Send(null,
ERPCs.RPC_SERVER_RESPAWN_MODE,
true, identity);
777 return m_RainProcHandler;
782 return m_ActiveRefresherLocations;
override string CreateRandomPlayer()
void SetDebugMonitorEnabled(int value)
proto int GetTime()
returns mission time in milliseconds
proto native int ServerConfigGetInt(string name)
Server config parsing. Returns 0 if not found.
MenuDefaultCharacterData GetMenuDefaultCharacterData(bool fill_data=true)
Super root of all classes in Enforce script.
void RandomArtillery(float deltaTime)
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 OnUpdate(float timeslice)
PluginAdditionalInfo m_moduleDefaultCharacter
DEPRECATED.
void AddNewPlayerLogout(PlayerBase player, notnull LogoutInfo info)
void SyncGlobalLighting(PlayerBase player)
override bool InsertCorpse(Man player)
void UpdateCorpseStatesServer()
override RainProcurementHandler GetRainProcurementHandler()
override void OnGameplayDataHandlerLoad()
void HandleBody(PlayerBase player)
void TickScheduler(float timeslice)
override void OnEvent(EventType eventTypeId, Param params)
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)
PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
void PlayerDisconnected(PlayerBase player, PlayerIdentity identity, string uid)
bool ShouldPlayerBeKilled(PlayerBase player)
void InvokeOnDisconnect(PlayerBase player)
void ControlPersonalLight(PlayerBase player)
bool VerifyAttachmentType(int slot_ID, string attachment_type)
void StartingEquipSetup(PlayerBase player, bool clothesChosen)
can be overriden to manually set up starting equip. 'clothesChosen' is legacy parameter,...
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()
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)
override bool IsPlayerDisconnecting(Man player)
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
The class that will be instanced (moddable)
Serialization general interface. Serializer API works with:
void UpdateBaseEnvTemperature(float timeslice)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
const EventType LogoutCancelEventTypeID
params: LogoutCancelEventParams
Param1< Man > LogoutCancelEventParams
Player.
const EventType ClientNewEventTypeID
params: ClientNewEventParams
Param5< PlayerIdentity, bool, vector, float, int > ClientPrepareEventParams
PlayerIdentity, useDB, pos, yaw, preloadTimeout (= additional time in seconds to how long server wait...
const EventType ClientReconnectEventTypeID
params: ClientReconnectEventParams
Param4< PlayerIdentity, Man, int, bool > ClientDisconnectedEventParams
PlayerIdentity, Man, LogoutTime, AuthFailed.
const EventType ClientRespawnEventTypeID
params: ClientRespawnEventParams
const EventType ClientDisconnectedEventTypeID
params: ClientDisconnectedEventParams
proto native CGame GetGame()
const EventType ClientReadyEventTypeID
params: ClientReadyEventParams
const EventType ClientPrepareEventTypeID
params: ClientPrepareEventParams
void Error(string err)
Messagebox with error message.
proto void Print(void var)
Prints content of variable to console/log.
proto native Hive GetHive()
Param2< int, string > LogoutInfo
int time of the logout end
PluginBase GetPlugin(typename plugin_type)