Commit be1228ca authored by Mikleo's avatar Mikleo

--

parent 28a76ec4
Pipeline #9288 passed with stages
in 13 seconds
......@@ -9,7 +9,7 @@
#include <updater>
#define PluginVersion "0.97"
#define PluginVersion "0.98"
float pVersion;
// note linearmap field is unstable
......@@ -43,7 +43,8 @@ bool lockgrabaxis [MAXPLAYERS+1][3];
bool lockgrabrotation [MAXPLAYERS+1] = {false, ...};
float playerGridSize [MAXPLAYERS+1] = {0.1, ...};
float playerGridSize [MAXPLAYERS+1][3];
float playerSnapRadius [MAXPLAYERS+1] = {0.1, ...};
float playerSnapAngle[MAXPLAYERS+1] = {0.1, ...};
......@@ -162,8 +163,8 @@ public void OnPluginStart()
RegConsoleCmd("sm_entcontextheight", Command_Ent_ContextHeight);
RegConsoleCmd("sm_entcontextangle", Command_Ent_ContextAngle);
RegConsoleCmd("sm_gridsize", Command_Player_Grid_Size);
RegConsoleCmd("sm_snapradius", Command_Player_Snap_Radius);
RegConsoleCmd("sm_snapangle", Command_Snap_Angle);
RegConsoleCmd("sm_snapangles", Command_Snap_Angle);
RegConsoleCmd("sm_lockgrabaxis", Command_Lock_Grab_Axis);
RegConsoleCmd("sm_lockgrabrotation", Command_Lock_Grab_Rotation);
......@@ -275,7 +276,10 @@ public void OnLibraryAdded(const char[] name)
public OnClientConnected(int client)
{
playerGridSize[client] = 0.1;
playerGridSize[client][0] = 0.1;
playerGridSize[client][1] = 0.1;
playerGridSize[client][2] = 0.1;
playerSnapRadius[client] = 0.1;
playerSnapAngle[client] = 0.1;
lockgrabaxis[client][0] = false;
lockgrabaxis[client][1] = false;
......@@ -285,7 +289,10 @@ public OnClientConnected(int client)
public OnMapStart()
{
currentScenarioKV = new KeyValues("Scenario");
// set up some default properties so they can be edited in file
currentScenarioKV.SetString("Description"," ");
currentScenarioKV.SetString("Details"," ");
currentScenarioKV.SetString("Tags"," ");
int ef_baseswap_temp = ef_baseswap.IntValue;
AutoExecConfig(true, "empfun");
......@@ -366,7 +373,16 @@ public OnGameStart()
}
}
}
Funcs_OnGameStart();
}
public OnGameEnd()
{
Funcs_OnGameEnd();
}
// not called on late loads, after onmapstart
public void OnConfigsExecuted()
......@@ -447,6 +463,9 @@ public bool StartScenarioVote(KeyValues kv)
return;
}
char path[128];
Menu menu = new Menu(Handle_VoteMenu);
......@@ -511,7 +530,7 @@ public bool StartScenarioVote(KeyValues kv)
{
Format(optionText,sizeof(optionText),"%s%s",optionText,displayName);
}
if(ef_scenario_vote_display_tags.IntValue == 1 && strlen(tags) > 0)
if(ef_scenario_vote_display_tags.IntValue == 1 && strlen(tags) > 1)
{
Format(optionText,sizeof(optionText),"%s (%s)",optionText,tags);
}
......@@ -838,7 +857,7 @@ public Action Command_Action(int client,int args)
if(client == 0)
client = 1;
OnMapEdited();
......@@ -1056,7 +1075,8 @@ public Action Command_Action(int client,int args)
char className[64];
GetEntityClassname(entity, className, sizeof(className));
PrintToChat(client,className);
int hammerid = GetEntProp(entity,Prop_Data,"m_iHammerID");
PrintToChat(client,"hammer_id:%d",hammerid);
}
......@@ -1545,7 +1565,6 @@ bool BaseSpawnPreset(int client,char[] presetName,bool isVehicle,float position[
} while (iterate && kv.GotoNextKey(false));
//PrintToServer("%d",kv);
delete kv;
}
......@@ -1878,7 +1897,7 @@ public Action Edit_Entity(int client, int entity,float position[3],bool editExis
if (!GetCmdArg(1, arg1, sizeof(arg1)) || !GetCmdArg(2, arg2, sizeof(arg2)))
{
char result[128] = "Keys: ";
char result[256] = "Keys: ";
for(int i = 0;i<keys.Length;i++)
{
keyData.GetArray(keys.Get(i),keyinfo,keyinfoenum);
......@@ -2575,11 +2594,29 @@ float SnapFloat(float value,float width)
return RoundFloat(value / width) * width;
}
void SnapToGrid(float position[3],float grid)
void SnapToRadius(float position[3],float radius)
{
if(radius < 1.0)
return;
float length = GetVectorLength(position, false);
float snapLength = RoundFloat(length / radius) * radius;
float transform = snapLength / length;
position[0] *= transform;
position[1] *= transform;
position[2] *= transform;
}
void SnapToGrid(float position[3],float gridSize[3])
{
position[0] = RoundFloat(position[0] / grid) * grid;
position[1] = RoundFloat(position[1] / grid) * grid;
position[2] = RoundFloat(position[2] / grid) * grid;
position[0] = RoundFloat(position[0] / gridSize[0]) * gridSize[0];
position[1] = RoundFloat(position[1] / gridSize[1]) * gridSize[1];
position[2] = RoundFloat(position[2] / gridSize[2]) * gridSize[2];
}
public void Release_Grab(int client)
{
......@@ -2824,7 +2861,14 @@ public Action:Hook_Grab(grabbingClient,client)
float positionDiff[3];
SubtractVectors(pos,grabStartPos[client],positionDiff);
SnapToRadius(positionDiff,playerSnapRadius[client]);
SnapToGrid(positionDiff,playerGridSize[client]);
AddVectors(positionDiff,grabStartPos[client],pos);
......@@ -3547,6 +3591,8 @@ public Action Command_Scenario_Info(int client, int args)
{
ShowScenarioInfo(client,12,true);
return Plugin_Handled;
}
......@@ -3861,7 +3907,10 @@ SaveScenario(int client,char [] filename,bool saveMetaData = true)
// save the author
char ScenarioAuthor[32];
GetClientName(client,ScenarioAuthor,sizeof(ScenarioAuthor));
kv.SetString("Author",ScenarioAuthor);
if(saveMetaData)
SaveMetaData(kv);
......@@ -3872,17 +3921,25 @@ SaveScenario(int client,char [] filename,bool saveMetaData = true)
int hLimit = latestKnownMapEntity;
if(hLimit == 0)
hLimit = BASEHAMMERID -1;
kv.Rewind();
kv.SetFloat("version",pVersion);
// hLimit is used so new entities a mapper adds will not be removed by default.
kv.SetNum("hLimit",hLimit);
ExportKV(kv,path);
kv.Rewind();
kv.DeleteKey("Entities");
kv.DeleteKey("BE_Research");
kv.DeleteKey("NF_Research");
RemoveScenarioKeys();
if(!StrEqual(filename,"default",false))
......@@ -3903,6 +3960,29 @@ SaveScenario(int client,char [] filename,bool saveMetaData = true)
}
// needs to be done on both save and load.
RemoveScenarioKeys()
{
KeyValues kv = currentScenarioKV;
//seems like its the only way to remove stuff we dont want to preserve
kv.Rewind();
kv.JumpToKey("Entities");
kv.DeleteThis();
kv.Rewind();
kv.JumpToKey("BE_Research");
kv.DeleteThis();
kv.Rewind();
kv.JumpToKey("NF_Research");
kv.DeleteThis();
kv.Rewind();
}
LoadCvars(KeyValues kv)
{
int ScenarioFreezeTime = kv.GetNum("CommFreezeTime",-1);
......@@ -3926,25 +4006,30 @@ LoadCvars(KeyValues kv)
bool LoadScenario(int client,char[] filename)
{
char path[256];
GetScenarioPath(filename,path,sizeof(path));
bool succeeded = false;
delete currentScenarioKV;
KeyValues kv = new KeyValues("Scenario");
currentScenarioKV = kv;
if(!kv.ImportFromFile(path))
{
if(client > 0)
PrintToChat(client,"\x04[DP] \x01 Unable to find file");
delete kv;
}
else
{
// map edited can load another scenario, overriting the currentscenario, needs to be done first!
OnMapEdited();
Funcs_OnLoadScenario();
delete currentScenarioKV;
currentScenarioKV = kv;
Funcs_PreLoadScenario();
char cfgName[64];
if(strlen(currentScenario) > 0)
{
......@@ -3969,8 +4054,9 @@ bool LoadScenario(int client,char[] filename)
int hLimit = kv.GetNum("hLimit",BASEHAMMERID -1 );
kv.JumpToKey("Entities");
LoadEntities(kv,version,hLimit);
kv.Rewind();
kv.DeleteKey("Entities");
if(client > 0)
......@@ -3979,16 +4065,28 @@ bool LoadScenario(int client,char[] filename)
GetClientName(client,clientName,sizeof(clientName));
PrintToChatAll("\x07ff6600%s \x01has loaded the scenario: %s",clientName,filename);
}
RemoveScenarioKeys();
succeeded = true;
// load the scripts last, in case there are any errors in them
Funcs_AfterLoadScenario();
}
int scenarioBaseSwap = currentScenarioKV.GetNum("BaseSwap",-1);
if(ef_baseswap.IntValue == 1 && scenarioBaseSwap != 0 || (ef_baseswap.IntValue == 0 && scenarioBaseSwap > 0) )
{
DelayedBaseSwap();
}
return succeeded;
......@@ -4188,7 +4286,7 @@ LoadEntities(KeyValues kv,float version,int hLimit)
kv.GetSectionName(hammer_id_buffer, sizeof(hammer_id_buffer));
kv.GetString("className",className,sizeof(className));
if(GetEntitySavingKeys(className,version,classInfo))
{
......@@ -4197,6 +4295,8 @@ LoadEntities(KeyValues kv,float version,int hLimit)
if(hammer_id > max_hammer_id)
max_hammer_id = hammer_id;
int entity = -1;
// if they are not a custom element just reload them regardless.
if( hammer_id <= hLimit)
......@@ -4604,6 +4704,7 @@ RemoveSavableEntitiesExcept(ArrayList list,float version, int hLimit)
}
GetEntityClassname(entity, className, sizeof(className));
int hammerID = GetEntProp(entity,Prop_Data,"m_iHammerID");
if((hammerID <= hLimit || hammerID >= BASEHAMMERID) && GetEntitySavingKeys(className,version,classInfo) && list.FindValue(entity) == -1 && ShouldSave(entity,className,classInfo))
{
// remove this entity
......@@ -4799,7 +4900,11 @@ int findEntityWithHammerID(int hammerID,char [] className)
}
GetEntityClassname(entity, edictClassName, sizeof(edictClassName));
if(GetEntProp(entity, Prop_Data, "m_iHammerID") == hammerID && StrEqual(className,edictClassName,true))
{
return entity;
}
}
return -1;
}
......@@ -5033,6 +5138,9 @@ SaveMetaData(KeyValues kv)
int researchManager = FindEntityByClassname(MaxClients + 1,"research_manager");
char numBuffer[8];
char propName[32];
......@@ -5067,6 +5175,11 @@ SaveMetaData(KeyValues kv)
}
}
LoadMetaData(KeyValues kv)
{
......@@ -5090,7 +5203,6 @@ LoadMetaData(KeyValues kv)
if(beTickets >=0.0)
SetTickets(3,beTickets);
......@@ -5126,6 +5238,7 @@ LoadMetaData(KeyValues kv)
{
kv.GotoFirstSubKey(false);
kv.GetSectionName(numBuffer, sizeof(numBuffer));
int num = StringToInt(numBuffer);
if(num >=0 && num < 128)
{
......@@ -5145,6 +5258,15 @@ LoadMetaData(KeyValues kv)
kv.DeleteKey("NF_Research");
}
// in future split by spaces.
char unresearch[128];
kv.GetString("Unresearch" ,unresearch,sizeof(unresearch),"");
if(strlen(unresearch) > 0 && StrContains(unresearch,";") == -1)
{
ServerCommand("emp_sv_unresearch_item %s",unresearch);
}
}
// hack for now;
SetResources(int team,float amount)
......@@ -5317,20 +5439,59 @@ public Action Command_Player_Grid_Size(int client, int args)
if(client == 0)
client = 1;
float values[3];
char arg[64];
GetCmdArg(1, arg, sizeof(arg));
float value = StringToFloat(arg);
values[0] = StringToFloat(arg);
char arg2[64];
values[1] = values[0];
if(GetCmdArg(2, arg2, sizeof(arg2)))
values[1] = StringToFloat(arg2);
char arg3[64];
values[2] = values[1];
if(GetCmdArg(3, arg3, sizeof(arg3)))
values[2] = StringToFloat(arg3);
for(int i = 0;i<3;i++)
{
if(values[i] < 0.1)
values[i] = 0.1;
}
if(value < 0.1)
value = 0.1;
playerGridSize[client] = value;
playerGridSize[client] = values;
PrintToChat(client,"Changed grid size to %.1f",value);
PrintToChat(client,"Changed grid size to %.1f %.1f %.1f",values[0],values[1],values[2]);
return Plugin_Handled;
}
public Action Command_Player_Snap_Radius(int client, int args)
{
if(!CanEditMap(client))
{
return Plugin_Handled;
}
if(client == 0)
client = 1;
float value;
char arg[64];
GetCmdArg(1, arg, sizeof(arg));
value = StringToFloat(arg);
playerSnapRadius[client] = value;
PrintToChat(client,"Changed snap radius to %.1f ",value);
return Plugin_Handled;
}
public Action Command_Snap_Angle(int client, int args)
{
......
This diff is collapsed.
......@@ -10,6 +10,13 @@
"tags_override" "-"
"description_override" "-"
}
"mik_artifact"
{
"min_players" "24"
"max_players" "64"
"tags_override" "-"
"description_override" "-"
}
}
"enabled" "1"
}
......@@ -35,6 +35,14 @@
"propType" "data"
"defaultValue" "0"
}
"rendermode"
{
"fgdName" "rendermode"
"type" "int"
"prop" "m_nRenderMode"
"propType" "data"
"defaultValue" "0"
}
}
}
"map_entity"
......@@ -874,6 +882,13 @@
"propType" "data"
"defaultValue" "0.000000"
}
"team"
{
"prop" "m_iTeamNum"
"type" "int"
"defaultValue" "0"
}
}
......
......@@ -4,7 +4,7 @@
{
"Version"
{
"Latest" "0.97"
"Latest" "0.98"
}
}
......@@ -27,6 +27,7 @@
"Plugin" "Path_Mod/scenarios/emp_isle/votelist_base.txt"
"Plugin" "Path_Mod/scenarios/emp_duststorm/mik_flags.snr"
"Plugin" "Path_Mod/scenarios/emp_duststorm/mik_artifact.snr"
"Plugin" "Path_Mod/scenarios/emp_duststorm/votelist_base.txt"
"Plugin" "Path_Mod/scenarios/emp_palmbay/mik_boats.snr"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment