Commit Graph
346 Commits
Author SHA1 Message Date
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
kitty624 b13bcaac71 Update Items.cpp
reworking r9343

- the part about Food System is obsolete, already was happening in code prior to r9343

- the flags got removed and a boolean is used instead, allowing a simpler function for the remaining disease

- wether an item is considered exclusive to disease feature or not is decided by usage of tag in items.xml
2024-04-15 01:33:47 +02: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
Marco Antonio Jaguaribe Costaandmajcosta b68f206969 remove annoying warning on MSVC 19.37.32822
`register` keyword does exactly nothing:
https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5033?view=msvc-170
2023-10-07 09:13:55 -03:00
sun-alf 5bfd19e5a8 [Fix] One of optimizations in (2482234e) commit is not suitable for MOLLE stuff in 1.13
It is revealed, MOLLE things in 1.13 are configured in XMLs using both NAS and OAS (old attachment system) methods even if NAS is enabled in New Game Options. Given this, logic of SetAttachmentSlotsFlag() cannot be splitted onto NAS and OAS parts, and both Attachment[] and AttachmentPoints must be checked disregarding the NAS option.
2023-09-14 01:04:55 +03:00
sun-alf f8637e5972 [~] Performance optimizations around Attachment[] and Launchable[] arrays
AIMNAS with its ~50K elements in Attachment[] suffered of performance drop when MOLLE stuff is in the visible inventory. To resolve it the following is done:
* Introduce gMAXATTACHMENTS_READ with actual number of elements in Attachment[]; according refactoring.
* Introduce gMAXLAUNCHABLES_READ with actual number of elements in Launchable[]; according refactoring.
* Introduce std::multimap AttachmentBackmap for quick access to attachments using itemId as a key.
* Sort Attachment[] by attachmentIndex right after loading from XML. According order in XML is not needed anymore.
* Introduce FindAttachmentRange() for quick access to attachments using attachmentId as a key (binary search in Attachment[]).
In a few words, GetHelpTextForItemInLaptop(), ValidAttachment(), SetAttachmentSlotsFlag() were heavily optimized.
2023-09-08 21:58:14 +03:00
Asdow 03482ffc3d Merge branch 'master' into ExtraMercs 2023-07-26 13:17:49 +03:00
sun-alf 9fc9d1c6e8 [Fix] Incorrect displaying info and tooltips in Advances Properties Tab
* Tooltips were shifted by one position due to wrong handling "Accuracy modifier".

* DrawAdvancedValues():
    if ( iFloatModifier[0] > 1.0 || ( fComparisonMode && iComparedFloatModifier[0] > 1.0 ) )
it checks number of laser range tiles  (iFloatModifier[0] > 1.0, "meters" / CELL_X_SIZE) right before actual drawing a line with values. So if someone put 1..9 into XML (<BestLaserRange>) it will not print that value. But number of "meters" was checked (like x > 0) everywhere prior to this code.
so all the code before decided to draw line with icon for laser range, but the guilty code line didn't
I suppose not to draw laser info at all if a modder screwed up <BestLaserRange> putting a 1..9 value
so all values 0..9 basically mean 0 tiles, i.e. there is no laser ability.
2023-05-27 21:04:17 +03:00
sun-alf ab2a26accb [Fix] A bunch of fixes for artillery strike
* Avoid using hard-coded Signal and HE mortar shell indices. This caused art.strikes malfunctioning in item mods.
* Trim max nubers of waves to duration of signal smoke. Otherwise art.strike turns into unnatural stupidity.
* If enemy AI tried to get art.strike but lacked of resources, player will not a warning anymore.
2023-05-22 22:06:18 +03:00
Marco Antonio Jaguaribe CostaandAsdow d4abc82488 Address review feedback 2023-01-19 00:13:08 +02:00
Marco Antonio Jaguaribe CostaandAsdow 8b1c4effa0 nuke all the #if 0's
scripted commit:

find . -not -path '*/.*' -and -not -path '*/ext*' -type d -exec coan source -R -E {} ';'

https://coan2.sourceforge.net/coan_man_1.html
2023-01-19 00:13: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 904fae7a96 CancelDrag, StartDrag: update interface panel to change drag icon status.
DrawTraitRadius uses usColour.
Allow to start dragging from any stance, soldier will crouch automatically.
Show draggable objects when drag skill menu is active.
Press [\] key to start dragging object/solder/corpse in front of merc.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9369 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2022-04-24 18:21:44 +00:00
rftr 746d15a1ba remove magic numbers from the usLimitedToSystem bitflag
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9355 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2022-04-02 01:11:25 +00:00
Asdow c334d4a0d4 Optimize RandomMagazine() called when deploying to tactical sector (by sun_alf)
Timings
Before:
RandomMagazine: 90044 us (total 90044 us)
RandomMagazine: 90007 us (total 180051 us)
RandomMagazine: 100009 us (total 280060 us)

