Class boomstick.Projectile
Projectile class from which custom projectiles can be created.
Usage:
local myprojectile = boomstick.Projectile:new({
_name = "Pellet",
_item_name = "pellet",
_entity_name = "boomstick:pellet",
-- How fast our projectile will go (optional)
_velocity = 50,
-- How long until our projectile should despawn (optional)
_lifetime = 2.5,
-- How much damage each projectile will do
_damage = 6,
initial_properties = {
-- Use a sprite for our projectile (instead of a mesh)
visual = "sprite",
textures = {"boomstick_projectile_pellet.png"},
-- If we want our projectile to be able to hit things
physical = true,
collide_with_objects = true,
-- How big our projectile looks
visual_size = {y = 0.1, x = 0.1, z = 0.1},
-- How big our projectile is for collision purposes
collisionbox = {-0.01, 0, -0.01, 0.01, 0.01, 0.01}
}
})
-- Register the entity with the Minetest engine
minetest.register_entity("boomstick:pellet", PelletProjectile)
Functions
| boomstick_api.Projectile:set_owner (player) | Registers a callback function to be called when the projectile has a collision. |
| boomstick_api.Projectile:get_owner (func) | Registers a callback function to be called when the projectile has a collision. |
| boomstick_api.Projectile:register_on_collision (func) | Registers a callback function to be called when the projectile has a collision. |
| boomstick_api.Projectile:collision_is_projectile (collision) | For determining whether or not a projectile collided with another projectile. |
| boomstick_api.Projectile:do_damage (collision) | Deal damage to whatever object or node the projectile collided with. |
| boomstick_api.Projectile:get_velocity (player) | Given a player look direction and a velocity value, create a vector that sends the projectile off in the direction the player is pointing. |
| boomstick_api.Projectile:get_acceleration (player, accuracy) | Given a player position and an accuracy value, create a randomized vector for the projectiles acceleration |
| boomstick_api.Projectile:get_position (player, accuracy) | Given a player position and an accuracy value, create a randomized position that the projectile should be spawned in at. |
Functions
- boomstick_api.Projectile:set_owner (player)
-
Registers a callback function to be called when the projectile has a collision.
If you'd like certain behavior to happen when a projectile collides with
something, you can pass another function as an argument to this function,
and it will be executed when the projectile collides with something.
Note: Unless you're doing something special, the owner of the weapon should be the player who is holding it.
Parameters:
- player ObjectRef An ObjectRef of the player that will own the weapon.
- boomstick_api.Projectile:get_owner (func)
-
Registers a callback function to be called when the projectile has a collision.
If you'd like certain behavior to happen when a projectile collides with
something, you can pass another function as an argument to this function,
and it will be executed when the projectile collides with something.
Note: It is usually not necesary to call this function directly to create a new weapon, unless you are extending the mod or making custom behavior.
Parameters:
- func function Function to be executed on collision.
- boomstick_api.Projectile:register_on_collision (func)
-
Registers a callback function to be called when the projectile has a collision.
If you'd like certain behavior to happen when a projectile collides with
something, you can pass another function as an argument to this function,
and it will be executed when the projectile collides with something.
Parameters:
- func function Function to be executed on collision.
- boomstick_api.Projectile:collision_is_projectile (collision)
-
For determining whether or not a projectile collided with another projectile.
Sometimes (especially with shotguns) projectiles will collide with one
another. It is often necessary to check if a collision happened between two
projectiles, so that we can do something (usually ignore it). Otherwise
projectiles would deal damage to one another.
Parameters:
- collision Collision object returned by Minetest
Returns:
-
boolean
whether or not the projectile collided with another
projectile.
- boomstick_api.Projectile:do_damage (collision)
-
Deal damage to whatever object or node the projectile collided with.
This is how we actually make projectiles do damage when they hit their
target.
Parameters:
- collision Collision object returned by Minetest
Returns:
-
bool
whether or not the projectile collided with another projectile.
- boomstick_api.Projectile:get_velocity (player)
-
Given a player look direction and a velocity value, create a
vector that sends the projectile off in the direction the player is
pointing.
Parameters:
- player
- A player ObjectRef. This is the player who fired the weapon.
- player
- boomstick_api.Projectile:get_acceleration (player, accuracy)
-
Given a player position and an accuracy value, create a randomized
vector for the projectiles acceleration
Parameters:
- player
- A player ObjectRef. This is the player who fired the weapon.
- accuracy
- An accuracy value that will determine randomized acceleration spread
- player
- boomstick_api.Projectile:get_position (player, accuracy)
-
Given a player position and an accuracy value, create a randomized
position that the projectile should be spawned in at.
Parameters:
- player
- A player ObjectRef. This is the player who fired the weapon.
- accuracy
- An accuracy value that will determine randomized acceleration spread
- player