This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
4rpl:commands:setfieldrect [2021/01/08 16:01] – external edit 127.0.0.1 | 4rpl:commands:setfieldrect [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 6: | Line 6: | ||
===== Description ===== | ===== Description ===== | ||
- | Sets the field cells as defined by the fieldRect.\\ | + | |
- | | + | Sets the field cells as defined by the fieldRect. |
- | | + | |
- | | + | **Fields are reset on map load, so any fields must be recreated in the [[func_awake|: |
- | | + | |
- | | + | This method is, in essence, a more performant way to call [[SetFieldCell]] over a larger area. Despite the name, this method **adds** field cells rather than sets them, meaning the effect of existing fields will not be erased. To cancel the effect of calling SetFieldRect on an area, you should call SetFieldRect with the same properties in the same position, but opposite strength to the call used to create it. This will cancel out the effect. |
- | | + | |
- | | + | * **cellX**: The X position to deploy the field rect. The center of the field rect will be at this position. |
- | | + | * **cellZ**: The Z position to deploy the field rect. The center of the field rect will be at this position. |
- | | + | * **fieldRect**: A list containing vectors that describe the field direction at each cell in the rectangle. Values are treated as normalized values in the range of -1 to 1. Each vector in the list specifies the X and Z directions of the field via the first and SECOND elements of the supplied vectors. |
- | | + | * **rectWidth**: The width of the rectangle that the fieldRect contains the data for. The height of the rectangle is determined by taking the fieldRect length and dividing it by the rectWidth. |
+ | * **strength**: The strength is multiplied by the normalized value in the fieldRect to determine the actual value writing | ||
+ | * **direction**: A fieldRect | ||
+ | * **affected**: 0 means the field applies to both creeper and AC. 1 means creeper only, and 2 means AC only. | ||
+ | * **deploy**: If //true //then values are written to the game's field array. | ||
+ | |||
+ | Note: The values are read from the bottom left corner, doing a row at a time. So if you're doing the double for loop like the example, the inner loop has to be x, and the outer loop has to be z. | ||
===== Examples ===== | ===== Examples ===== | ||
<code 4rpl> | <code 4rpl> | ||
- | CreateList -> | + | :Awake |
- | V2(1 0) ->v | + | CreateList -> |
- | do (21 0) | + | |
- | | + | |
- | AppendToList(< | + | do(101 0) |
+ | | ||
+ | loop | ||
loop | loop | ||
- | loop | + | SetFieldRect(119 86 <-field 101 1000000 0 0 true) |
- | SetFieldRect(119 86 <-field 101 1000000 0 0 true) | + | |
</ | </ | ||
< | < | ||