Home » MODDING HQ 1.13 » v1.13 Coding Talk » Trunk AI and improvements
Re: Trunk AI and improvements[message #359009 is a reply to message #359008] Tue, 11 February 2020 18:19 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
Xafloz wrote on Tue, 11 February 2020 21:00
But can this be done midplay?
I have no idea. I did not change anything related.

I could reproduce the described enemy behavior - enemy is not moving in realtime, starts moving when you switch to turnbased.
Tested in r8641, long before my recent changes.
Enemy moves in realtime in peaceful state (Green AI), then if your merc shoots, enemy starts moving to merc, but as soon as corpse appears in the way of enemy, they all suddenly stop in realtime, but start moving again if you switch to turnbased or when corpse warning reaches zero.

[Updated on: Tue, 11 February 2020 19:19]




Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359022 is a reply to message #359009] Wed, 12 February 2020 21:18 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8751/2518

Only check for fExplodeOnImpact in OBJECT_DETONATE_ON_IMPACT if item has IC_EXPLOSV class. This fixes situation when random items are thrown incorrectly.

Tweaked animation speeds:
- faster sidestepping
- faster radio animation
- faster ninja kick and focused punches and kicks

Play splash sound when thrown item hits water.

Demo video:



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359037 is a reply to message #359022] Sat, 15 February 2020 15:00 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8754

Explosions:
Don't spread fire on water tiles, explosions in water do not produce fragments.
Only normal, stun and flashbang explosives create water explosion.
Increase max force when throwing items into water (to compensate for no bouncing).

AI:
Enemy soldiers will try to move out of artillery strike danger zone.

FindBestNearbyCover:
- penalty to locations in red smoke danger zone
- avoid moving into red smoke danger zone if not in red smoke danger already
FindNearestUngassedLand:
- improved code
- try not to move closer to known enemies.
- calculate path with correct movement mode
FindNearbyDarkerSpot:
- improved code
- calculate path with correct movement mode
FindFlankingSpot:
- avoid locations near bombs
- avoid moving into red smoke danger zone
- removed check for edge of the map. (this should improve AI's ability to flank on the edge of the map)
SearchForItems: avoid locations with bombs or red smoke danger.
Added LegalNPCDestination check to AI location search routines.

[Updated on: Sat, 15 February 2020 15:39]




Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359038 is a reply to message #359037] Sat, 15 February 2020 18:33 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8755/2520

Uploaded LOBOT code (by Asdow, original code by Bio).
Feature description: http://thepit.ja-galaxy-forum.com/index.php?t=msg&goto=359041&#msg_359041
To use, activate in the ingame options.
Currently only walking with raised weapon animation supported.
Shown weapons/equipment:
- any rifle/shotgun, for example SKS (17) or M870 (31)
- Steel Helmet (176)
- TIMS Backpack (1094)
- Hat (285)
- Flak Jacket (161)

Demo video (by Asdow):

[Updated on: Sat, 15 February 2020 21:56]




Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359049 is a reply to message #359038] Mon, 17 February 2020 21:36 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8758

Various AI improvements:

Improved code to avoid moving into gas/deep water/light/artillery danger zone.
AI pathing: avoid deep water if not in deep water already and not SEEKENEMY (allow max 2 tiles of deep water for other soldiers).
DecideAction: improved deep water checks.
CONSIDERED_NEUTRAL: removed dying check as it may cause problems with AI.
When searching for closest disturbance , AI will now skip dying opponents if he found not dying one.
Allow deep water flanking for soldiers of ENEMY_TEAM with SEEKENEMY orders and CUNNINGSOLO attitude or athletics trait.
FindFlankingSpot: added condition to allow deep water flanking

CalcBestShot:
- dying, cowering or unconscious soldiers have very low priority
- added safety checks
- if best opponent is dying and new opponent is ok, use new opponent

Red, Black AI: when SEEKENEMY soldier is in deep water, move to closest opponent on the ground (to allow mass attack through deep water).

FindNearestUngassedLand:
- increased max search distance to 35 (in case we have some big water, for example in bigmaps)
- added speed optimization
- removed max AP budget

FindNearbyDarkerSpot:
- increased max search range to 25
- added speed optimization
- removed max AP budget



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359061 is a reply to message #359049] Thu, 20 February 2020 14:38 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8759/2521

Improved Flugente's Drag people and corpses feature:
- play sound when dragging something (Sounds\Misc\DragBody1.ogg .. DragBodyN.ogg)
- mercs always make movement noise when dragging
- stop dragging if another merc starts dragging this merc/body
- stop dragging if dragged merc gets up from collapsed state
- stop dragging when changing stance/cowering under suppression

Fixed grenade pin sound for signal smoke.
CalcBestShot: if new opponent is dying and best opponent is ok, ignore new opponent.

Demo video:



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359073 is a reply to message #359061] Sat, 22 February 2020 13:43 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8760/2522

New option AI_DECISION_INFO enables extended logging for AI decisions. The AI logs are stored in Logs folder which should be in game root folder.
The game will write a separate file for each AI soldier and a common file with all decisions for all soldiers.
The log allows to follow the process of AI decision and also has time stamps since the start of current AI, for example:
[104] (7439)  (0 ms) [Black Zombie]
[104] (7439)  (0 ms) Turn num 1 aware 1
[104] (7439)  (0 ms) current team 2 interrupt occurred 0
[104] (7439)  (0 ms) AP=58/58 Black SEEKENEMY AGGRESSIVE CREATURE_TEAM SOLDIER_CLASS_ZOMBIE
[104] (7439)  (0 ms) Health 78/78 Breath 99/100 Shock 0 Tolerance 7 AI Morale 4 Morale 90
[104] (7439)  (0 ms) Spot 7439 level 0 opponents 3
[104] (7439)  (0 ms) ubServiceCount 0 ubServicePartner 254 fDoingSurgery 0
[104] (7439)  (0 ms) Watched location 11291 level 0 points 4
[104] (7439)  (0 ms) Watched location 11289 level 0 points 4
[104] (7439)  (0 ms) Watched location 7761 level 0 points 4
[104] (7439)  (0 ms) personal opponent [0] knowledge SEEN_CURRENTLY gridno 7761 level 0
[104] (7439)  (10 ms) personal opponent [1] knowledge SEEN_CURRENTLY gridno 7602 level 0
[104] (7439)  (0 ms) personal opponent [2] knowledge SEEN_CURRENTLY gridno 7601 level 0
[104] (7439)  (0 ms) What I know 24
[104] (7439)  (0 ms) Has Gun 0, Short range weapon 1, Gun Range 0, Gun Ammo 0, Gun Scoped 0 
[104] (7439)  (0 ms) CanMove 1 InWater 0 InDeepWater 0
[104] (7439)  (0 ms) [attack]
[104] (7439)  (0 ms) found weapon in slot 5
[104] (7439)  (0 ms) min AP to attack 14
[104] (7439)  (0 ms) [find target for attack]
[104] (7439)  (0 ms) NPC decided to move to stab
[104] (7439)  (0 ms) copy the information on the best action selected into BestAttack struct
[104] (7439)  (0 ms) best attack = stab
[104] (7439)  (0 ms) prepare attack, AP cost 26 CTH 66
[104] (7439)  (0 ms) ubRealCTH 66
[104] (7439)  (0 ms) ubChanceHead 25
[104] (7439)  (0 ms) aim at torso
[104] (7439)  (0 ms) AimTime 0 AimShotLocation 2
[104] (7439)  (0 ms) attack opponent 1 at gridno 7602 level 0
We see that zombie with id = 104 is in black state, he sees soldier with id 0 and decides to attack opponent at gridno 7602.
Currently extended AI logging is implemented only for new zombie AI.
Also added new debug topic id TOPIC_DECISIONS for logging AI decisions.

Moved zombie AI into separate file ZombieDecideAction.cpp
New zombie AI:
- simplified code
- advancing using cover (so zombie cannot be attacked until he gets closer to opponent)
- if zombie cannot reach any opponent, he tries to hide (in case opponent is blocked or on a roof and zombie cannot climb)
- if zombie cannot reach opponent and cannot hide and he is under fire, he will retreat, seeking cover away from known opponents
- if zombie doesn't know enemy location, he will try to run to closest friend who knows enemy location (so even if this particular zombie cannot hear gunshot, for example, he will move to closest friend who is in contact with enemy)
- new zombie AI has extended AI logging
Updated projects for 2010, 2013 and 2017, for 2017 there is no file TacticalAI_VS2017.vcxproj.filters, maybe it needs to be created, unfortunately I have no vs2017.

CalcCoverValue:
- allow moving into shallow water if it provides better position
- special calculations for zombies: zombie is very dangerous at close range
- if soldier has no gun, use different calculation based on distance instead of CTGT

FindBestNearbyCover: zombies only choose spots that provide sight cover.

ClosestReachableDisturbance:
- if soldier is zombie and he cannot climb, skip location
- zombies do not attack vehicles
- improved check to avoid choosing dying opponents

EstimatePathCostToLocation: return 0 if checking for zombie which cannot climb and path needs climbing (so that zombies don't try to approach opponents on roof they cannot reach).
RoamingRange: always max roaming range for zombies.

SightCoverAtSpot, ProneSightCoverAtSpot:
- improved max sight range calculation (take into account that enemy can possibly raise weapon to extend sight range)
- added option for unlimited sight range check

New AI functions:
- AIDirection (simple direction from spot1 to spot2)
- AICheckIsSniper (sniper weapon or long range weapon, scope, high marksmanship, sniper skill)
- AICheckIsMarksman (rifle, sniper rifle or assault rifle, long weapon range, scoped weapon or high marksmanship or sniper skill)
- AICheckIsMedic (doctor bag, doctor skill)
- AICheckIsMortarOperator (has mortar in inventory)
- AICheckIsGLOperator (has grenade launcher and ammo for it)
- AICheckIsOfficer (has one squadleader trait)
- AICheckIsCommander (has two squadleader traits)
- AICheckIsMachinegunner (has machinegun)
- AIGunInHandScoped (gun in HANDPOS is scoped)
- AIGunScoped (gun in inventory used by AI is scoped)
- AIGunRange (range of the gun used by AI)
- AIGunClass (weapon class for gun used by AI)
- AIGunType (weapon type for gun used by AI)
- AIGunDeadliness (deadliness for gun used by AI)
- AIGunAmmo (gun shots left for gun used by AI)
- AIGunAutofireCapable (if gun used by AI can shoot in auto)
- FindObstacleNearSpot (if there is some structure near spot that can possibly be used as cover)
- InSmoke (check MAPELEMENT_EXT_SMOKE effect at spot/level)
- CorpseWarning (check if there is corpse with active AI warning at spot/level, checks if this corpse from the same team as soldier)
- CorpseEnemyTeam (checks if corpse is from enemy team)
- CorpseMilitiaTeam (checks if corpse is from militia team)
- AICheckUnderground (quick check that current sector is underground)
- AnyCoverAtSpot (check that spot has structures providing cover from directions to all known enemies, or unlimited sight cover)
- AICheckHasWeaponOfType (check if soldier has weapon of certain type in inventory)
- AICheckHasGun (check if soldier has any item of IC_GUN type in inventory)
- AICheckShortWeaponRange (check if soldier has gun with range < DAY_VISION_RANGE / 2)
GetCorpseAtGridNo: pointer safety check, additional check for valid gridno.

GetCorpseRotFactor: improved code to return FLOAT value between 0 and 1.
Original code was:
return (GetWorldTotalMin( ) - pCorpse->def.uiTimeOfDeath) / gGameExternalOptions.usCorpseDelayUntilRotting;
Since all operands are integer, resulting value will be integer - 0 or 1, also description says that max value should be limited by 1
// Flugente: how rotten is this corpse? values from 0 to 1, 1 as soon as it is rotting
so now it looks like
return (FLOAT)(min(gGameExternalOptions.usCorpseDelayUntilRotting, GetWorldTotalMin() - pCorpse->def.uiTimeOfDeath)) / gGameExternalOptions.usCorpseDelayUntilRotting;

More zombie raise sounds (Data\Sounds\Misc\ZombieRaise1.ogg .. ZombieRaiseN.ogg).
More water splash sounds (Data\Sounds\Misc\Splash1.ogg .. SplashN.ogg).



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359099 is a reply to message #359073] Thu, 27 February 2020 13:05 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8764

New tags in CivGroupNames.xml: Side, CustomSide allow setting custom side for civilian group.

When neutral civilian becomes hostile (MakeCivHostile is called):
- by default, any civilian will change side to 1 (hostile to player, allied to army)
- if soldier is IRA, DIMITRI, MIGUEL, CARLOS, MADLAB, DYNAMO, SHANK, he will change to 2 (hostile rebels)
- if soldier is MARIA or ANGEL and QUEST_RESCUE_MARIA is in process and QUEST_RESCUE_MARIA is done, then new side = 2 (hostile rebels)
- if civ group is REBEL_CIV_GROUP, then side = 2 (hostile rebels)
- if soldier has CustomSide = 1 in CivGroupNames.xml, his Side value will be used

Possible Side values:
0 - player
1 - enemy
2 - hostile rebels
3 - creatures

Soldier side is defined when he is created:
- player mercs always have side = 0
- militia starts with 0 but can change to 2 and become hostile to both player and enemy
- creatures always have side = 3.
- enemies have side = 1
- civilians have side = 1 by default but they start neutral, unless they are made hostile in GameInit.lua by using something like SetCivGroupHostile(Group.REBEL_CIV_GROUP, Civ_status.CIV_GROUP_HOSTILE)

This change allows to have 3 side battles, for example player + enemy + bandits (+ possible creatures who will attack anyone including neutral civilians).



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359118 is a reply to message #359099] Mon, 02 March 2020 03:28 Go to previous messageGo to next message
Kitty

 
Messages:443
Registered:October 2017
Location: Germany
Very cool, thank you very much. thumbs up My first try will be the smugglers.


How to get: latest 1.13, 7609 and more | 7609 SCI (eng) | Compiling+SVN

I need more details. (Didi Hallervorden)

Report message to a moderator

Master Sergeant
Re: Trunk AI and improvements[message #359122 is a reply to message #359118] Tue, 03 March 2020 20:03 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8767

Dynamic creation of light effects for fire and signal smoke (ADD_LIGHT_AFTER_EXPLOSION option).
First decay light effects and then decay smoke effects, because fire can create light.
Fixed/improved code to decay light effects so that ubDuration works correctly.
Note: <ubRadius> tag is not used for light effects as they cannot spread, light is always created with <ubStartRadius> and can only decay later.
Improved code to decay smoke effects.

Fire and light demo:

As you can see, light dynamically follows fire size and correctly disappears.
Light from break light has duration 10 and radius 3, so now it stays unchanged for 7 turns and then disappears in 3 turns. Previously light duration was limited to it's radius because of bug in the code.

AI soldier avoids light and corpses:

This is test scenario, not exactly how it works in the game, but it shows how AI can choose it's path trying to avoid dangerous places.



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359165 is a reply to message #359122] Mon, 09 March 2020 22:35 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8770/2525

Tactical ambients and sector steady ambients volume is now scaled with general effects volume.
VOLUME_TA and VOLUME_SSA in Ja2_Options.INI have range 1-127 with default value 100.
Removed old zombie AI code.
Improved AI path tweaks:
- tanks prefer moving in straight directions to avoid sliding effect
- combat jeeps prefer moving on roads (PAVED_ROAD, DIRT_ROAD)
- armed vehicles avoid moving into buildings (FLAT_FLOOR)
- increased value to avoid light and corpses for enemy soldiers

[Updated on: Tue, 10 March 2020 01:22]




Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359169 is a reply to message #359165] Wed, 11 March 2020 04:51 Go to previous messageGo to next message
Kitty

 
Messages:443
Registered:October 2017
Location: Germany
Quote:

- combat jeeps prefer moving on roads (PAVED_ROAD, DIRT_ROAD)
- armed vehicles avoid moving into buildings (FLAT_FLOOR)
I would like to keep this in mind while map-building, but can't find where those terrain-types are defined. Could you please help me narrow down the search or even point me to the defintion in code ?



How to get: latest 1.13, 7609 and more | 7609 SCI (eng) | Compiling+SVN

I need more details. (Didi Hallervorden)

Report message to a moderator

Master Sergeant
Re: Trunk AI and improvements[message #359170 is a reply to message #359169] Wed, 11 March 2020 11:52 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
Terrain types are defined in tiledef.h
enum TerrainTypeDefines
{
	NO_TERRAIN,
	FLAT_GROUND,
	FLAT_FLOOR,
	PAVED_ROAD,
	DIRT_ROAD,
	LOW_GRASS,
	HIGH_GRASS,
	TRAIN_TRACKS,
	LOW_WATER,
	MED_WATER,
	DEEP_WATER,
	NUM_TERRAIN_TYPES	
} ;



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359184 is a reply to message #359170] Sat, 14 March 2020 13:00 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8771

Fixed delayed mode for grenades.
Changing delayed mode for grenade launcher only possible with DELAYED_GRENADE_EXPLOSION = FALSE.

Now, with DELAYED_GRENADE_EXPLOSION = TRUE:
All hand/gl grenades of normal/stun/flashbang type (except grenades with fExplodeOnImpact set in Explosives.xml) will delay explosion to next turn after hitting the ground, instead of instant explosion.
Player cannot change delayed mode in the game when this option is enabled.

With DELAYED_GRENADE_EXPLOSION = FALSE:
By default, all grenades blow up instantly, player can change hand grenades to delayed mode by using transformation menu, GL grenades to delayed mode by using [B] key to switch firing mode.

Note: fExplodeOnImpact tag in Explosives.xml prevents grenade from bouncing, also it prevents grenade from using delayed explosion mode, apart from that, it has no relation to delayed explosion feature.

[Updated on: Sat, 14 March 2020 15:24]




Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359251 is a reply to message #359184] Tue, 24 March 2020 22:37 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8775

[F] key should correctly show CTH for different types of attacks:
- gun
- launcher
- grenade
- thrown knife
- punch
- toss item

So you can now estimate chance when throwing grenade or boxing.
Also fixed bug when uninitialized usAttackingWeapon caused incorrect shown CTH.



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359385 is a reply to message #359251] Thu, 02 April 2020 23:09 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8777/2526

Hotkey changes:
- press [SHIFT] key to move in formation (when several mercs are selected, they will try to keep their relative positions when moving)
- restored vanilla hotkey: [G] toggles light effects
- to switch formation mode, press [Ctrl]+[Alt]+[G]

Updated JA2_113_Hotkeys.odt

[Updated on: Fri, 03 April 2020 08:31]




Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359388 is a reply to message #359385] Fri, 03 April 2020 08:30 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8779/2527

Hotkeys for quick transformations:
[Shift]+[T] - transform item in hand (improved code)
[Shift]+[O] - transform scope for weapon in main hand (will find next higher magnification, if not found will switch to lowest)
[Shift]+[L] - transform flashlight (works for item in hand or flashlight attached to weapon)
[Shift]+[Y] - transform laser for weapon in hand (if mod supports laser modes or switching)

Updated JA2_113_Hotkeys.odt

[Updated on: Fri, 03 April 2020 08:31]




Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359422 is a reply to message #359388] Mon, 06 April 2020 03:20 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8780/2528

New option to enable New Weapon Sound System:
[Sound Settings]
NWSS = TRUE

Added new tags to support NWSS:
AmmoStrings.xml: <NWSSCaliber>
Weapons.xml: <ubNWSSCase>, <ubNWSSLast>, <szNWSSSound>

NWSS demo:



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359429 is a reply to message #359422] Mon, 06 April 2020 22:09 Go to previous messageGo to next message
grim is currently offline grim

 
Messages:344
Registered:July 2006
Location: France
This is a major change, and very nicely done with that, congrats!

The effect indoors could be even more accentuated maybe, what do you think?

Report message to a moderator

Master Sergeant
Re: Trunk AI and improvements[message #359430 is a reply to message #359429] Mon, 06 April 2020 22:16 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
grim wrote on Tue, 07 April 2020 00:09
The effect indoors could be even more accentuated maybe, what do you think?
The effect is achieved by playing room.ogg sound with every shot sound, you can change it to anything you like and see how it plays in the game.
From my experience, it's best when this effect is noticeable but not too loud, also it doesn't work well with some sounds like shotguns so by default it's disabled for 12g caliber.



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359432 is a reply to message #359430] Mon, 06 April 2020 23:41 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
NWSS description/modding guide.

The main difference between original 1.13 shot sounds and NWSS is that in new system every shot is played as separate sound, while in original system for every length of burst we should make a separate sound file like burst 1.ogg ... burst 30.ogg
Also we can play several sounds at the same time, simulating added echo, room/underground effect or adding new effects like case falling or Garand ping sound.
To make this system easy to use and adapt to any mod, sounds are based not on individual weapons but on calibers, so if you define a sound for 9x19mm, you will have working sounds for glock 19, calico, uzi etc. (individual custom sounds can be added later if you wish)

So, all you need to do to make this system work with your mod is:
- download AltSounds.7z and unpack into your Data folder (or use AltSounds from actual gamedir svn)
- open TableData\Items\AmmoStrings.xml and for every caliber that you want to use NWSS sound for, add new tag with the name of NWSS folder, like this:
<uiIndex>2</uiIndex>
<AmmoCaliber>9x19mm</AmmoCaliber>
<BRCaliber>9x19mm</BRCaliber>
<NWSSCaliber>9x19mm</NWSSCaliber>
Now, when any 9x19mm gun will shoot, the game will take sound from AltSounds\Caliber\9x18mm and play it.
Note: we cannot use existing tags like <AmmoCaliber> or <BRCaliber> because it will break compatibility with localized mods.

So, we have two folders in AltSounds:
AltSounds\Caliber
AltSounds\Common
"Caliber" folder holds sounds for various calibers, one folder for each caliber.
"Common" folder holds common sounds that are the same for all calibers (generic case falling, echo, room and underground effects).

Now let's take a look how weapon sound is composed in this system.
First, the game will make a folder name for caliber sound:
AltSounds\Caliber\<NWSSCaliber>, which will be AltSounds\Caliber\9x19mm in our example.
For the sound file name, we can have the following possible names:
- single shot sound: "single"
- single shot sound, silenced: "single_s"
- loop sound (for burst sounds): "loop"
- loop sound, silenced: "loop_s"

So, the absolute minimum you need is to provide AltSounds\Caliber\CaliberName\loop.ogg (and loop_s.ogg if weapon can be silenced) file for every caliber, and it will work.
If you want to provide special sounds for single shot weapons (not burst/autofire capable weapons), you can add single.ogg file to the same folder, for example you have UZI which will use loop.ogg sound and you have a special sound that you want to use with single shot calico rifle, and it will try to use single.ogg first and if not found, will use loop.ogg as generic sound. If Calico can be silenced in your mod, you can add single_s.ogg so it is played instead of loop_s.ogg for single shot weapons (not burst/autofire capable weapons).

What if we can have different types of weapons in 9x19 caliber (pistol, smg, rifle, machinegun) and want to use different sounds for them?
We can use prefixes:
- "pistol_" for pistols
- "MP_" for machine pistols
- "SMG_" for submachineguns
- "rifle_" for rifles
- "sniper_" for sniper rifles
- "AR_" for assault rifles
- "LMG_" for machineguns
- "shotgun_" for shotguns
(the game uses <ubWeaponType> from Weapons.xml to determine type, and values can be found in Lookup\WeaponType.xml)

So, if we place "loop.ogg", "pistol_loop.ogg" and "SMG_loop.ogg" files into 9x19mm folder, the game will use "SMG_loop.ogg" for UZI, "pistol_loop.ogg" for Glock 17 and "loop.ogg" for all other 9x19mm weapons.

What if having weapon types is not enough, and we want individual weapon sounds?
We can add new tag <szNWSSSound> to Weapons.xml, so if we add
<szNWSSSound>HK53</szNWSSSound>
to HK 53A3 (id 13), the game will try to play "5.56x45mm\HK53_loop.ogg" first and if not found, weapon type "5.56x45mm\SMG_loop.ogg" and then default value "5.56x45mm\loop.ogg"
So, you can assign this tag to every gun in Weapons.xml and have different sound for all of them.

Automatic sounds are simple, "loop.ogg" (or "loop_s.ogg" for silenced sounds) is usually short and simple sound which is played for every bullet fired.
Sounds for single shout weapons are a bit more complex, because they can have long and rich echo, so we have a special postfix "_noecho" which tells the game not to use additional echo/room effects for this sound, and another postfix "_noroom" which prevents room effect for this sound, for example, we can use "single_noecho.ogg" for a sniper rifle to prevent echo and room effects, and "single_noroom.ogg" for shotgun to prevent only room effect.

Additional sound effects:
1. Echo effect is added after single shot sound (unless _noecho is used) or last loop sound in a burst.
All echo sounds are stored in AltSounds\Common folder.
You can define different types of echo for different types of sectors and locations:
- "echo_underground" if it's underground sector
- "echo_building" when shooting soldier is in the room, on the ground level and shooting to the same room or same building (so it's echo for shooting inside building)
- "echo_town" is used when soldier is in a town
- "echo_hills" when sector type is "HILLS" or "HILLS_ROAD" (these types usually represent mountains with long echo)
- "echo_dense" when sector type is "DENSE", "DENSE_ROAD", "SWAMP" or "SWAMP_ROAD" (these types usually represent forested sectors)
- "echo" for generic type echo (plains etc)
Sector type is determined by <Here> movement type in TableData\Map\MovementCosts.xml
You can provide several files for each echo type, which should be named in consecutive order, for example:
echo_underground1.ogg
echo_underground2.ogg
echo_building1.ogg
echo_building2.ogg
echo_building3.ogg
echo_dense1.ogg
echo_dense2.ogg
echo_hills1.ogg
echo_town1.ogg
echo_town2.ogg
echo1.ogg
echo2.ogg
echo3.ogg
So, the game will first try and play special echo effect from available (for example, echo_dense1.ogg or echo_dense2.ogg), and if it cannot find special echo files or echo type is generic, it will use default echo types (echo1.ogg, echo2.ogg or echo3.ogg).

2. Room and undergound effects.
These effects are stored in AltSounds\Common folder, but you can also set place custom room/underground sound effect in caliber folder:
room.ogg
underground.ogg
They cannot have variations.
Room effect is played when soldier is shooting from a room (and no "_noecho" or "_noroom" postfix specified for single shot sound, and shot is not silenced).
Underground effect is played when soldier is shooting underground (and no "_noecho" or "_noroom" postfix specified for single shot sound, and shot is not silenced).
The game will play either room or underground effect, not both.
The idea of these effects is to enhance shot sound by adding "reverberation" effect.
So, the game will first try to play room/underground effect from caliber folder, and if not found, will play it from Common folder.

3. Case falling effect.
Common effects are stored in AltSounds\Common folder, but you can also set custom case effect in caliber folder.
You can provide as many case effects as you want, naming them in consecutive order, the game will use one of them randomly, for example:
case1.ogg
case2.ogg
Case falling effect is only played when soldier is located on FLAT_FLOOR or PAVED_ROAD type tile, which represents hard surface found in buildings, on roofs or on asphalt/concrete road.
There is random 50% chance of playing case sound each time the bullet is fires, so it doesn't sound too repetitive.
There is new <ubNWSSCase> tag in Weapons.xml, which can have values 0..2:
- 0: default value, case falling effect is only allowed if weapon has no <APsToReloadManually> or <EasyUnjam> tags defined
- 1: case falling effect is allowed for this weapon
- 2: case falling effect is disabled for this weapon

4. Last bullet in magazine effect.
Common effects are stored in AltSounds\Common folder, but you can also set custom case effect in caliber folder.
Sound file for this effect is named "empty.ogg", it cannot have variations.
This effect is played when last bullet in magazine is fired, so it can be used for Garand ping effect or slide stop effect for automatic weapons.
There is a new <szNWSSSound> tag in Weapons.xml, which can have values 0..2:
- 0: default value, last bullet effect is played if weapon has no <APsToReloadManually> tag
- 1: allow last bullet effect
- 2: disable last bullet effect for this weapon

If the game cannot find or play NWSS sound or NWSS system is disabled, it will use default 1.13 sound taken from Sounds.xml or BurstSounds.xml, so you can combine systems, for example only define NWSS sounds for new guns in your mod, while keeping old sounds for the rest of old guns.

[Updated on: Tue, 16 November 2021 15:41]




Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359448 is a reply to message #359432] Thu, 09 April 2020 00:29 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8782

AI soldiers will try to use sidearm if they have not enough AP for main weapon.
AI soldiers will always check if they can shoot at target seen by other soldier.
Added small bonus to AI aggressiveness if soldier has short range weapon or no gun, so AI should try to get closer to enemy.



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359479 is a reply to message #359448] Sat, 11 April 2020 00:28 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8723

Walkman in the head slot provides bonus 20% to morale (10% if merc has deafness disability, 0% if temporarily deafened by explosion).
May be useful for non-combat tasks or for sniper to improve accuracy.
Soldier morale is updated every turn and also every time player changes equipment.

Demo:

[Updated on: Sat, 11 April 2020 01:59]




Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359483 is a reply to message #359479] Sat, 11 April 2020 15:10 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8784/2529

New option SOLDIER_TOOLTIP_DEBUG_AI shows additional AI information in soldier tooltip, including list of watched locations and actual knowledge data.



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359660 is a reply to message #359483] Mon, 20 April 2020 19:48 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8787

Minor improvement for strategic AI:

Allow recruiting when pool size drops below iQueenPoolIncrementPerDifficultyLevel, this should result in more stable strategic AI behavior.
Previously, AI could only recruit soldiers when pool size dropped to 0, this could in theory create situation when AI has not enough troops to create a squad of reinforcements and at the same time too much troops to start recruiting more, resulting in passive AI behavior.

[Updated on: Mon, 20 April 2020 21:40]




Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359669 is a reply to message #359660] Tue, 21 April 2020 01:05 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8790

AI improvements:
- set watched location when soldier hears gunshot and can possibly see noise location
- set watched location when soldier is under attack
- set watched location to closest spot where enemy can appear

With these changes, AI soldiers will try to ambush opponents more often if they are under attack, can hear enemy or can try to predict where known enemy can appear.

Also improved watched location code: soldier will crouch, turn to watched location, raise gun and then possibly go prone if he can see watched location from prone stance.
Snipers and soldiers with scoped weapons will choose watch decision more often.
If soldier is under attack, in light at night or has no cover from known enemy, watch decision priority is greatly reduced, so he can try to find cover first.

[Updated on: Tue, 21 April 2020 01:15]




Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #359707 is a reply to message #359669] Thu, 23 April 2020 05:58 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8791

AI toss attack improvements:
- for mortars and grenade launchers, first try to find non smoke grenade/shell
- don't use mortar in building or underground
- don't use grenade launcher underground
- blinded soldier cannot use mortar/grenade launcher
- when calculating safety margin, correctly use BuddyItem defined for single shot RPG
- limit ubSafetyMargin to TACTICAL_RANGE / 2 in case radius set too high in XML
- use flares only at night
- use ValidOpponent() check to determine opponent
- use new knowledge functions
- allow attacking recently seen/heard opponents with mortar/grenade launcher
- improved code to spare grenade, don't spare: non lethal grenades, if some friends killed, when under attack, STATIONARY/SNIPER, when on the roof, when there are friends under attack nearby
- increase possible distance from opponent when opponent in a building or when using gas grenade
- improved check for gas/smoke when using gas/smoke grenade
- don't use smoke grenade if there's already smoke nearby (it can spread to this tile later)
- improved code for AP to attack calculation
- when attacking enemy in a building with mortar, allow shooting on the roof above the enemy, hoping that roof will collapse
- limit RPG use, unless can hit several enemies, shooting at tank/jeep or opponent is in a room
- soldiers should use RPGs against tanks/jeeps more often
- modify smoke attack value depending on range (less effective if too far from opponent)

In general, AI should be able now to attack recently seen/heard opponent with mortars and grenade launchers, and use them more effectively and more often.

[Updated on: Thu, 23 April 2020 06:01]




Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #360029 is a reply to message #359707] Wed, 13 May 2020 09:38 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8800

New tag <shotAnimation> in AmmoTypes.xml allows defining custom shot animation, for example to use MINIBOOM.sti animation, add:
<shotAnimation>TILECACHE\MINIBOOM.sti</shotAnimation>

Animation is only displayed for:
- merc bodytype (REGMALE .. REGFEMALE)
- visible soldier
- IC_GUN usItemClass
- no rocket launchers

Demo video:



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #360036 is a reply to message #360029] Thu, 14 May 2020 19:01 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8801/2533

New experimental NCTH options in CTHConstants.ini.

LIMIT_MAX_DEVIATION:
- limit max bullet deviation to improve suppression effectiveness
- this option has no effect on gun accuracy and chance to hit
- max deviation limit depends on weapon range, recoil and shooting mode, so machinegun should stay effective for suppression at longer range than SMG

LIMIT_GROUND_SHOTS:
- limit max vertical deviation (for the first shot only) so there will be less ground shots
- when this option enabled, VERTICAL_BIAS option has no effect on bullet deviation
- this option should have no effect on chance to hit

Both options are disabled by default.



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #360772 is a reply to message #360036] Fri, 31 July 2020 13:37 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8873

AI soldiers should now better avoid hitting each other.

Previously, friendly fire code never worked correctly, since friendly fire CTH was never stored, resulting in AI completely ignoring any friendly fire checks and calculations.
Now, attacks with friendly fire chance > 3% should be avoided by AI.
Also, AI will try to choose position taking into account possible friendly fire, penalizing positions where he can hit too many friends (needs AI_BETTER_COVER option enabled).
Also, CalcBestShot AI function will now test CTGT and friendly fire chance for every shooting stance, possibly improving situation when AI shoots from behind concrete walls and allowing AI to stand up when shooting over prone friends.
Another change is that AI will take into account not only members of the same team, but also same side and neutrals. As a result, militia should shoot into mercs backs less often.

There is still small standard 3% chance of shooting friends when shooting behind someone, also autofire can sometimes result in friendly fire since it has wide distribution, but in general, friendly fire for AI should be much more rare now.

Please test this change and report results here, if you are interested.
New exe can be found in the "trunk" link in my sig, also make sure you are using latest gamedir from svn.



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #360796 is a reply to message #360772] Sun, 02 August 2020 20:01 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8877

Boxing tweaks:
- counterattack after failed HTH attack (boxer should have AP > 0, so he can go into negative APs with counterattack
- opportunity attack if another boxer approaches from front direction, boxer should have AP > 0
- AI boxers turn to opponent
- more cautious AI boxer behavior (reserve APs for counterattack, reserve APs for second attack when approaching, rest when low on breath)
- only boxers are valid opponents for boxer if match is active (so he should not try to approach closest merc outside of the ring)
- bonus to CTH when boxer is attacking from the back
- chance for counterattack is halved if boxer was seriously hit recently
- chance for counterattack is based on boxers's effective dexterity and BP level
- chance for opportunity attack is based on boxer's effective agility and BP level
- direction modifiers for opportunity attack are 75% for frontal direction, 50% for diagonal and 25% for side direction
- AI boxer can sometimes step back if he has not enough APs for attack, to have chance for opportunity attack on approaching opponent, and force him to spend more APs on moving
- AI boxer can sometimes choose to attack opponent from diagonal direction, to minimize chance for opportunity attack
- lowered base chance for HTH attacks, so there's less situations with 99% hit chance

Some possible tactics:
- first punch to the legs or torso, to have higher CTH and minimize chance for counterattack, if it succeeds, second punch to the head to maximize damage
- in the beginning of the match (when enemy has high BP level and chance of counterattack is high), aim at the legs and step back one tile, this way you will minimize counterattack chance and have a chance for opportunity attack
- boxers with high agility are strong in opportunity attacks, boxers with high dexterity are good in counterattacks, boxers with bodybuilder traits have damage and breath reduction in HTH, so they can withstand more damage
- if enemy has high agility and BP, try to approach from diagonal (or even side) direction, to minimize chance for opportunity attack

Demo video:

[Updated on: Mon, 03 August 2020 06:18]




Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #360851 is a reply to message #360796] Thu, 06 August 2020 10:57 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8878

AI suppression fire improvements.

CalcBestShot:
- added standard check for valid opponent
- use standard knowledge functions
- blind soldier can only attack seen/heard personally
- determine suppression fire (shooting at target nobody sees currently)
- don't shoot if target location is seen and empty
- no fire on unseen opponents with throwing knives
- only enemy team can use blind suppression fire
- only try to suppress alive and conscious human targets
- additional check to limit shooting through walls
- alt weapon holding scope mode is used only when ubAllowAlternativeWeaponHolding == 3
- hip firing allowed only for human bodytypes
- take into account direction when checking stance
- shoot heavy guns in standing stance only when using hip fire
- penalize suppression fire

Red AI suppression fire:
- check valid target
- check weapon/ammo requirements
- check that soldier is not sniper
- check friendly fire chance
- reduce chance to shoot if target is beyond weapon range
- check that we have spare ammo

Improved code to prepare suppression fire:
- change stance first of needed
- allow shooting with aiming
- reserve APs to hide if no cover or enemy is close
- added debug messages

In general, AI should now be able to use suppression fire more often and more effectively, shooting at locations of recently seen or heard enemies.
Enemy machine gunners should be especially dangerous.



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #360858 is a reply to message #360851] Fri, 07 August 2020 15:16 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8879

AI improvements.

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

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

Demo video:



Note: using smoke should not be too often, since AI rarely has smoke grenades unless they were manually given in map editor.



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #360945 is a reply to message #360858] Sun, 16 August 2020 07:03 Go to previous messageGo to next message
SinMachina is currently offline SinMachina

 
Messages:48
Registered:August 2020
sevenfm , I am loving all these tweaks to the AI. From the videos you are posting it seems like the enemy is certainly acting less ' dumb ' and a bit more intuitive to what we would expect them to behave as.

I would love to play with these changes, but I'm unfortunately a little uncertain of what these changes are compatible with. I'm also unsure of what ' version [source] ' I should download the latest revision of the game is. The oldest revision I have is SCI 8573 GameDir 2426 and would like to upgrade to what is the modern platform now. I can see that I'm about 200 revisions behind [being about 2 years since I last updated].

So, can I get your 7609+AI , and Depri's latest SCI and that function properly? Can I use the WF map changes as well? Big maps?

Sorry for dumping these here. Its just not very clear anymore what is compatible with what.

Report message to a moderator

Corporal
Re: Trunk AI and improvements[message #360946 is a reply to message #360945] Sun, 16 August 2020 07:21 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
You can find latest SCI here: https://jenkins.maeyanie.com/job/JA2%20SCI/
Or you can update gamedir from official 1.13 svn and add latest exe from link in my sig (trunk).
Usually latest exe requires actual gamedir.
You can use the exe with any compatible mod for that revision (WF maps work well with latest unstable if you need them).
You can also use my unofficial mods (for unstable or 7609) as they already have all possible mods installed and configured and supplied with compatible exe (just unpack over clean vanilla Ja2, or simply add missing SLF files to unpacked modpack's Data folder).

Don't mix 7609+AI project with the main trunk, 7609+AI is for 7609 stable release only, while in this thread only main trunk (8XXX revisions) is discussed.
Please don't discuss 7609+AI here as it may confuse people, that project has it's own thread (Experimental project).



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #360947 is a reply to message #360946] Sun, 16 August 2020 07:23 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8887

AI thrown attacks improvements:
- improved AI code to avoid hitting friends with grenades (take into account grenade fragments, add one tile for safety in case of grenade miss)
- correctly set usGrenade for mortar attacks (allows AI to better determine effects of mortar attack)



Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #360959 is a reply to message #360947] Mon, 17 August 2020 09:19 Go to previous messageGo to next message
az75 is currently offline az75

 
Messages:178
Registered:June 2012
Location: Romania
Your pukazoids are shooting my squad situated 10 tiles away from the edge on a roof, proned, with a precision on suppression fire that my lvl. 10 sniper doesn't have. Tone that down!

[Updated on: Mon, 17 August 2020 09:25]

Report message to a moderator

Staff Sergeant
Re: Trunk AI and improvements[message #360960 is a reply to message #360959] Mon, 17 August 2020 09:27 Go to previous messageGo to next message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
removed

[Updated on: Mon, 17 August 2020 18:52]




Left this community.

Report message to a moderator

Lieutenant

Re: Trunk AI and improvements[message #360961 is a reply to message #360960] Mon, 17 August 2020 09:43 Go to previous messageGo to next message
az75 is currently offline az75

 
Messages:178
Registered:June 2012
Location: Romania
Sure, ignore me if it suits your transforming a beautiful game into an imbecility.

Don't be a jackass. You should know better. Enjoy your timeout. //SHANGA

[Updated on: Mon, 17 August 2020 14:28] by Moderator

Report message to a moderator

Staff Sergeant
Re: Trunk AI and improvements[message #360968 is a reply to message #360961] Tue, 18 August 2020 11:33 Go to previous messageGo to previous message
Deleted.

 
Messages:2663
Registered:December 2012
Location: Russian Federation
r8890

New option AI_SHOOT_UNSEEN (disabled by default): allow AI to shoot at recently seen/heard enemies (targets that nobody from soldier's team sees currently).
Also improved hit rate calculation for AI shooting decision, taking into account possible options INCREASE_AIMING_COSTS, FIRST_AIM_READY_COST_DIVISOR.
New AI function LOS_Raised checks LOS with forced raised gun status, to get max view distance with scope, used by AI to take into account possible enemy scope use.



Left this community.

Report message to a moderator

Lieutenant

Previous Topic: Ja2+AI: FAQ
Next Topic: Experimental Project 7
Goto Forum:
  


Current Time: Wed May 01 19:36:43 GMT+3 2024

Total time taken to generate the page: 0.02325 seconds