Go to file
Cahrs 7ddf0a91e7
Fix README
2020-04-22 21:47:54 -04:00
textures Add files via upload 2019-09-25 10:25:40 -04:00
LICENSE Add files via upload 2019-09-25 10:25:40 -04:00
README.md Fix README 2020-04-22 21:47:54 -04:00
api.lua add crits back and add documentation to README 2020-04-22 20:19:04 -04:00
init.lua Updates :] 2020-04-22 19:24:08 -04:00
mod.conf Add files via upload 2019-09-25 10:25:40 -04:00

README.md

w_api

Adds a melee weapons api for more advanced/deep combat within Minetest.

Features

  • Support for custom damage groups
  • Primary and secondary attacks
  • Variable slash depth and weapon reach
  • Directional slashes
  • Customizable swing delay and time per weapon
  • Critical hits
  • ???

Usage (mods)

w_api.register_weapon(name, weapon definition)

Weapon Definition

Used by w_api.register_weapon.

{
    description = "Super cool weapon",

    wield_scale = {x = 1, y = 1, z = 1},
    -- Weapon wield scale (see Minetest lua_api.txt).

    inventory_image = "your_weapon.png",

    -- Table fields used for both primary_use and secondary_use 
    primary_use = {
        ent_bl = false, 
        -- If true, objects will only be hit once (rather than by multiple raycasts).

        crit_mp = 1,
        -- Value multiplied by damage groups when hitter has a negative Y velocity.
    
        kb_mp = 1,
        -- Value to multiply by player / ent speed for knockback.

        slash_dir = "left",
        -- Weapon slash-to direction (eg. right-to-left).

        swing_delay = 1,
        -- Time (in seconds) until swing starts.

        delay = 1,
        -- Delay (in seconds) between each raycast in a swing.
    
        depth = 3,
        -- How many objects deep that a weapon can damage.

        range = 5,
        -- Sword reach (in nodes).

        spread = 20,
        -- Angle (in degrees) between each raycast in a swing.
    
        amount = 10,
        -- Ray count in a sword swing.

        damage_groups = {},
        -- A table of damage groups (see Minetest lua_api.txt).
    },

    callbacks = {
        -- Table fields used for both primary_use and secondary_use
        primary_use = {
            on_use = function(itemstack, user),
            -- Function to be called when weapon is used.
            -- Return false to prevent default behavior.

            on_hit = function(itemstack, hitter, object),
            -- Function to be called when an object is hit by the weapon.
            -- Return false to prevent default behavior.
        }
    },
}