remove horizontal view offset on engine and try to fix damage when sitting in train
parent
77de1965f9
commit
f9a7fa68b1
|
@ -1,5 +1,8 @@
|
||||||
--damage.lua
|
--damage.lua
|
||||||
--a globalstep that damages players overrolled by trains.
|
--a globalstep that damages players overrolled by trains.
|
||||||
|
|
||||||
|
advtrains.player_to_wagon_mapping={}
|
||||||
|
|
||||||
local tmr=0
|
local tmr=0
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
tmr=tmr-dtime
|
tmr=tmr-dtime
|
||||||
|
@ -10,7 +13,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
for _, object in pairs(minetest.get_objects_inside_radius(pos, 1)) do
|
for _, object in pairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||||
local le=object:get_luaentity()
|
local le=object:get_luaentity()
|
||||||
if le and le.is_wagon and le.initialized and le:train() then
|
if le and le.is_wagon and le.initialized and le:train() then
|
||||||
if le.driver~=player and math.abs(le:train().velocity)>2 then
|
if (not advtrains.player_to_wagon_mapping[player:get_player_name()] or le.train_id~=advtrains.player_to_wagon_mapping[player:get_player_name()].train_id) and math.abs(le:train().velocity)>2 then
|
||||||
--player:punch(object, 1000, {damage={fleshy=3*math.abs(le:train().velocity)}})
|
--player:punch(object, 1000, {damage={fleshy=3*math.abs(le:train().velocity)}})
|
||||||
player:set_hp(player:get_hp()-math.abs(le:train().velocity)-3)
|
player:set_hp(player:get_hp()-math.abs(le:train().velocity)-3)
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,12 +37,14 @@ function wagon:on_rightclick(clicker)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if self.driver and clicker == self.driver then
|
if self.driver and clicker == self.driver then
|
||||||
|
advtrains.player_to_wagon_mapping[self.driver:get_player_name()]=nil
|
||||||
advtrains.set_trainhud(self.driver:get_player_name(), "")
|
advtrains.set_trainhud(self.driver:get_player_name(), "")
|
||||||
self.driver = nil
|
self.driver = nil
|
||||||
clicker:set_detach()
|
clicker:set_detach()
|
||||||
clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
|
clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
|
||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
self.driver = clicker
|
self.driver = clicker
|
||||||
|
advtrains.player_to_wagon_mapping[clicker:get_player_name()]=self
|
||||||
clicker:set_attach(self.object, "", self.attach_offset, {x=0,y=0,z=0})
|
clicker:set_attach(self.object, "", self.attach_offset, {x=0,y=0,z=0})
|
||||||
clicker:set_eye_offset(self.view_offset, self.view_offset)
|
clicker:set_eye_offset(self.view_offset, self.view_offset)
|
||||||
end
|
end
|
||||||
|
@ -355,7 +357,7 @@ advtrains.register_wagon("newlocomotive", "steam",{
|
||||||
textures = {"advtrains_newlocomotive.png"},
|
textures = {"advtrains_newlocomotive.png"},
|
||||||
is_locomotive=true,
|
is_locomotive=true,
|
||||||
attach_offset={x=5, y=10, z=-10},
|
attach_offset={x=5, y=10, z=-10},
|
||||||
view_offset={x=0, y=6, z=18},
|
view_offset={x=0, y=6, z=0},
|
||||||
visual_size = {x=1, y=1},
|
visual_size = {x=1, y=1},
|
||||||
wagon_span=1.85,
|
wagon_span=1.85,
|
||||||
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
|
||||||
|
|
Loading…
Reference in New Issue