I haven't been able to use OnLevelInit for anything other than for something that should run before OnMapStart. The issue is that generally no entities are present OnLevelInit to be edited, and the mapEntities string is too large for any modification or even reading.
What I have done is hooking OnEntityCreated and blocking the creation of certain entities like logic_auto to be rebuilt by the entity cache after modifications or if they are on the whitelist of created entities.
OnEntityCreated will catch all entities spawned after level init. The issue is that entities at this point do not have any data assigned to them, so I can either create a 0.1 timer then check against what should be edited/deleted, or have it checked in the entity cache rebuild for removal or editing.
The entity cache can be generated by something like StripperSource, or the BuildEntityCache plugin (although slower, it doesn't require any offsets or extensions).
I haven't quite finished it for things like point_template's or npc_template_maker's, but for the most part, it is fully functional.
I had considered that a full recreation could be possible if all entities were blocked until after the entity cache was read, but there are the few entities that store further info such as the templates which still need to be implemented.
Here is an example of a slightly modified EDT from Synergy to work in Black Mesa:
https://github.com/Balimbanana/SM-BM...s/bm_c2a1a.edt
Here is a description of what it can do:
Code:
mapname
{
console
{
//CVars and some server commands can be executed here specific to the map.
//CVars that are modified will be restored on map change.
cvar "value"
}
entity
{
//Will delete all entities that match classname "this"
delete {classname "this"}
//Will delete all entities that match targetname "that"
delete {targetname "that"}
//Will delete all of a specific classname at specific origin (rounded to 1 decimal)
delete {classname "prop_physics" origin "100 200.5 50"}
//Will edit all entities that match classname "this" and re-create them as classname "that"
edit {classname "this" values {classname "that"} }
//Will edit all entities that match targetname "that" and change targetname to "this"
edit {targetname "that" values {targetname "this"} }
//Will edit all of a specific classname at specific origin (rounded to 1 decimal)
edit {classname "prop_physics" origin "100 200.5 50" values {targetname "this" origin "100 100 100" angles "0 90 0"} }
//Will assign the parent from the original origin of the parent
edit {classname "prop_physics" origin "100 200.5 50" values {parentname "elevator"} }
//Will change all cases of propertyname found in all by class to replacewith
modifycase {classname "npc_maker" values {m_spawnEquipment "weapon_mp5" replacewith "weapon_shotgun"} }
//Will change case of propertyname found in specific targetname
modifycase {targetname "that" values {m_spawnEquipment "weapon_mp5" replacewith "weapon_shotgun"} }
//Create entity
create {classname "logic_auto" values {spawnflags "1" OnMapSpawn "this,FireUser1,,0,-1"} }
//None of these are not specific to one line to be parsed, you can format it however even with or without quotes
//The only things that require quotes are values that contain spaces, otherwise it is read as another KV
create
{
"classname" "logic_auto"
"origin" "0 0 0"
"values"
{
"spawnflags" "1"
"OnMapSpawn" "this,FireUser1,,0,-1"
}
}
create {classname "trigger_once" origin "0 0 0"
values
{
//These shouldn't be combined, only one type should be used depending on what you are looking for
//Gets bsp model found from entity with name "this"
edt_getbspmodelfor_targetname "this"
//Gets bsp model found from entity with classname "that" at specific origin
edt_getbspmodelfor_classname "that"
edt_getbspmodelfor_origin "1 1 1"
//Customizable mins and maxs for custom trigger volumes
edt_mins "-10 -10 -10"
edt_maxs "10 10 10"
spawnflags "1"
}
}
}
}