Skip to content

Commit

Permalink
1.08 Support [v1.5]
Browse files Browse the repository at this point in the history
  • Loading branch information
Da0ne committed Jul 6, 2020
1 parent 67a9f4c commit fd52cda
Show file tree
Hide file tree
Showing 130 changed files with 40,371 additions and 1,018 deletions.
1 change: 1 addition & 0 deletions $PREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VPPAdminTools
1 change: 1 addition & 0 deletions $REVISION$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
55 changes: 55 additions & 0 deletions 3_Game/EventHandler/VPPEventHandler.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
class VPPEventHandler
{
private ref map<string, ref ScriptInvoker> events;

void VPPEventHandler()
{
events = new map<string, ref ScriptInvoker>;
AddEvent("OnPlayerConnect");
AddEvent("OnPlayerDisconnected");
AddEvent("OnClientDisconnectCancel");
}

void ~VPPEventHandler()
{
foreach(string name, ScriptInvoker invoker : events)
{
if(invoker != null)
{
invoker.Clear();
}
}
events.Clear();
delete events;
}

void AddEvent(string eventName)
{
if(events.Contains(eventName))
{
Print("[" + ClassName() + "]:: Duplicate Event Added: " + eventName);
return;
}

if(!events.Contains(eventName))
events.Insert(eventName, new ScriptInvoker());
}

ScriptInvoker GetEventInvoker(string eventName)
{
ScriptInvoker eventInvoker;

if(!events.Contains(eventName))
{
Print("[" + ClassName() + "]:: Invalid Event: " + eventName);
return null;
}

if(events.Contains(eventName))
{
eventInvoker = events[eventName];
}

return eventInvoker;
}
}
36 changes: 30 additions & 6 deletions 3_Game/VanillaPlusPlus.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
modded class DayZGame
{
#define VPP_Admintools_Loaded
private ref VPPEventHandler vppatEventHandler;

private bool m_SpectateStatus;
private bool m_IsLShiftHolding;

void DayZGame()
{
Print("[DayZ Game]:: DayZGame(): Initializing V++ Admin Tools.");
vppatEventHandler = new VPPEventHandler();
GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(this.RegisterRPCs, 500, false); //Register RPCs after 10 seconds of game boot
}

Expand All @@ -28,10 +30,16 @@ modded class DayZGame
}
}

ref VPPEventHandler VPPATGetEventHandler()
{
return vppatEventHandler;
}

//Register early RPCs after game is running.
void RegisterRPCs()
{
GetRPCManager().AddRPC( "RPC_MissionGameplay", "KickClientHandle", this );
GetRPCManager().AddRPC( "RPC_MissionGameplay", "GetConnectedSession", this );
}

void KickClientHandle( CallType type, ParamsReadContext ctx, PlayerIdentity sender, Object target )
Expand All @@ -46,14 +54,25 @@ modded class DayZGame
{
if (GetDayZGame().GetGameState() != DayZGameState.CONNECT || GetDayZGame().GetGameState() != DayZGameState.CONNECTING || g_Game.GetLoadState() != DayZLoadState.CONNECT_START)
{
GetGame().GetUIManager().ShowDialog("Session Disconnect", "V++ AdminTools: "+data.param1, 1, DBT_OK, DBB_OK, DMT_WARNING, g_Game.GetUIManager().GetMenu());
GetGame().GetUIManager().ShowDialog("#VSTR_SESSION_DISCONNECT", "V++ AdminTools: "+data.param1, 1, DBT_OK, DBB_OK, DMT_WARNING, g_Game.GetUIManager().GetMenu());
GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(GetGame().DisconnectSessionForce, 100, false);
done = true;
break;
}
}
}
}

void GetConnectedSession( CallType type, ParamsReadContext ctx, PlayerIdentity sender, Object target )
{
if (type == CallType.Client)
{
string address;
int port;
GetGame().GetHostAddress( address, port );
GetRPCManager().SendRPC( "RPC_MissionGameplay", "ConnectedSession", new Param1<string>(address), true);
}
}

void SetSpectateMode(bool state)
{
Expand Down Expand Up @@ -226,7 +245,7 @@ modded class DayZGame
return hitPos;
}

set< Object > GetObjectsAt( vector from, vector to, Object ignore = NULL, float radius = 0.6, Object with = NULL )
set< Object > GetObjectsAt( vector from, vector to, Object ignore = NULL, float radius = 0.0, Object with = NULL )
{
vector contact_pos;
vector contact_dir;
Expand All @@ -247,7 +266,7 @@ modded class DayZGame
return NULL;
}

