Page 1 of 1

[Bonus] Source code tweaks

PostPosted: Wed Jul 23, 2014 20:55
by Calinou
This topic guides you in changing settings which are normally not supposed to be changed. In order for this to work, you need to have the game's source code and you need to recompile it after each modification.


Third person distance
camera.cpp

You can change the third person distance by changing the value at line 385:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
for (int i = BS; i <= BS* 3.2; i++)



Damage flash and damage tilt
game.cpp

You can tweak or entirely disable the screen turning red when getting damaged, or the screen tilting when getting damaged, or both. Change the values between lines 2398 and 2403, or comment the instructions out using // like this:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
// damage_flash += 100.0;
// damage_flash += 8.0 * event.player_damage.amount;

// player->hurt_tilt_timer = 1.5;
// player->hurt_tilt_strength = event.player_damage.amount/2;
// player->hurt_tilt_strength = rangelim(player->hurt_tilt_strength, 2.0, 10.0);



Infotext position
game.cpp

The first number is the X offset (horizontal position from top-left of screen), the second one is the Y offset (vertical position from top-left of screen). Note that this doesn't scale depending on screen resolution, so the actual position will change depending on the screen aspect. Change the two numbers at the end of the line 1542:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
core::rect<s32>(0,0,400,text_height*5+5) + v2s32(100,200),



Light table
light.cpp

Many light tables are available, but only one of them can be used at a time. The only one which isn't commented out by default is the first one.

Most of them are commented by default, using #if 0. The first one is enabled using #if 1. Thus, to change the light table, you have to comment out the first one by changing #if 1 to #if 0 and enable another one by changing #if 0 to #if 1. Make sure only one light table is enabled at once!


Other player movement smoothing
content_cao.cpp

Change the value at line 109. Increasing it will make it less smooth but more instant, whereas decreasing it makes it less responsive by smoother. Older Minetest versions used a value like 0.5:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
moveratio = moveratio * 0.8;

Re: [Bonus] Source code tweaks

PostPosted: Wed Jul 23, 2014 20:58
by Krock
Thanks. Cheat teacher.

Re: [Bonus] Source code tweaks

PostPosted: Wed Jul 23, 2014 21:11
by rubenwardy
Not really cheating, unless you make it so you can see in the dark. God mode or giving yourself fly is cheating.

Re: [Bonus] Source code tweaks

PostPosted: Thu Jul 24, 2014 01:22
by paramat
Thanks for this, i find damage tilt very disorientating, sickening, it should be possible to disable it in minetest.conf. I have a strange form of motion sickness not triggered by most Minetest motion, but i don't like view bobbing or the Minecraft FOV changes i see in videos.

Re: [Bonus] Source code tweaks

