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

Adds Sakhal to the DayZCommunityOffline Repository #394

Open
wants to merge 7 commits into
base: production
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add files via upload
LoganHall195 authored Oct 16, 2024
commit ca64d1c2cec485aef624590bfaa2856a969d01e1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include ChernarusPlus files

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "$CurrentDir:missions\\DayZCommunityOfflineMode.ChernarusPlus\\core\\ModuleManager.c"
#include "$CurrentDir:missions\\DayZCommunityOfflineMode.ChernarusPlus\\core\\StaticFunctions.c"

#include "$CurrentDir:missions\\DayZCommunityOfflineMode.ChernarusPlus\\core\\CommunityOfflineClient.c"
#include "$CurrentDir:missions\\DayZCommunityOfflineMode.ChernarusPlus\\core\\CommunityOfflineServer.c"
136 changes: 136 additions & 0 deletions Missions/DayZCommunityOfflineMode.sakhal/core/CommunityOfflineClient.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
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.GetOvercast().SetLimits( 0.0 , 2.0 );
weather.GetRain().SetLimits( 0.0 , 2.0 );
weather.GetFog().SetLimits( 0.0 , 2.0 );

weather.GetOvercast().SetForecastChangeLimits( 0.0, 0.0 );
weather.GetRain().SetForecastChangeLimits( 0.0, 0.0 );
weather.GetFog().SetForecastChangeLimits( 0.0, 0.0 );

weather.GetOvercast().SetForecastTimeLimits( 1800 , 1800 );
weather.GetRain().SetForecastTimeLimits( 600 , 600 );
weather.GetFog().SetForecastTimeLimits( 600 , 600 );

weather.GetOvercast().Set( 0.0, 0, 0 );
weather.GetRain().Set( 0.0, 0, 0 );
weather.GetFog().Set( 0.0, 0, 0 );

weather.SetWindMaximumSpeed( 50 );
weather.SetWindFunctionParams( 0, 0, 1 );
}

override UIScriptedMenu CreateScriptedMenu(int id)
{
if(id == EditorMenu.MENU_ID)
{
return new EditorMenu();
}

return super.CreateScriptedMenu(id);
}
}
122 changes: 122 additions & 0 deletions Missions/DayZCommunityOfflineMode.sakhal/core/CommunityOfflineServer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
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()
{
//Offical DayZ SA weather code
Weather weather = g_Game.GetWeather();

weather.GetOvercast().SetLimits( 0.0 , 2.0 );
weather.GetRain().SetLimits( 0.0 , 2.0 );
weather.GetFog().SetLimits( 0.0 , 2.0 );

weather.GetOvercast().SetForecastChangeLimits( 0.0, 0.0 );
weather.GetRain().SetForecastChangeLimits( 0.0, 0.0 );
weather.GetFog().SetForecastChangeLimits( 0.0, 0.0 );

weather.GetOvercast().SetForecastTimeLimits( 1800 , 1800 );
weather.GetRain().SetForecastTimeLimits( 600 , 600 );
weather.GetFog().SetForecastTimeLimits( 600 , 600 );

weather.GetOvercast().Set( 0.0, 0, 0 );
weather.GetRain().Set( 0.0, 0, 0 );
weather.GetFog().Set( 0.0, 0, 0 );

weather.SetWindMaximumSpeed( 50 );
weather.SetWindFunctionParams( 0, 0, 1 );
}

override UIScriptedMenu CreateScriptedMenu(int id)
{
if(id == EditorMenu.MENU_ID)
{
return new EditorMenu();
}

return super.CreateScriptedMenu(id);
}
}
74 changes: 74 additions & 0 deletions Missions/DayZCommunityOfflineMode.sakhal/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;
}

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