Compiling with Saurons mod

General feedback and discussion of the game.

Moderator: Forum Moderators

Post Reply
User avatar
Crow_T
Posts: 851
Joined: February 24th, 2011, 4:20 am

Compiling with Saurons mod

Post by Crow_T »

I was wondering if it was possible to compile using http://forums.wesnoth.org/viewtopic.php?f=15&t=26803, and how to actually do it- what code needs to be replaced, and in what file, and if Sauron's code is still even valid in 1.10/1.11

Code: Select all

    void adjustDamage(   bool &hits, //standard wesnoth roll result
                   bool &temp_results_hits, //adjusted roll result
                   int &ran_num,//for storing randoms
                   const float&split_ratio,//part of damage inflicted for sure
                   const int &stats_chance_to_hit_target,//original cth
                   int &stats_damage_target_takes,//effective inflicted damage
                   const int & temp_stats_damage_target_takes,//original unit's damage per hit
                   const int &smooth_distribution)//amount of randoms to generate result
    {
       float temp_smooth_distribution_damage=0;
       int  temp_smooth_distribution_hits=0;

       if(split_ratio)
       {
          stats_damage_target_takes=ceil((split_ratio* stats_chance_to_hit_target*temp_stats_damage_target_takes)/100.0);
          if (hits)
          {
                temp_smooth_distribution_damage+=(1-split_ratio)*temp_stats_damage_target_takes;
                temp_smooth_distribution_hits++;
          }
          for(int i=1;i<smooth_distribution;i++)
          {
             ran_num = get_random();

             hits = (ran_num%100) < stats_chance_to_hit_target;
             if (hits)
             {
                temp_smooth_distribution_damage+=(1-split_ratio)*temp_stats_damage_target_takes;
                temp_smooth_distribution_hits++;
             }
          }

          stats_damage_target_takes+=floor(   temp_smooth_distribution_damage/(float)smooth_distribution);
          temp_results_hits=((temp_smooth_distribution_hits/(float)smooth_distribution)>=(stats_chance_to_hit_target/100.0));
          hits=1;
          resources::state_of_game->set_variable("damage_inflicted",
                    str_cast<int>(stats_damage_target_takes));
       }
       else if(smooth_distribution>1)
       {
          if (hits)
          {
                temp_smooth_distribution_damage+=temp_stats_damage_target_takes;
                temp_smooth_distribution_hits++;
          }
          for(int i=1;i<smooth_distribution;i++)
          {
             ran_num = get_random();

             hits = (ran_num%100) < stats_chance_to_hit_target;
             if (hits)
             {
                temp_smooth_distribution_damage+=temp_stats_damage_target_takes;
                temp_smooth_distribution_hits++;
             }

          }
          stats_damage_target_takes=round__(   temp_smooth_distribution_damage/(float)smooth_distribution);
          temp_results_hits=((temp_smooth_distribution_hits/(float)smooth_distribution)>=(stats_chance_to_hit_target/100.0));
          hits=1;
          resources::state_of_game->set_variable("damage_inflicted",
                    str_cast<int>(stats_damage_target_takes));
       }
       else //standard Wesnoth formula
       {
          temp_results_hits=hits;
          if(hits) {
             stats_damage_target_takes = temp_stats_damage_target_takes;
             resources::state_of_game->set_variable("damage_inflicted",
                       str_cast<int>(stats_damage_target_takes));
          } else {
             stats_damage_target_takes = 0;
          }
       }
    }
User avatar
iceiceice
Posts: 1056
Joined: August 23rd, 2013, 2:10 am

Re: Compiling with Saurons mod

Post by iceiceice »

Looking at the changelog, it looks like this was intended to be playable with "default" clients, and there were various OOS issues "fixed" at various points. I'm all but certain this wouldn't work in 1.12.

I would suggest to try applying the patch in 1.8 first, where it probably works, then try 1.10 and see if it works, if you are interested in using it.
User avatar
Crow_T
Posts: 851
Joined: February 24th, 2011, 4:20 am

Re: Compiling with Saurons mod

Post by Crow_T »

yeah, the build failed, oh well. Seems like in the 1.6 days there were a few efforts to create alternate battle systems- perhaps I'll try again using 1.8 sometime.
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Compiling with Saurons mod

Post by Pentarctagon »

There have been other attempts through less-luck/no-luck eras. Perhaps you would be able to take some of the code from those and make a alternative-luck coremod in 1.12.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
iceiceice
Posts: 1056
Joined: August 23rd, 2013, 2:10 am

Re: Compiling with Saurons mod

Post by iceiceice »

Hmm so I think that would be a bit hard, coremod will let you swap out configs but not C++ parts of the engine.

