Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Da0ne committed Sep 24, 2019
1 parent d22327e commit 7ecf029
Show file tree
Hide file tree
Showing 65 changed files with 2,856 additions and 1,392 deletions.
2 changes: 2 additions & 0 deletions 3_Game/VanillaPlusPlus.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
modded class DayZGame
{
#define VPP_Admintools_Loaded

private bool m_SpectateStatus;
private bool m_IsLShiftHolding;
void DayZGame()
Expand Down
88 changes: 88 additions & 0 deletions 3_Game/utils/xmlparser/XMLParser.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
class XMLParser
{
/*
Author: Vanilla++ DayZ SA Project
Note: This script is only desgin to work with a few specific XMLs (DayZ db loot types xmls)
*/

private ref array<string> m_RawLines;
private string FILE_PATH;
private FileHandle m_FileHandle;

void XMLParser(string filePath)
{
FILE_PATH = filePath;
Print("Init XMLParser...file: "+filePath);
}

bool Load()
{
m_FileHandle = OpenFile(FILE_PATH, FileMode.READ);
if (m_FileHandle == 0) return false;

m_RawLines = new array<string>;
string line_content = "";
int char_count = FGets( m_FileHandle, line_content );
while ( char_count != -1 )
{
m_RawLines.Insert(line_content);
char_count = FGets( m_FileHandle, line_content );
}

CloseFile(m_FileHandle);
return true;
}

bool VerifyXml()
{
string sTag = "<?xml";
string eTag = "?>";

if (m_RawLines == null || m_RawLines.Count() < 0) return false;

foreach(string line : m_RawLines)
{
if (line.Contains(sTag) && line.Contains(eTag))
{
Print("Valid Xml file :D");
return true;
}
}
Print("Invalid Xml file :(");
return false;
}

array<string> GetElementString(string eName, string param = "")
{
string sTag, eTag;
eTag = "</"+eName+">";
if (param == "")
sTag = "<"+eName+">";
else
sTag = "<"+eName+" name="+"\""+param+"\">";

bool pull = false;
autoptr array<string> data = new array<string>;

foreach(string line : m_RawLines)
{
if (line.Contains(sTag))
{
//Hit Start line of tag
Print("Hit-Start of Element: "+sTag+" "+eTag);
pull = true;
}

if (line.Contains(eTag) && pull)
{
data.Insert(line);
Print("Hit-End of Element: "+sTag+" "+eTag);
break;
}

if (pull)
data.Insert(line);
}
return data;
}
};
4 changes: 2 additions & 2 deletions 4_World/Entities/PlayerBase.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ modded class PlayerBase
void PlayerBase()
{
RegisterNetSyncVariableBool("m_isInvisible");
GetRPCManager().AddRPC( "RPC_PlayerBase", "InvokeReload", this, SingeplayerExecutionType.Server );
GetRPCManager().AddRPC( "RPC_PlayerBase", "InvokeReload", this, SingeplayerExecutionType.Server );
}

override void OnConnect()
{
super.OnConnect();
Expand Down
9 changes: 3 additions & 6 deletions 4_World/Misc/VPPCameras/VPPFreeCam.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class VPPFreeCam extends Camera
{
//---------
protected float CAM_SPEED = 5.0;
protected float MAX_CAM_SPEED = 55.0;
protected float MAX_CAM_SPEED = 75.0;
protected float CAM_BOOST = 10.0;
protected float CAM_MOVE_DRAG = 0.7;
protected float CAM_MOUSE_SENSE = 0.4;
Expand Down Expand Up @@ -69,11 +69,8 @@ class VPPFreeCam extends Camera
local_camspeed = local_camspeed * CAM_BOOST;
}

if (local_camspeed >= MAX_CAM_SPEED && !increaseSpeeds){
CAM_SPEED = 1.0;
Print("SPEED RESET");
}

if (local_camspeed >= MAX_CAM_SPEED && !increaseSpeeds)
CAM_SPEED = 5.0;

vector up = vector.Up;
vector direction = GetDirection();
Expand Down
20 changes: 18 additions & 2 deletions 4_World/Plugins/PluginBase/BuildingSetManager/BuildingSetManager.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class BuildingSetManager : ConfigurablePlugin
GetRPCManager().AddRPC("RPC_BuildingSetManager", "RemoteDeleteSet", this);
GetRPCManager().AddRPC("RPC_BuildingSetManager", "RemoteSaveEdits", this);
GetRPCManager().AddRPC("RPC_BuildingSetManager", "RemoteQuickDeleteObject", this);
GetRPCManager().AddRPC("RPC_BuildingSetManager", "ExportSetToCode", this);
//-------
}

Expand Down Expand Up @@ -214,11 +215,14 @@ class BuildingSetManager : ConfigurablePlugin
autoptr BuildingSet bSet = GetBuildingSetByName(data.param2);
if (bSet != null)
{
bool wasActive = bSet.GetActive();
bSet.SetActive(false);
bSet.ClearBuildings();
bSet.SetBuildingsArray(data.param1);

SaveBuildingSet(bSet);
bSet.SetActive(wasActive);
}
SaveBuildingSet(bSet);
bSet.SetActive(bSet.GetActive());

//Send new data to client
GetRPCManager().SendRPC("RPC_MenuObjectManager","HandleData", new Param1<ref array<string>>(GetSetsNames()),true,sender);
Expand All @@ -238,6 +242,18 @@ class BuildingSetManager : ConfigurablePlugin
if (data.param1 != null)
GetGame().ObjectDelete(data.param1);
}

