Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ClobberXD committed Mar 26, 2019
1 parent dce20ce commit 67e37a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
29 changes: 15 additions & 14 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,23 @@ The `gunslinger` namespace has the following members:
### `reload(stack, player)`

- Reloads stack if ammo exists and plays `def.sounds.reload`. Otherwise, just plays `def.sounds.ooa`.
- `stack` [ItemStack]: ItemStack of wielded item; passed by `on_lclick`.
- `player` [ObjectRef]: Player whose gun requires reloading; passed by `on_lclick`.
- Takes the same arguments as `on_lclick`.

### `fire(stack, player)`

- Responsible for firing one single round and dealing damage if target was hit. Updates wear by `def.unit_wear`.
- If gun is worn out, `reload` is called.
- `stack` [ItemStack]: ItemStack passed by `on_lclick`.
- `player` [ObjectRef]: Shooter player passed by `on_lclick`.
- Takes the same arguments as `on_lclick`.

### `burst_fire(stack, player)`

- Helper method to fire in burst mode. Takes the same arguments as `fire`.
- Helper method to fire in burst mode.
- Takes the same arguments as `on_lclick`.

### `splash_fire(stack, player)`

- Helper method to fire shotgun-style. Takes the same arguments as `fire`.
- Helper method to fire pellets shotgun-style.
- Takes the same arguments as `on_lclick`.

### `on_step(dtime)`

Expand All @@ -114,11 +114,9 @@ The `gunslinger` namespace has the following members:

- `itemdef` [table]: Item definition table passed to `minetest.register_item`.
- Note that `on_use`, `on_place`, and `on_secondary_use` will be overridden.
- `ammo` [string]: Name of valid registered item to be used as ammo for the gun. Defaults to `gunslinger:ammo` if undefined.
- `clip_size` [number]: Number of rounds per-clip.
- `fire_rate` [number]: Number of rounds per-second.
- `range` [number]: Range of fire in number of nodes.
- `dmg_mult` [number]: Damage multiplier. Multiplied by `base_dmg` to obtain final damage value.
- `mode` [string]: Firing mode.
- `"manual"`: One round per-click, but requires manual loading for every round; aka bolt-action rifles.
- `"semi-automatic"`: One round per-click. e.g. a typical 9mm pistol.
Expand All @@ -127,13 +125,16 @@ The `gunslinger` namespace has the following members:
- `"automatic"`: Fully automatic; shoots as long as primary button is held down. e.g. AKM, M416.
- `"hybrid"`: Same as `"automatic"`, but switches to `"burst"` mode when scope view is toggled.

- `ammo` [string]: Name of valid registered item to be used as ammo for the gun. Defaults to `gunslinger:ammo`.
- `dmg_mult` [number]: Damage multiplier. Multiplied by `base_dmg` to obtain initial/rated damage value. Defaults to 1.
- `reload_time` [number]: Reload time in seconds. Defaults to 3 to match default reload sound.
- `sounds` [table]: Sounds for various events.
- `fire` [string]: Sound played on fire. Defaults to `gunslinger_fire.ogg`.
- `reload` [string]: Sound played on reload. Defaults to `gunslinger_reload.ogg`.
- `ooa` [string]: Sound played when the gun is out of ammo and ammo isn't available in the player's inventory. Defaults to `gunslinger_ooa.ogg`.
- `load` [string]: Sound played when the gun is manually loaded. Only used if `mode` is set to `manual`.

- `scope` [string]: Name of scope overlay texture.
- Overlay texture would be stretched across the screen, and center of texture will be positioned on top of crosshair.
- `zoom` [number]: **(WARNING: Unimplemented)** Sets player FOV in degrees when scope is enabled (defaults to no zoom)
- Requires `scope` to be defined.

- `sounds` [table]: List of sounds for various events.
- `fire` [string]: Sound played on fire. Defaults to `gunslinger_fire`.
- `reload` [string]: Sound played on reload. Defaults to `gunslinger_reload`.
- `ooa` [string]: Sound played when the gun is out of ammo and ammo isn't available in the player's inventory. Defaults to `gunslinger_ooa`.
- `load` [string]: Sound played when the gun is manually loaded. Only required if `def.mode` is set to `manual`.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ This mod provides an API to add a variety of realistic and enjoyable guns to Min
## Settings

- `gunslinger.lite` [`bool`] (defaults to `false`)
- Toggles [lite mode](###Lite-mode)
- Toggles [lite mode](#lite-mode)
- `gunslinger.disable_builtin` [`bool`] (defaults to `false`)
- Enables/Disables builtin guns - only the API will be provided.
- Useful if mods/games provide custom guns.

## Architecture

Gunslinger makes use of gun _types_ in order to ease registration of similar guns. A `type` is made up of a name and a table of default values to be applied to all guns registered with that type. Types are optional, and can also be omitted altogether. Guns are allowed to override their type defaults, for maximum customisability. `Raycast` is used to find target in line-of-sight, and all objects including non-player entities take damage. See [Deferred Raycasting](###Deferred-Raycasting) section to know more about gunslinger's projectile calculations.
Gunslinger makes use of gun _types_ in order to ease registration of similar guns. A `type` is made up of a name and a table of default values to be applied to all guns registered with that type. Types are optional, and can also be omitted altogether. Guns are allowed to override their type defaults, for maximum customisability. `Raycast` is used to find target in line-of-sight, and all objects including non-player entities take damage. See [Deferred Raycasting](#deferred-raycasting) section to know more about gunslinger's projectile calculations.

Final damage is calculated like so:
Final damage to target is calculated like so:

- Initial/rated damage = `base_dmg * def.dmg_mult`
- If headshot, damage is increased by 50%
Expand All @@ -31,7 +31,7 @@ Final damage is calculated like so:

Enabling lite mode will disable the realistic/fancy features which are potentially lag-inducing. Recommended for large servers.

> Note: As of now, enabling lite mode will only disable automatic guns, but there are plans to allow lite mode to disable much more (see #22).
> Note: As of now, enabling lite mode will only disable automatic guns, but there are plans to allow lite mode to disable much more.
### Automatic guns

Expand Down

0 comments on commit 67e37a3

Please sign in to comment.