From 829414f7a1e37ce32e1ea666328aabe0a37da7b7 Mon Sep 17 00:00:00 2001 From: Zughy <4279489-marco_a@users.noreply.gitlab.com> Date: Sat, 23 Mar 2024 22:59:42 +0000 Subject: [PATCH] Use weapons_lib --- bl_tutorial/src/entities/ball.lua | 9 +- bl_tutorial/src/entities/sentry_gun.lua | 2 +- bl_tutorial/src/phases.lua | 5 +- block_league/GLOBALS.lua | 6 +- block_league/init.lua | 5 - block_league/mod.conf | 2 +- block_league/src/GUI/gui_profile.lua | 16 +- block_league/src/HUD/hud_weapons.lua | 2 +- block_league/src/_load.lua | 8 + block_league/src/arena_lib/on_celebration.lua | 2 +- block_league/src/arena_lib/on_death.lua | 4 +- block_league/src/arena_lib/on_entering.lua | 5 +- block_league/src/arena_lib/on_leaving.lua | 4 +- block_league/src/game/TD/ball.lua | 6 +- block_league/src/game/game_main.lua | 15 +- block_league/src/game/misc/stamina.lua | 3 +- block_league/src/skills/hp+.lua | 2 +- block_league/src/skills/shield.lua | 2 +- block_league/src/skills/sp+.lua | 2 +- block_league/src/utils.lua | 133 ++- block_league/src/weapons/bullets.lua | 270 ------ ..._launcher.lua => grenade_launcher_old.lua} | 0 block_league/src/weapons/pixelgun.lua | 39 +- block_league/src/weapons/propulsor.lua | 81 +- ...t_launcher.lua => rocket_launcher_old.lua} | 2 +- block_league/src/weapons/smg.lua | 49 +- block_league/src/weapons/sword.lua | 45 +- block_league/src/weapons/weapons.lua | 864 ------------------ block_league/src/weapons/weapons_utils.lua | 428 ++++----- 29 files changed, 489 insertions(+), 1522 deletions(-) delete mode 100644 block_league/src/weapons/bullets.lua rename block_league/src/weapons/{grenade_launcher.lua => grenade_launcher_old.lua} (100%) rename block_league/src/weapons/{rocket_launcher.lua => rocket_launcher_old.lua} (98%) delete mode 100644 block_league/src/weapons/weapons.lua diff --git a/bl_tutorial/src/entities/ball.lua b/bl_tutorial/src/entities/ball.lua index 51db72c..342cd23 100644 --- a/bl_tutorial/src/entities/ball.lua +++ b/bl_tutorial/src/entities/ball.lua @@ -85,11 +85,16 @@ function ball:reset() block_league.HUD_ball_update(p_name, extS("Ball reset")) local wielder = minetest.get_player_by_name(p_name) + local p_meta = wielder:p_meta() local ball_obj = self.object self._p_name = nil - wielder:set_physics_override({speed = block_league.SPEED}) - wielder:get_meta():set_int("bl_has_ball", 0) + + if p_meta:get_int("wl_weapon_state") == 0 then + wielder:set_physics_override({speed = block_league.SPEED}) + end + + p_meta:set_int("bl_has_ball", 0) ball_obj:set_detach() ball_obj:set_properties({textures={"bl_ball_unclaimed.png"}}) ball_obj:set_animation({x=0,y=40}, 20, 0, true) diff --git a/bl_tutorial/src/entities/sentry_gun.lua b/bl_tutorial/src/entities/sentry_gun.lua index e9760cd..30e10f0 100644 --- a/bl_tutorial/src/entities/sentry_gun.lua +++ b/bl_tutorial/src/entities/sentry_gun.lua @@ -145,7 +145,7 @@ function rotate_and_shoot(sentry, dir) sentry:set_bone_position("Rotation", vector.new(0,1,0), new_rot) local sentry_centre = 0.3 - local pointed_object = block_league.get_pointed_objects(sentry, 20, false, {height = sentry_centre, dir = dir}) + local pointed_object = weapons_lib.get_pointed_objects(sentry, 20, false, {height = sentry_centre, dir = dir}) draw_particles(dir, vector.add(sentry:get_pos(), vector.new(0, sentry_centre, 0))) audio_lib.play_sound("bl_smg_shoot", {pitch = 2.3, object = sentry, max_hear_distance = SENTRY_RANGE + 5}) diff --git a/bl_tutorial/src/phases.lua b/bl_tutorial/src/phases.lua index 548439c..3d12f5d 100644 --- a/bl_tutorial/src/phases.lua +++ b/bl_tutorial/src/phases.lua @@ -230,7 +230,6 @@ function phase3(player) inv:set_stack("main", 2, ItemStack("block_league:propulsor")) arena.weapons_disabled = false - arena.players[p_name].weapons_magazine[smg] = minetest.registered_nodes[smg].magazine panel_lib.get_panel(p_name, "bl_weapons"):show() block_league.HUD_weapons_update(arena, p_name, smg) @@ -340,7 +339,7 @@ function bl_tutorial.kill(player) player:set_hp(20) player:set_pos(start_coords) arena.players[p_name].stamina = 99 - arena.players[p_name].weapons_magazine[smg] = minetest.registered_nodes[smg].magazine + weapons_lib.refill(p_name, minetest.registered_nodes[smg]) block_league.HUD_weapons_update(arena, p_name, smg) bl_tutorial.hud_show(player) @@ -536,7 +535,7 @@ end function anchor_player(player) local p_pos = player:get_pos() local p_y = player:get_look_horizontal() - local dummy = minetest.add_entity(p_pos, "block_league:dummy") + local dummy = minetest.add_entity(p_pos, "weapons_lib:dummy") player:set_attach(dummy, "", {x=0,y=-5,z=0}, {x=0, y=-math.deg(p_y), z=0}) end diff --git a/block_league/GLOBALS.lua b/block_league/GLOBALS.lua index c74c73a..3b754f9 100755 --- a/block_league/GLOBALS.lua +++ b/block_league/GLOBALS.lua @@ -1,5 +1,5 @@ block_league.SPEED = 2.5 -block_league.SPEED_LOW = 1.5 +block_league.SHOOT_SPEED_MULTIPLIER = 0.6 block_league.PHYSICS = { speed = block_league.SPEED, @@ -7,6 +7,4 @@ block_league.PHYSICS = { gravity = 1.15, sneak_glitch = true, new_move = true -} - -block_league.MELEE_RANGE = 4 \ No newline at end of file +} \ No newline at end of file diff --git a/block_league/init.lua b/block_league/init.lua index 39fa4c8..fd0d39a 100644 --- a/block_league/init.lua +++ b/block_league/init.lua @@ -77,7 +77,6 @@ arena_lib.register_minigame("block_league", { kills = 0, points = 0, --entering_time = 0, -- inutilizzato, servirà prob in futuro per calcolare exp - weapons_magazine = {}, -- KEY: w_name, VALUE: curr_ammo current_weapon = "", dmg_received = {}, -- KEY: p_name, VALUE: {timestamp, dmg, weapon} dmg_dealt = 0 @@ -143,14 +142,10 @@ dofile(srcpath .. "/player/exp.lua") dofile(srcpath .. "/skills/hp+.lua") dofile(srcpath .. "/skills/sp+.lua") -- abstract weapons -dofile(srcpath .. "/weapons/bullets.lua") -dofile(srcpath .. "/weapons/weapons.lua") dofile(srcpath .. "/weapons/weapons_utils.lua") -- weapons -dofile(srcpath .. "/weapons/grenade_launcher.lua") dofile(srcpath .. "/weapons/pixelgun.lua") dofile(srcpath .. "/weapons/propulsor.lua") -dofile(srcpath .. "/weapons/rocket_launcher.lua") dofile(srcpath .. "/weapons/sword.lua") dofile(srcpath .. "/weapons/smg.lua") diff --git a/block_league/mod.conf b/block_league/mod.conf index c67a3d1..ed1b987 100644 --- a/block_league/mod.conf +++ b/block_league/mod.conf @@ -1,4 +1,4 @@ name = block_league description = Massive hack'n'slash FPS shooter inspired by S4 League. Pew pew! -depends = achievements_lib,arena_lib,controls,panel_lib,skills +depends = achievements_lib,arena_lib,controls,panel_lib,skills,weapons_lib optional_depends = visible_wielditem diff --git a/block_league/src/GUI/gui_profile.lua b/block_league/src/GUI/gui_profile.lua index d7b5242..f3ec7d0 100644 --- a/block_league/src/GUI/gui_profile.lua +++ b/block_league/src/GUI/gui_profile.lua @@ -70,7 +70,7 @@ function get_formspec(p_name) elseif skill then item = "image[2,1.7;1.5,1.5;bl_skill_" .. elem .. ".png]" elem_name = skill.name - body = "hypertext[0.3,4.2;4.48,4.3;elem_desc;\n\n" + _profile_description = S("Increases your health points by 5 @1(20>25)", "\n\n" .. S("Great for remaining in action longer, providing firepower to sustain your team. Get tanky!"), passive = true, on_start = function(self) diff --git a/block_league/src/skills/shield.lua b/block_league/src/skills/shield.lua index 7821892..93e0449 100644 --- a/block_league/src/skills/shield.lua +++ b/block_league/src/skills/shield.lua @@ -9,7 +9,7 @@ local S = minetest.get_translator("block_league") skills.register_skill("block_league:shield", { name = S("Shield"), icon = "bl_skill_shield.png", - profile_description = S("Summons a shield in front of you that assorbs bullets at the cost of stamina") .. "\n\n" + _profile_description = S("Summons a shield in front of you that assorbs bullets at the cost of stamina") .. "\n\n" .. S("Expose yourself without any risk"), attachments = { diff --git a/block_league/src/skills/sp+.lua b/block_league/src/skills/sp+.lua index c19ba85..643b27b 100644 --- a/block_league/src/skills/sp+.lua +++ b/block_league/src/skills/sp+.lua @@ -4,7 +4,7 @@ local S = minetest.get_translator("block_league") skills.register_skill("block_league:sp", { name = "SP+", icon = "bl_skill_sp.png", - profile_description = S("Increases your stamina points by 25 @1(100>125)", "\n\n" + _profile_description = S("Increases your stamina points by 25 @1(100>125)", "\n\n" .. S("Great choice for strikers, as it allows players to run more and perform tricks more often."), passive = true, on_start = function(self) diff --git a/block_league/src/utils.lua b/block_league/src/utils.lua index 54b557b..33c799e 100644 --- a/block_league/src/utils.lua +++ b/block_league/src/utils.lua @@ -1,6 +1,4 @@ -local function stop_and_update_last_sound() end - -local sounds = {} -- KEY: p_name; VALUE: { sounds_name = handle } +local S = minetest.get_translator("block_league") @@ -14,13 +12,130 @@ end --- interrompi l'ultimo suono chiamato "sound" e lo aggiorna a quello passatogli -function stop_and_update_last_sound(p_name, sound, handle) - sounds[p_name] = sounds[p_name] or {} +function block_league.hitter_or_suicide(arena, player, dmg_rcvd_table, no_hitter_img) + -- se le armi son disabilitate (quindi o in caricamento o dopo punto o in celebrazione) non mostrare niente + if arena.weapons_disabled then + block_league.HUD_spectate_update(arena, player:get_player_name(), "alive") + return end - if sounds[p_name][sound] then - minetest.sound_stop(sounds[p_name][sound]) + local last_hitter = "" + local last_hitter_timestamp = 99999 + + for pla_name, dmg_data in pairs(dmg_rcvd_table) do + if arena.current_time > dmg_data.timestamp - 5 and last_hitter_timestamp > dmg_data.timestamp then + last_hitter = pla_name + last_hitter_timestamp = dmg_data.timestamp + end end - sounds[p_name][sound] = handle + if last_hitter ~= "" then + block_league.kill(arena, minetest.registered_nodes[dmg_rcvd_table[last_hitter].weapon], minetest.get_player_by_name(last_hitter), player) + else + local p_name = player:get_player_name() + block_league.HUD_spectate_update(arena, p_name, "alive") + block_league.HUD_log_update(arena, no_hitter_img, p_name, "") + end end + + + +function block_league.kill(arena, weapon, player, target) + local p_name = player:get_player_name() + local t_name = target:get_player_name() + + -- riproduco suono morte e aggiorno avatar per spettatorɜ + arena_lib.sound_play(p_name, "bl_kill") + block_league.HUD_spectate_update(arena, t_name, "alive") + + if t_name ~= p_name then + -- informo dell'uccisione + block_league.HUD_kill_update(p_name, S("YOU'VE KILLED @1", t_name)) + minetest.chat_send_player(t_name, minetest.colorize("#d7ded7", S("You've been killed by @1", minetest.colorize("#eea160", p_name)))) + + if arena_lib.is_player_spectated(p_name) then + for sp_name, _ in pairs(arena_lib.get_player_spectators(p_name)) do + block_league.HUD_kill_update(sp_name, S("@1 HAS KILLED @2", p_name, t_name)) + end + end + + if arena_lib.is_player_spectated(t_name) then + for sp_name, _ in pairs(arena_lib.get_player_spectators(t_name)) do + minetest.chat_send_player(sp_name, minetest.colorize("#d7ded7", S("@1 has been killed by @2", minetest.colorize("#eea160", t_name), minetest.colorize("#eea160", p_name)))) + end + end + + local p_stats = arena.players[p_name] + local team_id = p_stats.teamID + local team = arena.teams[team_id] + local points + + -- aggiungo l'uccisione + team.kills = team.kills + 1 + p_stats.kills = p_stats.kills + 1 + + -- calcolo i punti + if arena.mode == 1 then + if player:get_meta():get_int("bl_has_ball") == 1 or target:get_meta():get_int("bl_has_ball") == 1 then + points = 4 + else + points = 2 + end + else + points = 2 + end + + p_stats.points = p_stats.points + points + + local dmg_table = arena.players[t_name].dmg_received + local a_dmg = 0 + local a_name + + -- controlla per assist.. + for pl_name, _ in pairs(dmg_table) do + local dmg = dmg_table[pl_name].dmg + if pl_name ~= p_name and arena.current_time > dmg_table[pl_name].timestamp - 5 and dmg > 5 and dmg > a_dmg then + a_name = pl_name + a_dmg = dmg + end + end + + -- ..e se esiste, esegui tutte le operazioni anche su chi l'ha + if a_name and arena.players[a_name] then + arena_lib.sound_play(a_name, "bl_kill") + block_league.HUD_kill_update(a_name, S("YOU'VE CONTRIBUTED TO KILL @1", t_name)) + + if arena_lib.is_player_spectated(a_name) then + for sp_name, _ in pairs(arena_lib.get_player_spectators(p_name)) do + block_league.HUD_kill_update(sp_name, S("@1 HAS CONTRIBUTED TO KILL @2", a_name, t_name)) + end + end + + arena.players[a_name].points = arena.players[a_name].points + (points / 2) + block_league.HUD_spectate_update(arena, a_name, "points") + end + + -- aggiorno HUD + block_league.HUD_infopanel_update_points(arena, team_id) + block_league.HUD_spectate_update(arena, p_name, "points") + block_league.HUD_log_update(arena, weapon.inventory_image, p_name, t_name, a_name) + + -- se è DM e il limite è raggiunto, finisce partita + if arena.mode == 2 then + block_league.HUD_scoreboard_update_score(arena) + if team.kills == arena.score_cap then + local mod = arena_lib.get_mod_by_player(p_name) + arena_lib.load_celebration(mod, arena, team_id) + end + end + + else + block_league.HUD_kill_update(t_name, S("You've killed yourself")) + block_league.HUD_log_update(arena, "bl_log_suicide.png", p_name, t_name) + end +end + + + +function block_league.print_error(pl_name, msg) + minetest.chat_send_player(pl_name, minetest.colorize("#e6482e", arena_lib.mods["block_league"].prefix .. msg)) +end \ No newline at end of file diff --git a/block_league/src/weapons/bullets.lua b/block_league/src/weapons/bullets.lua deleted file mode 100644 index c925d4d..0000000 --- a/block_league/src/weapons/bullets.lua +++ /dev/null @@ -1,270 +0,0 @@ -local function bullet_set_entity() end -local function spawn_particles_sphere() end - - - -function block_league.register_bullet(bullet, damage, bullet_trail) - local bullet_entity = bullet_set_entity(bullet.name, bullet, damage, bullet_trail) - - minetest.register_entity("block_league:" .. bullet.name .. "_entity", bullet_entity) - - return bullet_entity -end - - - - - ----------------------------------------------- ----------------FUNZIONI LOCALI---------------- ----------------------------------------------- - -function bullet_set_entity(name, def, dmg, trail) - local bullet = { - initial_properties = { - - 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, - - is_bullet = true - } - } - - function bullet:_destroy() - -- Crea le particelle dell'esplosione - spawn_particles_sphere(self.object:get_pos(), self.initial_properties.explosion_texture) - - self.initial_properties.on_destroy(self) - self.object:remove() - end - - - - -- Ottiene gli staticdata ogni 18 secondi circa - 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: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:on_activate(staticdata) - - if staticdata ~= "" and staticdata ~= nil then - self.p_name = staticdata -- nome utente come staticdata - self.lifetime = 0 -- tempo in aria - self.sliding = 0 -- se sta scivolando - self.particle = 0 -- contatore di buffer per le particelle della granata - self.object:set_armor_groups({immortal = 1}) -- lo imposta come immortale - else -- se non ci sono gli staticdata necessari allora rimuove l'entità - self.object:remove() - return - end - end - - - - function bullet:on_step(dtime, moveresult) - self.lifetime = self.lifetime + dtime - - if self.lifetime >= self.initial_properties.lifetime then - -- ESPLODE - self:_destroy() - return - end - local obj = self.object - local velocity = obj:get_velocity() - local pos = obj:getpos() - -- Controlla che il timer per mostrare le particelle che tracciano la granata sia superiore al valore definito e che eista una definizione delle particelle da creare - if self.initial_properties.bullet_trail and self.particle >= self.initial_properties.bullet_trail.interval then - -- Imposta il timer a 0 - self.particle = 0 - -- Aggiunge le particelle di tracciamento - minetest.add_particle({ - pos = obj:get_pos(), - velocity = vector.divide(velocity, 2), - acceleration = vector.divide(obj:get_acceleration(), -5), - expirationtime = self.initial_properties.bullet_trail.life, - size = self.initial_properties.bullet_trail.size, - collisiondetection = false, - collision_removal = false, - vertical = false, - texture = self.initial_properties.bullet_trail.image, - glow = self.initial_properties.bullet_trail.glow - }) - -- Controlla che il timer per mostrare le particelle che tracciano la granata sia inferiore al valore definito e che eista una definizione delle particelle da creare - elseif self.initial_properties.bullet_trail and self.particle < self.initial_properties.bullet_trail.interval then - -- Incrementa il timer - self.particle = self.particle + 1 - end - - - if self.initial_properties.explode_on_contact then - -- controlla se collide con qualcosa - if moveresult.collides == true then - local buffer_boolean = false - for k, collision in pairs(moveresult.collisions) do - - --object è l'oggetto(player/entità) con cui collide il proiettile - if collision.object then - --controlla se è un player - if collision.object:is_player() then - - if collision.object:get_player_name() ~= self.p_name then - -- TODO: non funziona, la funzione è stata cambiata. Bisogna far passare l'arma - block_league.apply_damage(minetest.get_player_by_name(self.p_name), collision.object, self.initial_properties.bullet_damage, 0, false) - buffer_boolean = true - elseif collision.object:get_player_name() == self.p_name then - - if self.lifetime < (15 / self.initial_properties.speed) then - obj:set_velocity({ - x=(collision.old_velocity.x), - y=(collision.old_velocity.y), - z=(collision.old_velocity.z), - }) - end - - end - - elseif collision.object:get_luaentity() then - --quando non è un player allora è una entity quindi la memorizzo per alleggerire il numero di accessi - local entity = collision.object:get_luaentity() - --i prossimi 2 check servono a verificare l'entità sia un proiettile - if entity and entity.initial_properties ~= nil then - - if entity.initial_properties.is_bullet then - --distrugge sia il proiettile con cui collide che se stesso - buffer_boolean = true - entity:_destroy() - end - end - end - elseif collision.type == "node" then - buffer_boolean = true - end - - end - if buffer_boolean then - self:_destroy() - return - end - end - - - else - - if moveresult.collides and moveresult.collisions[1] and not vector.equals(moveresult.collisions[1].old_velocity, velocity) and vector.distance(moveresult.collisions[1].old_velocity, velocity) > 4 then - if math.abs(moveresult.collisions[1].old_velocity.x - velocity.x) > 5 then -- Controlla se c'è stata una grande riduzione di velocità - velocity.x = moveresult.collisions[1].old_velocity.x * (self.initial_properties.gravity and -0.5 or -1) -- Inverte la velocità e la riduce - end - - if math.abs(moveresult.collisions[1].old_velocity.y - velocity.y) > 5 then -- Controlla se c'è stata una grande riduzione di velocità - velocity.y = moveresult.collisions[1].old_velocity.y * (self.initial_properties.gravity and -0.3 or -1) -- Inverte la velocità e la riduce - end - - if math.abs(moveresult.collisions[1].old_velocity.z - velocity.z) > 5 then -- Controlla se c'è stata una grande riduzione di velocità - velocity.z = moveresult.collisions[1].old_velocity.z * (self.initial_properties.gravity and -0.5 or -1) -- Inverte la velocità e la riduce - end - - obj:set_velocity(velocity) - end - if self.initial_properties.gravity then - if self.sliding == 0 and velocity.y == 0 then -- Controlla se la granata sta scivolando - self.sliding = 1 -- Attiva l'attrito - elseif self.sliding > 0 and velocity.y ~= 0 then - self.sliding = 0 -- Non influisce sull'attrito - end - - if self.sliding > 1 then -- Sta scivolando? - if vector.distance(vector.new(), velocity) <= 1 and not vector.equals(velocity, vector.new()) then -- Se la granata si muove a malapena - obj:set_velocity(vector.new(0, -9.8, 0)) -- Si assicura sia ferma - obj:set_acceleration(vector.new()) - end - end - end - end - - if self.initial_properties.gravity then - local direction = vector.normalize(velocity) - local node = minetest.get_node(pos) - local speed = vector.length(velocity) - local drag = math.max(minetest.registered_nodes[node.name].liquid_viscosity, 0.1) * self.sliding -- Ottiene l'attrito generato dal liquido che attraversa - local yaw = minetest.dir_to_yaw(direction) - local pitch = math.acos(velocity.y/speed) - math.pi/3 - -- Controlla che il pitch sia un numero - if tostring(pitch) ~= 'nan' then - obj:set_rotation({x = 0, y = yaw + math.pi/2, z = pitch}) -- Imposta la rotazione - end - - local acceleration = vector.multiply(velocity, -drag) - - acceleration.x = acceleration.x * (self.sliding * 10 * 2 + 1) -- Modifica la x in base a se sta scivolando o meno - acceleration.y = acceleration.y - 10 * ((7 - drag) / 7) -- Perdita in altezza del proiettile in base all' attrito - acceleration.z = acceleration.z * (self.sliding * 10 * 2 + 1) -- Modifica la Z in base a se sta scivolando o meno - - -- Controlla che l'accelerazione sia un numero - if tostring(acceleration) ~= 'nan' then - obj:set_acceleration(acceleration) -- Imposta l'accelerazione - end - end - - end - - -- Restituisce la definizione dell'entità - return bullet -end - - - -function spawn_particles_sphere(pos, particle_texture) - if not pos then return end - minetest.add_particlespawner({ - amount = 80, - time = .1, - minpos = {x=pos.x,y=pos.y,z=pos.z}, - maxpos = {x=pos.x,y=pos.y,z=pos.z}, - minvel = {x=-4, y=-4, z=-4}, - maxvel = {x=4, y=4, z=4}, - minacc = {x=0, y=-0.4, z=0}, - maxacc = {x=0, y=-0.8, z=0}, - minexptime = .5, - maxexptime = .5, - minsize = 1, - maxsize = 5, - collisiondetection = false, - vertical = false, - texture = particle_texture, - }) -end \ No newline at end of file diff --git a/block_league/src/weapons/grenade_launcher.lua b/block_league/src/weapons/grenade_launcher_old.lua similarity index 100% rename from block_league/src/weapons/grenade_launcher.lua rename to block_league/src/weapons/grenade_launcher_old.lua diff --git a/block_league/src/weapons/pixelgun.lua b/block_league/src/weapons/pixelgun.lua index b0df2cc..e510915 100644 --- a/block_league/src/weapons/pixelgun.lua +++ b/block_league/src/weapons/pixelgun.lua @@ -1,10 +1,10 @@ local S = minetest.get_translator("block_league") local dmg = 18 -block_league.register_weapon("block_league:pixelgun", { - +weapons_lib.register_weapon("block_league:pixelgun", { description = S("Pixelgun"), - profile_description = S("Sniping weapon: you'll never be too far away"), + _profile_description = S("Sniping weapon: you'll never be too far away"), + groups = {bl_weapon_mesh = 1}, mesh = "bl_pixelgun.obj", tiles = {"bl_pixelgun_texture.png"}, @@ -15,11 +15,32 @@ block_league.register_weapon("block_league:pixelgun", { weapon_type = "snipe", magazine = 4, reload_time = 4, + slow_down_user = true, sound_reload = "bl_pixelgun_reload", + can_use_weapon = function(player, action) + return block_league.util_weapon_use_check(player) + end, + + can_alter_speed = function(player) + return block_league.util_on_can_alter_speed(player:get_player_name()) + end, + + on_reload = function(player, weapon) + block_league.util_on_reload(player:get_player_name(), weapon.name) + end, + + on_reload_end = function(player, weapon) + block_league.util_on_reload_end(player:get_player_name(), weapon.name) + end, + + on_after_hit = function(hitter, weapon, action, objects_hit, total_damage) + block_league.util_on_after_hit(hitter, weapon, objects_hit, total_damage) + end, + action1 = { type = "raycast", - description = S("piercing shot, @1♥", "