Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
empfun
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sourcemod
empfun
Commits
e75bb7b5
Commit
e75bb7b5
authored
Apr 25, 2020
by
Mikleo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix black refinery bug.
parent
903b4119
Pipeline
#9515
passed with stages
in 13 seconds
Changes
6
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1187 additions
and
385 deletions
+1187
-385
dist/addons/sourcemod/plugins/empfun.smx
dist/addons/sourcemod/plugins/empfun.smx
+0
-0
dist/addons/sourcemod/scripting/empfun.sp
dist/addons/sourcemod/scripting/empfun.sp
+111
-92
dist/scenarios/emp_duststorm/mik_artifact.snr
dist/scenarios/emp_duststorm/mik_artifact.snr
+998
-279
dist/scenarios/entdata.txt
dist/scenarios/entdata.txt
+64
-13
dist/scenarios/standard_modelshortcuts.txt
dist/scenarios/standard_modelshortcuts.txt
+13
-0
dist/updater.txt
dist/updater.txt
+1
-1
No files found.
dist/addons/sourcemod/plugins/empfun.smx
View file @
e75bb7b5
No preview for this file type
dist/addons/sourcemod/scripting/empfun.sp
View file @
e75bb7b5
...
...
@@ -10,7 +10,7 @@
#include <SteamWorks>
#define PluginVersion "1.0
4
"
#define PluginVersion "1.0
5
"
float pVersion;
// note linearmap field is unstable
...
...
@@ -110,6 +110,7 @@ enum classdataenum {
bool:data_customOnly,
bool:data_isMovable,
bool:data_isRemovable,
bool:data_isBrushEntity,
ArrayList:data_keys
}
...
...
@@ -1643,15 +1644,13 @@ public Action Command_Save_Preset(int client, int args)
kv.JumpToKey(name,true);
ArrayList keys;
any classInfo[classdataenum];
if(selectedEntities[client].Length == 1 )
{
GetEntitySavingKeys(className,pVersion,classInfo);
keys = classInfo[data_keys];
SaveEntity(originEntity,kv,keys,className);
SaveEntity(originEntity,kv,classInfo,className);
kv.SetString("position","0.0 0.0 0.0");
if(kv.GetNum("pointNumber") > 0)
kv.SetNum("pointNumber",-1);
...
...
@@ -1666,8 +1665,7 @@ public Action Command_Save_Preset(int client, int args)
int entity = selectedEntities[client].Get(i);
GetEntityClassname(entity, className, sizeof(className));
GetEntitySavingKeys(className,pVersion,classInfo);
keys = classInfo[data_keys];
SaveEntity(entity,kv,keys,className);
SaveEntity(entity,kv,classInfo,className);
float entityPos[3];
GetEntPropVector( entity, Prop_Send, "m_vecOrigin", entityPos );
float offset[3];
...
...
@@ -1903,7 +1901,6 @@ public Action Edit_Entity(int client, int entity,float position[3],bool editExis
any classInfo[classdataenum];
ArrayList keys;
if(!GetEntitySavingKeys(className,pVersion,classInfo))
{
...
...
@@ -1911,13 +1908,13 @@ public Action Edit_Entity(int client, int entity,float position[3],bool editExis
return Plugin_Handled;
}
keys = classInfo[data_keys];
any keyinfo[keyinfoenum];
char arg1[64];
char arg2[64];
ArrayList keys = classInfo[data_keys];
if (!GetCmdArg(1, arg1, sizeof(arg1)) || !GetCmdArg(2, arg2, sizeof(arg2)))
{
...
...
@@ -1977,11 +1974,11 @@ public Action Edit_Entity(int client, int entity,float position[3],bool editExis
int hammerid = GetEntProp(entity,Prop_Data,"m_iHammerID");
// respawn the entity with altered value
KeyValues kv = new KeyValues("save");
SaveEntity(entity,kv,
keys
,className);
SaveEntity(entity,kv,
classInfo
,className);
ExecuteRemoveEntity(entity);
kv.Rewind();
kv.SetString(arg1,arg2);
int newEntity = RestoreEntity(-1,kv,
keys
,className);
int newEntity = RestoreEntity(-1,kv,
classInfo
,className);
...
...
@@ -2920,14 +2917,12 @@ int RespawnEntity(int entity,char [] className)
}
int CloneEntity(int entity,char [] className, float[3] position, int timeID = -1)
{
ArrayList keys;
int newEntity = entity;
any classInfo[classdataenum];
if(GetEntitySavingKeys(className,pVersion,classInfo))
{
keys = classInfo[data_keys];
KeyValues kv = new KeyValues("save");
SaveEntity(entity,kv,
keys
,className);
SaveEntity(entity,kv,
classInfo
,className);
kv.Rewind();
...
...
@@ -2958,7 +2953,7 @@ int CloneEntity(int entity,char [] className, float[3] position, int timeID = -1
newEntity = RestoreEntity(-1,kv,
keys
,className);
newEntity = RestoreEntity(-1,kv,
classInfo
,className);
delete kv;
...
...
@@ -2972,13 +2967,11 @@ int LoadPreset(KeyValues kv)
{
char className[32];
kv.GetString("className",className,sizeof(className));
ArrayList keys;
int entity = -1;
any classInfo[classdataenum];
if(GetEntitySavingKeys(className,pVersion,classInfo))
{
keys = classInfo[data_keys];
entity = RestoreEntity(-1,kv,keys,className);
entity = RestoreEntity(-1,kv,classInfo,className);
}
else
{
...
...
@@ -3925,7 +3918,12 @@ SaveScenario(int client,char [] filename,bool saveMetaData = true)
KeyValues kv;
if(currentScenarioKV)
{
// make sure its at start.
currentScenarioKV.Rewind();
kv = currentScenarioKV;
}
else
kv = new KeyValues("Scenario");
...
...
@@ -3974,7 +3972,6 @@ SaveScenario(int client,char [] filename,bool saveMetaData = true)
}
if(client > 0)
{
char clientName[128];
...
...
@@ -3982,6 +3979,8 @@ SaveScenario(int client,char [] filename,bool saveMetaData = true)
PrintToChatAll("\x07ff6600%s \x01has saved the scenario as %s",clientName,filename);
}
}
// needs to be done on both save and load.
...
...
@@ -4103,11 +4102,9 @@ bool LoadScenario(int client,char[] filename)
if(LibraryExists("SteamWorks") && StrContains(filename,"override") == -1)
{
char description[64];
currentScenarioKV.GetString("Description",description,sizeof(description));
char mapName[128];
GetCurrentMap(mapName, sizeof(mapName));
Format(mapName,sizeof(mapName),"%s:%s
\n%s",mapName,filename,description
);
Format(mapName,sizeof(mapName),"%s:%s
",mapName,filename
);
SteamWorks_SetMapName(mapName);
}
...
...
@@ -4233,7 +4230,6 @@ void SaveEntities(KeyValues kv)
ArrayList keys;
// need to use findEntitybyclassname for non edicts.
...
...
@@ -4247,7 +4243,6 @@ void SaveEntities(KeyValues kv)
classNameList.GetString(i,className,sizeof(className));
if(GetEntitySavingKeys(className,pVersion,classInfo))
{
keys = classInfo[data_keys];
while ((entity = FindEntityByClassname(entity,className)) != -1)
{
...
...
@@ -4269,7 +4264,7 @@ void SaveEntities(KeyValues kv)
// we always save position rotation and hammer_id
kv.JumpToKey(hammer_id_buffer, true);
SaveEntity(entity,kv,
keys
,className);
SaveEntity(entity,kv,
classInfo
,className);
kv.GoBack();
}
...
...
@@ -4308,44 +4303,57 @@ LoadEntities(KeyValues kv,float version,int hLimit)
ArrayList includedEntities = new ArrayList();
ArrayList keys;
kv.GetSectionName(hammer_id_buffer, sizeof(hammer_id_buffer));
kv.GotoFirstSubKey();
any classInfo[classdataenum];
do
for(int run = 0;run<2;run++)
{
kv.GetSectionName(hammer_id_buffer, sizeof(hammer_id_buffer));
kv.GetString("className",className,sizeof(className));
if(GetEntitySavingKeys(className,version,classInfo))
// do this in multiple runs. second run for refineries
do
{
keys = classInfo[data_keys];
int hammer_id = StringToInt(hammer_id_buffer);
if(hammer_id > max_hammer_id)
max_hammer_id = hammer_id;
kv.GetSectionName(hammer_id_buffer, sizeof(hammer_id_buffer));
int entity = -1;
// if they are not a custom element just reload them regardless.
if( hammer_id <= hLimit)
entity = findEntityWithHammerID(hammer_id,className);
kv.GetString("className",className,sizeof(className));
bool lateLoader = StrEqual(className,"emp_building_nf_refinery",true) || StrEqual(className,"emp_building_imp_refinery",true);
if(((run == 0 && !lateLoader) || run == 1 && lateLoader) && GetEntitySavingKeys(className,version,classInfo))
{
int hammer_id = StringToInt(hammer_id_buffer);
if(hammer_id > max_hammer_id)
max_hammer_id = hammer_id;
entity = RestoreEntity(entity,kv,keys,className);
// restore back hammer id
SetEntProp(entity,Prop_Data,"m_iHammerID",hammer_id);
if(entity != -1)
includedEntities.Push(entity);
}
int entity = -1;
// if they are not a custom element just reload them regardless.
if( hammer_id <= hLimit)
entity = findEntityWithHammerID(hammer_id,className);
entity = RestoreEntity(entity,kv,classInfo,className);
// restore back hammer id
SetEntProp(entity,Prop_Data,"m_iHammerID",hammer_id);
if(entity != -1)
includedEntities.Push(entity);
}
} while (kv.GotoNextKey(false));
kv.GoBack();
kv.GotoFirstSubKey();
} while (kv.GotoNextKey(false));
}
kv.Rewind();
RemoveSavableEntitiesExcept(includedEntities,version,hLimit);
...
...
@@ -4358,7 +4366,7 @@ LoadEntities(KeyValues kv,float version,int hLimit)
}
SaveEntity(int entity,KeyValues kv,
ArrayList keys
,char[] className)
SaveEntity(int entity,KeyValues kv,
any[] classInfo
,char[] className)
{
bool failed = false;
// get position and rotation and save them.
...
...
@@ -4407,7 +4415,7 @@ SaveEntity(int entity,KeyValues kv,ArrayList keys,char[] className)
EU_GetMapCoordinates(position,coordinates);
kv.SetString("coords",coordinates);
SaveKeys(kv,entity,
keys
);
SaveKeys(kv,entity,
classInfo[data_keys]
);
// just set render color back.
...
...
@@ -4416,6 +4424,19 @@ SaveEntity(int entity,KeyValues kv,ArrayList keys,char[] className)
SetEntityRenderColor(entity, r, g, b, a);
}
if(StrEqual(className,"emp_eng_map_model",true) && GetEntProp(entity,Prop_Data,"m_bRaiseOnBuild") == 1 && GetEntProp(entity,Prop_Data,"m_bSolidOnSpawn") == 0)
{
float min[3];
float max[3];
GetEntPropVector(entity, Prop_Send, "m_vecMins", min);
GetEntPropVector(entity, Prop_Send, "m_vecMaxs", max);
float dist = (0.5 * max[2] - min[2]) ;
position[2] += dist;
kv.SetVector("position",position);
}
if(StrEqual(className,"emp_eng_walls",true))
{
...
...
@@ -4433,9 +4454,7 @@ SaveEntity(int entity,KeyValues kv,ArrayList keys,char[] className)
position[2] += 7.0;
kv.SetVector("position",position);
}
if(StrEqual(className,"emp_vehicle",true))
{
...
...
@@ -4541,7 +4560,7 @@ SaveEntity(int entity,KeyValues kv,ArrayList keys,char[] className)
}
}
RestoreEntity(int entity,KeyValues kv,
ArrayList keys
,char[] className)
RestoreEntity(int entity,KeyValues kv,
any[] classInfo
,char[] className)
{
bool isNew = entity == -1;
...
...
@@ -4551,6 +4570,11 @@ RestoreEntity(int entity,KeyValues kv,ArrayList keys,char[] className)
kv.GetVector("position",position);
kv.GetVector("angles",angles);
bool hasPosition = KVHasKey(kv,"position");
bool hasAngles = KVHasKey(kv,"angles");
if(isNew )
{
...
...
@@ -4599,12 +4623,18 @@ RestoreEntity(int entity,KeyValues kv,ArrayList keys,char[] className)
// we are already in local space,move position into that space.
SubtractVectors(position, parentPos, position);
}
// if not new get the correct positions by moving down.
if(StrEqual(className,"emp_eng_map_model",true) && kv.GetNum("raiseOnBuild") == 1 && kv.GetNum("solidOnSpawn") == 0)
{
hasPosition = false;
}
}
bool hasPosition = KVHasKey(kv,"position");
bool hasAngles = KVHasKey(kv,"angles");
// make position and angles optional for existing entities.
...
...
@@ -4619,7 +4649,7 @@ RestoreEntity(int entity,KeyValues kv,ArrayList keys,char[] className)
RestoreKeys(kv,entity,
keys
,isNew,false);
RestoreKeys(kv,entity,
classInfo[data_keys]
,isNew,false);
...
...
@@ -4639,19 +4669,16 @@ RestoreEntity(int entity,KeyValues kv,ArrayList keys,char[] className)
CreateTimer(0.1, Timer_ParentEntity,entity);
}
if( StrEqual(className,"emp_building_nf_refinery",true) ||StrEqual(className,"emp_building_imp_refinery",true))
if(classInfo[data_isBrushEntity])
{
// if there is no target find one after all entities spawn.
char buffer[32];
GetEntPropString(entity,Prop_Data,"m_target",buffer,sizeof(buffer));
if(strlen(buffer) > 0)
{
CreateTimer(0.1, Timer_LateSpawnRef,entity);
return entity;
}
// some brush entities will crash if they dont have a starting model.
DispatchKeyValue(entity,"model","models/nf/buildings/armory/nf_armory.mdl");
}
DispatchSpawn(entity);
...
...
@@ -4659,8 +4686,8 @@ RestoreEntity(int entity,KeyValues kv,ArrayList keys,char[] className)
ActivateEntity(entity);
if(
StrEqual(className,"emp_cap_point",true)
)
// any brush entities
if(
classInfo[data_isBrushEntity]
)
{
float mins[3];
float maxs[3];
...
...
@@ -4693,8 +4720,8 @@ RestoreEntity(int entity,KeyValues kv,ArrayList keys,char[] className)
AcceptEntityInput(entity, "Wake");
}
}
...
...
@@ -4718,7 +4745,7 @@ RestoreEntity(int entity,KeyValues kv,ArrayList keys,char[] className)
// restore postspawn keys.
RestoreKeys(kv,entity,
keys
,isNew,true);
RestoreKeys(kv,entity,
classInfo[data_keys]
,isNew,true);
char funcs[256];
kv.GetString("funcs",funcs,sizeof(funcs));
...
...
@@ -4946,20 +4973,7 @@ int findEntityWithHammerID(int hammerID,char [] className)
// make sure that valid refinery points are available. hack for now
public Action Timer_LateSpawnRef(Handle timer,int entity)
{
if(!IsValidEntity(entity))
return;
// set the target to the name of the nearest refinery
char closestPointName[32];
float position[3];
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", position);
FindClosestResourcePoint(position,closestPointName);
DispatchKeyValue(entity,"target", closestPointName);
DispatchSpawn(entity);
ActivateEntity(entity);
}
int FindClosestResourcePoint(float position[3], char [] pointName)
{
...
...
@@ -5883,8 +5897,7 @@ int SwitchFaction(int entity,char[] classname)
}
// save and respawn the entity.
ArrayList keys;
if(ReplaceString(classname, 64, "nf", "imp", false) == 0)
{
...
...
@@ -5898,10 +5911,9 @@ int SwitchFaction(int entity,char[] classname)
// don't do ammo boxes for now until we can fix issues with existing flags. i.e. homeland crashes.
if(GetEntitySavingKeys(classname,pVersion,classInfo) && ShouldSave(entity,classname,classInfo) && classInfo[data_group] != 2 && (classInfo[data_group] !=1 || GetEntProp(entity,Prop_Data,"m_iCapNumber") != 0) && !StrEqual(classname,"emp_cap_model",false) && !StrEqual(classname,"emp_cap_point",false) )
{
keys = classInfo[data_keys];
KeyValues kv = new KeyValues("save");
SaveEntity(entity,kv,
keys
,classname);
SaveEntity(entity,kv,
classInfo
,classname);
if(kv.GetNum("team",-1) > 0)
{
kv.SetNum("team",OppositeTeam(kv.GetNum("team")));
...
...
@@ -5917,7 +5929,7 @@ int SwitchFaction(int entity,char[] classname)
}
kv.Rewind();
int newEntity = RestoreEntity(-1,kv,
keys
,classname);
int newEntity = RestoreEntity(-1,kv,
classInfo
,classname);
ExecuteRemoveEntity(entity);
entity = newEntity;
delete kv;
...
...
@@ -6514,6 +6526,7 @@ public void LoadEntData()
data[data_customOnly] = extendGameData[data_customOnly];
data[data_isMovable] = extendGameData[data_isMovable];
data[data_isRemovable] = extendGameData[data_isRemovable];
data[data_isBrushEntity] = extendGameData[data_isBrushEntity];
data[data_version] = extendGameData[data_version];
extended = true;
...
...
@@ -6525,6 +6538,7 @@ public void LoadEntData()
data[data_customOnly] = false;
data[data_isMovable] = true;
data[data_isRemovable] = true;
data[data_isBrushEntity] = false;
data[data_version] = 0.0;
keys = new ArrayList();
}
...
...
@@ -6549,6 +6563,11 @@ public void LoadEntData()
data[data_customOnly] = true;
}
if(kv.GetNum("isBrushEntity") == 1)
{
data[data_isBrushEntity] = true;
}
data[data_isMovable] = kv.GetNum("moveable", 1) == 1;
kv.GetString("removable",buffer,sizeof(buffer),"");
...
...
dist/scenarios/emp_duststorm/mik_artifact.snr
View file @
e75bb7b5
This diff is collapsed.
Click to expand it.
dist/scenarios/entdata.txt
View file @
e75bb7b5
...
...
@@ -292,10 +292,33 @@
}
}
"brush"
{
"extend" "entity"
"isBrushEntity" "1"
"fields"
{
"mins"
{
"prop" "m_vecMins"
"type" "vector"
"postSpawn" "true"
}
"maxs"
{
"prop" "m_vecMaxs"
"type" "vector"
"postSpawn" "true"
}
}
}
"emp_cap_point"
{
"extend" "
entity
"
"extend" "
brush
"
"group" "1"
"fields"
{
"pointNumber"
...
...
@@ -390,18 +413,6 @@
"prop" "m_iBECappable"
"propType" "data"
}
"mins"
{
"prop" "m_vecMins"
"type" "vector"
"postSpawn" "true"
}
"maxs"
{
"prop" "m_vecMaxs"
"type" "vector"
"postSpawn" "true"
}
}
...
...
@@ -1196,6 +1207,46 @@
}
"emp_comm_restrict"
{
"extend" "brush"
"customOnly" "1"
}
// add fields in future.
"emp_eng_restrict"
{
"extend" "brush"
"customOnly" "1"
"fields"
{
"restrictNF"
{
"fgdName" "restrictNF"
"prop" "m_iRestrict_NF"
"type" "int"
"propType" "data"
}
"restrictImp"
{
"fgdName" "restrictImp"
"prop" "m_iRestrict_Imp"
"type" "int"
"propType" "data"
}
"turretRestrict"
{
"fgdName" "turretRestrict"
"prop" "m_iTurretRestrict"
"type" "int"
"propType" "data"
}
}
}
}
dist/scenarios/standard_modelshortcuts.txt
View file @
e75bb7b5
...
...
@@ -319,6 +319,19 @@
{
"model" "models/props_canal/boat002b.mdl"
}
"nfapcwreck"
{
"model" "models/nf/vehicles/ground/apc/nf_apc_staticwreck.mdl"
}
"nfltwreck"
{
"model" "models/nf/vehicles/ground/tanklight/nf_light_wreck.mdl"
}
"nfjeepwreck"
{
"model" "models/nf/vehicles/ground/jeep/nf_jeep_wreck.mdl"
}
}
dist/updater.txt
View file @
e75bb7b5
...
...
@@ -4,7 +4,7 @@
{
"Version"
{
"Latest" "1.0
4
"
"Latest" "1.0
5
"
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment