From: PilzAdam Date: Sat, 20 Jul 2013 12:50:19 +0000 (+0200) Subject: Make range of tools configureable X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=cba90d4441bd2e81efb262e663e9c53c24322a54;p=zefram%2Fminetest%2Fminetest_engine.git Make range of tools configureable --- diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 6a4d1983..891a807c 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1868,6 +1868,7 @@ Item definition (register_node, register_craftitem, register_tool) wield_image = "", wield_scale = {x=1,y=1,z=1}, stack_max = 99, + range = 4.0, liquids_pointable = false, tool_capabilities = { full_punch_interval = 1.0, diff --git a/src/game.cpp b/src/game.cpp index ff694d12..3f14f09d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2488,7 +2488,12 @@ void the_game( //u32 t1 = device->getTimer()->getRealTime(); - f32 d = 4; // max. distance + f32 d = playeritem_def.range; // max. distance + f32 d_hand = itemdef->get("").range; + if(d < 0 && d_hand >= 0) + d = d_hand; + else if(d < 0) + d = 4.0; core::line3d shootline(camera_position, camera_position + camera_direction * BS * (d+1)); diff --git a/src/itemdef.cpp b/src/itemdef.cpp index e7498ce5..4ac23d0f 100644 --- a/src/itemdef.cpp +++ b/src/itemdef.cpp @@ -76,6 +76,7 @@ ItemDefinition& ItemDefinition::operator=(const ItemDefinition &def) groups = def.groups; node_placement_prediction = def.node_placement_prediction; sound_place = def.sound_place; + range = def.range; return *this; } @@ -109,6 +110,7 @@ void ItemDefinition::reset() } groups.clear(); sound_place = SimpleSoundSpec(); + range = -1; node_placement_prediction = ""; } @@ -146,6 +148,7 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const //serializeSimpleSoundSpec(sound_place, os); os<