Commit graph

364 commits

Author SHA1 Message Date
newfrenchy83
feef53d4ab
Add an 'alignment' attribute to attacks
This attribute, when set to a valid value of lawful|neutral|chaotic|liminal, will assign to the weapon a different alignment than the unit alignment used by default. This alignment is then used when attacking with this weapon.

The attribute is not accessible from lua so far since the fallback to unit alignment does not work.
2024-09-23 17:11:46 +02:00
Jonathan-Kelly
c4610a0283 Tests of events in [abilities] and [specials] tags 2024-09-16 21:07:38 -04:00
Steve Cotton
7f8e3344cf Add a second unit test for TEST_FORCE_CHANCE_TO_HIT
It should work even when the macro appears in the same event as the
attack; this tests that.

The new one uses the COMMON_KEEP macro, but I've left the existing
one unchanged, except for the renaming.
2024-09-13 19:15:56 +02:00
pentarctagon
d32a363ae8 plague tests 2024-09-10 18:14:50 -05:00
newfrenchy83
5c9065eb7e change calculation rules so that add and sub are always used independently
when two special weapons use multiply and divide with the same id, both operations are used, isn't that so why should it be different with 'add' and 'sub' where it's the larger value that is used (if asub=value_sub and add=value_add are used and value_sub>value_add then value_sub is used). This logic is counter-intuitive. that multiplication/division is applied to (base_value +- add/sub) is understandable but not this discrimination. For me add and sub should still be usable; even if it means changing the rules, but I think we will gain clarity in the end.
2024-09-08 14:16:28 +02:00
pentarctagon
9e756f9fc5 petrifies tests 2024-09-07 19:53:08 -05:00
Steve Cotton
547de5fd93 Test calculations of abilities with add and sub
Fix a typo in the add_sub_separated test, because it was testing
exactly the same code as add_sub_cumulative.