After:
RandomMagazine: 0 us (total 0 us)
RandomMagazine: 0 us (total 0 us)
RandomMagazine: 0 us (total 0 us)


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9354 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2022-03-31 15:10:19 +00:00
Shadooow 033ae4a191 Added two new tags into Items.xml, <FoodSystemExclusive> and <DiseaseSystemExclusive> which prevents specific items to appear without these systems enabled.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9343 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2022-03-24 05:40:46 +00:00
rftr 87b0c7c6b7 new feature: madlab's robot can be upgraded
requires gamedir r2642

https://thepit.ja-galaxy-forum.com/index.php?t=msg&goto=364403

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9338 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2022-03-21 17:34:49 +00:00
Sevenfm aa5e2dc4c3 PlaceObject: don't show incompatible face item message when doing autoplacement.
SwapGoggles: swap face item to helmet if possible.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9301 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2022-02-15 12:03:54 +00:00
Sevenfm d02547c7c8 When attaching launchable to attached launcher, use launcher's reload AP cost.
Don't apply ambidextrous attach speed bonus when attaching launchable to launcher.
When playing reload sounds, set volume and pan based on soldier's location.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9196 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-10-26 13:49:55 +00:00
Sevenfm 8413c5ee8f GetReliability: attached weapons should not add reliability.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9195 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-10-26 07:06:43 +00: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
Flugente a93e9b4a9c Added helper functions to easier determine gun stats
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9158 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-08-27 20:48:19 +00:00
Sevenfm a8c2fa6788 ADD_SMOKE_AFTER_EXPLOSION option:
- use default item SMOKE_GRENADE (151) if it's available
- search for first smoke grenade if default item is not grenade
- check that correct smoke grenade was found

Also added new functions:
- ItemIsHandGrenade to check if item is hand grenade
- GetFirstHandGrenadeOfType to find first item which is hand grenade of selected type
- GetHandGrenadeOfType same as GetFirstHandGrenadeOfType, but first check if provided default item is hand grenade of needed type

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9156 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-08-27 17:30:27 +00:00
Flugente ed82841e3c Fix: when using two guns, both are reloaded on the reload cursor prompt, even if one of them still has ammo. This has been changed so that now only empty guns get reloaded
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9146 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-07-24 19:15:18 +00:00
Shadooow 5e4d587baf fixed: KAC masterkey and other items without attachment flag to work
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9110 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-06-27 02:36:46 +00:00
Sevenfm 39b8911803 Fix: attaching guns to tripwire.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9027 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-05-15 06:26:37 +00:00
Sevenfm fc3869bcd6 Fixed function PickPocket to work with MOLLE type of LBEs (by Shadooow).
Changed code that handles putting medical kit from merc inventory into his main hand to respect pockets restrictions to avoid putting gun into medkit only pocket etc.. Writes an error in case that medical kit cannot be put into hands due to no suitable place for currently held items (by Shadooow).

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9015 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-05-11 04:40:54 +00:00
Sevenfm e4f12a68aa Reverted optimization code which prevented 40mm grenades to load if <attachment> tag is not set in mod (by Shadooow).
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9003 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-05-05 08:08:37 +00:00
Sevenfm d41c0f2f93 Efficiency improvements for code dealing with attachments validity to fix any potential lag issues (by Shadooow).
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8997 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-05-02 05:23:52 +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 c8cb9a0d6c SetAttachmentSlotsFlag: improved code to check array bounds.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8952 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-03-11 06:51:12 +00:00
Sevenfm d1de51605c TransformObject: disabled interrupt after sight check.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8951 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-03-09 22:26:02 +00:00
Sevenfm 0ccecc472c Fix: UI attack handling prioritised interactive structures over target soldiers even if target soldier was explicitly provided causing deadlocks e.g. when trying to punch enemy overlapped by a door (by anv).
ReInitMergedItem: show item id, attachment id when doing assert.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8935 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2021-02-13 05:48:17 +00:00
Sevenfm 50f45bc2d9 Improved r8460 fix: also check for incorrect ammo item.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8917 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2020-12-06 13:17:42 +00:00
Sevenfm e738e4424d Improved code to spawn item and it's attachments when disarming bomb.
Update sight after item transformation.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8909 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2020-10-23 13:15:31 +00:00
Sevenfm b45af3f575 FindNearestUngassedLand, FindNearbyDarkerSpot:
- optimization: don't check spots already checked in previous loop
- increase max distance to 35, reduce to 25 if complex AI not allowed, reduce to 15 in realtime
CanDragPerson: use world movement cost instead of LOS check.
Say TAUNT_RELOAD, TAUNT_OUT_OF_AMMO taunts if mag size > 4 or Chance (CHANCE_SAY_ANNOYING_PHRASE).
SpotDangerLevel: also check Water and CorpseWarning for danger level = 1.
ManSeesMan: only call SetNewSituation if location or level are different to reduce frequency of AI re-evaluation.
Only allow radio animation on initial red alert, if sector is not jammed.
Press ESC to stop dragging.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8904 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2020-10-17 06:30:23 +00:00
Sevenfm 144cdc0131 FindAmmoToReload: added assert messages to indicate that searching attached weapon failed.
DecideAction: initialize bWeaponMode = WM_NORMAL to prevent FindAmmoToReload from crashing.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8892 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2020-08-31 16:35:56 +00:00
Sevenfm 5903abee09 Various AI improvements.
FindThrowableGrenade: allows to specify type and damage of searched grenade.
New counter SOLDIER_COUNTER_RETREAT allows to set number of turns which soldier will try to retreat and take cover.
FindBestNearbyCover: use PrepareThreatlist as unified function to make list of all known opponents.

