mirror of
https://github.com/lhofhansl/rangedweapons.git
synced 2024-08-20 21:24:09 +02:00
Fix accuracy, no more weird acceleration
This commit is contained in:
parent
0870636171
commit
900ae63ce5
11
init.lua
11
init.lua
@ -693,12 +693,7 @@ end
|
|||||||
|
|
||||||
projectiles = projNum or 1
|
projectiles = projNum or 1
|
||||||
for i=1,projectiles do
|
for i=1,projectiles do
|
||||||
rndacc = (100 - accuracy) or 0
|
local obj = minetest.add_entity(pos, projEnt)
|
||||||
local spawnpos_x = pos.x + (math.random(-rndacc,rndacc)/100)
|
|
||||||
local spawnpos_y = pos.y + (math.random(-rndacc,rndacc)/100)
|
|
||||||
local spawnpos_z = pos.z + (math.random(-rndacc,rndacc)/100)
|
|
||||||
|
|
||||||
local obj = minetest.add_entity({x=spawnpos_x,y=spawnpos_y,z=spawnpos_z}, projEnt)
|
|
||||||
local ent = obj:get_luaentity()
|
local ent = obj:get_luaentity()
|
||||||
|
|
||||||
obj:set_properties(
|
obj:set_properties(
|
||||||
@ -725,9 +720,9 @@ glow = proj_glow,}
|
|||||||
ent.size = size
|
ent.size = size
|
||||||
ent.timer = 0 + (combined_velocity/2000)
|
ent.timer = 0 + (combined_velocity/2000)
|
||||||
ent.wear = proj_wear
|
ent.wear = proj_wear
|
||||||
obj:set_velocity({x=dir.x * combined_velocity, y=dir.y * combined_velocity, z=dir.z * combined_velocity})
|
|
||||||
acc = ((( 100 - accuracy ) / 10) / skill_value ) or 0
|
acc = ((( 100 - accuracy ) / 10) / skill_value ) or 0
|
||||||
obj:set_acceleration({x=math.random(-acc,acc), y=math.random(-acc,acc)-gravity, z=math.random(-acc,acc)})
|
obj:set_velocity({x=dir.x * combined_velocity + math.random(-acc,acc), y=dir.y * combined_velocity + math.random(-acc,acc), z=dir.z * combined_velocity + math.random(-acc,acc)})
|
||||||
|
obj:set_acceleration({x=0, y=-gravity, z=0})
|
||||||
obj:set_rotation({x=0,y=yaw + math.pi,z=-svertical})
|
obj:set_rotation({x=0,y=yaw + math.pi,z=-svertical})
|
||||||
end end end
|
end end end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user