PostPosted: Thu Jul 24, 2014 01:54
by hoodedice
Hmm, there is also a third player camera offset in the lua api. You can use set_eye_offset to do that (https://github.com/minetest/minetest/bl ... .txt#L1908)

Here is something I did while playing around with it:

Image

Re: [Bonus] Source code tweaks

PostPosted: Thu Jul 24, 2014 02:47
by Chinchow
hoodedice wrote:Hmm, there is also a third player camera offset in the lua api. You can use set_eye_offset to do that (https://github.com/minetest/minetest/bl ... .txt#L1908)

Here is something I did while playing around with it:

Image

Over the shoulder minetest gameplay.

Re: [Bonus] Source code tweaks

PostPosted: Thu Jul 24, 2014 07:17
by Calinou
rubenwardy wrote:Not really cheating, unless you make it so you can see in the dark. God mode or giving yourself fly is cheating.


I use the debug light table because my screen makes stuff very dark. Without it, it's impossible to even walk around at night. It also makes block lighting look much better.

Re: [Bonus] Source code tweaks

PostPosted: Thu Jul 24, 2014 14:31
by Sokomine
Calinou wrote:I use the debug light table because my screen makes stuff very dark. Without it, it's impossible to even walk around at night. It also makes block lighting look much better.

Seems I've got a similar problem. People sometimes complain that my houses are too brightly lit, while on screenshots or videos taken in the dark, it's almost impossible for me to make out what's going on.

Thanks for the thread!

Re: [Bonus] Source code tweaks

PostPosted: Thu Jul 24, 2014 17:05
by Casimir

Re: [Bonus] Source code tweaks

PostPosted: Sun Feb 22, 2015 20:00
by Casimir
One click drawing in craft
guiFormSpecMenu.cpp
line 3207

There is a feature that lets you "draw" your items on to the craft grid, similar to minecraft. But it is almost unusable at the moment. This is how to change it to one click. Just add the comments and recompile.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
      else if(updown == -1) {
         // Mouse has been moved and rmb is down and mouse pointer just
         // entered a new inventory field (checked in the entry-if, this
         // is the only action here that is generated by mouse movement)
         if(m_selected_item != NULL && s.isValid()){
            // Move 1 item
            // TODO: middle mouse to move 10 items might be handy
//            if (m_rmouse_auto_place) {
               // Only move an item if the destination slot is empty
               // or contains the same item type as what is going to be
               // moved
//               InventoryList *list_from = inv_selected->getList(m_selected_item->listname);
//               InventoryList *list_to = inv_s->getList(s.listname);
//               assert(list_from && list_to);
//               ItemStack stack_from = list_from->getItem(m_selected_item->i);
//               ItemStack stack_to = list_to->getItem(s.i);
//               if (stack_to.empty() || stack_to.name == stack_from.name)
                  move_amount = 1;
//            }
         }
      }


Immediate Respawn
game.cpp
line 3028

Respawn without being prompted with a button. This i only useful when using random-input. Add the line marked with "Add this" and add the comments in the lines below.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
      } else if (event.type == CE_DEATHSCREEN) {
         client->sendRespawn(); // Add this.
         //show_deathscreen(&current_formspec, client, gamedef, texture_src,
         //       device, client);

         chat_backend->addMessage(L"", L"You died.");

Re: [Bonus] Source code tweaks

PostPosted: Sun Feb 22, 2015 21:58
by Linuxdirk
Calinou wrote:Third person distance
Damage flash and damage tilt
Infotext position
Light table
Other player movement smoothing

Casimir wrote:One click drawing in craft
Immediate Respawn

And the main question here is: Why aren’t this options in minetest.conf but hardcoded values?

:)

Re: [Bonus] Source code tweaks

PostPosted: Mon Feb 23, 2015 16:44
by Calinou
A pull request could be made for that, but I guess you would need one pull request per variable (or two) added. Else, some people may vote against.

Re: [Bonus] Source code tweaks

PostPosted: Tue Feb 24, 2015 20:29
by Linuxdirk
Calinou wrote:… some people may vote against.

Why would someone vote against more “optional options” with sane defaults?

Re: [Bonus] Source code tweaks

PostPosted: Wed Feb 25, 2015 17:56
by Krock
Linuxdirk wrote:
Calinou wrote:… some people may vote against.

Why would someone vote against more “optional options” with sane defaults?

Would you like to have over 9000 different settings?

Re: [Bonus] Source code tweaks

PostPosted: Wed Feb 25, 2015 17:59
by rubenwardy
I'm going to be adding smooth movement settings for cinematic mode, if nobody does it first. Probably do it tomorrow.

Re: [Bonus] Source code tweaks

PostPosted: Wed Feb 25, 2015 18:35
by Krock
rubenwardy wrote:I'm going to be adding smooth movement settings for cinematic mode, if nobody does it first. Probably do it tomorrow.

You're 4 hours too late; master already has that feature - it's amazing.
https://github.com/minetest/minetest/commits

Re: [Bonus] Source code tweaks

PostPosted: Wed Feb 25, 2015 18:37
by rubenwardy
Krock wrote:
rubenwardy wrote:I'm going to be adding smooth movement settings for cinematic mode, if nobody does it first. Probably do it tomorrow.

You're 4 hours too late; master already has that feature - it's amazing.
https://github.com/minetest/minetest/commits


...

I wrote that commit. It only adds camera smoothing, not movement smoothing.

And thank you :P

Re: [Bonus] Source code tweaks

PostPosted: Wed Feb 25, 2015 22:08
by Linuxdirk
Krock wrote:Would you like to have over 9000 different settings?

If they’re all optional and with sane default and do not clutter minetest.conf: Yes, why not?