# Description
This datapack is made for the Dungeon map, and works with conjunction with the 'Dungeons' datapack.
It can be used on its own to only have the enemies and bosses, but you also need:
 - The *Dungeons Resourcepack* for the textures and sounds
 - Some parts of the *YouKnowWhen lib datapack*: rng, damage, launch, mrcd, countdown, olink, ykw, minecraft, const
 - The *Minecraft-Ray-Collision-Detector-master* datapack
 - The *Dungeons Effects* datapack
 - The *Dungeons Enemies* datapack
 - The *Dungeons Generics lib*

# Flags when spawning a mob
All flags are under the EB_generic scoreboard
| Flag          | 0            | 1             | -1                          | Scoreboard                                           |
|---------------|--------------|---------------|-----------------------------|------------------------------------------------------|
| summon_cursed | no           | yes           | use global system (default) | inidcates if the spawn will be cursed or not         |
| boss_spawn    | no (default) | yes           | -                           | is the next summon caused by a boss                  |
| spawn_count   | no           | yes (default) | -                           | Does it counts towards the enemies spawned statistic |

# Custom attack system 
## State Machine (SM)
```mermaid
graph LR;
    spawn -- after spawned -->  cooldown
    cooldown --automatic--> choosing
    choosing --finished choosing--> prepearing
    prepearing --automatic--> attacking
    attacking --finished attack--> cooldown
```

| State      | ID | Action                                             | Next State | Next StateCondition                              |
|------------| -- |----------------------------------------------------|------------|--------------------------------------------------|
| "Spawn"    | -  | Set cooldown value `spawn_cooldonw()`              | Cooldown   | Autoamtic (spawn function)                       |
| Cooldown   | 1  | -                                                  | Choosing   | Automatic (EB_attack_clock > EB_attack_cooldown) |
| Choosing   | 2  | Choose attack: set tag + attack preparing cooldown | Preparing  | Manual                                           |
| Prepearing | 3  | System plays particles                             | Attacking  | Automatic (EB_attack_clock > EB_attack_cooldown) |
| Attacking  | 4  | Run the attack                                     | Cooldown   | Manual                                           |

# Custom mob folder system
```
<mob_name>
├── tick.mcfunction:            Each tick runs the Sound system, the Attack SM and other custom stuff
├── sound:                      Sound system functions (play sound + sets a new delay for the next sound)/
│   ├── ambient.mcfunction
│   └── hurt.mcfunction
├── attacks:                    Attacks SM functions
│   ├── choosing.mcfunction:    It choooses an attack using rng (executes the corresponding <attack_folder>/choose.mcfunction)
│   ├── attacking.mcfunction:   Runs the corresponding attack function
│   ├── preparing.mcfunction:   Runs the corresponding preparing function (if needed)
│   └── <attack_folder>
│       ├── main.mcfunction:    Main function containing the action + the check to change state
│       ├── choose.mcfunction:  Prepares all the attack data needed (attack tag, attack preparing cooldown, reset clock, ...)
│       ├── prepare.mcfunction:  Runs the preparation animations/sounds/ ... (angry particles are managed by the system)
│       ├── finish.mcfunction:  Executed when attack finished (changes attack_state, removes tags, sets next attack cooldown, ...)
│       └── ...
└── ...
```