increase hit% across the board

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
mattsc
Developer
Posts: 1169
Joined: October 13th, 2010, 6:14 pm
Location: Hidden on the hex behind Fred

Re: increase hit% across the board

Post by mattsc »

Crow_T: I think you missed this part (maybe you did not, but that is how it looks to me):
Insinuator wrote:Save for the Marksman & Magical abilities, ALL chances to hit are based off terrain, not weapon type.
Or check out the 4th paragraph here, starting with "Every unit has a chance of being hit based on the terrain it is in..."

For each unit type, this is defined in the [defense] tag. For most units, these are defined in the Wesnoth data directory in core/units.cfg. Scroll down to the end of the file, under "Move Types". So, if you wanted to hack the game to have it be more enjoyable for yourself locally, this is where you can do that. And then you could change some abilities like marksman or magic separately as explained above.

If you wanted it to work for, say, a campaign for others as well, then some of the suggestions made above would be better. (Well, that would be generally better than hacking the core files, but the hack would be the quick and dirty workaround.)
User avatar
alexanderthegre
Posts: 193
Joined: December 8th, 2011, 3:23 am
Location: nowhere

Re: increase hit% across the board

Post by alexanderthegre »

I got this code from BMR. I haven't tested it. The author of BMR probably wrote the macro, look in there somewhere.

Code: Select all

{FORCE_CHANCE_TO_HIT side=2 side=1 100 (
        [variable]
            name=turn_number
            less_than=10
        [/variable]
    )}
User avatar
Pentarctagon
Project Manager
Posts: 4508
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: increase hit% across the board

Post by Pentarctagon »

You could also create an era whose sole purpose was to give all attacks the special I posted before to all leaders in a turn 1 event, then give it to all attacks of all units that are recruited in a recruit event. For example, the recruit event would essentially be this:

Code: Select all

  [event]
    name=recruit
    first_time_only=no
    
    [object]
      silent=yes
      [effect]
        apply_to=attack
        [set_specials]
          [chance_to_hit]
            id=id_here
            name= _ "name here"
            description= _ "description here"
            add=20
            active_on=offense
            cumulative=no
          [/chance_to_hit]
        [/set_specials]
      [/effect]
    [/object]
    
  [/event]
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
JaMiT
Developer
Posts: 511
Joined: January 22nd, 2012, 12:38 am

Re: increase hit% across the board

Post by JaMiT »

If I may make an observation:

0.0655%
The chance that four heavy infantry would miss on all their attacks, assuming the chocobone was on 40% defense terrain. (The OP did not mention the chance to hit, but 40% is fairly common.) This is approximately a 1-in-1500 chance, so it is practically bound to happen sooner or later, given the number of combats per campaign, and the number of people playing campaigns.) Does that mean the system is flawed? Perhaps, but there are two other numbers I would look at:

0.00656%
The chance that four heavy infantry would miss on all their attacks, assuming the defense rating was lowered to 30%.

0.00168%
The chance that four units with three attacks each would miss on all their attacks, assuming the defense rating stayed at 40%.

You get a smaller chance of failure by using better tactics than by changing the system. Heavy infantry are usually a good choice against chocobones since chocobones are weak against impact and heavy infantry are strong against pierce. However, once the chocobone is down to "a tick of energy", the heavy infantry's low number of attacks is a significant liability. (Unless... well, there are other strategies that might have been applicable, but there is no need to go into them here, I think. My point is that alternatives might be worth considering, not that they have to be considered.)

That is not to say you should not alter your game locally to better suit you. Rather, it might be worth asking if you are overreacting and is this work worth it? (Reloading the turn once in a while seems to me to be the smaller price to pay.)

Also keep in mind that this change is a double-edged sword. Not only will you become more likely to strike down your foes, but your foes will be able to more easily break through your defensive lines. Some scenarios might even become unbeatable. Still, this is all theoretical. Nothing beats a nice, practical trial to see how something actually works out.


That being said, how about I contribute something to the implementation? Let's see... maybe an example (of the long way to implement this)? To make a chocobone easier to hit, you would look for
Original undeadfoot

Code: Select all

    [movetype]
        name=undeadfoot
        [movement_costs]
            deep_water=3
            shallow_water=2
            reef=2
            swamp_water=2
            flat=1
            sand=2
            forest=2
            hills=2
            mountains=3
            village=1
            castle=1
            cave=2
            frozen=2
            fungus=2
        [/movement_costs]

        [defense]
            deep_water=90
            shallow_water=80
            reef=70
            swamp_water=70
            flat=60
            sand=70
            forest=50
            hills=50
            mountains=40
            village=40
            castle=40
            cave=60
            frozen=70
            fungus=40
        [/defense]

        [resistance]
            blade=90
            pierce=70
            impact=110
            fire=120
            cold=40
            arcane=150
        [/resistance]
    [/movetype]