Object getObjectAtCrosshair(float distance = 1000.0, float radius = 0.6, Object with = NULL)
Object getObjectAtCrosshair(float distance = 1000.0, float radius = 0.0, Object with = NULL)
{
vector rayStart = GetGame().GetCurrentCameraPosition();
vector rayEnd = rayStart + GetGame().GetCurrentCameraDirection() * distance;
Expand All @@ -258,4 +277,9 @@ modded class DayZGame

return NULL;
}
}
};

ref VPPEventHandler VPPATGetEventHandler()
{
return g_Game.VPPATGetEventHandler();
};
87 changes: 48 additions & 39 deletions 4_World/Entities/PlayerBase.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,25 @@ modded class PlayerBase
private bool hasUnlimitedAmmo;
private bool hasFlyinCar;
private bool m_isInvisible;
private bool m_freezePlayer;

void PlayerBase()
{
RegisterNetSyncVariableBool("m_isInvisible");
RegisterNetSyncVariableBool("m_freezePlayer");
GetRPCManager().AddRPC( "RPC_PlayerBase", "InvokeReload", this, SingeplayerExecutionType.Server );
}

override void OnConnect()
override void EOnFrame(IEntity other, float timeSlice)
{
super.OnConnect();

if(GetGame().IsServer() && GetGame().IsMultiplayer())
{
if(!GetPlayerListManager().HasPlayerInList(GetIdentity().GetPlainId()))
{
GetPlayerListManager().AddUserServer(GetIdentity().GetName(), GetIdentity().GetPlainId());
}

if(GetPermissionManager().HasUserGroup(GetIdentity().GetPlainId()))
{
GetPlayerListManager().SendPlayerList(GetIdentity());
}
}
super.EOnFrame(other, timeSlice);
//if ( GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT )
//{
if ( m_isInvisible )
{
this.ClearFlags(EntityFlags.VISIBLE|EntityFlags.SOLID, true );
}
//}
}

void InvokeReload(CallType type, ParamsReadContext ctx, PlayerIdentity sender, Object target)
Expand Down Expand Up @@ -54,28 +50,44 @@ modded class PlayerBase
override void OnVariablesSynchronized()
{
super.OnVariablesSynchronized();
setInvisibility(m_isInvisible);
VPPSetInvisibility(m_isInvisible);
FreezePlayer(m_freezePlayer);
}

void setInvisibility(bool state)
void VPPSetInvisibility(bool state)
{
m_isInvisible = state;

if (!IsAlive()) return;
SetInvisible(state);
if (state){
ClearFlags(EntityFlags.VISIBLE|EntityFlags.SOLID, true );
}else{
SetFlags(EntityFlags.VISIBLE|EntityFlags.SOLID, true);
if (!state && GetGame().IsClient())
this.SetFlags(EntityFlags.VISIBLE|EntityFlags.SOLID, true);
else if ( GetGame().IsServer() ){
m_isInvisible = state;
SetSynchDirty();
}
SetSynchDirty();
}

void setGodMode(bool trigger)
{
hasGodmode = trigger;
SetAllowDamage(!trigger);
}

void FreezePlayer(bool state)
{
if ( GetGame().IsServer() )
{
m_freezePlayer = state;
SetSynchDirty();
return;
}

HumanInputController hic = this.GetInputController();
if ( hic )
hic.SetDisabled( state );
}

bool IsFreezeControls()
{
return m_freezePlayer;
}

bool GodModeStatus()
{
Expand Down Expand Up @@ -106,7 +118,7 @@ modded class PlayerBase
{
return hasFlyinCar;
}

void UnlimitedAmmoCheck(Weapon_Base weapon)
{
if ( IsUnlimitedAmmo() )
Expand All @@ -115,25 +127,22 @@ modded class PlayerBase
if ( GetGame().IsServer() )
{
magazine = weapon.GetMagazine(weapon.GetCurrentMuzzle());


if ( GetGame().IsMultiplayer() && magazine)
GetGame().RemoteObjectDelete( magazine );

if(magazine)
{
if (magazine.GetAmmoCount() <= 5)
{
magazine.ServerSetAmmoMax();
}
}
magazine.ServerSetAmmoMax();

if ( GetGame().IsMultiplayer() && magazine)
GetGame().RemoteObjectCreate( magazine );
}
else
{
magazine = weapon.GetMagazine(weapon.GetCurrentMuzzle());

if(magazine)
{
if (magazine.GetAmmoCount() <= 5)
{
magazine.LocalSetAmmoMax();
}
magazine.LocalSetAmmoMax();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion 4_World/Entities/Weapon_Base.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
modded class Weapon_Base
{
override void EEFired (int muzzleType, int mode, string ammoType)
override void EEFired(int muzzleType, int mode, string ammoType)
{
super.EEFired (muzzleType, mode, ammoType);
PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
Expand Down
Loading

0 comments on commit fd52cda

Please sign in to comment.