void ExportSetToCode(CallType type, ParamsReadContext ctx, PlayerIdentity sender, Object target)
{
Param1<string> data;
if (!ctx.Read(data)) return;

autoptr BuildingSet bset = GetBuildingSetByName(data.param1);
if (bset != null)
{
bset.ExportBuildings();
}
}
/*
[End RPC's]
*/
Expand Down
71 changes: 59 additions & 12 deletions 4_World/Plugins/PluginBase/BuildingSetManager/Classes/BuildingSet.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ class BuildingSet
}

//use only for client when creating new objects
void AddBuildingObject(string name, vector pos, vector orientation, bool active, Object activeObj)
SpawnedBuilding AddBuildingObject(string name, vector pos, vector orientation, bool active, Object activeObj)
{
m_Buildings.Insert(new SpawnedBuilding(name, pos, orientation, active, activeObj));
ref SpawnedBuilding result = new SpawnedBuilding(name, pos, orientation, active, activeObj);
m_Buildings.Insert(result);
return result;
}

void SetBuildingActive(string name, bool active)
Expand All @@ -78,16 +80,22 @@ class BuildingSet
Print("[BuildingSetManager]:: SetBuildingActive: " + name + " is an invalid name.");
}

void SetActive(bool active)
{
m_IsActive = active;

foreach(SpawnedBuilding building : m_Buildings)
{
building.SetActive(active);
}
}

void SetActive(bool active)
{
m_IsActive = active;

foreach(SpawnedBuilding building : m_Buildings)
{
if (building != null)
{
if (m_IsActive)
building.SetActive(building.GetActive());
else
building.DestroySpawnedEntity();
}
}
}

array<ref SpawnedBuilding> GetBuildings()
{
return m_Buildings;
Expand Down Expand Up @@ -137,7 +145,46 @@ class BuildingSet
GetGame().ObjectDelete(trackerObj);
}
}

