|
1 |
| -# StripperCS2 |
| 1 | + |
| 2 | +# StripperCS2 |
| 3 | + |
| 4 | +A Metamod plugin that allows server operators to manage map lump data similarly to how [Stripper:Source](https://www.bailopan.net/stripper/) worked. |
| 5 | + |
| 6 | +## Folder structure |
| 7 | +Unlike Source, Source2 allows maps to include multiple lumps in the maps and reference each other. For example all entity templates will be turned into a new lump file. Stripper has to then also follow this. |
| 8 | + |
| 9 | +The folder structure consists of 3 main parts, the map, the world name and the lump name. To avoid conflicts I have intentionally scoped all of the configs to maps, the world name and lump name come as a requirement from the engine. |
| 10 | + |
| 11 | +The template of a stripper config file looks like `addons/StripperCS2/maps/<map>/<world name>/<lump name>.jsonc` |
| 12 | + |
| 13 | +You can view all of the lumps a map has by using the `entity_lump_list` command |
| 14 | + |
| 15 | +> [!CAUTION] |
| 16 | +> `entity_lump_list` is a defensive command, it has to be either unlocked by a metamod plugin like CS2Fixes or defensive commands have to be disabled in the csgo_core/gameinfo.gi configuration |
| 17 | +
|
| 18 | + |
| 19 | + |
| 20 | +You can also see all the lumps in the map vpks under the `maps/<map>/entities` folder and read the raw keyvalues through [Source2Viewer](https://valveresourceformat.github.io/) |
| 21 | + |
| 22 | +From the image above, if you wanted to edit entities inside the de_vertigo default_ents lump, you would have to create a `default_ents.jsonc` file under the `addons/StripperCS2/maps/de_vertigo` path. If you would want to edit the `default_ents` from `prefabs\misc\end_of_match` you would have to put the file inside `addons/StripperCS2/maps/de_vertigo/prefabs/misc/end_of_match` |
| 23 | + |
| 24 | +## Configuration |
| 25 | + |
| 26 | +StripperCS2 uses the JSON format instead of a custom config parser like Stripper:Source. Actions such as `filter`, `add`, `modify` are root arrays of the object. |
| 27 | +You can use per map configs as explained in [Folder structure](#folder-structure) or you can use the global config in `addons/StripperCS2/global.jsonc` which will apply all the rules to every loaded lump. |
| 28 | + |
| 29 | +### Filter |
| 30 | +```json |
| 31 | +{ |
| 32 | + "filter": [ |
| 33 | + { |
| 34 | + "classname": "/.*/" |
| 35 | + } |
| 36 | + ] |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +Similarly to Stripper:Source, each keyvalue is a string representation of its value, for example a color vector would be written as "255 0 0". Each key in the object is a keyvalue. |
| 41 | +Every value can be either a string or a Perl regexp using the `/regex/` syntax. |
| 42 | + |
| 43 | +#### Outputs |
| 44 | + |
| 45 | +In StripperCS2 outputs are natively supported. An output is represented as an object under the reserved "io" field. |
| 46 | + |
| 47 | +```json |
| 48 | +{ |
| 49 | + "filter": [ |
| 50 | + { |
| 51 | + "io": [ |
| 52 | + { |
| 53 | + "outputname": "OnMapStart" |
| 54 | + } |
| 55 | + ] |
| 56 | + } |
| 57 | + ] |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +This would filter all entities that have an OnMapStart output, the available keys are: `outputname`, `inputname`, `targetname`, `overrideparam`, `delay` (float), `timestofire` (int), `targettype` (int/EntityIOTargetType_t). |
| 62 | +The enum for targettype can be acquired from the hl2sdk. |
| 63 | +```c |
| 64 | +enum EntityIOTargetType_t |
| 65 | +{ |
| 66 | + ENTITY_IO_TARGET_INVALID = -1, |
| 67 | + ENTITY_IO_TARGET_CLASSNAME = 0, |
| 68 | + ENTITY_IO_TARGET_CLASSNAME_DERIVES_FROM = 1, |
| 69 | + ENTITY_IO_TARGET_ENTITYNAME = 2, |
| 70 | + ENTITY_IO_TARGET_CONTAINS_COMPONENT = 3, |
| 71 | + ENTITY_IO_TARGET_SPECIAL_ACTIVATOR = 4, |
| 72 | + ENTITY_IO_TARGET_SPECIAL_CALLER = 5, |
| 73 | + ENTITY_IO_TARGET_EHANDLE = 6, |
| 74 | + ENTITY_IO_TARGET_ENTITYNAME_OR_CLASSNAME = 7, |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +### Add |
| 79 | + |
| 80 | +```jsonc |
| 81 | +{ |
| 82 | + "add": [ |
| 83 | + { |
| 84 | + "classname": "func_button", |
| 85 | + // ... other keyvalues |
| 86 | + "io": [ |
| 87 | + { |
| 88 | + "outputname": "OnPressed", |
| 89 | + "targetname": "lockable_door", |
| 90 | + "inputname": "Lock" |
| 91 | + }, |
| 92 | + // ... more io |
| 93 | + ] |
| 94 | + } |
| 95 | + ] |
| 96 | +} |
| 97 | +``` |
| 98 | + |
| 99 | +Adding new entities matches the exact system as `filter`, except instead of using the keyvalues for matching it adds them as a new entity, `io` array turns into a list of all the outputs that will be added. Regex values will be ignored. |
| 100 | + |
| 101 | +### Modify |
| 102 | + |
| 103 | +Modify is a more complex action that allows you to edit an already existing entity. |
| 104 | +It has 4 sub objects matching Stripper:Source's behavior. |
| 105 | + |
| 106 | +- `match`: All values in this objects will be used as a requirement for an entity to match, regular expressions are allowed for every value. `io` array can be used the same way as in `filter` action |
| 107 | +- `replace`: Entity that passes the match requirements can have any of its keyvalues replaced with this sub object. Any keyvalue entered in here will be replaced with the right hand value. `io` **object** can also be used here, see [Replace Outputs](#replace-outputs) section |
| 108 | +- `delete`: Deletes all they keyvalues that match their value with the right hand value in the json, this means you can match a single classname and then decide here whether a keyvalue will always be removed or only if it matches a value |
| 109 | +- `insert`: Adds new keyvalues to the entity, works exactly the same as `add` action. |
| 110 | + |
| 111 | +#### Replace Outputs |
| 112 | + |
| 113 | +```jsonc |
| 114 | +{ |
| 115 | + "modify": [ |
| 116 | + { |
| 117 | + "match": |
| 118 | + { |
| 119 | + // in this example this classname will match an entity with 3 outputs, OnFullyClosed, OnOpen and OnFullyOpen |
| 120 | + "classname": "func_door_rotating", |
| 121 | + // this array is not exhaustive, it will match any entity with at least these outputs |
| 122 | + // all these matched outputs will be then replaced with the replace object below |
| 123 | + "io": [ |
| 124 | + { |
| 125 | + "outputname": "OnFullyClosed" |
| 126 | + }, |
| 127 | + { |
| 128 | + "outputname": "OnOpen" |
| 129 | + } |
| 130 | + ] |
| 131 | + }, |
| 132 | + "replace": |
| 133 | + { |
| 134 | + "io": |
| 135 | + // NOT ARRAY, ALL MATCHED IOs WILL BE REPLACED WITH THIS SINGLE OBJECT |
| 136 | + { |
| 137 | + // replaces only OnFullyClosed and OnOpen because they are in the match array, OnFullyOpen will be left alone |
| 138 | + "outputname": "CustomOutputName" |
| 139 | + } |
| 140 | + } |
| 141 | + } |
| 142 | + ] |
| 143 | +} |
| 144 | +``` |
| 145 | + |
| 146 | +Unlike Stripper:Source you don't need to delete and insert an output to modify it. You can use the `io` **OBJECT not array** to replace any value of the output. Note that this object is tightly connected with the match sub object. `replace` will only replace outputs that are explicitly matched inside the `io` array in the `match` sub object |
| 147 | + |
| 148 | + |
| 149 | +### Config example |
| 150 | + |
| 151 | +```jsonc |
| 152 | +{ |
| 153 | + "filter": [ |
| 154 | + { |
| 155 | + // no terrorists >:( |
| 156 | + "classname": "info_player_terrorist" |
| 157 | + } |
| 158 | + ], |
| 159 | + |
| 160 | + "modify": [ |
| 161 | + { |
| 162 | + "match": |
| 163 | + { |
| 164 | + "classname": "func_door_rotating", |
| 165 | + "io": [ |
| 166 | + { |
| 167 | + "outputname": "OnFullyClosed" |
| 168 | + } |
| 169 | + ] |
| 170 | + }, |
| 171 | + "replace": |
| 172 | + { |
| 173 | + "targetname": "yippe", |
| 174 | + "io": |
| 175 | + { |
| 176 | + "outputname": "OnClose" |
| 177 | + } |
| 178 | + }, |
| 179 | + "insert": |
| 180 | + { |
| 181 | + "renderamt": "100", |
| 182 | + "io": [ |
| 183 | + { |
| 184 | + "outputname": "OnFullyOpened", |
| 185 | + "inputname": "Lock", |
| 186 | + "targetname": "lockable_door" |
| 187 | + } |
| 188 | + ] |
| 189 | + }, |
| 190 | + "delete": |
| 191 | + { |
| 192 | + "model": "models/bruh.mdl", |
| 193 | + } |
| 194 | + } |
| 195 | + ], |
| 196 | + |
| 197 | + "add": [ |
| 198 | + { |
| 199 | + "classname": "func_button", |
| 200 | + "origin": "100 10 500" |
| 201 | + // ... |
| 202 | + } |
| 203 | + ] |
| 204 | +} |
| 205 | +``` |
0 commit comments