Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rostow #283

Open
wants to merge 4 commits into
base: production
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo off

taskkill /F /IM DayZ_x64.exe /T

RD /s /q "storage_-1" > nul 2>&1

cd ../../

start DayZ_x64.exe -mission=.\Missions\DayZCommunityOfflineMode.Rostow -nosplash -noPause -noBenchmark -filePatching -doLogs -scriptDebug=true "-mod=!Workshop\@Rostowmap"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "$CurrentDir:missions\\DayZCommunityOfflineMode.Rostow\\core\\ModuleManager.c"
#include "$CurrentDir:missions\\DayZCommunityOfflineMode.Rostow\\core\\StaticFunctions.c"

#include "$CurrentDir:missions\\DayZCommunityOfflineMode.Rostow\\core\\CommunityOfflineClient.c"
#include "$CurrentDir:missions\\DayZCommunityOfflineMode.Rostow\\core\\CommunityOfflineServer.c"
123 changes: 123 additions & 0 deletions Missions/DayZCommunityOfflineMode.Rostow/core/CommunityOfflineClient.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
class CommunityOfflineClient extends MissionGameplay
{
protected bool HIVE_ENABLED = true; //Local Hive / Economy / Infected spawn

protected bool m_loaded;

void CommunityOfflineClient()
{
m_loaded = false;

NewModuleManager();
}

override void OnInit()
{
super.OnInit();

InitHive();

SetupWeather();

SpawnPlayer();

GetDayZGame().SetMissionPath( "$saves:CommunityOfflineMode\\" ); // CameraToolsMenu
}

override void OnMissionStart()
{
super.OnMissionStart();

COM_GetModuleManager().OnInit();
COM_GetModuleManager().OnMissionStart();
}

override void OnMissionFinish()
{
COM_GetModuleManager().OnMissionFinish();

CloseAllMenus();

DestroyAllMenus();

if( GetHive() )
{
DestroyHive();
}

super.OnMissionFinish();
}

void OnMissionLoaded()
{
COM_GetModuleManager().OnMissionLoaded();
}

override void OnUpdate( float timeslice )
{
super.OnUpdate( timeslice );

COM_GetModuleManager().OnUpdate( timeslice );

if( !m_loaded && !GetDayZGame().IsLoading() )
{
m_loaded = true;
OnMissionLoaded();
}
}

void SpawnPlayer()
{
// #ifndef MODULE_PERSISTENCY
// GetGame().SelectPlayer( NULL, COM_CreateCustomDefaultCharacter() );
// #endif

// #ifdef DISABLE_PERSISTENCY
GetGame().SelectPlayer( NULL, COM_CreateCustomDefaultCharacter() );
// #endif
}

void InitHive()
{
if ( GetGame().IsClient() && GetGame().IsMultiplayer() ) return;

// RD /s /q "storage_-1" > nul 2>&1
if ( !HIVE_ENABLED ) return;

Hive oHive = GetHive();

if( !oHive )
{
oHive = CreateHive();
}

if( oHive )
{
oHive.InitOffline();
}

oHive.SetShardID("100");
oHive.SetEnviroment("stable");
}

static void SetupWeather()
{
Weather weather = g_Game.GetWeather();

weather.MissionWeather(false); // false = use weather controller from Weather.c

weather.GetOvercast().Set( Math.RandomFloatInclusive(0.02, 0.1), 1, 0);
weather.GetRain().Set( 0, 1, 0);
weather.GetFog().Set( 0, 1, 0);

//Rostow specific date
int year, month, day, hour, minute;
int reset_month = 8, reset_day = 10;
GetGame().GetWorld().GetDate(year, month, day, hour, minute);

if (month != reset_month)
{
GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
}
}
};
109 changes: 109 additions & 0 deletions Missions/DayZCommunityOfflineMode.Rostow/core/CommunityOfflineServer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
class CommunityOfflineServer : MissionServer
{
protected bool m_loaded;

void CommunityOfflineServer()
{
Print( "CommunityOfflineServer::CommunityOfflineServer()" );
m_loaded = false;

COM_GetModuleManager();
}

void ~CommunityOfflineServer()
{
Print( "CommunityOfflineServer::~CommunityOfflineServer()" );
}

override void OnInit()
{
super.OnInit();

SetupWeather();

COM_GetModuleManager().OnInit();
}

override void OnMissionStart()
{
super.OnMissionStart();

COM_GetModuleManager().OnMissionStart();
}

override void OnMissionFinish()
{
COM_GetModuleManager().OnMissionFinish();

super.OnMissionFinish();
}

void OnMissionLoaded()
{
COM_GetModuleManager().OnMissionLoaded();
}


override void OnUpdate( float timeslice )
{
super.OnUpdate( timeslice );

COM_GetModuleManager().OnUpdate( timeslice );

if( !m_loaded && !GetDayZGame().IsLoading() )
{
m_loaded = true;
OnMissionLoaded();
}
}

override void OnMouseButtonRelease( int button )
{
super.OnMouseButtonRelease( button );

//COM_GetModuleManager().OnMouseButtonRelease( button );
}

override void OnMouseButtonPress( int button )
{
super.OnMouseButtonPress( button );

//COM_GetModuleManager().OnMouseButtonPress( button );
}

override void OnKeyPress( int key )
{
super.OnKeyPress(key);

//COM_GetModuleManager().OnKeyPress( key );
}

override void OnKeyRelease( int key )
{
super.OnKeyRelease( key );

//COM_GetModuleManager().OnKeyRelease( key );
}

static void SetupWeather()
{
//Rostow specific
Weather weather = g_Game.GetWeather();

weather.MissionWeather(false); // false = use weather controller from Weather.c

weather.GetOvercast().Set( Math.RandomFloatInclusive(0.02, 0.1), 1, 0);
weather.GetRain().Set( 0, 1, 0);
weather.GetFog().Set( 0, 1, 0);

//Rostow specific date
int year, month, day, hour, minute;
int reset_month = 8, reset_day = 10;
GetGame().GetWorld().GetDate(year, month, day, hour, minute);

if (month != reset_month)
{
GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
}
}
}
74 changes: 74 additions & 0 deletions Missions/DayZCommunityOfflineMode.Rostow/core/KeyMouseBinding.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
class KeyMouseBinding
{
protected typename m_Object;
protected ref array< string > m_KeyBinds;

protected string m_CallbackFunction;
protected string m_UAInputName;
protected string m_Description;

protected bool m_CanBeUsedInMenu;

protected int m_ActionType;

void KeyMouseBinding( typename object, string callback, string description, bool menu = false )
{
m_Object = object;
m_KeyBinds = new array< string >;

m_CallbackFunction = callback;
m_UAInputName = "UA" + object.ToString() + callback;

m_Description = description;

m_CanBeUsedInMenu = menu;

m_ActionType = KeyMouseActionType.PRESS;
}

bool CanBeUsedInMenu()
{
return m_CanBeUsedInMenu;
}

void AddBinding( string key, int action = 1)
{
m_KeyBinds.Insert( key );
m_ActionType = action;
}

ref array< string > GetBindings()
{
return m_KeyBinds;
}

void SetActionType( int type )
{
m_ActionType = type;
}

int GetActionType()
{
return m_ActionType;
}

typename GetObject()
{
return m_Object;
}

string GetCallBackFunction()
{
return m_CallbackFunction;
}

string GetUAInputName()
{
return m_UAInputName;
}

string GetDescription()
{
return m_Description;
}
}
Loading