If we wanted core mods to allow you to change things like this, we would have to write a lua hook that lets you run lua in place of the wesnoth attack pathway... I think this was earlier requested by Crow_T also. It's not a bad idea imo.
User avatar
Crow_T
Posts: 851
Joined: February 24th, 2011, 4:20 am

Re: Compiling with Saurons mod

Post by Crow_T »

These are some early errors I get trying to build 1.10.7 + Sauron code, is this something I can fix?:

Code: Select all

src/game.cpp:177:3: error: ‘new_syntax’ is not a member of ‘game_config’
src/game.cpp: In function ‘int do_gameloop(int, char**)’:
src/game.cpp:360:2: error: ‘wesnoth_program_dir’ is not a member of ‘game_config’
src/game.cpp:370:6: error: ‘new_syntax’ is not a member of ‘game_config’
src/font.hpp: At global scope:
src/font.hpp:64:2: warning: ‘font::SIZE_TINY’ defined but not used [-Wunused-variable]
src/font.hpp:65:2: warning: ‘font::SIZE_SMALL’ defined but not used [-Wunused-variable]
src/font.hpp:67:2: warning: ‘font::SIZE_15’ defined but not used [-Wunused-variable]
src/font.hpp:68:2: warning: ‘font::SIZE_PLUS’ defined but not used [-Wunused-variable]
src/font.hpp:69:2: warning: ‘font::SIZE_LARGE’ defined but not used [-Wunused-variable]
src/font.hpp:70:2: warning: ‘font::SIZE_XLARGE’ defined but not used [-Wunused-variable]
scons: *** [build/release/game.o] Error 1
scons: building terminated because of errors.
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Compiling with Saurons mod

Post by Dugi »

For short, the old code contains calls to variables game_config::new_syntax and game_config::wesnoth_program_dir and they're inaccessible. game_config::wesnoth_program_dir still exists, there must be another reason why it was not found. game_config::new_syntax no longer exists and I have no idea what might it be, maybe somebody who was active in the times of old could reply to this. There might be more errors in other files, so expect that fixing this issue might be actually harder.

I wasn't able to find the source code of Sauron's mod (all the links seemed dead), maybe you could post it here in a suitable form. Without the source code, it's hard to tell where's the problem, the chunk of code you posted is very unlikely to be responsible for these errors.

If I was you, I'd look at the differences between Sauron's code and current code, understand what he changed and do the changes manually. Some functions could have been simply renamed and the patch would break it.
User avatar
Crow_T
Posts: 851
Joined: February 24th, 2011, 4:20 am

Re: Compiling with Saurons mod

Post by Crow_T »

Hey Dugi, the files are here: http://forums.wesnoth.org/viewtopic.php ... 03#p379338 The modified source files [zip] link. I tried building in 1.8 but there was a different error, one that came up much sooner in the build:

Code: Select all

Checking for Lua development files version 5.1... (cached) no
Client prerequisites are not met. wesnoth, cutter and exploder cannot be built.
Unit tests are disabled because their prerequisites are not met.
If any config checks fail, look in build/config.log for details
If a check fails spuriously due to caching, use --config=force to force its rerun
NLS tools are not present...
NLS catalogue installation is disabled.
scons: done reading SConscript files.
scons: Building targets ...
error_action(["wesnoth"], [])
scons: *** [wesnoth] Target disabled because its prerequisites are not met
scons: building terminated because of errors.
I really don't know what I am doing, I am simply writing sauron's files over the similarly named files in the src folder then building- one thing I am changing, Sauron's wesconfig.h refers to version 1.6.x, I am changing that line to match the version I am trying to build. (The first build fail I didn't change it, not sure how much it matters) :oops:

I'm also looking into this which may be easier(from the same link mentioned above): [C++] Damage System MOD(or Less Luck MOD) by A&J Edit: *nope, get the same font related errors there too. I think I may have to move on...
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Compiling with Saurons mod

Post by Dugi »

Replacing entire files between versions with such a large time difference is very bug-prone. Try to use diff to compare them with files with same names from wesnoth 1.6 source and copy only the changes, that's more likely to work.

The 1.8 error means that you have some unmet prerequisites, probably something that 1.8 needed and 1.10 doesn't need. Read the log to find what it's missing. This is related to wesnoth 1.8, not to Sauron's mod, so some problems are likely to appear there as well (if you get through this problem).
User avatar
Crow_T
Posts: 851
Joined: February 24th, 2011, 4:20 am

Re: Compiling with Saurons mod

Post by Crow_T »

All that stuff is beyond me- I'll just stick with the prng mod. The other mod, the damage system mod, is only 3 files, so I may focus on getting that to work instead.

Edit: scratch that, I'm downloading 1.6 instead :geek: Which I can't get to build either. I have no idea how you coders do it, I'm going back to painting :doh:
Post Reply