Add two new tests and clarify documentation, because in these tests
the order of the abilities determines whether the add or sub value is
used, it isn't that sub always overrides add.
2024-09-07 21:02:39 +02:00
newfrenchy83
c5351fb998
Fix recursion ability count version (#9296)
I use the same method what in master for weapon special recursion.
2024-09-07 16:45:26 +02:00
newfrenchy83
979289b579 fix tag_name check deficiencies
The tag_name check is deficient for two reasons:
1.when apply_to=both is used, in the case of [damage_type] [filter_opponent][filter_weapon]type= will check the modified type for application to the owner and the original type for application to the opponent, hence a risk of infinite recursion, especially if [filter_self][filter_weapon]type= is used in the same weapon.

2. in the case of apply_to=attacker/defender, the check for [filter_attacker/defender] must take into account both the value of the variable is_attacker but also the application AFFECT_SELF/OTHER, otherwise in the case apply_to=defender with [filter_defender][filter_weapon]type=, and[filter_attacker][filter_weapon]type= otherwise we end up in the same configuration as for apply_to=both

Finally tag_name is renamed check_if_recursion to mean that this variable is used to ensure that a recursion cannot be set up even if 743b146efc prevents it from causing a crash but with an error log
2024-09-05 18:35:35 -05:00
Steve Cotton
de342bb29c Fix typos in test of recursion 2024-09-03 18:39:22 +02:00
pentarctagon
96420da3d5 heal_on_hit tests - results are identical to drains aside from default value 2024-09-01 19:40:14 -05:00
pentarctagon
f22fb410a3 firststrike tests 2024-08-31 10:14:36 -05:00
newfrenchy83
67a491bb9b add test for apply_to=both and apply_to=attacker/defender when both type of self and opponent weapon are filtered.
if filtering type of damage in [damage_type] for both self and opponent when apply_to=both, it will create a recursion issue.

Idem for apply_to=attacker/defender when applied to opponent of owner of special.
2024-08-26 16:42:30 -05:00
pentarctagon
815739f1c2 drains tests 2024-08-25 20:46:15 -05:00
Steve Cotton
bd8a5fa038 Add tests for [store_locations] with an SUF
Prompted by a discussion over [filter_weapon][not]
when a unit has no usable weapon.
2024-08-19 00:17:37 +02:00
Steve Cotton
4afdc92f13 New ability recursion tests using a four cycle
Using four abilities instead of two means the C++ checking_tag
mechanism needs to handle multiple values, or needs to be supported
by recursion counting.

The branching test lets one level of recursion finish, and then tries
to go deeper. This tests for bugs where a recursion detection tool in
the engine gets its count reset when exiting one level of recursion.
2024-08-19 00:07:41 +02:00
newfrenchy83
f272d9022e Add tests for recursive weapon filters 2024-08-19 00:07:41 +02:00
pentarctagon
32063bfc7c add disable ability tests 2024-08-17 21:13:10 -05:00
Toom
31658e2587
Set unit hitpoints to 0 during [kill] (#9164) 2024-08-10 09:20:12 -05:00
pentarctagon
8bebc86b6a damage_type tests 2024-08-07 21:32:46 -05:00
Pentarctagon
3cef48fe38
damage ability tests (#9137) 2024-07-30 19:06:38 -05:00
Pentarctagon
124cf1ccf0
chance_to_hit tests (#9093) 2024-07-21 17:30:37 -05:00
Steve Cotton
302d78edc5 Reserve the name "_bug" for tests of behavior that should change
Even tests that don't have "_bug" in the name shouldn't prevent
intentional changes to behavior, I've added a paragraph about that.

Rewrite the non-reservation of "break" and "error" for clarity.
2024-07-20 11:19:51 +02:00
Toom
081866af7b
Add unit_hits, unit_misses events
Added new events "unit hits/misses" to simplify creating events that use attacker+defender hits/misses (issue #7782)
2024-06-30 12:02:55 +02:00
newfrenchy83
77d023690a Generalize the use of max_value and add the min_value attribute
In the case of [leadership], the fact that the values of each ability can be added when cumulative=yes can justify the addition of limit values not to be exceeded, but this can also apply to heals and [regenerates] with the use of 'add' or 'multiply'.

As for [resistance], it already uses max_value, but if cumulative=yes, then all max_values can add up which could be problematic.
2024-06-19 09:18:54 -05:00
Pentarctagon
a2993884cd
Add berserk weapon special abilities tests (#8973)
Changes:
* CHECK_STRIKES macro now takes a comma-delimited list of strike counts for when units have a different number of strikes for different weapons, and updates the existing usage in the attacks tests
* Fixed a typo in the attacks_zero test
* Adds tests for berserk as a weapon special ability.

Berserk's handling differs from attacks as a weapon special ability:
* A value less than 1 is treated as effectively infinite rounds of combat (undocumented)
* The cumulative attribute is handled differently - in some cases it sums the values instead of using the highest single value whereas for attacks it always uses the highest single value

Also now exclude data/tests/ from scons pot-update since it was hitting the argument limit for number of arguments to a script.
2024-06-15 20:20:54 -05:00
Steve Cotton
9cc0b15fbc Add a unit test for a weapon-special activating mid-attack
A weapon with poison, which does extra damage to poisoned opponents.
This tests that the weapon-special's filter is checked on each strike,
instead of being tested once and then cached during the battle.

(cherry picked from commit 55aa8b44cf)
2024-06-08 22:08:28 +02:00
newfrenchy83
1809af8cdf
Modify 'apply_to' in an ability filter to do an inclusion check for resistance abilities
Instead of needing to contain the exact string from the ability, 'apply_to' in the filter is now taken as a comma-separated list, where all elements need to be present in the ability.
For example if we filter for apply_to=fire,arcane given an ability [resistance]apply_to=arcane, fire, cold, it will match.
For an ability [resistance]apply_to=arcane, impact, cold, this will not match because 'fire' is missing.
2024-06-07 18:08:43 +02:00
newfrenchy83
3d097f2950 add [filter_wml] to filter abilities like [experimental_filter_ability], [experimental_filter_ability_active] or [overwrite][experimental_filter_specials]
adding a sub-filter should make it possible to take into account the sub_tags of the abilities in the checking
2024-05-21 14:54:44 +02:00
Steve Cotton
ac12be8342 Unit test cumulative resistance with a max_value
In 1.19 since 82499d0785, this will apply a
max_value of 15, which will also be the combined value.

The same test has surprising result on 1.18, the max_value attributes get added
together for a total max_value of 47, but the values don't, so the single
highest value of 30 is used.

(the corresponding 1.18 commit is 9632febdb5)
2024-04-24 14:52:22 +02:00
Steve Cotton
3fb8a91bc6 Unit test cumulative resistance with a base value
These tests clarify what "cumulative" means for non-leadership abilites,
which since Wesnoth 1.1.3 doesn't seem to fit the English word.

For cumulative abilities, if the base value from the unit is higher that
the ability's value, then the base value is used instead. In the case of
a Skeleton with 40% base resistance, "cumulative=yes" is equivalent to
"value,cumulative=40,no".

In all of these cases, a single ability's value is used; "cumulative"
doesn't mean that the values from multiple abilities interact.

This is all when using value=, not when using add= or sub=.

(cherry picked from commit 9b2016a4af)
2024-04-24 14:52:22 +02:00
newfrenchy83
c7080e0ecc
Select alternative damage type based on opponent resistances
If two [damage_type]alternative_type= are used with two different types, the chosen type displayed in the pre-combat window will be the one to which the opponent is most vulnerable. That type will then also be used in the attack if it is stronger than the original/replacement_type.

In the sidebar (report) all alternative_types are displayed.

---------

Co-authored-by: Gunter Labes <soliton@wesnoth.org>
2024-04-21 13:05:03 +02:00
newfrenchy83
82499d0785
add min_value to [resistance] (#8722)
max_value is used to limit the increase in resistance with the "resistance" capability, but there was no equivalent for its reduction.

To be able to add min_value without redoing the "resistance" checking for the umpteenth time, I prefer to modify effect:: so that the checking of these two attributes is done at the same time as the other numerical attributes and keep the door open to a possible generalization of the proceed
2024-04-11 04:48:41 +02:00
Steve Cotton
8e59da9186 Clearer documentation for the ATTACK_AND_VALIDATE macro 2024-04-09 00:28:22 +02:00
newfrenchy83
57c8e0cce0
Fix attack::damage_type bug for ability resistance
When [damage_type] is used but the opponent uses the resistance ability
against the added type, the ability filter only detected the original type and
the new type was not affected.
2024-04-04 18:01:36 +02:00
gfgtdf
851c909cd3
Fix #8460 [effect] apply_to=variation (#8475)
* Fix #8460 [effect] apply_to=variation

Previously the code could apply the variation effects
last, so that codes like
```
[effect]
  apply_to=variation
  ..
[/effect]
[effect]
  apply_to=hitpoints
  heal_full=yes
[/effect]
```
Would not set the unit hitpoints to the new variations
hitpoints because the variation effect was applied after
the healing effect.

In 1.16 this worked because healing was applied a little
too often but that lead also to bugs like #8342

* f prev

* f prev

* f prev

* f prev

* f prev

* Create modification_effect_type_variation.cfg

* Update wml_test_schedule
2024-03-07 01:25:59 +01:00
newfrenchy83
b4abee7c38
Fix increase by percentage returns 1 if experience is equal to zero (#8425)
Using `[effect]app/y_to,increase=experience,"40%"` on a unit with 0 XP used
to give that unit 1 XP, because of a minimum in the C++.
2024-02-19 13:49:09 +01:00
Steve Cotton
6b516e8aa5 Fix deprecation warning when setting [endlevel]end_credits=
Change the Lua implementation to directly call the
non-deprecated function, this is related to 9daa10a9f2.

Clean up the C++ header files by removing the declarations of
functions that were removed in 3c8de46771.

Use [endlevel]end_credits=no in the test scenario (trigger it
by moving to hex 9,3). If you debug with :next_level without
triggering the moveto, "The End" will show; trigger the moveto
first, and it won't show the credits.
2024-02-02 16:04:27 +01:00
Steve Cotton
84b1a778ae Backstab unit tests: check that backstab works in a free-for-all
The units on the outsides of a backstab don't have to be allied
to each other, they just have to be enemies of the victim. That's
hardcoded into the AI via attack.cpp's backstab_check() function,
hence a unit test to check that WEAPON_SPECIAL_BACKSTAB activates
in that situation.

Add a new map with 4 sides all on separate castles. This is a
variation of the generic 2p unit test map, extended in the south
with a horizontal reflection of existing map.

Add a MAP_FILE argument to COMMON_KEEP_A_B_C_D_UNIT_TEST,
because it's the same setup except for the map file.
2024-01-26 14:35:07 +00:00
Steve Cotton
87b42c404b Add a unit test for the event-handler reordering bug
This test would fail without the fix from the previous commit.
2024-01-21 01:38:48 +01:00
Steve Cotton
c25fc888a7 Make event_test_filter_condition check when the filters run
Also add the missing first_time_only=no, which is why the three [moveto]
events didn't trigger the third event three times.
2024-01-20 23:00:59 +01:00
Toom
2056be55a3
Support [harm_unit]experience values kill/attack/defend/fight/yes/no (#8231) 2024-01-18 11:32:18 +01:00
pentarctagon
26de1195e3 add a bunch of attacks tests 2024-01-08 12:04:45 -06:00
Steve Cotton
7c14bee3f8 Add tests for [harm_unit]
This is testing experience=yes and experience=no, with the expectation that
some new values for that attribute will be added afterwards.

Adds a new generic macro ASSERT_UNIT_HP_XP. Looking thorugh the ability tests,
ASSERT_UNIT_HP (without the XP) could be a heavily-used macro, but it wouldn't
be used by this particular commit, so I'm not adding it in this commit.
2024-01-04 17:50:49 +01:00
Pentarctagon
d4b1e7e6c4
Add some more abilities' tests (hides, skirmisher, teleport) 2024-01-01 12:34:08 +01:00
Pentarctagon
f992190267
add a bunch of illuminates tests. (#8139) 2023-12-23 12:07:45 -06:00
pentarctagon
23d7e3e7af add a comment. 2023-12-18 10:55:32 -06:00
pentarctagon
74e6f56d06 schema fixup. 2023-12-18 09:36:03 -06:00
pentarctagon
4080a6ebd0 max_value negative tests. 2023-12-17 23:42:35 -06:00
Pentarctagon
e94d4f0b7e
add a bunch of leadership ability tests (#8125) 2023-12-17 18:29:27 -06:00