void ExportBuildings()
{
FileHandle m_FileHandle;
m_FileHandle = OpenFile("$profile:VPPAdminTools/Exports/"+m_Name+".txt", FileMode.WRITE);
if (m_FileHandle == 0) return;

string function = "void SpawnObject(string objType, vector objPos, vector objOrientation)\n";
function += "{\n";
function += "\tObject m_Building = Object.Cast(GetGame().CreateObject(objType, objPos));\n";
function += "\tif (m_Building == null) return;\n";
function += "\tm_Building.SetAffectPathgraph(true, false);\n";
function += "\tGetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(GetGame().UpdatePathgraphRegionByObject, 100, false, m_Building);\n";
function += "\tm_Building.SetPosition(objPos);\n";
function += "\tm_Building.SetOrientation(objOrientation);\n";
function += "}\n\n\n";

FPrintln(m_FileHandle, function);

foreach(SpawnedBuilding building: m_Buildings)
{
string format = "SpawnObject( \"" + building.GetTypeName() + "\", \"" + building.GetPosition().ToString(false) + "\", \"" + building.GetOrientation().ToString(false) + "\" );";
FPrintln(m_FileHandle, format);
}

CloseFile(m_FileHandle);
}

SpawnedBuilding GetSpawnedBuilding(SpawnedBuilding compare)
{
foreach(SpawnedBuilding building : m_Buildings)
{
if(building.GetName() == compare.GetName() || building == compare)
{
return building;
}
}
return null;
}

SpawnedBuilding GetBuildingByName(string name)
{
foreach(SpawnedBuilding building : m_Buildings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SpawnedBuilding
private Object m_Building;
private string m_NetWorkId;

void SpawnedBuilding(string name, vector pos, vector orientation, bool isAlive = false, Object obj = null)
void SpawnedBuilding(string name, vector pos, vector orientation, bool isAlive = true, Object obj = null)
{
m_IsActive = isAlive;
m_ObjectName = name;
Expand All @@ -28,14 +28,18 @@ class SpawnedBuilding

void ~SpawnedBuilding()
{
if (m_Building != null){
GetGame().ObjectDelete(m_Building);
}else{
TStringArray strs = new TStringArray;
m_NetWorkId.Split( ",",strs );
autoptr Object netWrkObj = GetGame().GetObjectByNetworkId(strs[1].ToInt(), strs[0].ToInt()); //low,high
if (netWrkObj != null)
GetRPCManager().SendRPC("RPC_BuildingSetManager","RemoteQuickDeleteObject", new Param1<Object>(netWrkObj),true,null);
if (GetGame().IsServer() && GetGame().IsMultiplayer())
{
if (m_Building != null){
DestroySpawnedEntity();
}else{
TStringArray strs = new TStringArray;
m_NetWorkId.Split( ",",strs );
autoptr Object netWrkObj = GetGame().GetObjectByNetworkId(strs[1].ToInt(), strs[0].ToInt()); //low,high
GetGame().ObjectDelete(netWrkObj);
//if (netWrkObj != null)
//GetRPCManager().SendRPC("RPC_BuildingSetManager","RemoteQuickDeleteObject", new Param1<Object>(netWrkObj),true,null);
}
}
}

Expand Down Expand Up @@ -104,7 +108,7 @@ class SpawnedBuilding

if(!m_IsActive)
{
GetGame().ObjectDelete(m_Building);
DestroySpawnedEntity();
}

if(m_IsActive)
Expand All @@ -116,6 +120,12 @@ class SpawnedBuilding
}
}

void DestroySpawnedEntity()
{
if (m_Building != null)
GetGame().ObjectDelete(m_Building);
}

bool IsObject(Object obj)
{
if(m_Building)
Expand All @@ -124,8 +134,14 @@ class SpawnedBuilding
return m_ObjectName == obj.GetDisplayName();
}

string GetNetworkId()
string GetNetworkId(bool clean = false)
{
if (clean)
{
string edited = m_NetWorkId;
edited.Replace(",", "");
return edited;
}
return m_NetWorkId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class ChatCommandManager : PluginBase
Human human = Human.Cast(self);
Car toBeFilled = Car.Cast(human.GetCommand_Vehicle().GetTransport());

if(toBeFilled != null) return;
if(toBeFilled == null) return;

EntityAI carEntity = toBeFilled;
carEntity.SetHealth("", "",carEntity.GetMaxHealth());
Expand Down
Loading

0 comments on commit 7ecf029

Please sign in to comment.