21 Commits

Author SHA1 Message Date
RenechCDDA da2aaffffd Add quick setup option to clear map 2026-06-22 15:07:51 -04:00
thaelina ecb7ed024c Tests
Removed x_max x_cur x_bonus accesses outside of setters and getters in the character namespace
2026-03-02 03:17:11 -06:00
Andrew Krieger 0215b26cce Rewrite all tests to clear map without touching character map memory, for performance. 2026-02-08 23:05:55 -08:00
ehughsbaird b81b780afc terrain/furniture/field bashing can respond to more than bash damage (#81838)
* map/avatar bash return if they can smash

The skill/resistance are only used for this, so just simplify it.

* Use damage/hp for bashed objects

Add functions for bash data to generate damage/hp values, and use those
instead of directly querying str_{min,max}. This allows expanding how
furniture responds to damage in the future.

The bool arguments could be improved, but work well enough.

Sound shouldn't care about the supported/blocked strength, so just
ignore that, it won't be that different.

* Character/map bash respond to all damage types

Pass in a map of damage types and the amount, instead of just a strength
number.

Add a member to damage types that allows specifying how they convert
into bash damage. Right now, this is zero for all types but bash.

There are rough edges right now where this interacts with pathfinding
and monster bashing: those have a strength integer that they just
convert to {bash: strength}

For simplicity, keep a map::bash overload that takes integer strength,
and just converts it bash damage for the real bash function.

Special mention to the {{{}}} constructor, which is
pair{} -> initializer_list{pair{}} -> map{initializer_list{pair{}}}

* Monsters & pathfinding do bash by damage type

Instead of only bash damage.

This enables NPCs to properly pathfind based on their bash damage.

Enable specifying bash skill as more than just an amount of bash damage
for monsters. Not that anyone uses this in repo anyways. Update the
docs, including adding documentation for this feature.

* Allow specifying damage profile for bashing

Not everything will respond the same to attempting to break it in
different ways. Add infrastructure to allow specifying different
"profiles" for damage on bash data. Because there will be a fairly
limited set of these, and many objects will have the same, make a new
type for it, and just refer to it by id.

* Make bashing terrain/furniture deterministic

Because damage is stored, there's no reason to add a bunch of randomness
to this. Just directly apply damage, and update tests.

The "hp" for bash data can be updated to achieve the desired effect,
instead of rng.

* Add fireaxe test for bashing chances

Now that bashing can do multiple damage types, add a test case that uses
a weapon with a large non-bash damage component.

Because only bash is counted now, this doesn't look much different from
discarding the cut damage.

* Add bashing profile for wooden doors

As is seen in the famous documentary _The Shining_, fire axes are
relatively effective at breaking through doors. Add a bash profile that
favors cut damage, and apply it to wooden doors.

Adjust the tests to account for this.
2025-09-27 23:39:42 -05:00
ehughsbaird 5165d56efc Two small field fixes (#81837)
* Remove duplicate CHECK

Repeated two lines below.

* Fix bash fields for fields

Oops, the code to generate the fields was unreachable.
2025-07-16 12:34:08 +02:00
ehughsbaird 849ead96c6 Add tests for bashing creates fields
Tests for new feature. I would like to test it for fields too, but
bashing fields isn't handled in map::bash.
2025-07-08 15:38:20 +00:00
ehughsbaird 05a514a762 Merge pull request #81452 from ehughsbaird/79772
Somewhat relax shooting_at_terrain test passing criteria (Revive #79772)
2025-07-06 10:27:58 -04:00
moxian c44d65a8ae Run IWYU again to pick up the changes 2025-02-11 13:02:19 -08:00
moxian 2ee44002fd Mechanically IWYU the tests
python3 ~/github/include-what-you-use/iwyu_tool.py -j5 -p build $( find
src/ tests/ -maxdepth 1 -name '*.cpp' | grep -v -f
tools/iwyu/bad_files.txt )  --  -Xiwyu --comment_style=long -Xiwyu -
-max_line_length=1000 -Xiwyu --cxx17ns -Xiwyu
--mapping_file=../tools/iwyu/cata.imp   | tee out/iwyu/f-a-01.txt >
/dev/null

followed by

cat out/iwyu/f-a-02.txt | python3
~/github/include-what-you-use/fix_includes.py --reorder --nosafe_headers

followed by manual fixups of <stddef.h> -> <cstddef> and similar.

tests/generic_factory_test.cpp gets mangled very badly (IWYU bug) so
it's excluded from the list.

Code size:
includes:
$ cat obj/tiles/*.inc | wc
 288068  576136 17898260
$ cat tests/obj/tiles/*.inc | wc
 167044  334088 10465766

post-processed source (clang -E):
./make_preproc.sh src/
68567896 177775140 2134075721
./make_preproc.sh tests/
39341957 102891720 1243323710
2025-02-10 00:46:57 -08:00
osuphobia 3ca5327f8d fire more shots to ensure the test passes 2025-01-19 13:36:03 +08:00
Procyonae 982df19d0f Change /tests remaining uses of raw string item initialisation to use itype_id s
"remaining uses" being somewhat of an understatement -_-
2025-01-10 15:31:15 +00:00
Clarence "Sparr" Risher 8b27b967ae Replace point constants with static class members 2024-11-26 10:14:26 -05:00
ShnitzelX2 89657123e0 ter/furn code deduplication, improved "copy-from" support
Co-Authored-By: Procyonae <45432782+Procyonae@users.noreply.github.com>
2024-11-07 01:28:05 -05:00
PatrikLundell ef6b53acfb typified a little bit of map.h + dependents (#76340)
* typified a little bit of map.h + dependents
2024-09-27 15:10:36 -07:00
mqrause 4c69e47b2a change target_handler::trajectory to std::vector<tripoint_bub_ms> and then fix errors until it compiles again (#76671)
Co-authored-by: mqrause <martin@qrause.de>
2024-09-27 12:10:50 -07:00
PatrikLundell 4ba6a9f7a8 Typified parts of map.h/map.cpp + usages 2024-07-18 00:23:02 +02:00
Kevin Granade 9bd4e9d258 Add test for shooting terrain
This reproduces an error where shot is way too good at destroying terrain

Then fix the error, which was that the shot code wasn't exiting when hitting at point blank range, so each pellet was hitting as hard as the whole wad
2024-06-20 15:44:00 -07:00
Procyonae cc6ca5ddfc Remove extern furn ids (#72834)
* Part 1

* Part 2

* Part 3

* Part 4

* Part 5

* /tests

* Begone naughty lists

* Remove extern

* Appease our clang overlords

* I'm sorry clang daddy
2024-04-09 18:19:59 -04:00
Procyonae e9f4fbd110 Remove extern ter ids (#72766) 2024-04-04 07:08:37 -07:00
ehughsbaird 9ce6a995e7 Bashing furniture/terrain gradually gets easier
Bashing is frustrating. It's largely a result of RNG, because it does
not have persistent tracking of any data.

To fix this, add some semi-persistent (ephemeral) data to submaps to
track damage done to a tile. Change the formula for a successful bash to
use this data.

RNG is still a factor, but it will now take at most str_max - str_min
bashes once str_min has been exceeded.
2023-11-26 16:56:54 +00:00
ehughsbaird f5b21a6381 Add tests for ter/furn bash feasibility
These ensure bashing behavior stays consistent when changes are made to
it.
They're set up to verify the number of tries it takes to bash something,
but bashing behavior is pure RNG, so for now they just test if it is
possible.
2023-11-26 16:56:54 +00:00