1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-14 10:12:59 +02:00
Commit Graph

334 Commits

Author SHA1 Message Date
Andrii Danylchenko
33e0eeaa8a BattleAI: fix dragon breath 2024-07-22 20:39:32 +03:00
Xilmi
6f9309696d Merge remote-tracking branch 'upstream/develop' into develop 2024-07-21 19:06:14 +02:00
Ivan Savenko
1c522c49b6 Fix possible crash on trying to move to invalid battlefield hexes 2024-07-20 18:28:13 +00:00
Xilmi
fa2f883361 Merge remote-tracking branch 'upstream/develop' into develop 2024-07-19 15:26:31 +02:00
Ivan Savenko
63bcf7d83c Replaced most of usages of CRandomGenerator with vstd::RNG in library 2024-07-16 13:13:07 +00:00
Ivan Savenko
60a51e98de Remove usage of std::function from CRandomGenerator 2024-07-16 13:13:07 +00:00
Xilmi
a821978d4e Merge remote-tracking branch 'upstream/develop' into develop 2024-07-12 17:43:04 +02:00
Ivan Savenko
6b8f94e6e7 Merge remote-tracking branch 'vcmi/master' into develop 2024-07-11 17:43:44 +00:00
Xilmi
98415e98da Spellcasting-bug-fix
Fixed a bug that prevented the AI from using spells when attacking an enemy settlement that has towers.
The bug was caused by noticing how greatly effective spells would be against towers but not being able to actually target them.
By skipping invalid targets, this no longer is an issue.
2024-07-10 14:36:35 +00:00
Xilmi
073c5bee45 Spellcasting fixes
Allowed the AI to cast spells that are aimed at a location instead of a unit. For example meteor shower.
Fixed an issue that caused the AI to not kill unit-stacks with spells due to only considering stacks where at least one unit survives in it's score-calculations.
2024-07-10 02:40:42 +02:00
Xilmi
13bbb573bd Spellcasting-bug-fix
Fixed a bug that prevented the AI from using spells when attacking an enemy settlement that has towers.
The bug was caused by noticing how greatly effective spells would be against towers but not being able to actually target them.
By skipping invalid targets, this no longer is an issue.
2024-07-09 22:55:39 +02:00
Alexander Wilms
02e429e973 Fix typos using https://github.com/crate-ci/typos
Changes were reviewed manually
2024-06-24 03:47:19 +02:00
Ivan Savenko
3bea383b59 Merge branch 'vcmi/beta' into 'vcmi/develop' 2024-06-21 12:58:36 +00:00
Ivan Savenko
0e4be8c776 Fix crash on sieging Citadel or Castle 2024-06-19 19:59:06 +00:00
Ivan Savenko
a9cf322f61
Merge pull request #4161 from vcmi/fix-4142
#4142 - sometimes Battle AI wants to attack unit which is behind a lo…
2024-06-19 21:28:58 +03:00
Andrii Danylchenko
fc32078a3a #4142 - sometimes Battle AI wants to attack unit which is behind a lot of obstackles and other units 2024-06-18 20:03:07 +03:00
Ivan Savenko
b7efa6c8cc Fixed potential thread races in Battle AI 2024-06-17 16:15:19 +00:00
Ivan Savenko
eb67e04ccb Remove old and unmaintained codeblocks project 2024-05-17 10:44:57 +00:00
Ivan Savenko
3f6eb13ee0 Delete old and unmaintained msvc project files 2024-05-17 10:44:11 +00:00
Andrii Danylchenko
0935f931fa BattleAI: fix bypassing 2-hex moat 2024-04-20 15:28:57 +03:00
Ivan Savenko
ced0bbe526 Remove "catch everything and silently ignore" block 2024-04-16 18:54:51 +03:00
Ivan Savenko
9e49587749 Replace bonus string description with metastring that can properly
handle translations
2024-04-09 16:13:30 +03:00
Ivan Savenko
7359b66f99 Do not use floating point equality checks 2024-02-14 12:07:07 +02:00
Ivan Savenko
9ebd194ab1
Merge pull request #3609 from IvanSavenko/single_process
Allow running server as part of client process
2024-02-14 12:06:22 +02:00
Ivan Savenko
4c70abbeb5 Reduced usage of global variables - removed or made const / constexpr 2024-02-12 13:49:45 +02:00
Ivan Savenko
a909d7ddde Removed cmake_modules/VCMI_lib macro, use it directly in place 2024-02-11 20:38:24 +02:00
Ivan Savenko
f08c9f4d59 Renamed ENABLE_STATIC_AI_LIBS option to match its actual effect 2024-02-11 17:55:02 +02:00
Andrii Danylchenko
ec5c44bb92
Merge pull request #3594 from vcmi/fix-3550
#3550 - fix case when unit is in reachability map but only next turn
2024-02-04 10:07:44 +02:00
Andrii Danylchenko
c66de29550 #3550 - fix case when unit is in reachability map but only next turn 2024-02-03 17:48:52 +02:00
Ivan Savenko
a9866bb5c6 Added RandomGeneratorUtil::nextItemWeighted convenience method 2024-01-31 00:17:40 +02:00
Ivan Savenko
d5c4478816 Remove most of non-const access to VLC entities 2024-01-19 13:54:49 +02:00
Ivan Savenko
bd5682ecc3 Merge remote-tracking branch 'vcmi/master' into develop 2024-01-19 13:49:54 +02:00
Alexander Wilms
73019c204d Replace redundant types with auto for the lvalues of template factory functions for smart pointers
grep -r --include \*.h --include \*.cpp "= std::" * | grep -v auto | grep -Po ".*[^ ]+ [^ ]+ [^ ]*[ ]*=.*;" | grep -v "auto\|int\|char\|bool\|float|\double\|for\|if\|googletest\|fuzzylite\|size_t\|using\|return" | grep -v double | grep -v si64 | grep -v si32 | grep -v ui32 | grep \< | grep -v float | tr -d '\t' | grep -v assert > redundant_types.txt

