Created
July 22, 2019 19:15
-
-
Save ClockGen/b2c39ca0c248ac5b8e1da56c9020d865 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bweapons api provides two public functions: bweapons.register_weapon() and bweapons.register_ammo(). | |
bweapons.register_ammo() is not required (actual required ammo is specified in weapon definition), however it was defined for simplicity of registering ammo. | |
Automatic weapons are not implemented for the sake of saving server perfomance (for both rapid fire and need to constantly check input of every player). | |
All fields can be omited (except for mandatory ones), in that case they will either default to some value or a specific feature will be disabled. | |
Many features will only be enabled if a corresponding field was specified | |
(for example if you omit a "flare" field, a muzzle flash wont be shown, same for all other visuals and sounds). | |
The following examples contains all possible fields. Many fields are not required or used (for example there's no point in defining projectile options if your weapon is hitscan, | |
or defining ammo and type of ammo if your weapon is technic-powered). | |
All features are supposed to work together, and there are no conflicting features, so there's a big room for experimentation. | |
Main weapon registration function, with definition supplied in form of table: | |
bweapons.register_weapon({ | |
--Mandatory fields | |
name = "my_weapons_pack:rifle", --Tool ID | |
description = "Rifle", --Name shown in inventory | |
texture = "my_weapons_pack_rifle.png", --Texture, for both inventory icon and displayed in hand | |
--Ammo or energy | |
uses = 128, --Amount of uses until the tool breaks/needs to be recharged by technic | |
technic_powered = false, --Should weapon be energy-powered, instead of consuming ammo each shot. Requires technic modpack | |
max_charge = 350000, --Maximum charge that the weapon holds, in technic EU. | |
ammo_type = "my_weapons_pack:rifle_round", --Id of an inventory item that will be used as ammo. Ammo can be easily registered with bweapons.register_ammo(). | |
ammo_per_shot = 1, --How much ammo should be used per shot. | |
--Weapon configuration | |
hitscan = true, --Instantly trace shots to the target, use in weapons like firearms, lasers, etc. | |
distance = 100, --Distance in nodes in which hitscan traces will connect to the target | |
penetration = 2, --How many nodes/objects hitscan trace will go through before stopping (damaging each one) | |
liquids = false, --Should hitscan traces travel through liquid nodes. | |
damage = 15, --Damage per projectile/hitscan trace | |
shot_amount = 1, --Total amount of projectiles or hitscan traces per shot | |
spread = 0.02, --Random deviation of direction of every particle or hitscan trace from center of the screen | |
cooldown = 2, --Period of time after which you can fire the weapon again | |
spawn_distance = 1, --Distance in direction of player view at which projectile and hitscan traces start | |
aoe = false, --Enable Area Of Effect Damage | |
aoe_radius = 5, --Radius at which damage is inflicted, damage is calculated linearly, with highest at the center and lowest at the edge of radius | |
--Visuals | |
flare = "tnt_boom.png", --Muzzle flash texture, also used for little impact particles | |
flaresize = 10, --Size of muzzle flash texture | |
flare_glow = true, --Should muzzle flash glow | |
hit_flare_size_multiplier = 0.5, --Multiplier of size of initial hit flash (use big values for things like explosions, visuals for AoE, etc) | |
hit_particle = "tnt_smoke.png", --Texture of particles to emit when hit something | |
hit_particle_glow = false, --Should hit particles glow | |
hit_particle_size = 2, --Maximum visual size of hit particles. Minimum size is lowest integer of maximum size divided by two. | |
hit_particle_velocity = 2, --Starting velocity of hit particles | |
hit_particle_gravity = -10, --Acceleration on vertical axis of hit particles | |
--Sounds | |
fire_sound = "my_weapons_pack_fire_sound", --Sound when firing a weapon | |
reload_sound = "my_weapons_pack_reload_sound", --Sound when weapon is cooling down/not enough ammo or charge | |
hit_sound = "my_weapons_pack_hit_sound", --Sound, emitted at every place where projectile/hitscan trace hits something | |
--Projectile configuration | |
projectile_speed = 15, --Starting velocity of projectile | |
projectile_gravity = -10, --Acceleration on vertical axis of projectile | |
projectile_dampening = 0, --Dampening force of projectile | |
projectile_timeout = 35, --Timeout in server ticks after which projectile dissapears, calling on_timeout() | |
--Projectile visuals | |
projectile_texture = "my_weapons_pack_projectile.png", --Texture of projectiile | |
projectile_trail_texture = "my_weapons_pack_projectile_trail.png", --Texture of projectile trail particles | |
projectile_trail_glow = true, --Should projectile trail particles glow | |
projectile_glow = true, --Should projectile visual glow | |
projectile_visual_size = 1, --Size of projectile visual | |
--Drop on hit | |
drop = "default:stone", --Drop something on successful hit | |
drop_chance = 0.8, --Chance of drop (1 is always drop, 0 is never) | |
--Custom functions | |
on_fire = function(itemstack, user, pointed_thing) | |
print("Fired weapon") | |
end, --Custom function called on weapon fire. | |
on_hit = function (self.owner, self, t, pos) | |
print("Hit something") | |
end, --Custom function called on hitscan/projectile hit. With hitscan, self provides a user entity, | |
--with projectile self provides a projectile entity. Depending on occasion, t may reference a node or an object | |
on_timeout = function (self.owner, self, pos) | |
print("Projectile timeout") | |
end, --Custom function called on a projectile timeout | |
--Recipes | |
recipe={ | |
{ | |
{'moreores:tin_ingot', 'technic:diamond_drill_head', 'moreores:tin_ingot'}, | |
{'technic:stainless_steel_ingot', 'technic:motor', 'technic:stainless_steel_ingot'}, | |
{'', 'technic:red_energy_crystal', 'default:copper_ingot'} | |
}, | |
{ | |
{'moreores:tin_ingot', 'technic:diamond_drill_head', 'moreores:tin_ingot'}, | |
{'technic:stainless_steel_ingot', 'technic:tin_ingot', 'technic:stainless_steel_ingot'}, | |
{'', 'technic:red_energy_crystal', 'default:copper_ingot'} | |
} | |
}, --Recipes to be registered for this weapon. Table may contain multiple recipes | |
}) | |
Ammo registration function, with definition supplied in form of table: | |
bweapons.register_ammo({ | |
--Mandatory | |
name = "my_weapons_pack:rifle_round", --Ammo ID | |
description = "Pistol Round", --Inventory name | |
texture = "bweapons_firearms_pack_pistol_round.png", --Inventory texture | |
--Optional | |
recipe={ | |
{ | |
{'moreores:tin_ingot', 'technic:diamond_drill_head', 'moreores:tin_ingot'}, | |
{'technic:stainless_steel_ingot', 'technic:motor', 'technic:stainless_steel_ingot'}, | |
{'', 'technic:red_energy_crystal', 'default:copper_ingot'} | |
}, | |
{ | |
{'moreores:tin_ingot', 'technic:diamond_drill_head', 'moreores:tin_ingot'}, | |
{'technic:stainless_steel_ingot', 'technic:tin_ingot', 'technic:stainless_steel_ingot'}, | |
{'', 'technic:red_energy_crystal', 'default:copper_ingot'} | |
} | |
}, --Recipes to be registered for this ammo. Table may contain multiple recipes | |
amount = 1, --Amount of ammo to be given after crafting | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment