Commit Graph
186 Commits
Author SHA1 Message Date
Asdow a46d2dbb96 Add global to selectively log AI status BLACK decisions 2026-01-19 22:31:34 +02:00
Asdow 20dadec54c Merge branch 'master' into decideaction 2026-01-13 00:38:40 +02:00
Asdow f3ce1d5ff9 Fix Tank suppression fire
Code used wrong item to calculate recoil and burst APs causing the burst length loop to be stuck until the whole 2000 round mg magazine would be fired in one go.
2026-01-10 16:38:00 +02:00
Asdow f075963bca Merge branch 'master' into decideaction 2025-12-25 18:58:41 +02:00
Asdow 82aca548f5 Merge branch 'master' into ExtraMercs 2025-09-24 16:14:10 +03:00
BeatAroundTheBuscherandGitHub ed00830202 Fixes Upper/Lower Casing for include paths (#487)
* Fixing upper/lower case for includes

types.h, zconf.h and zlib.h were renamed so that global includes like Types.h
are not used.
2025-08-16 22:01:12 -03:00
Asdow c62d767622 Update to Master 2025-08-08 18:00:31 +03:00
Asdow dd58f904f4 Do not offer surrender for multiplayer 2025-04-24 21:52:11 +03:00
Asdow e3a542bf5d Exclude robots from trying to activate panic triggers 2025-02-14 16:47:03 +02:00
Asdow bfb724eab9 Use SoldierID 2024-12-01 18:23:52 +02:00
Asdow 24656f2810 Use SoldierID 2024-11-30 15:20:18 +02:00
Asdow b74ccf3ddc Convert to SoldierID 2024-11-17 23:45:48 +02:00
Asdow 10250dc035 Merge branch 'master' into ExtraMercs 2024-11-09 13:44:53 +02:00
AsdowandGitHub 49a119e6b9 Convert INVTYPE boolean fields to flagmask (#325)
Rearranged fields from largest to smallest to remove alignment padding
2024-08-22 08:48:29 +03:00
Asdow ab2c5fc10d Add BOXER() & ISVIP() macros 2024-02-18 12:03:43 +02:00
Asdow 67a26e0936 Add more AI logging 2024-02-11 11:21:41 +02:00
Asdow 1a98420160 Remove extraneous check
Allow at least considering throwing smoke for cover even if pSoldier has used some AP from its initial amount.
2024-02-10 18:56:11 +02:00
Asdow 877ec385ee Whitespace changes 2024-02-10 18:50:30 +02:00
Asdow 5c86cf0b07 Attempt to continue moving towards enemy
when in water. If our current or last action was AI_ACTION_SEEK_OPPONENT.

The AI tends to flipflop between jumping into water, swimming a certain distance and then "panic" because they're in the water and then try to reach the closest land tile. Which is often right where they entered the water. Adding a bit of decision momentum with this change should help with that.
2024-02-10 18:12:30 +02:00
Asdow 79372d5d23 Try to find a cover spot when advancing to attack
Calling InternalGoAsFarAsPossibleTowards() with target's gridno means AI doesn't take into account eg. nearby friendlies resulting in them bunching up and  making a beeline straight at whoever they're trying to attack.
We'll first at least attempt to find a cover spot near said target, if it doesn't work, only then head straight at them.
2024-02-04 21:05:54 +02:00
Asdow 0ed68b6214 Set functions to static 2024-02-04 16:17:36 +02:00
Asdow f646bc2bfa Set correct next action if npc has no AP
With aiData.bAction = AI_ACTION_NONE and aiData.bNextAction = AI_ACTION_END_TURN, the npc turn is correctly ended in the next call to TurnBasedHandleNPCAI()
2024-02-04 16:14:01 +02:00
Asdow f249406ba0 Allow specific alert status AI logging
Less clutter in the AI logs if, for example one is only interested in BLACK status decisions
2024-02-04 15:29:05 +02:00
Asdow ffb95a2418 Remove unused variable from if checks
aiData.bRTPCombat is never initialized and is always 0 when valid values should be

#define RTP_COMBAT_AGGRESSIVE		1
#define RTP_COMBAT_CONSERVE			2
#define RTP_COMBAT_REFRAIN			3
2024-02-03 20:49:43 +02:00
Asdow 22f2c9ff9a Correct AP check
We can't do anything with negative action points either.
2024-02-02 01:00:12 +02:00
Asdow a90e11619d Merge branch 'master' into decideaction 2023-10-10 23:21:12 +03:00
AsdowandGitHub b8a870df02 Reduce code duplication (#233)
* Use ConvertGridNoToCenterCellXY instead of CenterX & CenterY

* Add direction utility function

We have a lot of places in the code that calculate direction based on center cell coordinates, but lack a utility function for it similar to other direction methods.

* Use utility function for calculating direction

* Use ConvertGridNoToCenterCellXY

* Use utility function for direction

* Use ConvertGridNoToCenterCellXY instead of CenterX & CenterY

* Use ConvertGridNoToCenterCellXY instead of CenterX & CenterY

* Remove CenterX & CenterY functions

Use ConvertGridNoToCenterCellXY instead

* Remove CenterX & CenterY calls from UB configuration

* Address review feedback

* Remove duplicate function

ConvertGridNoToCenterCellXY and ConvertMapPosToWorldTileCenter do the exact same thing

* Use PythSpacesAway instead of GetRangeFromGridNoDiff

Both functions calculate the same thing

* Remove GetRangeFromGridNoDiff

* Remove calls to abs()

The values end up being squared anyways making these unnecessary
2023-10-07 15:14:15 +03:00
Asdow 1586e8fd2b Allow possibly taking cover without full APs 2023-10-02 22:28:56 +03:00
Asdow a45f3ae319 Add more AI logging 2023-08-20 23:38:56 +03:00
Asdow 318e4a40cf Improve AI logging 2023-08-19 23:23:59 +03:00
Asdow 1170f82159 Move variable declarations to point of initialization 2023-08-19 21:47:31 +03:00
Asdow d28ed97dff Add section comments do DecideActionRed 2023-08-19 21:45:01 +03:00
Asdow 96a7fa0538 Add section comments to DecideActionBlack 2023-08-19 14:41:16 +03:00
Asdow c5d1615035 Move decision if stuck in water or gas into its own function 2023-08-19 14:39:33 +03:00
Asdow a0cbe42a01 Create function for decision to wear a gasmask 2023-08-18 23:56:40 +03:00
Asdow 06478266d0 Moved armed vehicle/robot in gas check into function
Originally placed in DecideAction(green/yellow/red/black) functions separately
2023-08-18 23:11:39 +03:00
Asdow 613de1b869 Remove useless code
!AimingGun(pSoldier) would always evaluate to true and there are no hits to CrowDecideAction in the entire solution even in commented out code
2023-08-18 21:05:11 +03:00
Asdow 1c8d008a66 Move DebugAI() calls inside if blocks
Clutters logs and slows down game less when logging is on.
2023-08-17 19:49:55 +03:00
Asdow d99b12cb5f Allow status black cover advance with full AP 2023-08-16 23:08:03 +03:00
Asdow 070867d965 Check for closest known opponent in status black 2023-08-16 23:07:29 +03:00
Asdow 03482ffc3d Merge branch 'master' into ExtraMercs 2023-07-26 13:17:49 +03:00
AsdowandGitHub 35109a5615 Guard against possible illegal array access (by Seven) (#121)
ClosestPanicTrigger() can return -1 but its use in indexing gTacticalStatus.bPanicTriggerIsAlarm was not checked in all the places in the code
2023-01-31 20:26:21 +02:00
AsdowandGitHub ae1fd0a2ee Prisoner feature bugfix (#110)
* Allow game to continue after offering to surrender to enemies

* Fix issues related to surrender and POW quests

- Quests were ended prematurely if one had prisoners in both alma and tixa
- Strategic status flags for rescue/escape were not set properly
- Only the maximum amount a prison can hold will be taken as POWs, rest of the mercs will either escape or have to fight to the death, to prevent a player having unrescuable POWs
- Capturing a mercenary had a lot of functions called that should not have been, IF the merc is not going to be captured after all

* Switch all tactical surrender calls to use one unified function

* Only mercs that are capable can escape

Incapacitated mercs left behind will die.
Should probably prioritize incapacitated mercs to be captured by the enemy to prevent needless deaths

* Combine pow quest state changes into one function

* Add JumpIntoEscapedSector to header file

* Allow enemy to demand surrender even if they already have POWs in Tixa and Alma

* Remove surrender from UB

* Address review feedback
2023-01-22 23:35:08 +02:00
majcostaandGitHub 24425a82b1 More unused stuff removal (#49)
* More unused stuff removal

delete:
- giant 'metaheaders' (JA2 All.h, Laptop All.h, etc), preferring to add #includes directly where needed
- unused ExceptionHandling and DbMan translation units
- unused WizShare.h, Bitmap.h, trle.h, video_private.h headers

* remove mentions from vc proj files too

* remove preprocessor conditionals for unused definitions

find . -iname '*.h' -o -iname '*.cpp' -exec unifdef.exe -m -UPRECOMPILED_HEADERS -UJA2_PRECOMPILED_HEADERS -UWIZ8_PRECOMPILED_HEADERS -UPRECOMPILEDHEADERS {} ';'

then manually fixed a couple files the tool errored out on

* yes, the comments too

as title
2023-01-03 15:51:48 +02:00
Asdow 1f0a8f46e8 Import changes from the local SVN working copy 2022-10-10 10:08:44 +03:00
Sevenfm b11957691c Fix for critical bug introduced in r9182: replace CoweringShockLevel check which calculates suppression tolerance every time, with IsCowering, which uses cowering animation check.
DrawBarsInUIBox: fix possible divide by zero.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9184 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-10-16 16:07:31 +00:00
Shadooow f779c0cb37 Major rework of getting captured quests and mechanics.
- new feature: added Tixa as another prison where capture mercs can be held (Alma is still primary choice though)
- fix: all mercs in the map will be taken POW when surrendered, however only 3 will appear in Alma/Tixa/N7, rest will be POW forever without chance of getting free
- fix: whenever player liberates any of the POW sectors (Alma, Tixa, N7) the respective quest/cutscene with POW will be disabled in that sector until enemy recapture the sector
- robot will be destroyed when surrendered as it makes no sense to inprison mechanical units
- externalized the GridNos for freeing POW mercs into Mod_Settings.ini

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9095 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-06-21 13:53:56 +00:00
Sevenfm cf7588cacd Only show "sniper" message when shooter uses sniper rifle.
Disabled "sniper" message for vehicles.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9014 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-05-09 03:54:41 +00:00
Sevenfm b6f15b2347 Add robots to enemy groups (by rftr).
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8956 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-04-03 03:32:40 +00:00
Sevenfm 1abb292f8e New militia order: Move to (works in realtime only, switches militia soldier to DTATIONARY/DEFENSIVE).
Cancel current AI order when giving militia order.
Check if desired stance is possible here when ordering militia to crouch/prone.
Green AI: reworked climb code (only climb up, only at the start of the turn, disable for STATIONARY).

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8947 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-02-26 12:14:11 +00:00