Rework armi
This commit is contained in:
parent
676a00e8f7
commit
33aac3b255
@ -11,18 +11,18 @@ function block_league.bullets_hud_create(p_name)
|
||||
local sub_txt_elems = {}
|
||||
local offset = -120
|
||||
|
||||
for i = 0, inv:get_size("main"), 1 do
|
||||
for i = 1, 3 do
|
||||
|
||||
local stack = inv:get_stack("main", i)
|
||||
local item_name = stack:get_name()
|
||||
local definition = minetest.registered_nodes[item_name]
|
||||
local weapon = minetest.registered_nodes[item_name]
|
||||
|
||||
if definition ~= nil and (definition.throwable_by_hand ~= nil or definition.bullet ~= nil) then
|
||||
if weapon ~= nil and weapon.magazine ~= nil then
|
||||
sub_img_elems[item_name .. "_icon"] = {
|
||||
scale = { x = 2, y = 2 },
|
||||
offset = { x = 10, y = offset },
|
||||
alignment = { x = 1, y = 0 },
|
||||
text = definition.inventory_image,
|
||||
text = weapon.inventory_image,
|
||||
z_index = 1
|
||||
}
|
||||
sub_img_elems[item_name .. "_bg"] = {
|
||||
@ -33,23 +33,10 @@ function block_league.bullets_hud_create(p_name)
|
||||
z_index = 0
|
||||
}
|
||||
|
||||
local count = 0
|
||||
|
||||
if definition.bullet then
|
||||
for i=0, inv:get_size("main"), 1 do
|
||||
local stack = inv:get_stack("main", i)
|
||||
local item_name = stack:get_name()
|
||||
if item_name == definition.bullet then
|
||||
count = stack:get_count()
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
sub_txt_elems[definition.name .. "_reload_txt"] = {
|
||||
sub_txt_elems[weapon.name .. "_magazine_txt"] = {
|
||||
alignment = { x = 3, y = 0 },
|
||||
offset = { x = 50, y = offset },
|
||||
text = definition.magazine and definition.magazine or "-1",
|
||||
text = weapon.magazine and weapon.magazine or "-1",
|
||||
z_index = 1
|
||||
}
|
||||
offset = offset - 50
|
||||
@ -75,19 +62,15 @@ end
|
||||
|
||||
|
||||
function get_bullet_count(definition, inv)
|
||||
if definition.throwable_by_hand then
|
||||
return stack:get_count()
|
||||
else
|
||||
if not definition.bullet then return end
|
||||
if not definition.bullet then return end
|
||||
|
||||
for i=0,inv:get_size("main"),1 do
|
||||
for i=0,inv:get_size("main"),1 do
|
||||
|
||||
local stack = inv:get_stack("main", i)
|
||||
local item_name = stack:get_name()
|
||||
local stack = inv:get_stack("main", i)
|
||||
local item_name = stack:get_name()
|
||||
|
||||
if item_name == definition.bullet then
|
||||
return stack:get_count()
|
||||
end
|
||||
if item_name == definition.bullet then
|
||||
return stack:get_count()
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -100,7 +83,7 @@ function block_league.weapons_hud_update(arena, p_name, item_name, magazine)
|
||||
|
||||
panel:update(nil,
|
||||
{
|
||||
[weapon_def.name .. "_reload_txt"] = {
|
||||
[weapon_def.name .. "_magazine_txt"] = {
|
||||
text = magazine
|
||||
}
|
||||
})
|
||||
|
@ -11,7 +11,7 @@ arena_lib.on_load("block_league", function(arena)
|
||||
|
||||
for pl_name, stats in pairs(arena.players) do
|
||||
reset_meta(pl_name)
|
||||
equip_weapons(pl_name, arena)
|
||||
equip_weapons(arena, pl_name)
|
||||
create_and_show_HUD(arena, pl_name)
|
||||
block_league.refill_weapons(arena, pl_name)
|
||||
|
||||
@ -43,7 +43,7 @@ end)
|
||||
arena_lib.on_join("block_league", function(p_name, arena)
|
||||
|
||||
reset_meta(p_name)
|
||||
equip_weapons(p_name, arena)
|
||||
equip_weapons(arena, p_name)
|
||||
create_and_show_HUD(arena, p_name)
|
||||
block_league.refill_weapons(arena, p_name)
|
||||
|
||||
@ -158,7 +158,7 @@ end
|
||||
|
||||
|
||||
|
||||
function equip_weapons(p_name, arena)
|
||||
function equip_weapons(arena, p_name)
|
||||
|
||||
--TODO avere una tabella per giocatore che tenga traccia delle armi equipaggiate
|
||||
local default_weapons = {"block_league:smg", "block_league:sword", "block_league:pixelgun"}
|
||||
|
@ -9,12 +9,13 @@ function block_league.round_start(arena)
|
||||
|
||||
player:set_hp(20)
|
||||
arena.players[p_name].energy = 100
|
||||
block_league.energy_update(arena, p_name)
|
||||
|
||||
block_league.refill_weapons(arena, p_name)
|
||||
player:get_meta():set_int("bl_reloading", 0)
|
||||
|
||||
player:set_physics_override({
|
||||
speed = vel,
|
||||
speed = block_league.SPEED,
|
||||
jump = 1.5
|
||||
})
|
||||
|
||||
|
@ -1,139 +1,70 @@
|
||||
function block_league.register_bullet(name, def)
|
||||
minetest.register_node(name,{
|
||||
name = name,
|
||||
description = def.description,
|
||||
inventory_image = def.inventory_image,
|
||||
wield_scale = def.wield_scale,
|
||||
function block_league.register_bullet(bullet, damage, bullet_trail)
|
||||
|
||||
drawtype = def.mesh and "mesh" or "item",
|
||||
mesh = def.mesh or nil,
|
||||
tiles = def.tiles or nil,
|
||||
wield_image = def.wield_image or nil,
|
||||
local bullet_entity = bullet_set_entity(bullet.name, bullet, damage, bullet_trail)
|
||||
|
||||
pierce = def.pierce,
|
||||
knockback = def.knockback,
|
||||
decrease_damage_with_distance = def.decrease_damage_with_distance,
|
||||
bullet_damage = def.bullet_damage,
|
||||
bullet_trail = def.bullet_trail,
|
||||
bullet = def.bullet,
|
||||
|
||||
stack_max = def.stack_max,
|
||||
on_drop = function() end,
|
||||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
if def.throwable_by_hand then
|
||||
local inv = user:get_inventory()
|
||||
|
||||
-- se sono immune e sparo, perdo l'immunità
|
||||
if user:get_armor_groups().immortal and user:get_armor_groups().immortal == 1 then
|
||||
user:set_armor_groups({immortal = nil})
|
||||
end
|
||||
|
||||
local p_name = user:get_player_name()
|
||||
local arena = arena_lib.get_arena_by_player(p_name)
|
||||
|
||||
if not arena or not arena.in_game or user:get_hp() <= 0 or arena.weapons_disabled then return end
|
||||
|
||||
if def.consume_on_throw then
|
||||
itemstack:take_item()
|
||||
end
|
||||
|
||||
block_league.shoot_bullet(name, def, nil, itemstack, user, pointed_thing)
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
if def.throwable_by_hand then
|
||||
local inv = user:get_inventory()
|
||||
|
||||
-- se sono immune e sparo, perdo l'immunità
|
||||
if user:get_armor_groups().immortal and user:get_armor_groups().immortal == 1 then
|
||||
user:set_armor_groups({immortal = nil})
|
||||
end
|
||||
|
||||
local p_name = user:get_player_name()
|
||||
local arena = arena_lib.get_arena_by_player(p_name)
|
||||
|
||||
if not arena or not arena.in_game or user:get_hp() <= 0 or arena.weapons_disabled then return end
|
||||
|
||||
if def.consume_on_throw then
|
||||
itemstack:take_item()
|
||||
end
|
||||
|
||||
block_league.shoot_bullet(name, def, nil, itemstack, user, pointed_thing)
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
if def.shootable then
|
||||
-- Ottiene la definizione dell'entità
|
||||
local bullet_entity = bullet_set_entity(name, def)
|
||||
-- Registra l'entità
|
||||
minetest.register_entity(name .. "_entity", bullet_entity)
|
||||
end
|
||||
minetest.register_entity("block_league:" .. bullet.name .. "_entity", bullet_entity)
|
||||
|
||||
return bullet_entity
|
||||
end
|
||||
|
||||
|
||||
|
||||
function bullet_set_entity(name, def)
|
||||
local bullet_entity = {
|
||||
function bullet_set_entity(name, def, dmg, trail)
|
||||
local bullet = {
|
||||
initial_properties = {
|
||||
name = name,
|
||||
bullet_speed = def.bullet.bullet_speed,
|
||||
bullet_explosion_damage = def.bullet.bullet_explosion_damage,
|
||||
|
||||
name = def.name,
|
||||
visual = def.mesh and "mesh" or "item",
|
||||
mesh = def.mesh,
|
||||
visual_size = def.visual_size,
|
||||
textures = def.textures,
|
||||
collisionbox = def.collisionbox,
|
||||
|
||||
damage = dmg,
|
||||
speed = def.speed,
|
||||
lifetime = def.lifetime,
|
||||
|
||||
explosion_range = def.explosion_range,
|
||||
explosion_damage = def.explosion_damage,
|
||||
explosion_texture = def.explosion_texture,
|
||||
bullet_trail = trail,
|
||||
|
||||
explode_on_contact = def.explode_on_contact,
|
||||
gravity = def.gravity,
|
||||
|
||||
on_destroy = def.on_destroy,
|
||||
on_right_click = def.on_right_click,
|
||||
|
||||
physical = true,
|
||||
collide_with_objects = true,
|
||||
visual_size = def.bullet.visual_size,
|
||||
collisionbox = def.bullet.collisionbox,
|
||||
|
||||
visual = def.bullet.mesh and "mesh" or "item",
|
||||
mesh = def.bullet.mesh,
|
||||
textures = def.bullet.textures,
|
||||
wield_item = name,
|
||||
bullet_explosion_texture = def.bullet.bullet_explosion_texture,
|
||||
bullet_speed = def.bullet.bullet_speed,
|
||||
explode_on_contact = def.bullet.explode_on_contact,
|
||||
bullet_explosion_range = def.bullet.bullet_explosion_range,
|
||||
gravity = def.bullet.gravity,
|
||||
on_right_click = def.bullet.on_right_click,
|
||||
on_destroy = def.bullet.on_destroy,
|
||||
duration = def.duration,
|
||||
bullet_trail = def.bullet_trail,
|
||||
bullet_damage = def.bullet_damage,
|
||||
is_bullet = true
|
||||
}
|
||||
}
|
||||
|
||||
function bullet_entity:_destroy()
|
||||
function bullet:_destroy()
|
||||
-- Crea le particelle dell'esplosione
|
||||
spawn_particles_sphere(self.object:get_pos(), self.initial_properties.bullet_explosion_texture)
|
||||
-- Se ha una funzione apposita da usare quando esplode la esegue
|
||||
if self.initial_properties.on_destroy then
|
||||
self.initial_properties.on_destroy(self)
|
||||
end
|
||||
spawn_particles_sphere(self.object:get_pos(), self.initial_properties.explosion_texture)
|
||||
|
||||
-- Distrugge l'entità
|
||||
self.object:remove()
|
||||
self.initial_properties.on_destroy(self)
|
||||
self.object:remove()
|
||||
end
|
||||
|
||||
-- Ottiene gli staticdata ogni 18 secondi circa
|
||||
function bullet_entity:get_staticdata(self)
|
||||
function bullet:get_staticdata(self)
|
||||
if self == nil or self.p_name == nil then return end
|
||||
return self.p_name
|
||||
end
|
||||
|
||||
-- L'entità esplode quando colpita
|
||||
function bullet_entity:on_punch()
|
||||
function bullet:on_punch()
|
||||
if self.initial_properties.on_right_click then
|
||||
self.initial_properties.on_right_click(self)
|
||||
end
|
||||
end
|
||||
|
||||
-- quando si istanzia un'entità
|
||||
function bullet_entity:on_activate(staticdata)
|
||||
function bullet:on_activate(staticdata)
|
||||
|
||||
if staticdata ~= "" and staticdata ~= nil then
|
||||
self.p_name = staticdata -- nome utente come staticdata
|
||||
@ -147,10 +78,10 @@ function bullet_set_entity(name, def)
|
||||
end
|
||||
end
|
||||
|
||||
function bullet_entity:on_step(dtime, moveresult)
|
||||
function bullet:on_step(dtime, moveresult)
|
||||
self.lifetime = self.lifetime + dtime
|
||||
|
||||
if self.lifetime >= self.initial_properties.duration then
|
||||
if self.lifetime >= self.initial_properties.lifetime then
|
||||
-- ESPLODE
|
||||
self:_destroy()
|
||||
return
|
||||
@ -198,7 +129,7 @@ function bullet_set_entity(name, def)
|
||||
buffer_boolean = true
|
||||
elseif collision.object:get_player_name() == self.p_name then
|
||||
|
||||
if self.lifetime < (15 / self.initial_properties.bullet_speed) then
|
||||
if self.lifetime < (15 / self.initial_properties.speed) then
|
||||
obj:set_velocity({
|
||||
x=(collision.old_velocity.x),
|
||||
y=(collision.old_velocity.y),
|
||||
@ -294,7 +225,7 @@ function bullet_set_entity(name, def)
|
||||
end
|
||||
|
||||
-- Restituisce la definizione dell'entità
|
||||
return bullet_entity
|
||||
return bullet
|
||||
|
||||
end
|
||||
|
||||
|
@ -1,42 +0,0 @@
|
||||
block_league.register_bullet("block_league:grenade", {
|
||||
description = "grenade",
|
||||
mesh = "bl_grenade.obj",
|
||||
tiles = {"bl_grenade.png"},
|
||||
wield_scale = {x=1.5, y=1.5, z=1.5},
|
||||
inventory_image = "bl_grenade_icon.png",
|
||||
stack_max = 99,
|
||||
pierce = false,
|
||||
throwable_by_hand = true,
|
||||
bullet_damage = 10,
|
||||
decrease_damage_with_distance = false,
|
||||
bullet_trail = {
|
||||
image = "bl_bullet_rocket.png",
|
||||
life = 1,
|
||||
size = 2,
|
||||
glow = 0,
|
||||
interval = 5,
|
||||
amount = 20,
|
||||
},
|
||||
knockback = 0,
|
||||
duration = 1.5,
|
||||
shootable = true,
|
||||
bullet = {
|
||||
bullet_speed = 17,
|
||||
bullet_explosion_damage = 16,
|
||||
|
||||
visual_size = {x=7, y=7, z=7},
|
||||
mesh = "bl_grenade.obj",
|
||||
bullet_explosion_texture = "bl_rocket_particle.png",
|
||||
explode_on_contact = false,
|
||||
textures = {"bl_grenade.png"},
|
||||
collisionbox = {-0.2, -0.2, -0.2, 0.2, 0.2, 0.2},
|
||||
bullet_explosion_range = 4,
|
||||
gravity = true,
|
||||
on_destroy = block_league.grenade_explode,
|
||||
on_right_click = function(self)
|
||||
self:_destroy()
|
||||
end
|
||||
|
||||
},
|
||||
|
||||
})
|
@ -1,19 +1,59 @@
|
||||
|
||||
block_league.register_weapon("block_league:grenade_launcher", {
|
||||
|
||||
description = S("Grenade Launcher"),
|
||||
mesh = "bl_rocketlauncher.obj",
|
||||
tiles = {"bl_rocketlauncher.png"},
|
||||
wield_scale = {x=1.3, y=1.3, z=1.3},
|
||||
inventory_image = "bl_grenade_launcher.png",
|
||||
|
||||
weap_delay = 0.8,
|
||||
weap_sound_shooting = "bl_rocketlauncher_shoot",
|
||||
continuos_fire = false,
|
||||
slow_down_when_firing = false,
|
||||
consume_bullets = false,
|
||||
type = 2,
|
||||
launching_force = 10,
|
||||
|
||||
bullet = "block_league:grenade",
|
||||
damage = 10,
|
||||
knockback = 1,
|
||||
weap_delay = 0.8,
|
||||
|
||||
pierce = false,
|
||||
decrease_damage_with_distance = false,
|
||||
slow_down_when_firing = true,
|
||||
continuos_fire = false,
|
||||
|
||||
weap_sound_shooting = "bl_rocketlauncher_shoot",
|
||||
bullet_trail = {
|
||||
image = "bl_bullet_rocket.png",
|
||||
life = 1,
|
||||
size = 2,
|
||||
glow = 0,
|
||||
interval = 5,
|
||||
amount = 20,
|
||||
},
|
||||
|
||||
consume_bullets = false,
|
||||
|
||||
|
||||
bullet = {
|
||||
name = "grenade",
|
||||
|
||||
mesh = "bl_grenade.obj",
|
||||
visual_size = {x=7, y=7, z=7},
|
||||
textures = {"bl_grenade.png"},
|
||||
collisionbox = {-0.2, -0.2, -0.2, 0.2, 0.2, 0.2},
|
||||
|
||||
speed = 17,
|
||||
lifetime = 1.5,
|
||||
|
||||
explosion_range = 4,
|
||||
explosion_damage = 16,
|
||||
explosion_texture = "bl_rocket_particle.png",
|
||||
|
||||
explode_on_contact = true,
|
||||
gravity = true,
|
||||
|
||||
on_destroy = block_league.grenade_explode,
|
||||
on_right_click = function(self)
|
||||
self:_destroy()
|
||||
end
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
@ -1,21 +1,32 @@
|
||||
|
||||
block_league.register_weapon("block_league:pixelgun", {
|
||||
|
||||
--Definizione apparenza
|
||||
description = S("pixelgun"),
|
||||
mesh = "bl_pixelgun.obj",
|
||||
tiles = {"bl_pixelgun.png"},
|
||||
wield_scale = {x=1.3, y=1.3, z=1.3},
|
||||
inventory_image = "bl_pixelgun_icon.png",
|
||||
|
||||
type = 1,
|
||||
|
||||
damage = 999,
|
||||
knockback = 0,
|
||||
weap_delay = 0.9,
|
||||
|
||||
pierce = true,
|
||||
decrease_damage_with_distance = false,
|
||||
slow_down_when_firing = true,
|
||||
continuos_fire = false,
|
||||
|
||||
weap_sound_shooting = "bl_pixelgun_shoot",
|
||||
bullet_trail = {
|
||||
image = "bl_pixelgun_trail.png",
|
||||
amount = 20,
|
||||
},
|
||||
|
||||
consume_bullets = false,
|
||||
magazine = 4,
|
||||
reload_time = 4,
|
||||
type = 1,
|
||||
weap_delay = 0.9,
|
||||
slow_down_when_firing = true,
|
||||
continuos_fire = false,
|
||||
bullet = "block_league:pixelgun_bullet",
|
||||
|
||||
range = 100, --Se non hitscan calcolarsi il tempo necessario per percorrere quello
|
||||
--spazio in base alla velocità
|
||||
|
@ -1,25 +0,0 @@
|
||||
block_league.register_bullet("block_league:pixelgun_bullet", {
|
||||
description = "proiettile pixelgun",
|
||||
mesh = "bl_grenade.obj",
|
||||
tiles = {"bl_grenade.png"},
|
||||
wield_scale = {x=1.5, y=1.5, z=1.5},
|
||||
inventory_image = "bl_grenade_icon.png",
|
||||
stack_max = 99,
|
||||
throwable_by_hand = false,
|
||||
pierce = true,
|
||||
knockback = 0,
|
||||
decrease_damage_with_distance = false,
|
||||
bullet_damage = 777,
|
||||
shootable = false,
|
||||
bullet_trail = {
|
||||
image = "bl_pixelgun_trail.png",
|
||||
life = 1,
|
||||
size = 2,
|
||||
glow = 0,
|
||||
interval = 5,
|
||||
amount = 20,
|
||||
},
|
||||
|
||||
|
||||
|
||||
})
|
@ -1,43 +0,0 @@
|
||||
block_league.register_bullet("block_league:rocket",{
|
||||
description = "rocket",
|
||||
mesh = "bl_rocket.obj",
|
||||
wield_scale = {x=1, y=1, z=1},
|
||||
tiles = {"bl_bullet_rocket.png"},
|
||||
stack_max = 99,
|
||||
-- {xmin, ymin, zmin, xmax, ymax, zmax}
|
||||
bullet_damage = 10,
|
||||
throwable_by_hand = false,
|
||||
duration = 5,
|
||||
pierce = false,
|
||||
decrease_damage_with_distance = false,
|
||||
bullet_trail = {
|
||||
image = "bl_bullet_rocket.png",
|
||||
life = 1,
|
||||
size = 2,
|
||||
glow = 0,
|
||||
interval = 5,
|
||||
amount = 20,
|
||||
},
|
||||
knockback = 0,
|
||||
shootable = true,
|
||||
|
||||
bullet = {
|
||||
|
||||
mesh = "bl_rocket.obj",
|
||||
visual_size = {x=1, y=1, z=1},
|
||||
textures = {"bl_bullet_rocket.png"},
|
||||
|
||||
bullet_explosion_texture = "bl_rocket_particle.png",
|
||||
bullet_speed = 30,
|
||||
collisionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
|
||||
bullet_explosion_range = 4,
|
||||
bullet_explosion_damage = 10,
|
||||
on_destroy = block_league.explode,
|
||||
on_right_click = function(self)
|
||||
self:_destroy()
|
||||
end,
|
||||
explode_on_contact = true,
|
||||
gravity = false,
|
||||
}
|
||||
|
||||
})
|
@ -1,18 +1,58 @@
|
||||
|
||||
block_league.register_weapon("block_league:rocket_launcher", {
|
||||
|
||||
description = S("Rocket Launcher"),
|
||||
mesh = "bl_rocketlauncher.obj",
|
||||
tiles = {"bl_rocketlauncher.png"},
|
||||
wield_scale = {x=1.3, y=1.3, z=1.3},
|
||||
inventory_image = "bl_rocketlauncher_icon.png",
|
||||
|
||||
weap_delay = 0.8,
|
||||
weap_sound_shooting = "bl_rocketlauncher_shoot",
|
||||
type = 2,
|
||||
continuos_fire = true,
|
||||
|
||||
damage = 10,
|
||||
knocback = 0,
|
||||
weap_delay = 0.8,
|
||||
|
||||
pierce = false,
|
||||
decrease_damage_with_distance = false,
|
||||
slow_down_when_firing = false,
|
||||
continuos_fire = true,
|
||||
|
||||
weap_sound_shooting = "bl_rocketlauncher_shoot",
|
||||
bullet_trail = {
|
||||
image = "bl_bullet_rocket.png",
|
||||
life = 1,
|
||||
size = 2,
|
||||
glow = 0,
|
||||
interval = 5,
|
||||
amount = 20,
|
||||
},
|
||||
|
||||
consume_bullets = false,
|
||||
launching_force = 10,
|
||||
bullet = "block_league:rocket",
|
||||
|
||||
|
||||
bullet = {
|
||||
name = "rocket",
|
||||
|
||||
mesh = "bl_rocket.obj",
|
||||
visual_size = {x=1, y=1, z=1},
|
||||
textures = {"bl_bullet_rocket.png"},
|
||||
collisionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
|
||||
|
||||
speed = 30,
|
||||
lifetime = 5,
|
||||
|
||||
explosion_range = 4,
|
||||
explosion_damage = 10,
|
||||
explosion_texture = "bl_rocket_particle.png",
|
||||
|
||||
explode_on_contact = true,
|
||||
gravity = false,
|
||||
|
||||
on_destroy = block_league.explode,
|
||||
on_right_click = function(self)
|
||||
self:_destroy()
|
||||
end
|
||||
},
|
||||
|
||||
})
|
||||
|
@ -32,12 +32,11 @@ block_league.register_weapon("block_league:nomearma", {
|
||||
consume_bullets = true, --Se usa proiettili
|
||||
magazine = 0, --Dopo quanti colpi ricaricare
|
||||
reload_time = 5,
|
||||
launching_force = 10,
|
||||
bullet = "block_league:nomeproiettile", --Che proiettile/granata spara
|
||||
on_right_click = function(arena, name, def, itemstack, user, pointed_thing) end, --Cosa fare quando si clicca destro
|
||||
|
||||
type = 3, --1) Hitscan 2) Entity based 3) Sword
|
||||
weap_damage = 10, --Danno inflitto
|
||||
damage = 10, --Danno inflitto
|
||||
knockback = 0, --Il contraccolpo da applicare al bersaglio
|
||||
on_right_click = function(arena, name, def, itemstack, user, pointed_thing) end, --Cosa fare quando si clicca destro
|
||||
|
||||
@ -56,17 +55,12 @@ block_league.register_bullet("block_league:nomeproiettile", {
|
||||
--Se si vuole il proiettile 2D
|
||||
wield_image = "wield_image.png", --Immagine da mostrare in mano
|
||||
|
||||
stack_max = 99, --Numero massimo di proiettili possedibili
|
||||
|
||||
throwable_by_hand = true, --Se si può lanciare a mano
|
||||
consume_on_throw = true,
|
||||
|
||||
pierce = true, --Se può attraversare il bersaglio NB: Utilizzabile solo con proiettili hitscan
|
||||
knockback = 0, --Il contraccolpo da applicare al bersaglio
|
||||
decrease_damage_with_distance = true, --Se il danno diminuisce con la distanza
|
||||
bullet_damage = 10, --Danno inflitto
|
||||
bullet_trail = {
|
||||
image = "weap_trail.png",
|
||||
image = "bullet_trail.png",
|
||||
life = 1,
|
||||
size = 2,
|
||||
glow = 0,
|
||||
@ -74,7 +68,7 @@ block_league.register_bullet("block_league:nomeproiettile", {
|
||||
amount = 20,
|
||||
},
|
||||
|
||||
duration = 10, --Tempo di vita dell'entità (da spostare dentro bullet)
|
||||
lifetime = 10, --Tempo di vita dell'entità (da spostare dentro bullet)
|
||||
|
||||
bullet = {
|
||||
|
||||
@ -90,11 +84,11 @@ block_league.register_bullet("block_league:nomeproiettile", {
|
||||
|
||||
explode_on_contact = true, --Se rimbalza quando si scontra con qualcosa
|
||||
|
||||
bullet_explosion_damage = 10, --Danno inflitto con l'esplosione
|
||||
bullet_explosion_range = 4, --Raggio dell'esplosione
|
||||
bullet_explosion_texture = "explosion_texture.png",
|
||||
explosion_damage = 10, --Danno inflitto con l'esplosione
|
||||
explosion_range = 4, --Raggio dell'esplosione
|
||||
explosion_texture = "explosion_texture.png",
|
||||
|
||||
bullet_speed = 30, --Velocità a cui lanciare/sparare il proiettile
|
||||
speed = 30, --Velocità a cui lanciare/sparare il proiettile
|
||||
|
||||
gravity = true, --Se la gravità ha effetto sul proiettile
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
block_league.register_weapon("block_league:smg", {
|
||||
|
||||
description = S("Sub Machine Gun"),
|
||||
@ -6,17 +5,27 @@ block_league.register_weapon("block_league:smg", {
|
||||
wield_scale = {x=1, y=1, z=1},
|
||||
inventory_image = "bl_smg.png",
|
||||
|
||||
weap_sound_shooting = "bl_smg_shoot",
|
||||
type = 1,
|
||||
|
||||
damage = 3, -- stava in bullet
|
||||
knockback = 0, -- stava in bullet
|
||||
weap_delay = 0.1,
|
||||
|
||||
pierce = false, -- stava in bullet
|
||||
decrease_damage_with_distance = true, -- stava in bullet
|
||||
slow_down_when_firing = true,
|
||||
continuos_fire = true,
|
||||
bullet = "block_league:smg_bullet",
|
||||
|
||||
weap_sound_shooting = "bl_smg_shoot",
|
||||
bullet_trail = { -- stava in bullet
|
||||
image = "bl_smg_trail.png",
|
||||
amount = 5
|
||||
},
|
||||
|
||||
consume_bullets = false,
|
||||
magazine = 30,
|
||||
reload_time = 2,
|
||||
|
||||
range = 30, --Se non hitscan calcolarsi il tempo necessario per percorrere quello
|
||||
--spazio in base alla velocità
|
||||
range = 30, -- Se non hitscan calcolarsi il tempo necessario per percorrere
|
||||
-- quello spazio in base alla velocità
|
||||
})
|
||||
|
@ -1,22 +0,0 @@
|
||||
block_league.register_bullet("block_league:smg_bullet", {
|
||||
description = S("Proiettile SMG"),
|
||||
wield_image = "bl_smg.png",
|
||||
wield_scale = {x=1, y=1, z=1},
|
||||
inventory_image = "bl_smg.png",
|
||||
|
||||
stack_max = 99,
|
||||
throwable_by_hand = false,
|
||||
pierce = false,
|
||||
knockback = 0,
|
||||
decrease_damage_with_distance = true,
|
||||
bullet_damage = 3,
|
||||
shootable = false,
|
||||
bullet_trail = {
|
||||
image = "bl_smg_trail.png",
|
||||
life = 1,
|
||||
size = 2,
|
||||
glow = 0,
|
||||
interval = 5,
|
||||
amount = 5,
|
||||
}
|
||||
})
|
@ -1,18 +1,18 @@
|
||||
block_league.register_weapon("block_league:sword", {
|
||||
|
||||
description = "Spada",
|
||||
inventory_image = "bl_sword.png",
|
||||
wield_scale = {x=1.3, y=1.3, z=1.3},
|
||||
wield_image = "bl_sword.png",
|
||||
wield_scale = {x=1.3, y=1.3, z=1.3},
|
||||
inventory_image = "bl_sword.png",
|
||||
|
||||
type = 3,
|
||||
|
||||
damage = 7,
|
||||
knockback = 40,
|
||||
weap_delay = 2,
|
||||
weap_secondary_delay = 3,
|
||||
|
||||
type = 3,
|
||||
weap_damage = 7,
|
||||
knockback = 40,
|
||||
|
||||
on_right_click = function(arena, name, def, itemstack, user, pointed_thing)
|
||||
on_right_click = function(arena, name, weapon, user, pointed_thing)
|
||||
|
||||
local dir = user:get_look_dir()
|
||||
local pos = user:get_pos()
|
||||
@ -42,7 +42,7 @@ block_league.register_weapon("block_league:sword", {
|
||||
end)
|
||||
|
||||
if not pointed_players then return end
|
||||
block_league.apply_damage(user, pointed_players, def.weap_damage, def.knockback, false)
|
||||
block_league.apply_damage(user, pointed_players, weapon.damage, weapon.knockback, false)
|
||||
|
||||
end,
|
||||
})
|
||||
|
@ -1,136 +1,67 @@
|
||||
local function get_dist() end
|
||||
local function draw_particles() end
|
||||
local function weapon_reload() end
|
||||
local function weapon_left_click() end
|
||||
local function weapon_right_click() end
|
||||
local function weapon_reload() end
|
||||
local function gestione_sparo() end
|
||||
local function shoot_generic() end
|
||||
local function after_damage() end
|
||||
local function kill() end
|
||||
|
||||
function block_league.register_weapon(name, def)
|
||||
minetest.register_node(name, {
|
||||
name = name,
|
||||
description = def.description,
|
||||
inventory_image = def.inventory_image,
|
||||
wield_scale = def.wield_scale,
|
||||
|
||||
-- usato per avere una dichiarazione pulita E al tempo stesso non dover
|
||||
-- passare anche il nome in on_use (che lo richiede)
|
||||
def.name = name
|
||||
|
||||
minetest.register_node(name, {
|
||||
name = def.name,
|
||||
|
||||
description = def.description,
|
||||
drawtype = def.mesh and "mesh" or "item",
|
||||
mesh = def.mesh or nil,
|
||||
tiles = def.tiles or nil,
|
||||
wield_image = def.wield_image or nil,
|
||||
wield_scale = def.wield_scale,
|
||||
inventory_image = def.inventory_image,
|
||||
|
||||
weap_sound_shooting = def.weap_sound_shooting or nil,
|
||||
weap_trail = def.weap_trail or nil,
|
||||
weap_damage = def.weap_damage or nil,
|
||||
consume_bullets = def.consume_bullets or nil,
|
||||
bullet = def.bullet or nil,
|
||||
magazine = def.magazine or nil,
|
||||
type = def.type,
|
||||
|
||||
damage = def.damage,
|
||||
knockback = def.knockback,
|
||||
weap_delay = def.weap_delay,
|
||||
|
||||
pierce = def.pierce,
|
||||
decrease_damage_with_distance = def.decrease_damage_with_distance,
|
||||
slow_down_when_firing = def.slow_down_when_firing,
|
||||
continuos_fire = def.continuos_fire,
|
||||
|
||||
weap_sound_shooting = def.weap_sound_shooting,
|
||||
bullet_trail = def.bullet_trail,
|
||||
|
||||
consume_bullets = def.consume_bullets,
|
||||
magazine = def.magazine,
|
||||
reload_time = def.reload_time,
|
||||
|
||||
bullet = def.bullet and block_league.register_bullet(def.bullet, def.damage, def.bullet_trail) or nil,
|
||||
|
||||
-- LMB = first fire
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
|
||||
local p_name = user:get_player_name()
|
||||
|
||||
if not gestione_sparo(p_name, user, def, name) then return end
|
||||
|
||||
if def.weap_sound_shooting then
|
||||
-- riproduzione suono
|
||||
minetest.sound_play(def.weap_sound_shooting, {
|
||||
to_player = p_name,
|
||||
max_hear_distance = 5,
|
||||
})
|
||||
end
|
||||
if def.slow_down_when_firing then
|
||||
user:set_physics_override({
|
||||
speed = block_league.SPEED_LOW,
|
||||
jump = 1.5,
|
||||
gravity = 1.15,
|
||||
sneak_glitch = true,
|
||||
new_move = true
|
||||
})
|
||||
end
|
||||
|
||||
shoot_generic(def, p_name, itemstack, user, pointed_thing)
|
||||
|
||||
if def.continuos_fire then
|
||||
controls.register_on_hold(function(player, key, time)
|
||||
if key~="LMB" then return end
|
||||
|
||||
if player:get_wielded_item():get_name() == name then
|
||||
|
||||
local p_name = player:get_player_name()
|
||||
|
||||
if not gestione_sparo(p_name, player, def, name) then return end
|
||||
|
||||
if def.weap_sound_shooting then
|
||||
-- riproduzione suono
|
||||
minetest.sound_play(def.weap_sound_shooting, {
|
||||
to_player = p_name,
|
||||
max_hear_distance = 5,
|
||||
})
|
||||
end
|
||||
|
||||
shoot_generic(def, p_name, itemstack, player, pointed_thing)
|
||||
|
||||
elseif def.slow_down_when_firing and player:get_meta():get_int("bl_has_ball") == 0 and arena_lib.is_player_in_arena(p_name) then
|
||||
if player then
|
||||
player:set_physics_override({
|
||||
speed = block_league.SPEED,
|
||||
jump = 1.5,
|
||||
gravity = 1.15,
|
||||
sneak_glitch = true,
|
||||
new_move = true
|
||||
})
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
controls.register_on_release(function(player, key, time)
|
||||
if key~="LMB" then return end
|
||||
local wielditem = player:get_wielded_item()
|
||||
if wielditem:get_name()==name then
|
||||
|
||||
if def.slow_down_when_firing and player:get_meta():get_int("bl_has_ball") == 0 then
|
||||
minetest.after(0.1, function()
|
||||
if player then
|
||||
player:set_physics_override({
|
||||
speed = block_league.SPEED,
|
||||
jump = 1.5,
|
||||
gravity = 1.15,
|
||||
sneak_glitch = true,
|
||||
new_move = true
|
||||
})
|
||||
end
|
||||
end)
|
||||
end
|
||||
elseif def.slow_down_when_firing and player:get_meta():get_int("bl_has_ball") == 0 and arena_lib.is_player_in_arena(player:get_player_name()) then
|
||||
if player then
|
||||
player:set_physics_override({
|
||||
speed = block_league.SPEED,
|
||||
jump = 1.5,
|
||||
gravity = 1.15,
|
||||
sneak_glitch = true,
|
||||
new_move = true
|
||||
})
|
||||
end
|
||||
end
|
||||
end)
|
||||
weapon_left_click(def, user, pointed_thing)
|
||||
end,
|
||||
|
||||
-- RMB = secondary use
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
weapon_right_click(itemstack, user, pointed_thing)
|
||||
weapon_right_click(def, user, pointed_thing)
|
||||
end,
|
||||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
weapon_right_click(itemstack, user, pointed_thing)
|
||||
weapon_right_click(def, user, pointed_thing)
|
||||
end,
|
||||
|
||||
-- Q = reload
|
||||
on_drop = function(itemstack, user, pointed_thing)
|
||||
weapon_reload(user, def, name)
|
||||
weapon_reload(def, user, name)
|
||||
end
|
||||
|
||||
})
|
||||
@ -139,37 +70,29 @@ end
|
||||
|
||||
|
||||
|
||||
function block_league.shoot_hitscan(name, def, bullet_definition, itemstack, user, pointed_thing)
|
||||
function block_league.shoot_hitscan(user, weapon, itemstack, pointed_thing)
|
||||
local dir = user:get_look_dir()
|
||||
local pos = user:get_pos()
|
||||
local pos_head = {x = pos.x, y = pos.y+1.475, z = pos.z}
|
||||
local pointed_players = block_league.get_pointed_players(pos_head, dir, def.range, user, bullet_definition.bullet_trail, bullet_definition.pierce)
|
||||
local pointed_players = block_league.get_pointed_players(pos_head, dir, weapon.range, user, weapon.bullet_trail, weapon.pierce)
|
||||
|
||||
if pointed_players then
|
||||
block_league.apply_damage(user, pointed_players, bullet_definition.bullet_damage, bullet_definition.knockback, bullet_definition.decrease_damage_with_distance)
|
||||
block_league.apply_damage(user, pointed_players, weapon.damage, weapon.knockback, weapon.decrease_damage_with_distance)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function block_league.shoot_bullet(name, def, def2, itemstack, user, pointed_thing)
|
||||
local yaw = user:get_look_horizontal()
|
||||
local pitch = user:get_look_vertical()
|
||||
local dir = user:get_look_dir()
|
||||
function block_league.shoot_bullet(user, bullet, itemstack, pointed_thing)
|
||||
|
||||
local pos = user:get_pos()
|
||||
local pos_head = {x = pos.x, y = pos.y + user:get_properties().eye_height, z = pos.z}
|
||||
local username = user:get_player_name()
|
||||
local bullet_name = nil
|
||||
local speed = nil
|
||||
local bullet_name = bullet.name .. '_entity'
|
||||
|
||||
if def2 then
|
||||
bullet_name = (def2.name and def2.name or name) .. '_entity'
|
||||
speed = def2.bullet.bullet_speed + def.launching_force
|
||||
else
|
||||
bullet_name = (def.name and def.name or name) .. '_entity'
|
||||
speed = def.bullet.bullet_speed
|
||||
end
|
||||
local bullet = minetest.add_entity(pos_head, bullet_name, user:get_player_name())
|
||||
|
||||
local bullet = minetest.add_entity(pos_head, bullet_name, username)
|
||||
local speed = bullet.speed
|
||||
local dir = user:get_look_dir()
|
||||
|
||||
bullet:set_velocity({
|
||||
x=(dir.x * speed),
|
||||
@ -177,7 +100,10 @@ function block_league.shoot_bullet(name, def, def2, itemstack, user, pointed_thi
|
||||
z=(dir.z * speed),
|
||||
})
|
||||
|
||||
local yaw = user:get_look_horizontal()
|
||||
local pitch = user:get_look_vertical()
|
||||
local rotation = ({x = -pitch, y = yaw, z = 0})
|
||||
|
||||
bullet:set_rotation(rotation)
|
||||
end
|
||||
|
||||
@ -362,34 +288,84 @@ end
|
||||
|
||||
|
||||
|
||||
function weapon_reload(user, def, name)
|
||||
function weapon_left_click(weapon, player, pointed_thing)
|
||||
|
||||
local p_name = user:get_player_name()
|
||||
local p_meta = user:get_meta()
|
||||
local arena = arena_lib.get_arena_by_player(p_name)
|
||||
if not gestione_sparo(player, weapon) then return end
|
||||
|
||||
if not arena or not arena.in_game or user:get_hp() <= 0
|
||||
or arena.weapons_disabled or def.type == 3 or not def.magazine
|
||||
or def.magazine == 0 or p_meta:get_int("bl_reloading") == 1
|
||||
then return end
|
||||
local p_name = player:get_player_name()
|
||||
|
||||
p_meta:set_int("bl_reloading", 1)
|
||||
if weapon.weap_sound_shooting then
|
||||
minetest.sound_play(weapon.weap_sound_shooting, {to_player = p_name})
|
||||
end
|
||||
|
||||
minetest.after(def.reload_time, function()
|
||||
if not arena_lib.is_player_in_arena(p_name, "block_league") then return end
|
||||
p_meta:set_int("bl_weap_delay", 0)
|
||||
p_meta:set_int("bl_reloading", 0)
|
||||
if weapon.slow_down_when_firing then
|
||||
player:set_physics_override({
|
||||
speed = block_league.SPEED_LOW,
|
||||
jump = 1.5
|
||||
})
|
||||
end
|
||||
|
||||
arena.players[p_name].weapons_magazine[name] = def.magazine
|
||||
block_league.weapons_hud_update(arena, p_name, name, arena.players[p_name].weapons_magazine[name])
|
||||
shoot_generic(weapon, p_name, itemstack, player, pointed_thing)
|
||||
|
||||
if weapon.continuos_fire then
|
||||
controls.register_on_hold(function(player, key, time)
|
||||
if key~="LMB" then return end
|
||||
|
||||
if player:get_wielded_item():get_name() == weapon.name then
|
||||
|
||||
local p_name = player:get_player_name()
|
||||
|
||||
if not gestione_sparo(player, weapon) then return end
|
||||
|
||||
if weapon.weap_sound_shooting then
|
||||
minetest.sound_play(weapon.weap_sound_shooting, {to_player = p_name})
|
||||
end
|
||||
|
||||
shoot_generic(weapon, p_name, itemstack, player, pointed_thing)
|
||||
|
||||
elseif weapon.slow_down_when_firing and player:get_meta():get_int("bl_has_ball") == 0 and arena_lib.is_player_in_arena(p_name) then
|
||||
if player then
|
||||
player:set_physics_override({
|
||||
speed = block_league.SPEED,
|
||||
jump = 1.5
|
||||
})
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
controls.register_on_release(function(player, key, time)
|
||||
if key~="LMB" then return end
|
||||
local wielditem = player:get_wielded_item()
|
||||
if wielditem:get_name() == weapon.name then
|
||||
|
||||
if weapon.slow_down_when_firing and player:get_meta():get_int("bl_has_ball") == 0 then
|
||||
minetest.after(0.1, function()
|
||||
if player then
|
||||
player:set_physics_override({
|
||||
speed = block_league.SPEED,
|
||||
jump = 1.5
|
||||
})
|
||||
end
|
||||
end)
|
||||
end
|
||||
elseif weapon.slow_down_when_firing and player:get_meta():get_int("bl_has_ball") == 0 and arena_lib.is_player_in_arena(player:get_player_name()) then
|
||||
if player then
|
||||
player:set_physics_override({
|
||||
speed = block_league.SPEED,
|
||||
jump = 1.5
|
||||
})
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function weapon_right_click(itemstack, player, pointed_thing)
|
||||
if not def.on_right_click then return end
|
||||
function weapon_right_click(weapon, player, pointed_thing)
|
||||
|
||||
if not weapon.on_right_click then return end
|
||||
|
||||
local p_name = player:get_player_name()
|
||||
local arena = arena_lib.get_arena_by_player(p_name)
|
||||
@ -404,7 +380,7 @@ local function weapon_right_click(itemstack, player, pointed_thing)
|
||||
|
||||
p_meta:set_int("bl_weap_secondary_delay", 1)
|
||||
|
||||
minetest.after(def.weap_secondary_delay, function()
|
||||
minetest.after(weapon.weap_secondary_delay, function()
|
||||
if not arena_lib.is_player_in_arena(p_name, "block_league") then return end
|
||||
p_meta:set_int("bl_weap_secondary_delay", 0)
|
||||
end)
|
||||
@ -415,19 +391,48 @@ local function weapon_right_click(itemstack, player, pointed_thing)
|
||||
player:set_armor_groups({immortal = nil})
|
||||
end
|
||||
|
||||
if def.on_right_click then
|
||||
def.on_right_click(arena, name, def, itemstack, player, pointed_thing)
|
||||
if weapon.on_right_click then
|
||||
weapon.on_right_click(arena, name, weapon, player, pointed_thing)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function gestione_sparo(p_name, user, def, name)
|
||||
function weapon_reload(weapon, player, name)
|
||||
|
||||
local p_name = player:get_player_name()
|
||||
local p_meta = player:get_meta()
|
||||
local arena = arena_lib.get_arena_by_player(p_name)
|
||||
|
||||
if not arena or not arena.in_game or player:get_hp() <= 0
|
||||
or arena.weapons_disabled or weapon.type == 3 or not weapon.magazine
|
||||
or weapon.magazine == 0 or p_meta:get_int("bl_reloading") == 1
|
||||
then return end
|
||||
|
||||
p_meta:set_int("bl_reloading", 1)
|
||||
|
||||
minetest.after(weapon.reload_time, function()
|
||||
if not arena_lib.is_player_in_arena(p_name, "block_league") then return end
|
||||
p_meta:set_int("bl_weap_delay", 0)
|
||||
p_meta:set_int("bl_reloading", 0)
|
||||
|
||||
arena.players[p_name].weapons_magazine[name] = weapon.magazine
|
||||
block_league.weapons_hud_update(arena, p_name, name, arena.players[p_name].weapons_magazine[name])
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
function gestione_sparo(player, weapon)
|
||||
|
||||
local p_name = player:get_player_name()
|
||||
|
||||
if not arena_lib.is_player_in_arena(p_name) then return end
|
||||
|
||||
local p_meta = player:get_meta()
|
||||
local arena = arena_lib.get_arena_by_player(p_name)
|
||||
local p_meta = user:get_meta()
|
||||
local w_name = weapon.name
|
||||
|
||||
----- gestione delay dell'arma -----
|
||||
if p_meta:get_int("bl_weap_delay") == 1 or
|
||||
@ -436,79 +441,80 @@ function gestione_sparo(p_name, user, def, name)
|
||||
return false end
|
||||
|
||||
p_meta:set_int("bl_weap_delay", 1)
|
||||
if def.magazine then
|
||||
if not arena.players[p_name].weapons_magazine[name] then
|
||||
arena.players[p_name].weapons_magazine[name] = 0
|
||||
|
||||
if weapon.magazine then
|
||||
if not arena.players[p_name].weapons_magazine[w_name] then
|
||||
arena.players[p_name].weapons_magazine[w_name] = 0
|
||||
end
|
||||
end
|
||||
|
||||
minetest.after(def.weap_delay, function()
|
||||
minetest.after(weapon.weap_delay, function()
|
||||
if not arena_lib.is_player_in_arena(p_name, "block_league") then return end
|
||||
if def.magazine and user:get_meta():get_int("bl_reloading") == 0 then
|
||||
user:get_meta():set_int("bl_weap_delay", 0)
|
||||
elseif not def.magazine then
|
||||
user:get_meta():set_int("bl_weap_delay", 0)
|
||||
if weapon.magazine and p_meta:get_int("bl_reloading") == 0 then
|
||||
p_meta:set_int("bl_weap_delay", 0)
|
||||
elseif not weapon.magazine then
|
||||
p_meta:set_int("bl_weap_delay", 0)
|
||||
end
|
||||
end)
|
||||
----- fine gestione delay -----
|
||||
|
||||
-- se sono immune e sparo, perdo l'immunità
|
||||
if user:get_armor_groups().immortal and user:get_armor_groups().immortal == 1 then
|
||||
user:set_armor_groups({immortal = nil})
|
||||
if player:get_armor_groups().immortal and player:get_armor_groups().immortal == 1 then
|
||||
player:set_armor_groups({immortal = nil})
|
||||
end
|
||||
|
||||
if user:get_hp() <= 0 or arena.weapons_disabled then return end
|
||||
if player:get_hp() <= 0 or arena.weapons_disabled then return end
|
||||
|
||||
--[[ Per quando si avranno caricatori limitati
|
||||
if def.consume_bullets then
|
||||
if inv:contains_item("main", def.bullet) then
|
||||
inv:remove_item("main", def.bullet)
|
||||
block_league.weapons_hud_update(arena, p_name, name)
|
||||
if weapon.consume_bullets then
|
||||
if inv:contains_item("main", weapon.bullet) then
|
||||
inv:remove_item("main", weapon.bullet)
|
||||
block_league.weapons_hud_update(arena, p_name, w_name)
|
||||
else
|
||||
return false
|
||||
end
|
||||
end]]
|
||||
|
||||
-- controllo caricamento
|
||||
if def.magazine and def.magazine > 0 then
|
||||
arena.players[p_name].weapons_magazine[name] = arena.players[p_name].weapons_magazine[name] - 1
|
||||
if arena.players[p_name].weapons_magazine[name] == 0 and user:get_meta():get_int("bl_reloading") == 0 then
|
||||
if weapon.magazine and weapon.magazine > 0 then
|
||||
arena.players[p_name].weapons_magazine[w_name] = arena.players[p_name].weapons_magazine[w_name] - 1
|
||||
if arena.players[p_name].weapons_magazine[w_name] == 0 and p_meta:get_int("bl_reloading") == 0 then
|
||||
p_meta:set_int("bl_reloading", 1)
|
||||
|
||||
minetest.after(def.reload_time, function()
|
||||
if user and user:get_meta() then
|
||||
minetest.after(weapon.reload_time, function()
|
||||
if player then
|
||||
p_meta:set_int("bl_weap_delay", 0)
|
||||
p_meta:set_int("bl_reloading", 0)
|
||||
arena.players[p_name].weapons_magazine[name] = def.magazine
|
||||
block_league.weapons_hud_update(arena, p_name, name, arena.players[p_name].weapons_magazine[name])
|
||||
arena.players[p_name].weapons_magazine[w_name] = weapon.magazine
|
||||
block_league.weapons_hud_update(arena, p_name, w_name, arena.players[p_name].weapons_magazine[w_name])
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
if def.type and def.type ~= 3 then
|
||||
block_league.weapons_hud_update(arena, p_name, name, arena.players[p_name].weapons_magazine[name])
|
||||
if weapon.type and weapon.type ~= 3 then
|
||||
block_league.weapons_hud_update(arena, p_name, w_name, arena.players[p_name].weapons_magazine[w_name])
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
function shoot_generic(def, name, itemstack, user, pointed_thing)
|
||||
function shoot_generic(weapon, p_name, itemstack, user, pointed_thing)
|
||||
|
||||
if def.type ~= 3 then
|
||||
local bullet_def = def.bullet and minetest.registered_nodes[def.bullet] or nil
|
||||
if weapon.type ~= 3 then
|
||||
local bullet = weapon.bullet or nil
|
||||
|
||||
if def.type == 1 then
|
||||
block_league.shoot_hitscan(name, def, bullet_def, itemstack, user, pointed_thing)
|
||||
elseif def.type == 2 then
|
||||
block_league.shoot_bullet(name, def, bullet_def, itemstack, user, pointed_thing)
|
||||
if weapon.type == 1 then
|
||||
block_league.shoot_hitscan(user, weapon, itemstack, pointed_thing)
|
||||
elseif weapon.type == 2 then
|
||||
block_league.shoot_bullet(user, bullet, itemstack, pointed_thing)
|
||||
end
|
||||
|
||||
else
|
||||
if pointed_thing.type ~= "object" or not pointed_thing.ref:is_player() then return end
|
||||
|
||||
block_league.apply_damage(user, pointed_thing.ref, def.weap_damage, def.knockback, false, user:get_look_dir())
|
||||
block_league.apply_damage(user, pointed_thing.ref, weapon.damage, weapon.knockback, false, user:get_look_dir())
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
block_league.explode = function(self)
|
||||
local explosion_range = self.initial_properties.bullet_explosion_range
|
||||
local explosion_damage = self.initial_properties.bullet_explosion_damage
|
||||
local explosion_range = self.initial_properties.explosion_range
|
||||
local explosion_damage = self.initial_properties.explosion_damage
|
||||
local origin = self.object:get_pos()
|
||||
local p_name = self.p_name
|
||||
if origin == nil then return end
|
||||
@ -59,8 +59,8 @@ end
|
||||
|
||||
|
||||
block_league.grenade_explode = function(self)
|
||||
local explosion_range = self.initial_properties.bullet_explosion_range
|
||||
local explosion_damage = self.initial_properties.bullet_explosion_damage
|
||||
local explosion_range = self.initial_properties.explosion_range
|
||||
local explosion_damage = self.initial_properties.explosion_damage
|
||||
local origin = self.object:get_pos()
|
||||
local p_name = self.p_name
|
||||
if origin == nil then return end
|
||||
|
@ -169,7 +169,7 @@ ChatCmdBuilder.new("bleagueadmin", function(cmd)
|
||||
|
||||
end, {
|
||||
description = S("mod management"),
|
||||
privs = { block_league_admin = true }
|
||||
privs = { blockleague_admin = true }
|
||||
})
|
||||
|
||||
|
||||
|
4
init.lua
4
init.lua
@ -81,15 +81,11 @@ dofile(modpath .. "/bl_weapons/weapons.lua")
|
||||
dofile(modpath .. "/bl_weapons/weapons_utils.lua")
|
||||
-- weapons
|
||||
dofile(modpath .. "/bl_weapons/bouncer.lua")
|
||||
dofile(modpath .. "/bl_weapons/grenade.lua")
|
||||
dofile(modpath .. "/bl_weapons/grenade_launcher.lua")
|
||||
dofile(modpath .. "/bl_weapons/pixelgun.lua")
|
||||
dofile(modpath .. "/bl_weapons/pixelgun_bullet.lua")
|
||||
dofile(modpath .. "/bl_weapons/rocket.lua")
|
||||
dofile(modpath .. "/bl_weapons/rocket_launcher.lua")
|
||||
dofile(modpath .. "/bl_weapons/sword.lua")
|
||||
dofile(modpath .. "/bl_weapons/smg.lua")
|
||||
dofile(modpath .. "/bl_weapons/smg_bullet.lua")
|
||||
-- modes
|
||||
dofile(modpath .. "/bl_modes/game_main.lua")
|
||||
dofile(modpath .. "/bl_modes/TD/ball.lua")
|
||||
|
@ -30,16 +30,9 @@ end)
|
||||
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
|
||||
local p_name = player:get_player_name()
|
||||
if not arena_lib.is_player_in_arena(player:get_player_name(), "block_league") then return end
|
||||
|
||||
if not arena_lib.is_player_in_arena(p_name, "block_league") then return end
|
||||
|
||||
local arena = arena_lib.get_arena_by_player(p_name)
|
||||
|
||||
arena.players[p_name].energy = 100
|
||||
block_league.energy_update(arena, p_name)
|
||||
player:get_meta():set_int("bl_death_delay", 1)
|
||||
arena.players[p_name].weapons_magazine = {}
|
||||
|
||||
minetest.after(6, function()
|
||||
if not player or not player:get_meta() then return end
|
||||
@ -56,13 +49,20 @@ minetest.register_on_respawnplayer(function(player)
|
||||
if not arena_lib.is_player_in_arena(player:get_player_name(), "block_league") then return end
|
||||
|
||||
death_delay(player, player:get_pos())
|
||||
|
||||
local p_name = player:get_player_name()
|
||||
local arena = arena_lib.get_arena_by_player(p_name)
|
||||
|
||||
arena.players[p_name].energy = 100
|
||||
block_league.energy_update(arena, p_name)
|
||||
|
||||
block_league.refill_weapons(arena, p_name)
|
||||
block_league.immunity(player)
|
||||
|
||||
player:set_physics_override({
|
||||
speed = block_league.SPEED,
|
||||
jump = 1.5
|
||||
})
|
||||
|
||||
block_league.refill_weapons(arena, p_name)
|
||||
block_league.immunity(player)
|
||||
end)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user