import re

with open("redundant_types.txt") as f:
    for line in f:
        line = line.strip()
        path = line.split(":", 1)[0]
        original_code = ":".join(line.split(":")[1:]).strip()

        print()
        print(path)
        print(original_code)
        prefix = "auto "
        if original_code.startswith("static"):
            static = True
        else:
            static = False

        cpp_type = " ".join(original_code.split("=")[0].strip().split(" ")[0:-1])
        print(cpp_type)

        if static:
            new_code = "static auto "+ " ".join(original_code.split(" ")[2:])
        else:
            new_code = "auto "+ " ".join(original_code.split(" ")[1:])
        print(new_code)

        if True:
            with open(path, "r") as f:
                filedata = f.read()

            filedata = filedata.replace(original_code, new_code)

            with open(path, "w") as f:
                f.write(filedata)
2024-01-17 12:50:00 +00:00
Ivan Savenko
a582cb554e
Merge pull request #3500 from IvanSavenko/fix_dendroid_bind
[1.4.3] Fix handling of Dendroid's Bind ability
2024-01-15 12:02:06 +02:00
Ivan Savenko
0d0d3d8c80 Renamed speed -> getMovementRange, remove misleading default parameter 2024-01-14 17:14:36 +02:00
Andrii Danylchenko
3602be5eab BattleAI: remove adjustPositions method as it gives more troubles than usefulness 2024-01-14 10:23:44 +02:00
Alexander Wilms
f3277b7953 Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
Andrii Danylchenko
1a1ae5cd8b BattleAI: fixes 2024-01-02 17:35:10 +02:00
Ivan Savenko
85de3143ff Fixed Genie spellcasting logic to account for spell immunities 2023-12-24 01:13:19 +02:00
Dydzio
fe39faf36c Add UNTIL_OWN_ATTACK bonus duration and use for berserk 2023-12-19 19:52:40 +01:00
Ivan Savenko
d326c53b9a AI will now respect current value of "Use spells in autocombat" setting 2023-11-28 15:48:35 +02:00
Ivan Savenko
b58301849b Pass functor via reference to avoid costly copies 2023-11-18 19:43:11 +02:00
Ivan Savenko
9b8145f522 Compute creature speed only once during evaluation 2023-11-18 19:41:29 +02:00
Alexander Wilms
5cbc75d3b7 Merge remote-tracking branch 'upstream/develop' into develop 2023-10-29 13:35:37 +00:00
Alexander Wilms
ed86a917eb AI/BattleAI/BattleAI.cpp: Use Class template argument deduction for wallParts array
Co-authored-by: Ivan Savenko <saven.ivan@gmail.com>
2023-10-29 13:34:19 +00:00
Alexander Wilms
0232ae5327 AI/BattleAI/BattleEvaluator.cpp: Convert this integer literal to a bool literal.
Integer literals should not be cast to bool
2023-10-29 13:34:19 +00:00
Alexander Wilms
bfddc90ff4 AI/BattleAI.cpp: Use "std::array" or "std::vector" instead of a C-style array.
Variables of array type should not be declared cpp:M23_356
2023-10-29 13:34:19 +00:00
Ivan Savenko
0169c65937
Merge pull request #3100 from IvanSavenko/split_net_packs
Split netpacks.h into multiple files
2023-10-29 13:46:40 +02:00
Alexander Wilms
457e73ed12 AI/BattleAI/BattleExchangeVariant.cpp: Do not assign data members in a constructor. Initialize members in an initialization list.
Member data should be initialized in-class or in a constructor initialization list
2023-10-27 23:34:11 +00:00
Alexander Wilms
b10b1a5444 AI/BattleAI/BattleExchangeVariant.cpp: This function should be declared "const".
Member functions that don't mutate their objects should be declared "const"
2023-10-27 23:34:11 +00:00
Alexander Wilms
af330ff038 AI/BattleAI/BattleEvaluator.cpp: Remove this redundant cast.
Redundant casts should not be used
2023-10-27 18:19:17 +00:00
Ivan Savenko
5cbf5031ea move SetStackEffect to a separate file 2023-10-24 01:27:52 +03:00
Ivan Savenko
b88a8da4e8 Split off some netpack structures into separate files 2023-10-23 13:59:15 +03:00
Andrii Danylchenko
f74daa2e1f BattleAI: fix health bounty calculation 2023-10-22 22:06:42 +03:00
Andrii Danylchenko
870fbd50e3 BattleAI: bigger reachability map 2023-10-22 21:37:55 +03:00
Andrii Danylchenko
9eb9404f28 BattleAI: divide only positive part of score onto turns count 2023-10-22 21:37:54 +03:00
Johannes Schauer Marin Rodrigues
a1a5bc28c2
convert line endings from CRLF (Windows) to LF (Linux/Unix)
Mixed line endings cause problems when exporting patches with
git-format-patch and then trying to "git am" a patch with mixed and
non-matching line endings. In such a situation git will fail to apply
the patch.

