Skip to content

Commit

Permalink
describe .aggro more together with chatgpt
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsndk authored Jun 13, 2024
1 parent 3a3ae0f commit d035d88
Showing 1 changed file with 89 additions and 3 deletions.
92 changes: 89 additions & 3 deletions .readme/monsters.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,37 @@ if (player == "aggro") {
} //aggro check is arbitrary
```

last_aggro will be updated.
if the following is true `monster.aggro > 0.99 || Math.random() < monster.aggro` the monster is added to a list of agressives
The list of `aggressives` is looped for each player, if the player is in front of the player, or the monster can attack the player, they will start attacking the player

The list of agressives is looped for each player, if the player is in front of the player, or the monster can attack the player, they will start attacking the player
`aggressives` is populated in `update_instance` if the monsters `aggro` property is more than 0.99 it is considered aggressive, else it has a chance of being aggressive
```ts
if (
!monster.pet &&
!monster.trap &&
mode.aggro &&
!monster.target &&
monster.aggro &&
can_attack(monster, "aggro")
) {
monster.last_aggro = new Date();
if (monster.aggro > 0.99 || Math.random() < monster.aggro) {
set_ghash(aggressives, monster, 32);
}
}
```

`update_instance` will loop the following list of aggressives
`var l = get_nearby_ghash(aggressives, player, 32);`
`32` is what is considered a `zone` and is used with `ghash` to generate a hash that can be looked up in aggressives

```ts
function ghash(entity, zone, a_d, b_d) {
//zone is the square's dimension, a_d, and b_d are displacements
var a = floor((1.0 * entity.x) / zone) + (a_d || 0);
var b = floor((1.0 * entity.y) / zone) + (b_d || 0);
return a + "|" + b;
}
```

There is a little tiein to the .rage property of monsters here. if the following evaluates to true, the agressive monster will also target the player

Expand All @@ -32,6 +59,65 @@ if (monster.rage && Math.random() < monster.rage - player.aggro_diff) {
}
```

## player.aggro_def
Sure! Let's break down the `aggro_diff` calculation step by step.

Here's the formula:

```javascript
player.aggro_diff = player.bling / 100 - player.cuteness / 100;
```

This formula determines a value `aggro_diff` based on two attributes of the player: `bling` and `cuteness`. Both attributes are divided by 100 and then subtracted from each other.

Let's analyze the effect of `bling` and `cuteness`:

1. **Bling**: This represents some form of status, wealth, or attractiveness related to the player's appearance or possessions.
2. **Cuteness**: This represents how cute or adorable the player is perceived to be.

The division by 100 normalizes these attributes, scaling them down to a range that impacts the calculation proportionately.

### Impact of `bling` and `cuteness` on `aggro_diff`

- **When `bling` is high and `cuteness` is low**:
- `player.bling / 100` will be a larger value.
- `player.cuteness / 100` will be a smaller value.
- The result of the subtraction (`bling/100 - cuteness/100`) will be positive, resulting in a higher `aggro_diff`.

- **When `bling` is low and `cuteness` is high**:
- `player.bling / 100` will be a smaller value.
- `player.cuteness / 100` will be a larger value.
- The result of the subtraction (`bling/100 - cuteness/100`) will be negative, resulting in a lower `aggro_diff`.

- **When both `bling` and `cuteness` are equal**:
- Both `player.bling / 100` and `player.cuteness / 100` will be the same.
- The result of the subtraction (`bling/100 - cuteness/100`) will be zero, resulting in an `aggro_diff` of 0.

### Interpretation of `aggro_diff`

- **Positive `aggro_diff`**: Indicates that the player has more `bling` relative to their `cuteness`. This might suggest that the player is more attention-grabbing or intimidating due to their wealth/status.
- **Negative `aggro_diff`**: Indicates that the player has more `cuteness` relative to their `bling`. This might suggest that the player is more endearing or non-threatening.
- **Zero `aggro_diff`**: Indicates a balance between `bling` and `cuteness`, suggesting a neutral or balanced perception.

In summary, the `aggro_diff` calculation helps quantify the difference in the player's perceived status/attractiveness (bling) versus their cuteness. The resulting value indicates whether the player is more likely to attract attention due to their bling or be perceived as cute and non-threatening.

### Impact of `aggro_diff` on the Logic

- **Positive `aggro_diff`**:
- Increases the chance that `Math.random() < player.aggro_diff` will be true, leading to an early return and no further action. This makes it less likely for the player to be targeted by the monster.
- Decreases the value of `monster.rage - player.aggro_diff`, making it less likely that `Math.random() < monster.rage - player.aggro_diff` will be true, further reducing the chances of the player being targeted.

- **Negative `aggro_diff`**:
- Decreases the chance that `Math.random() < player.aggro_diff` will be true, making it more likely for the code to proceed to the second `if` statement.
- Increases the value of `monster.rage - player.aggro_diff`, making it more likely that `Math.random() < monster.rage - player.aggro_diff` will be true, increasing the chances of the player being targeted.

### Summary

- The **first `if` statement** uses `player.aggro_diff` to determine if the function should exit early, with a higher `aggro_diff` increasing the likelihood of an early exit.
- The **second `if` statement** uses `monster.rage` adjusted by `player.aggro_diff` to determine if the monster should target the player. A higher `aggro_diff` reduces the likelihood of being targeted.

In essence, a player with higher `bling` relative to `cuteness` (positive `aggro_diff`) is less likely to be targeted by the monster, while a player with higher `cuteness` relative to `bling` (negative `aggro_diff`) is more likely to be targeted.

# Rage

0.5, // 50% chance to target the player on attack
Expand Down

0 comments on commit d035d88

Please sign in to comment.