Corretta assegnazione delle kill.
parent
dcf9f5c5c5
commit
d1b1f3b7e4
|
@ -46,6 +46,7 @@ arena_lib.on_start("quake", function(arena)
|
|||
|
||||
local weapon = ItemStack("quake:railgun")
|
||||
local weapon2 = ItemStack("quake:rocket_launcher")
|
||||
local grenade = ItemStack("quake:grenade")
|
||||
|
||||
for pl_name, stats in pairs(arena.players) do
|
||||
|
||||
|
@ -55,6 +56,8 @@ arena_lib.on_start("quake", function(arena)
|
|||
|
||||
player:get_inventory():add_item("main", weapon)
|
||||
player:get_inventory():add_item("main", weapon2)
|
||||
player:get_inventory():add_item("main", grenade)
|
||||
|
||||
player:set_physics_override({
|
||||
speed = 2.3,
|
||||
jump = 1.5,
|
||||
|
@ -76,6 +79,7 @@ arena_lib.on_join("quake", function(p_name, arena)
|
|||
local player = minetest.get_player_by_name(p_name)
|
||||
local weapon = ItemStack("quake:railgun")
|
||||
local weapon2 = ItemStack("quake:rocket_launcher")
|
||||
local grenade = ItemStack("quake:grenade")
|
||||
|
||||
quake.HUD_stats_create(p_name)
|
||||
quake.HUD_broadcast_create(p_name)
|
||||
|
@ -88,8 +92,13 @@ arena_lib.on_join("quake", function(p_name, arena)
|
|||
|
||||
player:get_meta():set_int("quake_weap_delay", 0)
|
||||
|
||||
|
||||
player:get_inventory():add_item("main", weapon)
|
||||
player:get_inventory():add_item("main", weapon2)
|
||||
|
||||
player:get_inventory():set_stack("main", 1, "grenade " .. 5)
|
||||
player:get_inventory():add_item("main", grenade)
|
||||
|
||||
player:set_physics_override({
|
||||
speed = 2.3,
|
||||
jump = 1.5,
|
||||
|
@ -128,6 +137,8 @@ arena_lib.on_celebration("quake", function(arena, winner_name)
|
|||
local inv = minetest.get_player_by_name(pl_name):get_inventory()
|
||||
inv:remove_item("main", ItemStack("quake:railgun"))
|
||||
inv:remove_item("main", ItemStack("quake:rocket_launcher"))
|
||||
inv:remove_item("main", ItemStack("quake:grenade"))
|
||||
|
||||
inv:add_item("main", ItemStack("quake:match_over"))
|
||||
panel_lib.get_panel(pl_name, "quake_scoreboard"):show()
|
||||
end
|
||||
|
|
|
@ -28,31 +28,22 @@ function quake.register_bullet(name, def)
|
|||
duration = def.duration,
|
||||
jump = def.jump,
|
||||
explosion_damage = def.explosion_damage,
|
||||
no_collision_time = 1/(2*def.speed), -- il tempo necessario per non far impattare il proiettile contro il giocatore
|
||||
def = def,
|
||||
on_destroy = def.on_destroy,
|
||||
is_bullet = true,
|
||||
},
|
||||
}
|
||||
|
||||
-- variabili assegnate alla SINGOLA entity quando istanziata. Non rimangono in memoria al riavvio
|
||||
local shooter = nil
|
||||
local p_name = nil
|
||||
local lifetime = 0
|
||||
|
||||
|
||||
|
||||
-- cosa succede alla distruzione del proiettile. In pratica prende il metodo impostato
|
||||
-- nella creazione del proiettile e lo usa alla distruzione. Comodo perchè così è astratta anche quella
|
||||
function bulletentity:_destroy()
|
||||
|
||||
-- Crea le particelle dell'esplosione
|
||||
spawn_particles_sphere(self.object:get_pos(), self.initial_properties.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
|
||||
|
||||
self.object:remove()
|
||||
-- Distrugge l'entità
|
||||
self.object:remove()
|
||||
|
||||
|
||||
end
|
||||
|
@ -67,14 +58,15 @@ function quake.register_bullet(name, def)
|
|||
function bulletentity:on_activate(staticdata)
|
||||
|
||||
if staticdata ~= "" and staticdata ~= nil then
|
||||
-- variabili assegnate alla SINGOLA entity quando istanziata. Non rimangono in memoria al riavvio
|
||||
self.p_name = staticdata -- nome utente come staticdata
|
||||
self.shooter = minetest.get_player_by_name(staticdata)
|
||||
self.lifetime = 0
|
||||
else
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
self.lifetime = 0
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ quake.register_grenade("quake:grenade", {
|
|||
tiles = {"quake_grenade.png"},
|
||||
wield_scale = {x=1.5, y=1.5, z=1.5},
|
||||
inventory_image = "quake_grenade_icon.png",
|
||||
stack_max = 99,
|
||||
|
||||
entity = {
|
||||
throw_speed = 17,
|
||||
|
@ -12,11 +13,11 @@ quake.register_grenade("quake:grenade", {
|
|||
collide_with_objects = true,
|
||||
visual = "mesh",
|
||||
--wield_item = "quake:grenade",
|
||||
visual_size = {x=5, y=5, z=5},
|
||||
visual_size = {x=7, y=7, z=7},
|
||||
mesh = "quake_grenade.obj",
|
||||
explosion_texture = "quake_rocket_particle.png",
|
||||
textures = {"quake_grenade.png"},
|
||||
collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.3, 0.3},
|
||||
collisionbox = {-0.2, -0.2, -0.2, 0.2, 0.2, 0.2},
|
||||
explosion_range = 4,
|
||||
duration = 1.5,
|
||||
gravity = true,
|
||||
|
@ -24,7 +25,7 @@ quake.register_grenade("quake:grenade", {
|
|||
particle = {
|
||||
image = "quake_bullet_rocket.png",
|
||||
life = 1,
|
||||
size = 1,
|
||||
size = 2,
|
||||
glow = 0,
|
||||
interval = 5,
|
||||
},
|
||||
|
@ -32,16 +33,4 @@ quake.register_grenade("quake:grenade", {
|
|||
|
||||
},
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
--[[
|
||||
diminuire tempo di esplosione
|
||||
stesso danno per tutti
|
||||
diminuire loslancio dato dalla corsa
|
||||
|
||||
|
||||
|
||||
|
||||
]]
|
||||
|
|
|
@ -6,8 +6,8 @@ quake.register_bullet("quake:rocket",{
|
|||
visual_size = {x=1, y=1, z=1},
|
||||
textures = {"quake_bullet_rocket.png"},
|
||||
explosion_texture = "quake_rocket_particle.png",
|
||||
collisionbox = {-0.05, -0.05, -0.05, 0.05, 0.05, 0.05}, -- {xmin, ymin, zmin, xmax, ymax, zmax}
|
||||
speed = 30,
|
||||
collisionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1}, -- {xmin, ymin, zmin, xmax, ymax, zmax}
|
||||
speed = 5, --30
|
||||
damage = 14,
|
||||
jump = 0,
|
||||
explosion_range = 4,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
-- definisco le proprietà e i costruttori delle entità 'proiettili' e le registro alla fine
|
||||
-- Registra item ed entità
|
||||
function quake.register_grenade(name, def)
|
||||
|
||||
if not def.entity.throw_speed then return end
|
||||
|
@ -10,65 +10,58 @@ function quake.register_grenade(name, def)
|
|||
tiles = def.tiles,
|
||||
wield_scale = def.wield_scale,
|
||||
inventory_image = def.inventory_image,
|
||||
stack_max = def.stack_max,
|
||||
on_drop = function() end,
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
-- lancia la granata
|
||||
grenade_throw(itemstack, user, pointed_thing)
|
||||
-- Toglie la granata se non si è in creative
|
||||
-- momentaneamente disattivato perchè il server è in creative
|
||||
--[[
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
end
|
||||
]]
|
||||
return itemstack
|
||||
end,
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
grenade_throw(itemstack, user, pointed_thing)
|
||||
-- lancia la granata
|
||||
grenade_throw(itemstack, user, pointed_thing)
|
||||
-- Toglie la granata se non si è in creative
|
||||
-- momentaneamente disattivato perchè il server è in creative
|
||||
--[[
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
end
|
||||
]]
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
-- Ottiene la definizione dell'entità
|
||||
local grenade_entity = grenade_set_entity(name, def)
|
||||
|
||||
-- Registra l'entità
|
||||
minetest.register_entity(name .. "_entity", grenade_entity)
|
||||
|
||||
end
|
||||
|
||||
--Lancia la granata
|
||||
function grenade_throw(itemstack, player, pointed_thing)
|
||||
|
||||
local dir = player:get_look_dir()
|
||||
local yaw = player:get_look_horizontal()
|
||||
local pitch = player:get_look_vertical()
|
||||
local pos = player:get_pos()
|
||||
local grenade = itemstack:get_name() .. '_entity'
|
||||
local obj = minetest.add_entity({x = pos.x, y = pos.y + player:get_properties().eye_height, z = pos.z}, grenade, player:get_player_name())
|
||||
local grenade = itemstack:get_name() .. '_entity' -- Nome dell'entità
|
||||
local obj = minetest.add_entity({x = pos.x, y = pos.y + player:get_properties().eye_height, z = pos.z}, grenade, player:get_player_name()) -- add_entity(posizione, nome_entità, staticdata)
|
||||
|
||||
local throw_speed = obj:get_luaentity().initial_properties.throw_speed
|
||||
local player_vel = player:get_player_velocity()
|
||||
obj:set_velocity(vector.add(player_vel, vector.multiply(dir, throw_speed)))
|
||||
--obj:set_velocity({x = dir.x * throw_speed, y = dir.y * throw_speed/1.5, z = dir.z * throw_speed})
|
||||
--obj:set_acceleration({x = 0, y = -13, z = 0})
|
||||
local rotation = vector.new(0, yaw + math.pi/2, pitch + math.pi/6)
|
||||
obj:set_rotation(rotation)
|
||||
--[[
|
||||
local grenade = itemstack:get_name() .. '_entity'
|
||||
local player_pos = player:get_pos()
|
||||
local head_pos = vector.new(player_pos.x, player_pos.y + player:get_properties().eye_height, player_pos.z)
|
||||
local direction = player:get_look_dir()
|
||||
local throw_pos = vector.add(head_pos, vector.multiply(direction,0.5))
|
||||
local pitch = player:get_look_vertical()
|
||||
local yaw = player:get_look_horizontal()
|
||||
local rotation = vector.new(0, yaw + math.pi/2, pitch + math.pi/6)
|
||||
local grenade_object = minetest.add_entity(throw_pos, grenade, player:get_player_name())
|
||||
local throw_speed = grenade_object:get_luaentity().initial_properties.throw_speed
|
||||
local player_vel = player:get_player_velocity()
|
||||
grenade_object:set_velocity(vector.add(player_vel, vector.multiply(direction, throw_speed)))
|
||||
|
||||
|
||||
grenade_object:set_rotation(rotation)
|
||||
grenade_object:set_rotation(vector.new(0, 0, 0))
|
||||
]]
|
||||
local throw_speed = obj:get_luaentity().initial_properties.throw_speed -- Velocità a cui viene lanciata la granta di base
|
||||
local player_vel = player:get_player_velocity() -- Velocità del player
|
||||
obj:set_velocity(vector.add(player_vel, vector.multiply(dir, throw_speed))) -- Imposta la velocità alla granata in base alla velocità del player ed alla velocità default
|
||||
|
||||
local rotation = vector.new(0, yaw + math.pi/2, pitch + math.pi/6) -- Calcola la rotazione
|
||||
obj:set_rotation(rotation) --Imposta la rotazione della granata così che sia sempre orientata correttamente
|
||||
|
||||
return true
|
||||
end
|
||||
|
@ -100,25 +93,25 @@ function grenade_set_entity(name, def)
|
|||
}
|
||||
|
||||
function grenade_entity:_destroy()
|
||||
|
||||
-- Crea le particelle dell'esplosione
|
||||
spawn_particles_sphere(self.object:get_pos(), self.initial_properties.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
|
||||
|
||||
-- spawna le particelle
|
||||
|
||||
-- Distrugge l'entità
|
||||
self.object:remove()
|
||||
|
||||
|
||||
end
|
||||
|
||||
-- Ottiene gli staticdata ogni 18 secondi circa
|
||||
function grenade_entity: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 grenade_entity:on_punch()
|
||||
self:_destroy()
|
||||
return
|
||||
|
@ -128,12 +121,12 @@ function grenade_set_entity(name, def)
|
|||
function grenade_entity:on_activate(staticdata)
|
||||
|
||||
if staticdata ~= "" and staticdata ~= nil then
|
||||
self.p_name = staticdata -- nome utente come staticdata
|
||||
self.lifetime = 0
|
||||
self.sliding = 0
|
||||
self.particle = 0
|
||||
self.object:set_armor_groups({immortal = 1})
|
||||
else
|
||||
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
|
||||
|
@ -142,7 +135,6 @@ function grenade_set_entity(name, def)
|
|||
function grenade_entity:on_step(dtime, moveresult)
|
||||
self.lifetime = self.lifetime + dtime
|
||||
|
||||
|
||||
if self.initial_properties.gravity then
|
||||
local obj = self.object
|
||||
local velocity = obj:get_velocity()
|
||||
|
@ -150,97 +142,61 @@ function grenade_set_entity(name, def)
|
|||
local pos = obj:getpos()
|
||||
|
||||
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 -- Check for a large reduction in velocity
|
||||
velocity.x = moveresult.collisions[1].old_velocity.x * -0.5 -- Invert velocity and reduce it a bit
|
||||
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 * -0.5 -- Inverte la velocità e la riduce
|
||||
end
|
||||
|
||||
if math.abs(moveresult.collisions[1].old_velocity.y - velocity.y) > 5 then -- Check for a large reduction in velocity
|
||||
velocity.y = moveresult.collisions[1].old_velocity.y * -0.3 -- Invert velocity and reduce it a bit
|
||||
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 * -0.3 -- Inverte la velocità e la riduce
|
||||
end
|
||||
|
||||
if math.abs(moveresult.collisions[1].old_velocity.z - velocity.z) > 5 then -- Check for a large reduction in velocity
|
||||
velocity.z = moveresult.collisions[1].old_velocity.z * -0.5 -- Invert velocity and reduce it a bit
|
||||
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 * -0.5 -- Inverte la velocità e la riduce
|
||||
end
|
||||
|
||||
obj:set_velocity(velocity)
|
||||
end
|
||||
|
||||
--[[
|
||||
print("#########################")
|
||||
print(dump(velocity))
|
||||
print("#########################")
|
||||
]]
|
||||
|
||||
if self.sliding == 0 and velocity.y == 0 then -- Check if grenade is sliding
|
||||
self.sliding = 1 -- Multiplies drag by 2
|
||||
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 -- Doesn't affect drag
|
||||
self.sliding = 0 -- Non influisce sull'attrito
|
||||
end
|
||||
|
||||
if self.sliding > 1 then -- Is the grenade sliding?
|
||||
if vector.distance(vector.new(), velocity) <= 1 and not vector.equals(velocity, vector.new()) then -- Grenade is barely moving
|
||||
obj:set_velocity(vector.new(0, -9.8, 0)) -- Make sure it stays unmoving
|
||||
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
|
||||
--else
|
||||
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
|
||||
local yaw = minetest.dir_to_yaw(direction)
|
||||
local speed = vector.length(velocity)
|
||||
local pitch = math.acos(velocity.y/speed) - math.pi/3
|
||||
if tostring(pitch) ~= 'nan' then
|
||||
obj:set_rotation({x = 0, y = yaw + math.pi/2, z = pitch})
|
||||
end
|
||||
--print(drag)
|
||||
local acceleration = vector.multiply(velocity, -drag)
|
||||
--local acceleration = vector.multiply(direction, -drag)
|
||||
--print(acceleration.y)
|
||||
|
||||
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 * 5 * 2 + 1)
|
||||
acceleration.y = acceleration.y - 10 * ((7 - drag) / 7)
|
||||
acceleration.z = acceleration.z * (self.sliding * 5 * 2 + 1)
|
||||
acceleration.x = acceleration.x * (self.sliding * 5 * 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 * 5 * 2 + 1) -- Modifica la Z in base a se sta scivolando o meno
|
||||
|
||||
--[[
|
||||
print("XXXXXXXXXXXXXXXXXXXXXXXXXXXX")
|
||||
print(acceleration.x * (self.sliding * 5 * 2 + 1))
|
||||
print(-direction.x * 13 * (self.sliding + 1))
|
||||
print("XXXXXXXXXXXXXXXXXXXXXXXXXXXX")
|
||||
print("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ")
|
||||
print(acceleration.z * (self.sliding * 5 * 2 + 1))
|
||||
print(-direction.z * 13 * (self.sliding + 1))
|
||||
print("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ")
|
||||
]]
|
||||
if tostring(acceleration) ~= 'nan' then
|
||||
obj:set_acceleration(acceleration)
|
||||
end
|
||||
--[[
|
||||
obj:set_acceleration({
|
||||
x = -direction.x * (self.initial_properties.throw_speed/2) * self.sliding,
|
||||
y = -9.8 * drag,
|
||||
z = -direction.z * (self.initial_properties.throw_speed/2) * self.sliding,
|
||||
})
|
||||
]]
|
||||
|
||||
|
||||
|
||||
|
||||
--[[
|
||||
local direction = vector.normalize(velocity)
|
||||
obj:set_acceleration({
|
||||
x = -direction.x * self.initial_properties.acceleration * self.sliding,
|
||||
y = -9.8,
|
||||
z = -direction.z * self.initial_properties.acceleration * self.sliding,
|
||||
})]]
|
||||
--end
|
||||
|
||||
if self.initial_properties.particle and self.particle >= 4 then
|
||||
self.particle = 0
|
||||
-- Controlla che l'accelerazione sia un numero
|
||||
if tostring(acceleration) ~= 'nan' then
|
||||
obj:set_acceleration(acceleration) -- Imposta l'accelerazione
|
||||
end
|
||||
|
||||
-- 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.particle and self.particle >= self.initial_properties.particle.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),
|
||||
|
@ -253,48 +209,27 @@ function grenade_set_entity(name, def)
|
|||
texture = self.initial_properties.particle.image,
|
||||
glow = self.initial_properties.particle.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.particle and self.particle < self.initial_properties.particle.interval then
|
||||
-- Incrementa il timer
|
||||
self.particle = self.particle + 1
|
||||
end
|
||||
|
||||
-- Se ha raggiunto la durata di vita massima
|
||||
if self.lifetime >= self.initial_properties.duration then
|
||||
-- ESPLODE
|
||||
self:_destroy()
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--[[
|
||||
|
||||
local speed = vector.length(velocity)
|
||||
local direction = vector.normalize(velocity)
|
||||
local yaw = minetest.dir_to_yaw(direction)
|
||||
local pitch = math.acos(velocity.y/speed) - math.pi/3
|
||||
local pos = self.object:get_pos()
|
||||
local node = minetest.get_node(pos)
|
||||
local drag = math.max(minetest.registered_nodes[node.name].liquid_viscosity, 0.1)
|
||||
if velocity.y == 0 then
|
||||
drag = drag * 2
|
||||
end
|
||||
local acceleration = vector.multiply(velocity, -drag)
|
||||
acceleration.y = acceleration.y - 10 * ((7 - drag) / 7)
|
||||
if tostring(acceleration) ~= 'nan' then
|
||||
self.object:set_acceleration(acceleration)
|
||||
end
|
||||
if tostring(yaw) ~= 'nan' and tostring(pitch) ~= 'nan' then
|
||||
self.object:set_rotation({x = 0, y = yaw + math.pi/2, z = pitch})
|
||||
end
|
||||
]]
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
-- Restituisce la definizione dell'entità
|
||||
return grenade_entity
|
||||
end
|
||||
|
||||
|
||||
--aggiunge le particelle dell'esplosione
|
||||
-- Aggiunge le particelle dell'esplosione
|
||||
function spawn_particles_sphere(pos, particle_texture)
|
||||
if not pos then return end
|
||||
minetest.add_particlespawner({
|
||||
|
|
|
@ -111,6 +111,9 @@ function get_pointed_players(head_pos, dir, dist, username)
|
|||
|
||||
if entity.initial_properties.is_bullet or entity.initial_properties.is_grenade then
|
||||
--distrugge sia il proiettile con cui collide che se stesso
|
||||
entity.old_p_name = entity.p_name
|
||||
entity.p_name = username
|
||||
|
||||
entity:_destroy()
|
||||
end
|
||||
end
|
||||
|
@ -235,6 +238,13 @@ function kill(arena, p_name, target)
|
|||
|
||||
if t_name ~= p_name then
|
||||
|
||||
--[[
|
||||
local grenade = ItemStack("quake:grenade")
|
||||
local player = minetest.get_player_by_name(p_name)
|
||||
add_item("main", grenade)
|
||||
player:get_inventory():set_stack("main", 1, "arena_lib:players_min " .. arena.min_players)
|
||||
]]
|
||||
|
||||
-- informo dell'uccisione
|
||||
quake.HUD_broadcast_player(p_name, S("YOU'VE KILLED @1", t_name), 2.5)
|
||||
minetest.chat_send_player(t_name, minetest.colorize("#d7ded7", S("You've been killed by @1", minetest.colorize("#eea160", p_name))))
|
||||
|
|
|
@ -2,31 +2,37 @@ quake.explode = function(self)
|
|||
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
|
||||
if origin.x == nil or origin.y == nil or origin.z == nil then return end
|
||||
|
||||
|
||||
local objs = minetest.env:get_objects_inside_radius(origin, explosion_range)
|
||||
local entities = {}
|
||||
-- se ho colpito qualcosa
|
||||
-- Se ho colpito qualcosa
|
||||
if objs then
|
||||
for _, obj in ipairs(objs) do
|
||||
if obj:is_player() then
|
||||
--if obj:get_player_name() ~= self.initial_properties.name then
|
||||
local p_pos = obj:get_pos()
|
||||
local lenx = math.abs(p_pos.x - origin.x)
|
||||
local leny = math.abs(p_pos.y - origin.y)
|
||||
local lenz = math.abs(p_pos.z - origin.z)
|
||||
local hypot = math.sqrt((lenx * lenx) + (lenz * lenz))
|
||||
local dist = math.sqrt((hypot * hypot) + (leny * leny))
|
||||
local damage = explosion_damage - (explosion_damage * dist / explosion_range)
|
||||
|
||||
-- se colpisco me stesso, prendo 1/5 di danno
|
||||
if (obj:get_player_name() ~= self.p_name) then
|
||||
quake.shoot(self.p_name, obj, damage, false)
|
||||
else
|
||||
quake.shoot(self.p_name, obj, (damage/5), false)
|
||||
end
|
||||
--end
|
||||
local p_pos = obj:get_pos()
|
||||
local lenx = math.abs(p_pos.x - origin.x)
|
||||
local leny = math.abs(p_pos.y - origin.y)
|
||||
local lenz = math.abs(p_pos.z - origin.z)
|
||||
local hypot = math.sqrt((lenx * lenx) + (lenz * lenz))
|
||||
local dist = math.sqrt((hypot * hypot) + (leny * leny))
|
||||
local damage = explosion_damage - (explosion_damage * dist / explosion_range)
|
||||
local target_name = obj:get_player_name()
|
||||
|
||||
|
||||
if self.old_p_name and p_name == target_name then
|
||||
p_name = self.old_p_name
|
||||
end
|
||||
|
||||
-- Se colpisco me stesso, prendo 1/5 di danno
|
||||
if (target_name ~= p_name) then
|
||||
quake.shoot(p_name, obj, damage, false)
|
||||
else
|
||||
quake.shoot(p_name, obj, (damage/5), false)
|
||||
end
|
||||
|
||||
elseif obj ~= self.object and obj:get_luaentity() then
|
||||
local entity = obj:get_luaentity()
|
||||
|
@ -34,19 +40,21 @@ quake.explode = function(self)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
if #entities == 0 then return end
|
||||
self.object:remove()
|
||||
for _,entity in pairs(entities) do
|
||||
if entity.initial_properties ~= nil then
|
||||
if entity.initial_properties.is_bullet or entity.initial_properties.is_grenade then
|
||||
--distrugge sia il proiettile con cui collide che se stesso
|
||||
|
||||
entity.old_p_name = entity.p_name
|
||||
entity.p_name = p_name
|
||||
|
||||
entity:_destroy()
|
||||
--return true --perchè ho attivato un'altra entità che esploda
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--return false --non ho attivato un'altra entità
|
||||
end
|
||||
|
||||
|
||||
|
@ -54,29 +62,31 @@ quake.grenade_explode = function(self)
|
|||
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
|
||||
if origin.x == nil or origin.y == nil or origin.z == nil then return end
|
||||
|
||||
|
||||
local objs = minetest.env:get_objects_inside_radius(origin, explosion_range)
|
||||
local entities = {}
|
||||
-- se ho colpito qualcosa
|
||||
-- Se ho colpito qualcosa
|
||||
if objs then
|
||||
for _, obj in ipairs(objs) do
|
||||
if obj:is_player() then
|
||||
--if obj:get_player_name() ~= self.initial_properties.name then
|
||||
local p_pos = obj:get_pos()
|
||||
local lenx = math.abs(p_pos.x - origin.x)
|
||||
local leny = math.abs(p_pos.y - origin.y)
|
||||
local lenz = math.abs(p_pos.z - origin.z)
|
||||
local hypot = math.sqrt((lenx * lenx) + (lenz * lenz))
|
||||
local dist = math.sqrt((hypot * hypot) + (leny * leny))
|
||||
local damage = explosion_damage - (explosion_damage * dist / explosion_range)
|
||||
|
||||
quake.shoot(self.p_name, obj, damage, false)
|
||||
local p_pos = obj:get_pos()
|
||||
local lenx = math.abs(p_pos.x - origin.x)
|
||||
local leny = math.abs(p_pos.y - origin.y)
|
||||
local lenz = math.abs(p_pos.z - origin.z)
|
||||
local hypot = math.sqrt((lenx * lenx) + (lenz * lenz))
|
||||
local dist = math.sqrt((hypot * hypot) + (leny * leny))
|
||||
local damage = explosion_damage - (explosion_damage * dist / explosion_range)
|
||||
local target_name = obj:get_player_name()
|
||||
|
||||
--end
|
||||
if self.old_p_name and p_name == target_name then
|
||||
p_name = self.old_p_name
|
||||
end
|
||||
|
||||
quake.shoot(p_name, obj, damage, false)
|
||||
|
||||
elseif obj ~= self.object and obj:get_luaentity() then
|
||||
local entity = obj:get_luaentity()
|
||||
|
@ -90,12 +100,13 @@ quake.grenade_explode = function(self)
|
|||
for _,entity in pairs(entities) do
|
||||
if entity.initial_properties ~= nil then
|
||||
if entity.initial_properties.is_bullet or entity.initial_properties.is_grenade then
|
||||
--distrugge sia il proiettile con cui collide che se stesso
|
||||
|
||||
entity.old_p_name = entity.p_name
|
||||
entity.p_name = p_name
|
||||
|
||||
entity:_destroy()
|
||||
--return true --perchè ho attivato un'altra entità che esploda
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--return false --non ho attivato un'altra entità
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue