remove horizontal view offset on engine and try to fix damage when sitting in train

master
orwell96 2016-06-09 21:59:06 +02:00
parent 77de1965f9
commit f9a7fa68b1
2 changed files with 7 additions and 2 deletions

View File

@ -1,5 +1,8 @@
--damage.lua
--a globalstep that damages players overrolled by trains.
advtrains.player_to_wagon_mapping={}
local tmr=0
minetest.register_globalstep(function(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
local le=object:get_luaentity()
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:set_hp(player:get_hp()-math.abs(le:train().velocity)-3)
end

View File

@ -37,12 +37,14 @@ function wagon:on_rightclick(clicker)
return
end
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(), "")
self.driver = nil
clicker:set_detach()
clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
elseif not self.driver then
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_eye_offset(self.view_offset, self.view_offset)
end
@ -355,7 +357,7 @@ advtrains.register_wagon("newlocomotive", "steam",{
textures = {"advtrains_newlocomotive.png"},
is_locomotive=true,
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},
wagon_span=1.85,
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},