Militia Control:
- start retreating mode for 2 turns when ordering retreat
- replace AI_ACTION_RUN_AWAY with AI_ACTION_TAKE_COVER order so that militia do not retreat from sector

New AI behavior:
- soldier can use smoke grenade to cover himself when under fire
- soldier can use use smoke grenade on his friend to cover him
- if soldier used smoke, he starts retreat mode for 2 turns
- added retreat code to Red, Black AI
- improved Main Red AI for civilians (they only run away)

Improved suppression code:
- less chance of suppression when opponent has high shock level
- prefer using suppression fire when soldier is in cover

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8879 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2020-08-07 12:12:31 +00:00
Flugente 8e4961f021 Fix: various compile warnings
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8872 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2020-07-24 19:27:34 +00:00
Flugente 00313a526b Minor code improvements
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8833 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2020-07-02 22:11:11 +00:00
Flugente 098dc8e280 Disease update:
- <InfectionChance_WOUND_FIRE> can cause infections when taking fire damage
- <InfectionChance_WOUND_GAS> can cause infections when taking non-fire gas damage
- <fSpecialFlagLimitedUseArms> causes the infected to be unable to use one arm
- <fSpecialFlagLimitedUseLegs> causes the infected to be unable to run, and walk and travel slowly
- JA2_options.ini option DISEASE_SEVERE_LIMITATIONS controls whether <fSpecialFlagContractDisability>, <fSpecialFlagLimitedUseArms> and <fSpecialFlagLimitedUseLegs> are used

For more info, see http://thepit.ja-galaxy-forum.com/index.php?t=msg&th=22099&goto=360451&#msg_360451

- Gas damage split up in fire and non-fire damage.
- Flamethrower projectile damaged is affected by fire resistance.

Requires GameDir >= r2553.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8828 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2020-06-25 22:42:44 +00:00
Sevenfm 3eb699c45f Walkman: bonus 20% to morale when in head slot.
Update soldier morale every turn.
Update soldier morale when changing inventory.
Improved code for 'l' hotkey.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8783 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2020-04-10 21:20:05 +00:00
Sevenfm 4e34605f86 Red, Black AI: try to use sidearm if not enough AP to shoot with main weapon.
Black AI: improved check to avoid friendly fire.
FindAIUsableObjClass: by default search for weapon with longest range, if fSidearm = TRUE search for fastest weapon.
AICalcChanceToHitGun: if AI_EXTRA_SUPPRESSION = TRUE, always return min 1% for AI.
RangeChangeDesire:
- civilians only want to run away
- added small bonus to range change desire if soldier has no gun or short range weapon
CalcBestShot, CheckIfShotPossible: always check if can shoot at target seen by another soldier.
CalcBestShot, CalcBestThrow, CalcBestStab: initialize attack data.
Removed obsolete code.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8782 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2020-04-08 21:24:56 +00:00
Sevenfm d02a4ddd7d Implemented some of the merc05's fixes (http://thepit.ja-galaxy-forum.com/index.php?t=msg&th=24256):
- fix for stopping snitches from preventing misbehavior
- fix for stopping snitches reports
- improved code for refused handcuffing
- fixed item bug with items dropping from backpack after using transformation in turnbased mode
- improved code for dart ammotype effect
- removed assert in AddCharacterToAnySquad to prevent crash when selecting merc in vehicle and plotting travel route
- added EXPLOSV_CREATUREGAS effect in UpdateAniTiles()

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8720 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2019-12-22 06:22:23 +00:00
silversurfer 6a1fd17026 Fix: Items that were placed by function AutoPlaceObjectToWorld() had incorrect sGridNo so they could end up in inaccessible places.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8690 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2019-08-20 17:41:56 +00:00
Flugente 84d08a8821 A paramedic can use empty bloodbags (<emptybloodbag>-tag, item #1756) to create blood bags (<bloodbag>-tag, item #1757) from other mercs. These can then boost the health returned by surgery by ONTOP_PERCENT_SURGERY_HEAL_BLOODBAG percent.
Requires GameDir >= r2467.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8662 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2019-02-10 16:26:48 +00:00
Flugente 08ed5cf378 - New mergetype 15: works like mergetype 6 but lowers status of firstItemIndex by 10%
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8650 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2019-01-24 21:38:42 +00:00
silversurfer 384572098b - fixed incorrect rounding in several places in the code
- diagonal movement now uses the proper amount of AP and BP

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8634 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2018-11-03 16:11:21 +00:00