This commit runs the dos2unix tools on the remaining files with CRLF
(\r\n) line endings to convert them to line-feeds (\n) only.

Files that are Windows specific like *.vcxproj and *.props files were
not converted.

Closes: #3073
2023-10-19 16:23:21 +02:00
Ivan Savenko
ef94e7a78a Fix build 2023-09-06 16:03:47 +03:00
Ivan Savenko
9fa7a93fb0 Properly pass battleID in all battle netpack's 2023-09-06 16:03:47 +03:00
Ivan Savenko
036df2e0ad Support multiple battles in AI 2023-09-06 16:03:46 +03:00
Ivan Savenko
3a88180494 Separated game and battle callback (server & client only) 2023-09-06 16:03:39 +03:00
Ivan Savenko
86a7f5f5cd Removed getStr(bool), replaced with similar toString() 2023-09-04 22:21:02 +03:00
Ivan Savenko
f6a4a1ae0c
Merge pull request #2686 from vcmi/fix-battle-freeze
BattleAI: fix freeze
2023-08-31 01:06:47 +03:00
Ivan Savenko
695a51d8c8 Merge remote-tracking branch 'vcmi/beta' into develop 2023-08-28 21:19:53 +03:00
Andrii Danylchenko
4b807e01f1 BattleAI: fix freeze 2023-08-27 21:03:55 +03:00
Andrii Danylchenko
5f13a0bbda BattleAI: spellcast fixes and floating point score 2023-08-26 14:17:33 +03:00
Andrii Danylchenko
dc88f14e0b BattleAI: positive/negative effect multiplier 2023-08-26 13:06:51 +03:00
Andrii Danylchenko
03395a3d8a TBB for battle AI spellcast an fixes 2023-08-26 13:06:51 +03:00
Andrii Danylchenko
274bf739b8 BattleAI: damage cache and switch to different model of spells evaluation 2023-08-26 13:06:51 +03:00
Ivan Savenko
0240ee886d Converted (almost) all namespace enum's to enum classes 2023-08-25 13:38:02 +03:00
Ivan Savenko
2be9664d26 Remove no longer used code 2023-08-21 17:55:49 +03:00
Ivan Savenko
013417fb7e Code cleanup 2023-08-21 17:55:49 +03:00
Ivan Savenko
a1d3181a98 Unified spellcasting handling with other actions 2023-08-21 17:55:49 +03:00
Ivan Savenko
6297140bf5 Start of stabilization - battles now start correctly 2023-08-21 17:55:49 +03:00
Dydzio
6bfbe80cc9 Allow toggling quick combat spells usage 2023-08-19 17:23:55 +02:00
Andrii Danylchenko
ba9998ac66 BattleAI: fast targets optimization 2023-08-08 20:10:29 +03:00
Andrii Danylchenko
e7394ad20c BattleAI: log time to make a decission 2023-08-08 18:54:49 +03:00
Andrii Danylchenko
f1a9ae99ee NKAI: various behavior fixes, undo max_gold_preasure 2023-07-31 22:01:12 +03:00
Ivan Savenko
aed8c411fc Minor rework & cleanup of combat replays 2023-07-27 19:25:55 +03:00
Ivan Savenko
e23166df88 Fix locking of mutexes by StupidAI 2023-07-24 23:01:18 +03:00
Ivan Savenko
639880a426 Fix handling of tactics by AI 2023-07-23 14:03:22 +03:00
Ivan Savenko
58dd87d727 Fix AI spellcasting 2023-07-19 12:54:23 +03:00
Ivan Savenko
556763fb7b Fixed handling of tactics 2023-07-18 22:02:35 +03:00
Ivan Savenko
1bf6bbd9b6 Significantly simplified threading model in battles 2023-07-18 19:55:59 +03:00
Ivan Savenko
f27f5ebc7c Split BattleAI::activeStack into several smaller methods 2023-07-18 17:35:19 +03:00
Andrii Danylchenko
fe65edd55d BattleAI: stacks should not measure damage against turret 2023-05-10 09:22:13 +03:00
Konstantin
05eccbc2bb vcmi: split bonus to enumerator and HeroBonus.h 2023-05-03 18:01:06 +03:00
Konstantin
fbc05c70ac vcmi: camelCase methods of new classes
Also use EGameSettings for clamping morale and luck
2023-05-02 12:09:13 +03:00
Konstantin
a6de9097be vcmi: rename HeroBonus.h to Bonus.h 2023-05-02 11:20:58 +03:00
Konstantin
6fa1b2b19f vcmi: move bonuses to its own folder 2023-05-02 00:53:50 +03:00
Konstantin
86f5d6de69 vcmi: modernize headers 2023-04-30 13:35:54 +03:00
Konstantin P
b472c89276 vcmi: make some CStack properties private
There is a getters for this properties already available
2023-04-27 20:58:49 +03:00
krs
e348193f7e Tactics movement is limited to movement range 2023-04-26 21:56:20 +04:00
Konstantin
7a5775a9f9 vcmi: use std::optional 2023-04-17 00:43:13 +03:00
Nordsoft91
3951bbb395
Merge pull request #1108 from Nordsoft91/battle-dialog
[HDMod features] Quick combat
2023-04-11 21:18:04 +04:00
Ivan Savenko
dfa2e2a349 Merge beta into develop 2023-04-11 19:37:35 +03:00
nordsoft
bfc75ccd39 Merge remote-tracking branch 'upstream/develop' into battle-dialog 2023-04-11 02:22:42 +04:00
Andrii Danylchenko
737c34b8c6 BattleAI: avoid selfblocking on siege 2023-04-09 16:22:37 +03:00
krs
dab07bdef9 Now unit range is shown in Tactics phase as well
A new parameter: isActiveStack was needed in battleGetAvailableHexes, so that we show the propper Tactics range.
2023-04-08 20:39:59 +03:00
nordsoft
ce3028bd73 Intermediate commit 2023-04-06 19:34:07 +04:00