Compare commits

...

5 Commits

Author SHA1 Message Date
Zemtzov7 52b594c1bc
ContentDB downloads counter 2022-08-31 11:57:36 +05:00
Zemtzov7 75600d54f9
fix particle randomization 2022-08-30 17:08:21 +05:00
Zemtzov7 3bc887e3fd
Update README.md 2022-08-28 02:05:45 +05:00
Zemtzov7 47b9105793
safe_areas 2022-08-28 02:04:10 +05:00
Zemtzov7 075558ff1b
added safe_areas setting 2022-08-28 02:03:38 +05:00
3 changed files with 23 additions and 8 deletions

View File

@ -1,9 +1,12 @@
# minetest-mod-rocket_launcher
Simple rocket launcher that uses tnt.explode() function
Simple rocket launcher that uses tnt.explode() function
![ContentDB](https://content.minetest.net/packages/Zemtzov7/rocket_launcher/shields/downloads/)
### Features
* Rockets are 3d meshes
* Default radius can be set in settings - `rocket_launcher_radius`, default is `3`,
* Also radius can be set individually for each launcher(radius will displayed in item icon, e.g. `R12`) by the `/rocket-radius <number>` command(keep launcher in the hand to use this command)
* Rocket's ballistic enabled by default and can be disabled in settings(`rocket_launcher_ballistic = false`)
* Explosions in protected areas (damage only, not breaking nodes) can be enabled by setting `rocket_launcher_safe_areas` to `false`
### License of media (textures and model)
* `rocket.obj` - by Zemtzov7. License - CC-BY-SA-4.0

View File

@ -1,5 +1,7 @@
local default_radius = tonumber(core.settings:get("rocket_launcher_radius")) or 3
local ballistic = core.settings:get("rocket_launcher_ballistic") or true
local ballistic = core.settings:get_bool("rocket_launcher_ballistic", true)
local safe_areas = core.settings:get_bool("rocket_launcher_safe_areas", true)
local reloading = {}
local function reload(name)
if not reloading[name] then
@ -10,6 +12,14 @@ local function reload(name)
end
end
local function can_boom(pos)
if safe_areas == false then
return true
else
return not core.is_protected(pos,"")
end
end
core.register_chatcommand("rocket-radius", {
description = "Set rocket explosion radius for wielded rauncher",
params = "<number>",
@ -71,7 +81,7 @@ core.register_tool("rocket_launcher:launcher", {
obj:set_yaw(yaw)
end
end
core.sound_play('fire_extinguish_flame',{to_player = name, gain=0.5})
core.sound_play('fire_extinguish_flame',{to_player = name, gain = 0.5})
return itemstack
end
end})
@ -97,11 +107,10 @@ end
rocket.on_step = function(self, dtime, moveresult)
self.timer = self.timer + dtime
local pos = self.object:get_pos()
local rnd = math.random()
core.after(0.1,function()
core.add_particle({
pos = pos,
velocity = {x=rnd,y=rnd,z=rnd},
velocity = {x=math.random(-0.5,0.5),y=math.random(-0.5,0.5),z=math.random(-0.5,0.5)},
expirationtime = 0.1,
size = 6,
collisiondetection = false,
@ -110,7 +119,7 @@ rocket.on_step = function(self, dtime, moveresult)
glow = 15})
core.add_particle({
pos = pos,
velocity = {x=rnd,y=rnd,z=rnd},
velocity = {x=math.random(-1,1),y=math.random(-1,1),z=math.random(-1,1)},
expirationtime = 0.7,
size = 6,
collisiondetection = false,
@ -128,7 +137,7 @@ rocket.on_step = function(self, dtime, moveresult)
local prop = obj:get_properties()
if not prop then goto nodes end
if obj:is_player() or prop.collide_with_objects == true then
if not core.is_protected(pos,"") then
if can_boom(pos) then
tnt.boom(pos,{radius=self["radius"]})
end
self.object:remove()
@ -137,7 +146,9 @@ rocket.on_step = function(self, dtime, moveresult)
end
::nodes::
if moveresult.collides then
tnt.boom(pos,{radius=self["radius"]})
if can_boom(pos) then
tnt.boom(pos,{radius=self["radius"]})
end
self.object:remove()
end
end

View File

@ -1,2 +1,3 @@
rocket_launcher_radius (Rocket explosion radius) int 3
rocket_launcher_ballistic (Rocket ballistic) bool true
rocket_launcher_safe_areas (Dont boom in protected areas) bool true