Commit 10ea9c4c authored by Mikleo's avatar Mikleo
Browse files

Added Lava atoll scenario

Added Resource files
Added the ability to change the editingset on a per scenario basis.
parent b202bab4
......@@ -10,7 +10,7 @@
#include <SteamWorks>
#define PluginVersion "1.32"
#define PluginVersion "1.33"
float pVersion;
// note linearmap field is unstable
......@@ -22,6 +22,8 @@ float pVersion;
char currentScenario[64];
KeyValues currentScenarioKV;
StringMap scenarioEditingSet;
int lastMinorEditTime = 0;
......@@ -55,7 +57,7 @@ char lastCommand[64];
bool usedFlagIndex[32] = {false,...};
ConVar ef_editlock,ef_baseswap,ef_scenario_vote_delay,ef_scenario_vote_duration,ef_scenario_vote_runoff_duration,ef_scenario_vote_min_timeleft,ef_scenario_vote_display_description,ef_scenario_vote_display_name,ef_scenario_vote_display_tags,ef_scenario_reload_map_config,ef_votelist_base,ef_alledit,ef_downloadeditorcfg,ef_useblockmodels;
ConVar ef_editlock,ef_baseswap,ef_scenario_vote_delay,ef_scenario_vote_duration,ef_scenario_vote_runoff_duration,ef_scenario_vote_min_timeleft,ef_scenario_vote_display_description,ef_scenario_vote_display_name,ef_scenario_vote_display_tags,ef_scenario_reload_map_config,ef_votelist_base,ef_alledit,ef_downloadeditorcfg;
ConVar emp_sv_commander_freeze_time, emp_sv_player_refinery_multiplier, emp_sv_refinery_multiplier;
......@@ -191,6 +193,8 @@ public void OnPluginStart()
// save a preset here
RegAdminCmd("sm_saveprefab", Command_Save_Prefab, ADMFLAG_SLAY);
RegAdminCmd("sm_scenariovar", Command_Scenario_Var, ADMFLAG_SLAY);
RegAdminCmd("sm_editingset", Command_EditingSet, ADMFLAG_SLAY);
RegAdminCmd("sm_scenariovote", Command_Scenario_Vote, ADMFLAG_SLAY);
RegAdminCmd("sm_scenariovotelist", Command_Scenario_Votelist, ADMFLAG_SLAY);
RegAdminCmd("sm_renamescenario", Command_Rename_Scenario, ADMFLAG_SLAY);
......@@ -226,8 +230,6 @@ public void OnPluginStart()
ef_votelist_base = CreateConVar("ef_votelist_base", "votelist_base.txt", "the name of the votelist file to use if no votelist is available.");
ef_alledit = CreateConVar("ef_alledit","0","Allow non admins to edit the map");
ef_useblockmodels = CreateConVar("ef_useblockmodels","0","Add block models to download list");
ef_downloadeditorcfg = CreateConVar("ef_downloadeditorcfg","0","Add editor.cfg to download list");
idxArmor = FindSendPropInfo("CEmpTank", "m_iEngine") -12;
......@@ -243,6 +245,9 @@ public void OnPluginStart()
LoadEntData();
scenarioEditingSet = new StringMap();
Funcs_OnPluginStart();
}
......@@ -322,6 +327,9 @@ public OnMapStart()
currentScenarioKV.SetString("Details"," ");
currentScenarioKV.SetString("Tags"," ");
scenarioEditingSet.Clear();
// reset currentscenario;
SetScenarioName("");
......@@ -358,42 +366,16 @@ public OnMapStart()
{
AddFileToDownloadsTable("cfg/editor.cfg");
}
if(ef_useblockmodels.IntValue > 0)
{
AddFileToDownloadsTable("models/empfun/platform2.dx90.vtx");
AddFileToDownloadsTable("models/empfun/platform2.mdl");
AddFileToDownloadsTable("models/empfun/platform2.phy");
AddFileToDownloadsTable("models/empfun/platform2.vvd");
AddFileToDownloadsTable("models/empfun/platform4.dx90.vtx");
AddFileToDownloadsTable("models/empfun/platform4.mdl");
AddFileToDownloadsTable("models/empfun/platform4.phy");
AddFileToDownloadsTable("models/empfun/platform4.vvd");
AddFileToDownloadsTable("models/empfun/platform8.dx90.vtx");
AddFileToDownloadsTable("models/empfun/platform8.mdl");
AddFileToDownloadsTable("models/empfun/platform8.phy");
AddFileToDownloadsTable("models/empfun/platform8.vvd");
AddFileToDownloadsTable("models/empfun/cube4.dx90.vtx");
AddFileToDownloadsTable("models/empfun/cube4.mdl");
AddFileToDownloadsTable("models/empfun/cube4.phy");
AddFileToDownloadsTable("models/empfun/cube4.vvd");
AddFileToDownloadsTable("materials/models/empfun/platform.vmt");
AddFileToDownloadsTable("materials/models/empfun/platform2.vmt");
AddFileToDownloadsTable("materials/models/empfun/platform3.vmt");
AddFileToDownloadsTable("materials/models/empfun/platform4.vmt");
AddFileToDownloadsTable("materials/models/empfun/platform5.vmt");
AddFileToDownloadsTable("materials/models/empfun/platform6.vmt");
AddFileToDownloadsTable("materials/models/empfun/platform7.vmt");
AddFileToDownloadsTable("materials/models/empfun/platform8.vmt");
AddFileToDownloadsTable("materials/models/empfun/platform9.vmt");
AddFileToDownloadsTable("materials/models/empfun/platform10.vmt");
AddFileToDownloadsTable("materials/models/empfun/platform11.vmt");
AddFileToDownloadsTable("materials/models/empfun/platform12.vmt");
}
PrecacheSound("weapons/mortar/mortar_explode2.wav");
// load resources from the map path.
char Path[128];
GetScenarioMapPath(Path,sizeof(Path));
LoadResources(Path);
// load resources from the global resources folder.
LoadResources("scenarios/_resources");
// some maps don't precache this, is essential
PrecacheModel("models/nf/buildings/armory/nf_armory.mdl", true);
......@@ -751,6 +733,7 @@ public Action Timer_LoadStartingScenario(Handle timer,int entity)
{
if(!EU_HasGameStarted())
{
if(strlen(nextMapScenario) > 0)
{
LoadScenario(0,nextMapScenario);
......@@ -767,29 +750,39 @@ public Action Timer_LoadStartingScenario(Handle timer,int entity)
SetupScenarioVote();
}
}
}
bool LoadOverrideScenario()
{
ArrayList items = new ArrayList(128);
GetScenarioList(items,true);
ArrayList scenarioList = new ArrayList(128);
GetScenarioList(scenarioList);
char fileBuffer[128];
bool loadedOverride = false;
if(items.Length > 0)
for(int i = 0;i<scenarioList.Length;i++)
{
int index = GetRandomInt(0,items.Length - 1);
items.GetString(index,fileBuffer,sizeof(fileBuffer));
LoadScenario(0,fileBuffer);
PrintToServer("loaded %s ", fileBuffer);
loadedOverride = true;
scenarioList.GetString(i,fileBuffer,sizeof(fileBuffer));
if(StrContains(fileBuffer, "override", true) == 0)
{
LoadScenario(0,fileBuffer);
PrintToServer("loaded %s ", fileBuffer);
loadedOverride = true;
break;
}
}
delete items;
delete scenarioList;
return loadedOverride;
}
GetScenarioList(ArrayList items,bool onlyOverride = false)
GetScenarioList(ArrayList items)
{
char fileBuffer[128];
char Path[128];
......@@ -798,7 +791,7 @@ GetScenarioList(ArrayList items,bool onlyOverride = false)
if(dL != null)
{
while (dL.GetNext(fileBuffer, sizeof(fileBuffer))) {
if(StrContains(fileBuffer, ".snr", true) >= 0 && (!onlyOverride || StrContains(fileBuffer, "override", true) == 0))
if(StrContains(fileBuffer, ".snr", true) >= 0)
{
items.PushString(fileBuffer);
}
......@@ -806,6 +799,48 @@ GetScenarioList(ArrayList items,bool onlyOverride = false)
}
delete dL;
}
LoadResources(char[] Path)
{
char fileBuffer[128];
DirectoryListing dL = OpenDirectory(Path);
char filePath[128];
if(dL != null)
{
while (dL.GetNext(fileBuffer, sizeof(fileBuffer))) {
if(StrContains(fileBuffer, ".res", true) >= 0)
{
// open and add files to download folder.
KeyValues kv = new KeyValues("Resources");
Format(filePath,sizeof(filePath),"%s/%s",Path,fileBuffer);
if(kv.ImportFromFile(filePath))
{
kv.Rewind();
char downloadFile[256];
kv.GotoFirstSubKey(false);
do
{
kv.GetSectionName(downloadFile, sizeof(downloadFile));
AddFileToDownloadsTable(downloadFile);
} while (kv.GotoNextKey(false) );
}
delete kv;
}
}
}
delete dL;
}
public Action Command_Plugin_Version(client, const String:command[], args)
{
......@@ -961,6 +996,11 @@ public Action Command_Action(int client,int args)
float rotation = clientAngles[1] - 180;
int entity = GetLookingPoint(clientOrigin,clientAngles,position);
// only select handleless entities
if(entity >= 0 && !IsHandlelessEntity(entity))
{
entity = -1;
}
if(entity <= 0)
{
entity = FindClosestHandlelessEntity(position,60.0);
......@@ -3748,44 +3788,82 @@ public Action Command_Scenario_Var(int client, int args)
// set description and baseswap "Options: Description Author Baseswap(1/0)"
char arg1 [128];
char arg2 [128];
char matching[128];
if(!GetCmdArg(1, arg1, sizeof(arg1)) || !GetCmdArg(2, arg2, sizeof(arg2)))
{
PrintToChat(client,"Options: Description,Details,CommFreezeTime,RefineryMultiplier,PlayerRefineryMultiplier CanBaseSwap(yes/no/-1(default)). eg /scenariovar description \"This is My Description\"");
return Plugin_Handled;
}
if(StrEqual(arg1,"Description",false))
{
currentScenarioKV.SetString("Description",arg2);
PrintToChat(client,"Set Description to:%s",arg2);
}
strcopy(matching,sizeof(matching),"Description");
if(StrEqual(arg1,"Details",false))
{
currentScenarioKV.SetString("details",arg2);
PrintToChat(client,"Set Details to:%s",arg2);
}
strcopy(matching,sizeof(matching),"Details");
if(StrEqual(arg1,"CanBaseSwap",false))
strcopy(matching,sizeof(matching),"CanBaseSwap");
if(StrEqual(arg1,"CommFreezeTime",false))
strcopy(matching,sizeof(matching),"CommFreezeTime");
if(StrEqual(arg1,"RefineryMultiplier",false))
strcopy(matching,sizeof(matching),"RefineryMultiplier");
if(StrEqual(arg1,"PlayerRefineryMultiplier",false))
strcopy(matching,sizeof(matching),"PlayerRefineryMultiplier");
if(StrEqual(arg1,"hMin",false))
strcopy(matching,sizeof(matching),"hMin");
if(StrEqual(arg1,"hMax",false))
strcopy(matching,sizeof(matching),"hMax");
currentScenarioKV.Rewind();
if(strlen(matching) > 0)
{
currentScenarioKV.SetString("CanBaseSwap",arg2);
PrintToChat(client,"Set CanBaseSwap to:%s",arg2);
if(StrEqual(arg2,"delete",false))
{
currentScenarioKV.DeleteKey(matching);
}
else
{
currentScenarioKV.SetString(matching,arg2);
}
PrintToChat(client,"Set %s to:%s",matching,arg2);
}
if(StrEqual(arg1,"CommFreezeTime",false))
PrintToChat(client,"Remember: You will need to save the scenario for your variables to be saved.");
return Plugin_Handled;
}
public Action Command_EditingSet(int client, int args)
{
// set description and baseswap "Options: Description Author Baseswap(1/0)"
char arg1 [128];
char arg2 [128];
if(!GetCmdArg(1, arg1, sizeof(arg1)) || !GetCmdArg(2, arg2, sizeof(arg2)))
{
currentScenarioKV.SetString("CommFreezeTime",arg2);
PrintToChat(client,"Set CommFreezeTime to:%d",arg2);
PrintToChat(client,"/editingset classname [Yes/No]");
return Plugin_Handled;
}
if(StrEqual(arg1,"RefineryMultiplier",false))
currentScenarioKV.Rewind();
currentScenarioKV.JumpToKey("EditingSet",true);
if(StrEqual(arg2,"yes",false))
{
currentScenarioKV.SetString("RefineryMultiplier",arg2);
PrintToChat(client,"Set RefineryMultiplier to:%f",arg2);
currentScenarioKV.SetString(arg1,"Yes");
scenarioEditingSet.SetValue(arg1,1);
}
if(StrEqual(arg1,"PlayerRefineryMultiplier",false))
else if(StrEqual(arg2,"no",false))
{
currentScenarioKV.SetString("PlayerRefineryMultiplier",arg2);
PrintToChat(client,"Set PlayerRefineryMultiplier to:%f",arg2);
currentScenarioKV.SetString(arg1,"No");
scenarioEditingSet.SetValue(arg1,-1);
}
PrintToChat(client,"Remember: You will need to save the scenario for your variables to be saved.");
PrintToChat(client,"Set editingset %s to:%s",arg1,arg2);
return Plugin_Handled;
}
......@@ -4141,6 +4219,25 @@ LoadCvars(KeyValues kv)
}
}
LoadEditingSet(KeyValues kv)
{
scenarioEditingSet.Clear();
char classnameBuffer[64];
char valueBuffer[32];
kv.GotoFirstSubKey(false);
do
{
kv.GetSectionName(classnameBuffer, sizeof(classnameBuffer));
kv.GetString(classnameBuffer,valueBuffer,sizeof(valueBuffer));
if(StrEqual(valueBuffer,"yes",false))
scenarioEditingSet.SetValue(classnameBuffer,1);
else if(StrEqual(valueBuffer,"no",false))
scenarioEditingSet.SetValue(classnameBuffer,-1);
} while (kv.GotoNextKey(false));
}
bool LoadScenario(int client,char[] filename)
......@@ -4202,6 +4299,11 @@ bool LoadScenario(int client,char[] filename)
hLimit = hMax;
kv.JumpToKey("EditingSet");
LoadEditingSet(kv);
kv.Rewind();
kv.JumpToKey("Entities");
LoadEntities(kv,version,hMin,hLimit);
......@@ -5149,6 +5251,14 @@ int FindClosestResourcePoint(float position[3], char [] pointName)
}
int EditingSetValue(char[] classname)
{
int value = 0;
scenarioEditingSet.GetValue(classname,value);
return value;
}
// returns isSelectable, include list of fields to
bool GetEntityData(char[] classname,any[] classInfo)
......@@ -5163,8 +5273,13 @@ bool ShouldSave(int entity,char[] classname,any[] classInfo)
if(hammerID == -1)
return false;
int editingSetValue = EditingSetValue(classname);
if(editingSetValue == -1)
return false;
// if the entity is customonly, don't save any non-custom entities.
if( hammerID < BASEHAMMERID && classInfo[data_customOnly])
if( hammerID < BASEHAMMERID && classInfo[data_customOnly] && editingSetValue < 1)
{
return false;
}
......@@ -5183,21 +5298,20 @@ bool ShouldSave(int entity,char[] classname,any[] classInfo)
if(parent > 0 && IsBuilding(parent))
return false;
}
if( StrEqual(classname,"emp_building_imp_mgturret",true) || StrEqual(classname,"emp_building_nf_mgturret",true) ||StrEqual(classname,"emp_building_imp_mlturret",true) || StrEqual(classname,"emp_building_nf_mlturret",true) )
else if( StrEqual(classname,"emp_building_imp_mgturret",true) || StrEqual(classname,"emp_building_nf_mgturret",true) ||StrEqual(classname,"emp_building_imp_mlturret",true) || StrEqual(classname,"emp_building_nf_mlturret",true) )
{
// do not save turrets with a player owner
if(GetEntProp(entity,Prop_Send,"m_iOwner") != 0)
return false;
}
if( StrEqual(classname,"emp_eng_walls",true))
else if( StrEqual(classname,"emp_eng_walls",true))
{
// do not save walls with a player owner.
if(GetEntProp(entity,Prop_Send,"m_iOwner") != 0)
return false;
}
if(StrEqual(classname,"emp_info_player_nf",false) || StrEqual(classname,"emp_info_player_imp",false))
else if(StrEqual(classname,"emp_info_player_nf",false) || StrEqual(classname,"emp_info_player_imp",false))
{
int capNumber = GetEntProp(entity,Prop_Data,"m_iCapNumber");
......@@ -7166,6 +7280,10 @@ public void AddHandle(int target,char[] color)
// prevent saving.
SetEntProp(entindex,Prop_Data,"m_iHammerID",-1);
SDKHook(entindex, SDKHook_SetTransmit, Hook_AlwaysTransmit);
SetEntityRenderMode(entindex, RENDER_TRANSCOLOR);
SetEntityRenderColor(entindex, r, g, b,220);
......@@ -7230,6 +7348,10 @@ public void DisableHandles()
// remove entity handles, use name
}
public Action:Hook_AlwaysTransmit(entity,client)
{
// always transmit, display outside map.
return Plugin_Continue;
}
......@@ -94,6 +94,9 @@ void Funcs_OnPluginStart()
AddCommand("Dec",DecVariable,1,false);
AddCommand("OnStartTouch",OnStartTouchHookCommand,2,false);
AddCommand("OnEndTouch",OnEndTouchHookCommand,2,false);
AddCommand("ClearParent",ClearParentCommand,0,false);
AddCommand("MoveToTarget",MoveToTargetCommand,6);
......@@ -1140,6 +1143,16 @@ public int PrintToTarget(int entity,char[] args,char[] remainder)
}
// prints to clients
public int ClearParentCommand(int entity,char[] args,char[] remainder)
{
AcceptEntityInput(entity, "ClearParent");
return entity;
}
void ApplyOperation(PropFieldType type,char[] variable, char operatorChar, char [] adjuster)
......@@ -1676,7 +1689,7 @@ public int MoveToTargetCommand(int entity,char[] args,char[] remainder)
WritePackFloat(dataPack1, speed);
WritePackVector(dataPack1,targetposition);
WritePackCell(dataPack1,target);
......@@ -1703,6 +1716,7 @@ public Action Timer_MoveTo(Handle timer, any dataPack)
float targetposition[3];
ReadPackVector(dataPack,targetposition);
int targetEntity = ReadPackCell(dataPack);
float toTarget[3];
......@@ -1732,8 +1746,26 @@ public Action Timer_MoveTo(Handle timer, any dataPack)
if(atTarget)
{
char mTarget[32];
GetEntPropString(targetEntity,Prop_Data,"m_target",mTarget,sizeof(mTarget));
int target = FindEntityByName(mTarget);
if(target == -1)
{
GetEntPropString(targetEntity,Prop_Data,"m_iName",mTarget,sizeof(mTarget));
// get the index of "#" so that target #2 will move to target #3
}
// when at target execute the next command.
ExecuteCommand(commandTrack,true);
if(target != -1)
{
// change target and continue moving to new target
}
else
{
ExecuteCommand(commandTrack,true);
}
}
}
......
"VertexLitGeneric"
{
"$basetexture" "flasche/lava/lava_basecolor"
"$bumpmap" "flasche/lava/lava_normal"
"$surfaceprop" "dirt"
"%tooltexture" "flasche/lava/lava_basecolor"
"%keywords" "empires fury flasche lava"
"$nocull" "1"
"$selfillum" "1"
"Proxies"
{
"TextureScroll"
{
"texturescrollvar" "$basetexturetransform"
"texturescrollrate" "0.1"
"texturescrollangle" "0.0"
}
}
}
......@@ -49,6 +49,13 @@
"position" "0.000000 0.000000 00.000000"
"angles" "0.000000 0.000000 0.000000"
}
"lava_target"
{
"className" "info_target"
"name" "*lava_target"
"position" "0.000000 0.000000 00.000000"
"angles" "0.000000 0.000000 0.000000"
}
"killzone_medium_east"
{
"0"
......@@ -61,6 +68,7 @@
"model" "models/empfun/cube4.mdl"
"SolidType" "0"
"skin" "11"
"effects" "80"
}
"1"
{
......@@ -74,6 +82,21 @@
"damage" "65"
"StartDisabled" "1"
"spawnflags" "64"
"DamageType" "16384"
}
"2"
{
"className" "trigger_hurt"
"parent" "KillZone_1"
"name" "killZone_hurt"
"position" "0.000000 0.000000 -500.000000"
"angles" "0.000000 0.000000 0.000000"
"mins" "50 -7950 -7950"
"maxs" "15950 7950 7950"
"damage" "300"
"StartDisabled" "1"
"spawnflags" "64"
"DamageType" "1"
}
}
......@@ -90,6 +113,7 @@
"MoveType" "0"
"SolidType" "0"
"skin" "11"
"effects" "80"
}
"1"
{
......@@ -98,11 +122,26 @@
"name" "killZone_hurt"
"position" "0.000000 0.000000 -500.000000"
"angles" "0.000000 0.000000 0.000000"
"mins" "-1600 -8000 -8000"
"mins" "-16000 -8000 -8000"
"maxs" "0 8000 8000"
"damage" "65"
"StartDisabled" "1"
"spawnflags" "64"
"DamageType" "16384"
}
"2"
{
"className" "trigger_hurt"
"parent" "KillZone_1"
"name" "killZone_hurt"
"position" "0.000000 0.000000 -500.000000"
"angles" "0.000000 0.000000 0.000000"
"mins" "-15950 -7950 -7950"
"maxs" "-50 7950 7950"
"damage" "300"
"StartDisabled" "1"
"spawnflags" "64"
"DamageType" "1"
}
}
......@@ -120,6 +159,7 @@
"model" "models/empfun/cube4.mdl"
"SolidType" "0"
"skin" "11"
"effects" "80"
}
"1"
{
......@@ -133,10 +173,24 @@
"damage" "65"
"StartDisabled" "1"
"spawnflags" "64"
"DamageType" "16384"