Skip to content

Commit

Permalink
add missing implementations for setRule rules
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanJPNM committed Feb 20, 2024
1 parent 0225eb2 commit ded08ae
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions compiler/lib/world.d.ts
Expand Up @@ -362,6 +362,16 @@ export namespace setRule {
*/
function buildSpeed(team: TeamIdentifier, multiplier: number): void;

/**
* Sets the health multiplier for units on a given team. The multiplier cannot
* have a value lower than `0.001`.
*
* ```js
* setRule.unitHealth(Teams.sharded, 1.5);
* ```
*/
function unitHealth(team: TeamIdentifier, multiplier: number): void;

/**
* Sets the speed multiplier for unit factories. The multiplier will always be
* clamped between `0` and `50`.
Expand Down
4 changes: 4 additions & 0 deletions compiler/src/macros/commands/SetRule.ts
Expand Up @@ -21,7 +21,10 @@ export class SetRule extends ObjectValue {
lighting: { args: ["enabled"] },
ambientLight: { args: ["rgbaData"] },
solarMultiplier: { args: ["multiplier"] },
ban: { args: ["content"] },
unban: { args: ["content"] },
buildSpeed: { args: ["team", "multiplier"] },
unitHealth: { args: ["team", "multiplier"] },
unitBuildSpeed: { args: ["team", "multiplier"] },
unitCost: { args: ["team", "multiplier"] },
unitDamage: { args: ["team", "multiplier"] },
Expand All @@ -42,6 +45,7 @@ export class SetRule extends ObjectValue {
break;
}
case "buildSpeed":
case "unitHealth":
case "unitBuildSpeed":
case "unitCost":
case "unitDamage":
Expand Down
9 changes: 9 additions & 0 deletions website/docs/guide/commands.md
Expand Up @@ -802,6 +802,15 @@ Contains the multiple variants of the `setrule` instruction.
::: command-example
:::

- #### `setRule.unitHealth`

Sets the health multiplier for units on a given team. The multiplier cannot
have a value lower than `0.001`.

```js
setRule.unitHealth(Teams.sharded, 1.5);
```

- #### `setRule.unitBuildSpeed`

Sets the speed multiplier for unit factories.
Expand Down

0 comments on commit ded08ae

Please sign in to comment.