in the above-mentioned core/units.cfg and replace it with
Lowered defenses

Code: Select all

    [movetype]
        name=undeadfoot
        [movement_costs]
            deep_water=3
            shallow_water=2
            reef=2
            swamp_water=2
            flat=1
            sand=2
            forest=2
            hills=2
            mountains=3
            village=1
            castle=1
            cave=2
            frozen=2
            fungus=2
        [/movement_costs]

        [defense]
            deep_water=100
            shallow_water=90
            reef=80
            swamp_water=80
            flat=70
            sand=80
            forest=60
            hills=60
            mountains=50
            village=50
            castle=50
            cave=70
            frozen=80
            fungus=50
        [/defense]

        [resistance]
            blade=90
            pierce=70
            impact=110
            fire=120
            cold=40
            arcane=150
        [/resistance]
    [/movetype]
In addition, you would need to make a similar edit to core/units/undead/Skele_Chocobone.cfg, since a chocobone's village defense is overridden there. So basically, follow this example for all the [movetype]s in units.cfg, plus edit each [unit_type] that overrides defenses. (Hmm... there might be a reason others are favoring an object-based approach. ;) However, seeing how to do it the long way might give you a better understanding of what you are doing.)
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: increase hit% across the board

Post by zookeeper »

I think Pentarctagon's suggestion is the most convenient. Write an event (or several) which ensures that every unit receives such a +10% CtH weapon special on all their attacks, wrap those events in a macro and use that macro in every scenario you intend to play, or in every era you want to use.

The LessLuck Era (1.6) does something very similar, and you could use that as an example.
User avatar
Crow_T
Posts: 851
Joined: February 24th, 2011, 4:20 am

Re: increase hit% across the board

Post by Crow_T »

Thanks for the replies and the patience :)

Out of curiousity, when Insinuator said this:
First question, qualified yes. Each unit type, not each unit.
Which file would I be modifying? And would this code work there?

Code: Select all

[chance_to_hit]
  id=add_chance
  name= _ "add_change"
  description= _ "description"
  add=20
  active_on=offense
  cumulative=no
[/chance_to_hit]
Thanks again, I'll also look into modifying movetypes. I was thinking of increasing hit% but also increasing resistances a slight bit as a balance.
0.00168%
The chance that four units with three attacks each would miss on all their attacks, assuming the defense rating stayed at 40%.
I think maybe I need to set up my workstation like an old lady at bingo :lol2:
Insinuator
Posts: 706
Joined: January 6th, 2004, 10:42 pm
Location: Portland, OR

Re: increase hit% across the board

Post by Insinuator »

Crow_T wrote:Out of curiousity, when Insinuator said this:
First question, qualified yes. Each unit type, not each unit.
Which file would I be modifying? And would this code work there?

Code: Select all

[chance_to_hit]
  id=add_chance
  name= _ "add_change"
  description= _ "description"
  add=20
  active_on=offense
  cumulative=no
[/chance_to_hit]
Well, if I remember correctly, you can either define that as a macro within it's own separate file and reference it or within your scenario file. Then, you alter the Unit file directly by inserting your macro's name under the [specials] tag. Remember, though, you'll need to use

Code: Select all

#define NAME
&

Code: Select all

#enddef
to make your macro.
User avatar
Crow_T
Posts: 851
Joined: February 24th, 2011, 4:20 am

Re: increase hit% across the board

Post by Crow_T »

Ok thanks, I'm going to try modding the movetype list first, only because I'm still pretty new with the code and it seems easier. If I end up liking this and want to make a campaign that utilizes this custom unit.cfg, how do I go about referencing it? Thanks again, the help is much appreciated, I think this is finally sinking into my thick skull.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: increase hit% across the board

Post by zookeeper »

Crow_T wrote:Ok thanks, I'm going to try modding the movetype list first, only because I'm still pretty new with the code and it seems easier. If I end up liking this and want to make a campaign that utilizes this custom unit.cfg, how do I go about referencing it?
Editing your units.cfg (and some of the individual unit .cfg's if/when necessary) is only suitable for making your copy of Wesnoth work differently. If you want to do such changes in a campaign you want other people to be able to play, then you have to do it differently; either according to my/Pentarctagon's suggestion, or by only using custom units in your campaign (based on core units, obviously, with only their defenses changed).
User avatar
Crow_T
Posts: 851
Joined: February 24th, 2011, 4:20 am

Re: increase hit% across the board

Post by Crow_T »

Post Reply