DOCS: improve readability of actions section

This commit is contained in:
marco_a 2024-04-04 01:08:46 +02:00
parent bd21cf76ae
commit c6cac58906
2 changed files with 25 additions and 27 deletions

50
DOCS.md
View File

@ -55,45 +55,43 @@ Then there are the built-in weapons_lib parameters:
Custom parameters are supported as well. It's recommended putting a `_` at the beginning of the parameter so to avoid conflicts with upcoming official ones
### Actions structure
Actions are tables containing info about how they should work. Actions also support custom parameters: it's recommended putting a `_` at the beginning of the parameter so to avoid conflicts with upcoming official ones
Actions are tables containing info about how they should work. Actions also support custom parameters: it's recommended putting a `_` at the beginning of the parameter so to avoid conflicts with upcoming official ones.
#### All types
* `type`: (string) mandatory. It can be `"raycast"`, `"bullet"`, `"zoom"`, `"punch"` or `"custom"` (TODO: `"install"`?, `"parry"`)
* `damage`: (float) how much damage deals
* `range`: (float, no punch) range of the weapon
* `delay`: (float) how much time it should pass between being able to rerun the action
* `loading_time`: (float) how much time before actually running the action. NOT YET IMPLEMENTED
* `knockback`: (int) how much knockback the action should inflict
* `physics_override`: (table or string) how the player physics should change when running the action. Physics is restored when the recovery phase ends
* `type`: (string) mandatory. It can be `"raycast"` (⚡️), `"bullet"` (🥏), `"zoom"` (🔎), `"punch"` (👊) or `"custom"` (TODO: `"install"`?, `"parry"`)
* `damage` (float) ⚡️🥏👊 how much damage deals
* `delay`: (float) ⚡️🥏👊 how much time it should pass between being able to rerun the action
* `range`: (float) ⚡️ range of the action
* `bullet`: (table) 🥏 the properties of the physical bullet shot with this action. See the Bullets structure section down below.
* `loading_time`: (float) ⚡️🥏👊 how much time before actually running the action. NOT YET IMPLEMENTED
* `attack_on_release`: (bool) ⚡️🥏👊🔎 whether it should attack when the action key is released. NOT YET IMPLEMENTED, [waiting for MT](https://gitlab.com/zughy-friends-minetest/weapons_lib/-/issues/5)
* `knockback`: (int) ⚡️🥏👊 how much knockback the action should inflict
* `ammo_per_use`: (int) ⚡️🥏 how much ammo is needed to run the action
* `continuous_fire`: (bool) ⚡️🥏 whether it should keep firing when holding down the action key (waiting `delay` seconds between a shot and another). Default is `false`
* `decrease_damage_with_distance`: (bool) ⚡️👊 whether damage should decrease as the distance from the target increases. Default is `false`
* `pierce`: (bool) ⚡️🥏👊 whether the hit should stop on the first person or continue. Default is `false`
* `physics_override`: (table or string) ⚡️🥏👊🔎 how the player physics should change when running the action. Physics is restored when the recovery phase ends
* It takes either a Minetest physics table or the string `"FREEZE"`, which will block the player
* If this parameter is declared, `slow_down_user` won't get called
* `attack_on_release`: (bool) whether it should attack when the action key is released. NOT YET IMPLEMENTED, [waiting for MT](https://gitlab.com/zughy-friends-minetest/weapons_lib/-/issues/5)
* `pierce`: (bool) whether the hit should stop on the first person or continue. Default is `false`
* `sound`: (string) the sound to play when the action is run
* `trail`: (table) the trail the action should leave. Fields are:
* `sound`: (string) ⚡️🥏👊 the sound to play when the action is run
* `trail`: (table) ⚡️🥏👊 the trail the action should leave. Fields are:
* `image`: (string) the particle to spawn
* `amount`: (int) how many particles to draw along the line
* `on_use`: (function(player, weapon, action, \<pointed_thing>)) additional behaviour when the action is successfully run
* `on_use`: (function(player, weapon, action, \<pointed_thing>)) ⚡️🥏👊 additional behaviour when the action is successfully run
* `pointed_thing` is only passed with custom and punch action types
* if `continuous_fire` is on, the callback is run repeatedly
* a must for `"custom"` type to actually do something
* `on_hit`: (function(hitter, target, weapon, action, hit_point, damage, knockback)) additional behaviour when hitting a player or an entity
* `on_hit`: (function(hitter, target, weapon, action, hit_point, damage, knockback)) ⚡️🥏👊 additional behaviour when hitting a player or an entity
* It must return the damage that will be inflicted (int) and the knockback (int or `nil`)
* `hit_point` only works with type `"raycast"` at the moment, [waiting for MT](https://gitlab.com/zughy-friends-minetest/weapons_lib/-/issues/6)
* `on_end`: (function(player, weapon, action)) additional behaviour for when the action reaches its end
* `on_recovery_end`: (function(player, weapon, action)) additional behaviour for when the weapon is ready to be used again
* `on_end`: (function(player, weapon, action)) ⚡️🥏👊 additional behaviour for when the action reaches its end
* `on_recovery_end`: (function(player, weapon, action)) ⚡️🥏👊 additional behaviour for when the weapon is ready to be used again
#### Except for "punch"
* `ammo_per_use`: (int) how much ammo is needed to run the action
* `continuous_fire`: (bool, no punch) whether it should keep firing when holding down the action key (waiting `delay` seconds between a shot and another). Default is `false`
TODO: `fov`
TODO: physics_override con zoom al momento prob dà problemi
#### Except for "bullet"
* `decrease_damage_with_distance`: (bool) whether damage should decrease as the distance from the target increases. Default is `false`
#### Bullet type
* `bullet`: (table, "bullet" type only) the properties of the physical bullet shot with this action.
#### Bullets structure
TODO
* `remove_on_contact`: (boolean) whether the bullet should cause an explosion when hitting something. It needs `explosion`
* TODO
### Metadata
Weapons communicate their state through players metadata:

View File

@ -45,7 +45,7 @@ weapons_lib.register_weapon("weapons_lib:test3", {
texture = "test1_trail2.png",
},
remove_on_contact = true, -- TODO: considera rinominare in remove_on_contact (l'esplosione avviene se c'è explosion)
remove_on_contact = true,
gravity = false,
-- TODO particelle per quando svanisce? Tipo effetto fumo